my $qtyfactor = $params{table} eq 'ap' ? '* -1' : '';
my $q_billed = qq|SELECT i.parts_id, i.qty ${qtyfactor} AS qty, i.unit, p.unit AS partunit
my $qtyfactor = $params{table} eq 'ap' ? '* -1' : '';
my $q_billed = qq|SELECT i.parts_id, i.qty ${qtyfactor} AS qty, i.unit, p.unit AS partunit
next if (!scalar @arap_ids);
# Retrieve all positions for this order. Calculate the ordered quantity for each position.
next if (!scalar @arap_ids);
# Retrieve all positions for this order. Calculate the ordered quantity for each position.
do_statement($form, $h_ordered, $q_ordered, $oe_id);
while (my $ref = $h_ordered->fetchrow_hashref()) {
do_statement($form, $h_ordered, $q_ordered, $oe_id);
while (my $ref = $h_ordered->fetchrow_hashref()) {
do_statement($form, $h_billed, $q_billed, $arap_id);
while (my $ref = $h_billed->fetchrow_hashref()) {
do_statement($form, $h_billed, $q_billed, $arap_id);
while (my $ref = $h_billed->fetchrow_hashref()) {
-# $main::lxdebug->message(0, "all_billed $all_billed");
-# $main::lxdebug->dump(0, "ordered", \%ordered);
-# $main::lxdebug->dump(0, "billed", \%billed);
-
# Close orders that have been billed fully.
if (scalar @close_oe_ids) {
my $query = qq|UPDATE oe SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar @close_oe_ids) . qq|)|;
do_query($form, $dbh, $query, @close_oe_ids);
# Close orders that have been billed fully.
if (scalar @close_oe_ids) {
my $query = qq|UPDATE oe SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar @close_oe_ids) . qq|)|;
do_query($form, $dbh, $query, @close_oe_ids);