diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-02 07:03:56 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-02 07:03:56 +0000 |
commit | f0ac3781f1a75e5c82434b7d78a5c3e0f6027eb2 (patch) | |
tree | a2813acac1c7b9f2e8d8c2b58094d7a7102d6856 /LedgerSMB | |
parent | e306c45c3515c825e35cdac87ebfa04bb088795f (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/trunk@1502 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/IR.pm | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index 197c9943..0afbc827 100644 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -414,39 +414,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); } |