Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4791c790

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 4791c7907d43d3b8f967eb3d6df26b14485a08f9
  • Vorgänger 576b67fd
  • Nachfolger 6b935d52

Das Drucken von erzeugten wiederkehrenden Rechnungen implementiert

Unterschiede anzeigen:

SL/BackgroundJob/CreatePeriodicInvoices.pm
50 50

  
51 51
      _log_msg("Invoice " . $invoice->invnumber . " posted for config ID " . $config->id . ", period start date " . $::locale->format_date(\%::myconfig, $date) . "\n");
52 52
      push @new_invoices,      $invoice;
53
      push @invoices_to_print, $invoice if $config->print;
53
      push @invoices_to_print, [ $invoice, $config ] if $config->print;
54 54

  
55 55
      # last;
56 56
    }
57 57
  }
58 58

  
59
  map { _print_invoice($_) } @invoices_to_print;
59
  map { _print_invoice(@{ $_ }) } @invoices_to_print;
60 60

  
61
  _send_email(\@new_invoices, \@invoices_to_print) if @new_invoices;
61
  _send_email(\@new_invoices, [ map { $_->[0] } @invoices_to_print ]) if @new_invoices;
62 62

  
63 63
  return 1;
64 64
}
......
219 219
  $mail->send;
220 220
}
221 221

  
222
sub _print_invoice {
223
  my ($invoice, $config) = @_;
224

  
225
  return unless $config->print && $config->printer_id && $config->printer->printer_command;
226

  
227
  my $form = Form->new;
228
  $invoice->flatten_to_form($form, format_amounts => 1);
229

  
230
  $form->{printer_code} = $config->printer->template_code;
231
  $form->{copies}       = $config->copies;
232
  $form->{formname}     = $form->{type};
233
  $form->{format}       = 'pdf';
234
  $form->{media}        = 'printer';
235
  $form->{OUT}          = "| " . $config->printer->printer_command;
236

  
237
  $form->prepare_for_printing;
238

  
239
  $form->throw_on_error(sub {
240
    eval {
241
      $form->parse_template(\%::myconfig, $::userspath);
242
      1;
243
    } || die $EVAL_ERROR->{error};
244
  });
245
}
246

  
222 247
1;
223 248

  
224 249
__END__
......
247 272

  
248 273
Strings like month names are hardcoded to German in this file.
249 274

  
250
=item *
251

  
252
Implement printing the invoices if requested.
253

  
254 275
=back
255 276

  
256 277
=head1 AUTHOR

Auch abrufbar als: Unified diff