retrieve_accounts: 'current_date' richtig in Queries einbauen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 22 Nov 2010 17:01:09 +0000 (18:01 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 22 Nov 2010 17:02:01 +0000 (18:02 +0100)
SL/IC.pm

index 35718f6..f1840d8 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -1467,8 +1467,8 @@ sub follow_account_chain {
 
   $form->{ACCOUNT_CHAIN_BY_ID} ||= {
     map { $_->{id} => $_ }
-      selectall_hashref_query($form, $dbh, <<SQL, $transdate) };
-    SELECT c.id, c.new_chart_id, date(?) >= c.valid_from AS is_valid, cnew.accno
+      selectall_hashref_query($form, $dbh, <<SQL) };
+    SELECT c.id, c.new_chart_id, ${transdate} >= c.valid_from AS is_valid, cnew.accno
     FROM chart c
     LEFT JOIN chart cnew ON c.new_chart_id = cnew.id
     WHERE NOT c.new_chart_id IS NULL AND (c.new_chart_id > 0)
@@ -1518,7 +1518,7 @@ sub retrieve_accounts {
   if ($transdate eq "") {
     $transdate = "current_date";
   } else {
-    $transdate = $dbh->quote($transdate);
+    $transdate = 'date(' . $dbh->quote($transdate) . ')';
   }
   #/transdate
   my $inc_exp = $form->{"vc"} eq "customer" ? "income_accno_id" : "expense_accno_id";
@@ -1551,7 +1551,7 @@ SQL
     WHERE t.id IN
       (SELECT tk.tax_id
        FROM taxkeys tk
-       WHERE tk.chart_id = ? AND startdate <= ?
+       WHERE tk.chart_id = ? AND startdate <= ${transdate}
        ORDER BY startdate DESC LIMIT 1)
 SQL
 
@@ -1569,7 +1569,7 @@ SQL
 
     $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense);
 
-    $sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate));
+    $sth_tax->execute($accounts{$inc_exp});
     $ref = $sth_tax->fetchrow_hashref or next;
 
     $form->{"taxaccounts_$index"} = $ref->{"accno"};