diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-02 07:02:25 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-02 07:02:25 +0000 |
commit | 3b8fb147fe3870ed3da803782e11d74ed4aaf8c9 (patch) | |
tree | 87e2c156ce2b66aa9288946c4fd4584258924673 /LedgerSMB | |
parent | c783f4b3f02adf14a24c68101c0e14567847ef42 (diff) |
Correcting bug 1753372: COGS posts to closed dates when books closed after sales invoice issued.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1501 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rwxr-xr-x | LedgerSMB/IR.pm | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index 3f3b0aed..62eea7c6 100755 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -371,39 +371,52 @@ sub post_invoice { if ($linetotal) { $query = qq| - INSERT INTO acc_trans - (trans_id, - chart_id, - amount, - transdate, - project_id, - invoice_id) - VALUES (?, ?, ?, ?, - ?, ?)|; + INSERT INTO acc_trans + (trans_id, + chart_id, + amount, + project_id, + invoice_id, + transdate) + VALUES (?, ?, ?, ?, + ?, (SELECT CASE WHEN ? > value::date + THEN ? + ELSE value::date + + '1 day'::interval + END AS value + FROM defaults + WHERE setting_key = 'closedto' + ))|; my $sth = $dbh->prepare($query); $sth->execute( $ref->{trans_id}, $ref->{inventory_accno_id}, - $linetotal, $ref->{transdate}, - $ref->{project_id}, $invoice_id + $linetotal, + $ref->{project_id}, $invoice_id, + $ref->{transdate}, $ref->{transdate}, ) || $form->dberror($query); # add expense $query = qq| - INSERT INTO acc_trans - (trans_id, - chart_id, - amount, - transdate, - project_id, - invoice_id) - VALUES (?, ?, ?, ?, - ?, ?)|; + INSERT INTO acc_trans + (trans_id, chart_id, amount, + project_id, invoice_id, + transdate) + VALUES (?, ?, ?, ?, + ?, (SELECT CASE WHEN ? > value::date + THEN ? + ELSE value::date + + '1 day'::interval + END AS value + FROM defaults + WHERE setting_key = 'closedto' + ))|; $sth = $dbh->prepare($query); $sth->execute( $ref->{trans_id}, $ref->{expense_accno_id}, - $linetotal * -1, $ref->{transdate}, - $ref->{project_id}, $invoice_id + $linetotal * -1, + $ref->{project_id}, $invoice_id, + $ref->{transdate}, $ref->{transdate}, ) || $form->dberror($query); } |