X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=1df0eb2f9f5a320a4cc6dc243565ec65572a19a0;hb=c59e85c3a7538b1279e25022a6cf431ca1dee700;hp=6018634dd8c3a0d01e83876619c4d089e1c79ae9;hpb=aa63ebae1c0a758ec438c594acb328b1f0e5e001;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 6018634dd..1df0eb2f9 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -52,6 +52,7 @@ use SL::IC; use SL::IO; use SL::TransNumber; use SL::DB::Default; +use SL::DB::Draft; use SL::DB::Tax; use SL::DB::TaxZone; use SL::TransNumber; @@ -1402,19 +1403,19 @@ SQL do_query($form, $dbh, $query, @orphaned_ids); } + if ($form->{draft_id}) { + SL::DB::Manager::Draft->delete_all(where => [ id => delete($form->{draft_id}) ]); + } + # safety check datev export if ($::instance_conf->get_datev_check_on_sales_invoice) { - my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; - $transdate ||= DateTime->today; my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; @@ -2129,6 +2130,11 @@ sub get_customer { my $payment_id; # get customer + my $where = ''; + if ($cid) { + $where .= 'AND c.id = ?'; + push @values, $cid; + } $query = qq|SELECT c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, @@ -2140,8 +2146,7 @@ sub get_customer { FROM customer c LEFT JOIN business b ON (b.id = c.business_id) LEFT JOIN currencies cu ON (c.currency_id=cu.id) - WHERE c.id = ?|; - push @values, $cid; + WHERE 1 = 1 $where|; $ref = selectfirst_hashref_query($form, $dbh, $query, @values); delete $ref->{salesman_id} if !$ref->{salesman_id};