X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAR.pm;h=3da550d68d7d83e9ea21a6e0f53896a24fea6447;hb=a3511b2d8974c72e4d26b2d85c5cf1cd711ccb6f;hp=adffeb6bc677cb7d132919789c3348965c559196;hpb=9c0ec2622da20eb96c8b4bbd98a8cce47cb8a6ee;p=kivitendo-erp.git diff --git a/SL/AR.pm b/SL/AR.pm index adffeb6bc..3da550d68 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -40,6 +40,7 @@ use SL::DBUtils; use SL::IO; use SL::MoreCommon; use SL::DB::Default; +use SL::TransNumber; use strict; @@ -136,7 +137,10 @@ sub post_transaction { ($form->{id}) = selectrow_query($form, $dbh, $query); $query = qq|INSERT INTO ar (id, invnumber, employee_id, currency_id) VALUES (?, 'dummy', ?, (SELECT id FROM currencies WHERE name=?))|; do_query($form, $dbh, $query, $form->{id}, $form->{employee_id}, $form->{currency}); - $form->{invnumber} = $form->update_defaults($myconfig, "invnumber", $dbh) unless $form->{invnumber}; + if (!$form->{invnumber}) { + my $trans_number = SL::TransNumber->new(type => 'invoice', dbh => $dbh, number => $form->{partnumber}, id => $form->{id}); + $form->{invnumber} = $trans_number->create_unique; + } } } @@ -509,8 +513,8 @@ sub ar_transactions { qq|LEFT JOIN employee e ON (a.employee_id = e.id) | . qq|LEFT JOIN employee e2 ON (a.salesman_id = e2.id) | . qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id)| . - qq|LEFT JOIN tax_zones tz ON (tz.id = c.taxzone_id)| . - qq|LEFT JOIN payment_terms pt ON (pt.id = c.payment_id)| . + qq|LEFT JOIN tax_zones tz ON (tz.id = a.taxzone_id)| . + qq|LEFT JOIN payment_terms pt ON (pt.id = a.payment_id)| . qq|LEFT JOIN business b ON (b.id = c.business_id)| . qq|LEFT JOIN department d ON (d.id = a.department_id)|; @@ -638,7 +642,7 @@ sub setup_form { my ($self, $form, $for_post_payments) = @_; my ($exchangerate, $akey, $j, $k, $index, $taxamount, $totaltax, $taxrate, $diff, $totalwithholding, $withholdingrate, - $totalamount, $taxincluded, $tax); + $totalamount, $tax); # forex $form->{forex} = $form->{exchangerate}; @@ -722,7 +726,6 @@ sub setup_form { } } - $form->{taxincluded} = $taxincluded if ($form->{id}); $form->{paidaccounts} = 1 if not defined $form->{paidaccounts}; if ($form->{taxincluded} && $form->{taxrate} && $totalamount) { @@ -801,4 +804,3 @@ sub storno { 1; -