X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDN.pm;h=ebfa4f374b67556f5a311223da2f7320b00c5261;hb=bfd8b7a229bf1bec0a6ed2c2e8a76d6cab30704a;hp=6d00f438afe1b8d9732fa53e7d6f1857ba1c3c37;hpb=94944f0868721e5140fc97f78948c298a122dcbe;p=kivitendo-erp.git diff --git a/SL/DN.pm b/SL/DN.pm index 6d00f438a..ebfa4f374 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -36,6 +36,7 @@ package DN; use SL::Common; use SL::DBUtils; +use SL::DB::Default; use SL::GenericTranslations; use SL::IS; use SL::Mailer; @@ -208,7 +209,7 @@ sub create_invoice_for_fees { $query = qq|INSERT INTO ar (id, invnumber, transdate, gldate, customer_id, taxincluded, amount, netamount, paid, duedate, - invoice, curr, notes, + invoice, currency_id, notes, employee_id) VALUES ( ?, -- id @@ -228,7 +229,7 @@ sub create_invoice_for_fees { -- duedate: (SELECT duedate FROM dunning WHERE dunning_id = ? LIMIT 1), 'f', -- invoice - ?, -- curr + (SELECT id FROM currencies WHERE name = ?), -- curr ?, -- notes -- employee_id: (SELECT id FROM employee WHERE login = ?) @@ -326,12 +327,13 @@ sub save_dunning { $form->{DUNNING_PDFS_EMAIL} = []; + $form->{dunning_id} = $dunning_id; + $self->create_invoice_for_fees($myconfig, $form, $dbh, $dunning_id); $self->print_invoice_for_fees($myconfig, $form, $dunning_id, $dbh); $self->print_dunning($myconfig, $form, $dunning_id, $dbh); - $form->{dunning_id} = $dunning_id; if ($send_email) { $self->send_email($myconfig, $form, $dunning_id, $dbh); @@ -393,7 +395,9 @@ sub set_template_options { my ($self, $myconfig, $form) = @_; - $form->{templates} = "$myconfig->{templates}"; + my $defaults = SL::DB::Default->get; + $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates; + $form->{templates} = $defaults->templates; $form->{language} = $form->get_template_language($myconfig); $form->{printer_code} = $form->get_printer_code($myconfig); @@ -432,7 +436,7 @@ sub set_template_options { $form->{IN} = undef; for my $filename (@template_files) { - if (-f "$form->{templates}/$filename") { + if (-f ($defaults->templates . "/$filename")) { $form->{IN} = $filename; last; } @@ -483,6 +487,7 @@ sub get_invoices { "ordnumber" => "a.ordnumber", "invnumber" => "a.invnumber", "notes" => "a.notes", + "country" => "ct.country", ); foreach my $key (keys(%columns)) { next unless ($form->{$key}); @@ -747,6 +752,16 @@ sub print_dunning { $dunning_id =~ s|[^\d]||g; + my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates); + if ($form->{"language_id"}) { + ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) = + AM->get_language_details($myconfig, $form, $form->{language_id}); + } else { + $output_dateformat = $myconfig->{dateformat}; + $output_numberformat = $myconfig->{numberformat}; + $output_longdates = 1; + } + my $query = qq|SELECT da.fee, da.interest, @@ -759,7 +774,7 @@ sub print_dunning { ar.transdate, ar.duedate, ar.customer_id, ar.invnumber, ar.ordnumber, ar.cp_id, ar.amount, ar.netamount, ar.paid, - ar.curr, + (SELECT cu.name FROM currencies cu WHERE cu.id=ar.currency_id) AS curr, ar.amount - ar.paid AS open_amount, ar.amount - ar.paid + da.fee + da.interest AS linetotal @@ -833,6 +848,17 @@ sub print_dunning { $form->{total_open_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{total_open_amount}, 2), 2); $form->{total_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{fee} + $ref->{total_interest} + $ref->{total_open_amount}, 2), 2); + $::form->format_dates($output_dateformat, $output_longdates, + qw(dn_dunning_date dn_dunning_duedate dn_transdate dn_duedate + dunning_date dunning_duedate transdate duedate) + ); + $::form->reformat_numbers($output_numberformat, 2, qw( + dn_amount dn_netamount dn_paid dn_open_amount dn_fee dn_interest dn_linetotal + amount netamount paid open_amount fee interest linetotal + total_interest total_open_interest total_amount total_open_amount + )); + $::form->reformat_numbers($output_numberformat, undef, qw(interest_rate)); + $self->set_customer_cvars($myconfig, $form); $self->set_template_options($myconfig, $form);