summaryrefslogtreecommitdiff
path: root/LedgerSMB/Tax.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-05 23:05:40 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-05 23:05:40 +0000
commit8266444ddc033a4d6584d2d023565df98173e5ea (patch)
tree274e5515945ba3799de63dfcb886bdf2578bed5f /LedgerSMB/Tax.pm
parent311db34c7abbc4c78fe28994b13f21c4eb7f1e8d (diff)
Fixing bug 1761766: Sales tax change will affect previous invoices
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1511 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Tax.pm')
-rw-r--r--LedgerSMB/Tax.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/LedgerSMB/Tax.pm b/LedgerSMB/Tax.pm
index 01bff4d4..dda940ec 100644
--- a/LedgerSMB/Tax.pm
+++ b/LedgerSMB/Tax.pm
@@ -44,18 +44,25 @@ sub init_taxes {
}
}
- my $query = qq|SELECT t.taxnumber, c.description,
+ my $query = qq|
+ SELECT t.taxnumber, c.description,
t.rate, t.chart_id, t.pass, m.taxmodulename
FROM tax t INNER JOIN chart c ON (t.chart_id = c.id)
- INNER JOIN taxmodule m ON (t.taxmodule_id = m.taxmodule_id)
- WHERE c.accno = ?|;
+ INNER JOIN taxmodule m
+ ON (t.taxmodule_id = m.taxmodule_id)
+ WHERE c.accno = ?
+ AND coalesce(validto::timestamp, 'infinity')
+ >= coalesce(?::timestamp, now())
+ ORDER BY validto ASC
+ LIMIT 1
+ |;
my $sth = $dbh->prepare($query);
foreach $taxaccount (@accounts) {
next if ( !defined $taxaccount );
if ( defined $taxaccounts2 ) {
next if $taxaccounts2 !~ /\b$taxaccount\b/;
}
- $sth->execute($taxaccount) || $form->dberror($query);
+ $sth->execute($taxaccount, $form->{transdate}) || $form->dberror($query);
my $ref = $sth->fetchrow_hashref;
my $module = $ref->{'taxmodulename'};