Revision a2b43e37
Von Jan Büren vor etwa 4 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
51 | 51 |
use SL::Util qw(trim); |
52 | 52 |
use SL::DB; |
53 | 53 |
|
54 |
use File::Copy; |
|
55 |
|
|
54 | 56 |
use strict; |
55 | 57 |
|
56 | 58 |
sub get_config { |
... | ... | |
338 | 340 |
|
339 | 341 |
my @invoice_ids; |
340 | 342 |
my ($next_dunning_config_id, $customer_id); |
341 |
my $send_email = 0;
|
|
343 |
my ($send_email, $print_invoice) = (0, 0);
|
|
342 | 344 |
|
343 | 345 |
foreach my $row (@{ $rows }) { |
344 | 346 |
push @invoice_ids, $row->{invoice_id}; |
... | ... | |
348 | 350 |
@values = ($row->{next_dunning_config_id}, $row->{invoice_id}); |
349 | 351 |
do_statement($form, $h_update_ar, $q_update_ar, @values); |
350 | 352 |
|
351 |
$send_email |= $row->{email}; |
|
353 |
$send_email |= $row->{email}; |
|
354 |
$print_invoice |= $row->{print_invoice}; |
|
352 | 355 |
|
353 | 356 |
my $next_config_id = conv_i($row->{next_dunning_config_id}); |
354 | 357 |
my $invoice_id = conv_i($row->{invoice_id}); |
... | ... | |
371 | 374 |
$self->print_invoice_for_fees($myconfig, $form, $dunning_id, $dbh); |
372 | 375 |
$self->print_dunning($myconfig, $form, $dunning_id, $dbh); |
373 | 376 |
|
377 |
if ($print_invoice) { |
|
378 |
$self->print_original_invoices($myconfig, $form, $_, $dbh) for @invoice_ids; |
|
379 |
} |
|
374 | 380 |
|
375 | 381 |
if ($send_email) { |
376 | 382 |
$self->send_email($myconfig, $form, $dunning_id, $dbh); |
... | ... | |
1076 | 1082 |
|
1077 | 1083 |
} |
1078 | 1084 |
|
1085 |
sub print_original_invoices { |
|
1086 |
my ($self, $myconfig, $form, $invoice_id) = @_; |
|
1087 |
# get one invoice as object and print to pdf |
|
1088 |
my $invoice = SL::DB::Invoice->new(id => $invoice_id)->load; |
|
1089 |
|
|
1090 |
die "Invalid invoice object" unless ref($invoice) eq 'SL::DB::Invoice'; |
|
1091 |
|
|
1092 |
my $print_form = Form->new(''); |
|
1093 |
$print_form->{type} = 'invoice'; |
|
1094 |
$print_form->{formname} = 'invoice', |
|
1095 |
$print_form->{format} = 'pdf', |
|
1096 |
$print_form->{media} = 'file'; |
|
1097 |
# no language override, should always be the object's language |
|
1098 |
$invoice->flatten_to_form($print_form, format_amounts => 1); |
|
1099 |
$print_form->prepare_for_printing; |
|
1100 |
|
|
1101 |
my $filename = SL::Helper::CreatePDF->create_pdf( |
|
1102 |
template => 'invoice.tex', |
|
1103 |
variables => $print_form, |
|
1104 |
return => 'file_name', |
|
1105 |
); |
|
1106 |
|
|
1107 |
my $spool = $::lx_office_conf{paths}->{spool}; |
|
1108 |
my ($volume, $directory, $file_name) = File::Spec->splitpath($filename); |
|
1109 |
my $full_file_name = File::Spec->catfile($spool, $file_name); |
|
1110 |
|
|
1111 |
move($filename, $full_file_name) or die "The move operation failed: $!"; |
|
1112 |
|
|
1113 |
# form get_formname_translation should use language_id_$i |
|
1114 |
my $saved_reicpient_locale = $form->{recipient_locale}; |
|
1115 |
$form->{recipient_locale} = $invoice->language; |
|
1116 |
|
|
1117 |
push @{ $form->{DUNNING_PDFS} }, $file_name; |
|
1118 |
push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$file_name", |
|
1119 |
'name' => $form->get_formname_translation('invoice') . "_" . $invoice->invnumber . ".pdf" }; |
|
1120 |
|
|
1121 |
$form->{recipient_locale} = $saved_reicpient_locale; |
|
1122 |
} |
|
1123 |
|
|
1079 | 1124 |
1; |
Auch abrufbar als: Unified diff
Mahnungen: Optional auch Original-Rechnung hinzufügen