summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-18 03:57:28 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-18 03:57:28 +0000
commit22aa4cf5590502392a846eb6c911e8afa239018b (patch)
tree62982473b328307501f81d65a0d107d2d3f2e2f2
parentfa92ca7f3c24f9b71c61675365c54a3750cffe3a (diff)
Applying Victors invoice reversal patches
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1421 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xLedgerSMB/IS.pm38
1 files changed, 21 insertions, 17 deletions
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm
index 6973c04f..3307bff2 100755
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -1081,26 +1081,30 @@ sub post_invoice {
qq|id = $ref->{id}|, $qty * -1
);
$allocated += $qty;
+ my $linetotal = $qty*$ref->{sellprice};
+ $query = qq|
+ INSERT INTO acc_trans
+ (trans_id, chart_id, amount,
+ transdate, project_id, invoice_id)
+ VALUES (?, ?, ?, ?, ?, ?)|;
+ my $sth1 = $dbh->prepare($query);
+ $sth1->execute(
+ $form->{id}, $form->{"expense_accno_id_$i"},
+ $linetotal, $form->{transdate},
+ $form->{"project_id_$i"}, $ref->{id}
+ ) || $form->dberror($query);
+
+ $linetotal = (-1)*$linetotal;
+ $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, invoice_id) VALUES (?, ?, ?, ?, ?, ?)|;
+ $sth1 = $dbh->prepare($query);
+ $sth1->execute(
+ $form->{id}, $form->{"inventory_accno_id_$i"},
+ $linetotal, $form->{transdate},
+ $form->{"project_id_$i"}, $ref->{id}
+ ) || $form->dberror($query);
last if ( ( $totalqty += $qty ) >= 0 );
}
- $query = qq|
- INSERT INTO acc_trans
- (trans_id, chart_id, amount,
- transdate, project_id)
- VALUES (?, ?, ?, ?, ?)|;
- $sth = $dbh->prepare($query);
- $sth->execute(
- $form->{id},
- $form->{"expense_accno_id_$i"},
- $total_inventory, $form->{transdate},
- $form->{"project_id_$i"}
- ) || $form->dberror($query);
-
- $total_inventory = (-1)*$total_inventory;
- $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id) VALUES (?, ?, ?, ?, ?)|;
- $sth = $dbh->prepare($query);
- $sth->execute($form->{id}, $form->{"inventory_accno_id_$i"}, $total_inventory, $form->{transdate}, $form->{"project_id_$i"} ) || $form->dberror($query);
}
}
}