summaryrefslogtreecommitdiff
path: root/LedgerSMB/IS.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-18 03:57:57 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-18 03:57:57 +0000
commit0d48810d44ef1c0d37585d4b636847c5e825df26 (patch)
treef59d0d3f1e3dc09bfbe98d6a937c219b52bba909 /LedgerSMB/IS.pm
parent2e86f2c33e5954c6b1e50c7687bc74c6766b5d0f (diff)
Applying Victors invoice reversal patches
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1422 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/IS.pm')
-rw-r--r--LedgerSMB/IS.pm43
1 files changed, 25 insertions, 18 deletions
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm
index 0a7d6486..724dc4f2 100644
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -1081,27 +1081,34 @@ sub post_invoice {
$dbh, "invoice", "allocated",
qq|id = $ref->{id}|, $qty * -1
);
+ my $linetotal = $qty*$ref->{sellprice};
$allocated += $qty;
+ $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 (?, ?, ?, ?, ?)|;
- my $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);
}
}
}