X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FOE.pm;h=c5e36654dc57fe0c37243e4475a674694ee1f56c;hb=7ec334735373f140fb8ab48d9cdbe8dedecd99d0;hp=888f422bea062ce8a3efa55c97906b2d6268c861;hpb=92daa1a66a9ff737c92df86da3c28d663c421032;p=kivitendo-erp.git diff --git a/SL/OE.pm b/SL/OE.pm index 888f422be..c5e36654d 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -787,10 +787,9 @@ sub retrieve { my %oid = ('Pg' => 'oid', 'Oracle' => 'rowid'); - my $transdate = "'$form->{transdate}'"; - if (!$transdate) { - $transdate = "current_date"; - } + my $transdate = + $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date"; + if(!$form->{taxzone_id}) { $form->{taxzone_id} = 0; } @@ -869,19 +868,13 @@ sub retrieve { # delete orderitems_id in collective orders, so that they get cloned no matter what delete $ref->{orderitems_id} if (@ids); - #set expense_accno=inventory_accno if they are different => bilanz - $vendor_accno = - ($ref->{expense_accno} != $ref->{inventory_accno}) - ? $ref->{inventory_accno} - : $ref->{expense_accno}; - # get tax rates and description $accno_id = - ($form->{vc} eq "customer") ? $ref->{income_accno} : $vendor_accno; + ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; $query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber - FROM tax t LEFT JOIN chart c ON (c.id=t.chart_id) - WHERE t.taxkey in (SELECT taxkey_id from chart where accno = '$accno_id') - ORDER BY accno|; + FROM tax t LEFT JOIN chart c on (c.id=t.chart_id) + WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1) + ORDER BY c.accno|; $stw = $dbh->prepare($query); $stw->execute || $form->dberror($query); $ref->{taxaccounts} = "";