X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FDN.pm;h=291c99ced1458882b2650b6895771ee61bfc0074;hb=a2aca2e1d8136681d2a95fefd240d509581c8bc8;hp=587379b72ca63c581d859fa48f2079022a3a4e58;hpb=2aaa83f4b2d4f9ebbbc144b1bbfbf7f4d3251577;p=kivitendo-erp.git diff --git a/SL/DN.pm b/SL/DN.pm index 587379b72..291c99ced 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -109,7 +109,7 @@ sub save_config { (dunning_level, dunning_description, email_subject, email_body, template, fee, interest_rate, active, auto, email, email_attachment, payment_terms, terms, create_invoices_for_fees) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; } do_query($form, $dbh, $query, @values); } @@ -198,6 +198,7 @@ sub create_invoice_for_fees { } my ($ar_id) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|); + my $curr = $form->get_default_currency($myconfig); $query = qq|INSERT INTO ar (id, invnumber, transdate, gldate, customer_id, @@ -220,7 +221,7 @@ sub create_invoice_for_fees { ?, -- netamount 0, -- paid -- duedate: - (SELECT duedate FROM dunning WHERE dunning_id = ?), + (SELECT duedate FROM dunning WHERE dunning_id = ? LIMIT 1), 'f', -- invoice ?, -- curr ?, -- notes @@ -233,7 +234,7 @@ sub create_invoice_for_fees { $amount, $amount, $dunning_id, # duedate - (split m/:/, $myconfig->{currency})[0], # currency + $curr, # default currency sprintf($main::locale->text('Automatically created invoice for fee and interest for dunning %s'), $dunning_id), # notes $form->{login}); # employee_id do_query($form, $dbh, $query, @values); @@ -265,7 +266,7 @@ sub create_invoice_for_fees { sub save_dunning { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form, $rows, $userspath, $spool, $sendmail) = @_; + my ($self, $myconfig, $form, $rows, $userspath, $spool) = @_; # connect to database my $dbh = $form->dbconnect_noauto($myconfig); @@ -512,7 +513,7 @@ sub get_invoices { $form->{DUNNINGS} = []; while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - next if !$ref->{terms} || ($ref->{pastdue} < $ref->{terms}); + next if ($ref->{pastdue} < $ref->{terms}); $ref->{interest} = $form->round_amount($ref->{interest}, 2); push(@{ $form->{DUNNINGS} }, $ref); @@ -685,7 +686,7 @@ sub print_dunning { dcfg.email_subject, dcfg.email_body, dcfg.email_attachment, ar.transdate, ar.duedate, ar.customer_id, - ar.invnumber, ar.ordnumber, + ar.invnumber, ar.ordnumber, ar.cp_id, ar.amount, ar.netamount, ar.paid, ar.amount - ar.paid AS open_amount, ar.amount - ar.paid + da.fee + da.interest AS linetotal @@ -711,10 +712,13 @@ sub print_dunning { $query = qq|SELECT c.id AS customer_id, c.name, c.street, c.zipcode, c.city, - c.country, c.department_1, c.department_2, c.email, c.customernumber + c.country, c.department_1, c.department_2, c.email, c.customernumber, + -- contact information + co.* FROM dunning d - LEFT JOIN ar ON (d.trans_id = ar.id) - LEFT JOIN customer c ON (ar.customer_id = c.id) + LEFT JOIN ar ON (d.trans_id = ar.id) + LEFT JOIN customer c ON (ar.customer_id = c.id) + LEFT JOIN contacts co ON (ar.cp_id = co.cp_id) WHERE (d.dunning_id = ?) LIMIT 1|; $ref = selectfirst_hashref_query($form, $dbh, $query, $dunning_id); @@ -802,7 +806,7 @@ sub print_invoice_for_fees { $query = qq|SELECT - ar.invnumber, ar.transdate, ar.amount, ar.netamount, + ar.invnumber, ar.transdate AS invdate, ar.amount, ar.netamount, ar.duedate, ar.notes, ar.notes AS invoicenotes, c.name, c.department_1, c.department_2, c.street, c.zipcode, c.city, c.country,