summaryrefslogtreecommitdiff
path: root/LedgerSMB/OE.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-10 01:08:48 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-10 01:08:48 +0000
commitfdc51082c09fbe2d3db25bcc85945959a5728ffd (patch)
treea3d9572684c236afbe919cfc9ab2be3b25a6d8e2 /LedgerSMB/OE.pm
parent553b444aa1cf282f89c58a416f52df7ef9f78348 (diff)
Applying fix for order consolidation
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1366 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/OE.pm')
-rw-r--r--LedgerSMB/OE.pm38
1 files changed, 16 insertions, 22 deletions
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm
index f3838c13..a2959d4b 100644
--- a/LedgerSMB/OE.pm
+++ b/LedgerSMB/OE.pm
@@ -2515,8 +2515,12 @@ sub consolidate_orders {
$form->{entity_id} = $vc_id;
$amount = 0;
$netamount = 0;
+ my @orderids;
+ my $orderid_str = "";
foreach $id ( @{ $oe{orders}{$curr}{$vc_id} } ) {
+ push(@orderids, $id);
+ $orderid_str .= "?, ";
# header
$ref = $oe{oe}{$curr}{$id};
@@ -2584,34 +2588,24 @@ sub consolidate_orders {
$sth = $dbh->prepare($query);
$sth->execute() || $form->dberror($query);
+ $orderid_str =~ s/, $//;
+
# add items
- foreach $item (@orderitems) {
- for (
- qw(
- qty sellprice discount project_id ship)
- )
- {
- $item->{$_} *= 1;
- }
- $query = qq|
+ $query = qq|
INSERT INTO orderitems
(trans_id, parts_id, description,
qty, sellprice, discount, unit, reqdate,
project_id, ship, serialnumber, notes)
- VALUES
- (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
-
- $sth = $dbh->prepare($query);
- $sth->execute(
- $id, $item->{parts_id},
- $item->{description}, $item->{qty},
- $item->{sellprice}, $item->{discount},
- $item->{unit}, $form->{reqdate},
- $item->{project_id}, $item->{ship},
- $item->{serialnumber}, $item->{notes}
- ) || $form->dberror($query);
+ SELECT ?, parts_id, description,
+ qty, sellprice, discount, unit, reqdate,
+ project_id, ship, serialnumber, notes
+ FROM orderitems
+ WHERE trans_id IN ($orderid_str)|;
- }
+ $sth = $dbh->prepare($query);
+ $sth->execute($id, @orderids) || $form->dberror($query);
+
+
}
}