summaryrefslogtreecommitdiff
path: root/LedgerSMB/Tax.pm
diff options
context:
space:
mode:
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'};