From 07c1576523439c0d62350bfa164d7c89f09db74a Mon Sep 17 00:00:00 2001 From: tetragon Date: Fri, 28 Dec 2007 02:42:48 +0000 Subject: Fixing the ordering of the rows returned by the tax retrieval query (anarcat 1818792). git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@2012 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Tax.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LedgerSMB/Tax.pm b/LedgerSMB/Tax.pm index bc0ba5fe..7c0d9681 100755 --- a/LedgerSMB/Tax.pm +++ b/LedgerSMB/Tax.pm @@ -49,15 +49,17 @@ sub init_taxes { 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 = ? AND coalesce(validto, ?) >= ? - ORDER BY coalesce(validto, now()) DESC|; + WHERE c.accno = ? AND + coalesce(validto::timestamp, 'infinity'::timestamp) >= ? + ORDER BY + coalesce(validto::timestamp, 'infinity'::timestamp) ASC|; my $sth = $dbh->prepare($query); foreach $taxaccount (@accounts) { next if ( !defined $taxaccount ); if ( defined $taxaccounts2 ) { next if $taxaccounts2 !~ /\b$taxaccount\b/; } - $sth->execute($taxaccount, $transdate, $transdate) + $sth->execute($taxaccount, $transdate) || $form->dberror($query); my $ref = $sth->fetchrow_hashref; -- cgit v1.2.3