Die Dokumente werden nun bei der entsprechenden Rechnung abgespeichert.
Da ja Rechnungen zusammengefasst werden können, wäre die Zuordnung ggf bei den Kundendaten besser
impl redmine #274
my @files;
$main::lxdebug->message(LXDebug->DEBUG2(), "do_list: object_id=".$self->object_id." object_type=".$self->object_type." file_type=".$self->file_type." json=".$json);
if ( $self->file_type eq 'document' ) {
+ my @object_types;
+ push @object_types, $self->object_type;
+ push @object_types, ('dunning','dunning1','dunning2','dunning3') if $self->object_type eq 'invoice';
@files = SL::File->get_all_versions(object_id => $self->object_id ,
- object_type => $self->object_type,
+ object_type => \@object_types,
file_type => $self->file_type );
$main::lxdebug->message(LXDebug->DEBUG2(), "cnt1=".scalar(@files));
c.greeting, c.contact, c.phone, c.fax, c.homepage,
c.email, c.taxincluded, c.business_id, c.taxnumber, c.iban,
c.ustid,
+ ar.id AS invoice_id,
co.*
FROM dunning d
LEFT JOIN ar ON (d.trans_id = ar.id)
$query =
qq|SELECT
- cfg.interest_rate, cfg.template AS formname,
+ cfg.interest_rate, cfg.template AS formname, cfg.dunning_level,
cfg.email_subject, cfg.email_body, cfg.email_attachment,
d.transdate AS dunning_date,
(SELECT SUM(fee)
$form->get_employee_data('prefix' => 'employee', 'id' => $form->{employee_id});
$form->get_employee_data('prefix' => 'salesman', 'id' => $form->{salesman_id});
+ $form->{attachment_type} = "dunning";
+ if ( $form->{dunning_level} ) {
+ $form->{attachment_type} .= $form->{dunning_level} if $form->{dunning_level} < 4;
+ }
+ $form->{attachment_filename} = $form->get_formname_translation($form->{attachment_type}) . "_${dunning_id}.pdf";
+ $form->{attachment_id} = $form->{invoice_id};
$form->parse_template($myconfig);
$main::lxdebug->leave_sub();
$query =
qq|SELECT
d.fee_interest_ar_id,
- dcfg.template
+ d.trans_id AS invoice_id,
+ dcfg.template,
+ dcfg.dunning_level
FROM dunning d
LEFT JOIN dunning_config dcfg ON (d.dunning_config_id = dcfg.id)
WHERE d.dunning_id = ?|;
- my ($ar_id, $template) = selectrow_query($form, $dbh, $query, $dunning_id);
+ my ($ar_id, $invoice_id, $template, $dunning_level) = selectrow_query($form, $dbh, $query, $dunning_id);
if (!$ar_id) {
$main::lxdebug->leave_sub();
map { delete $form->{$_} } grep /^[a-z_]+_\d+$/, keys %{ $form };
+ $form->{attachment_filename} = $form->get_formname_translation('dunning_invoice') . "_${dunning_id}.pdf";
+ $form->{attachment_type} = "dunning";
+ $form->{attachment_id} = $form->{invoice_id};
$form->parse_template($myconfig);
restore_form($saved_form);
sales_delivery_order => $main::locale->text('Delivery Order'),
purchase_delivery_order => $main::locale->text('Delivery Order'),
dunning => $main::locale->text('Dunning'),
+ dunning1 => $main::locale->text('Payment Reminder'),
+ dunning2 => $main::locale->text('Dunning'),
+ dunning3 => $main::locale->text('Last Dunning'),
+ dunning_invoice => $main::locale->text('Dunning Invoice'),
letter => $main::locale->text('Letter'),
ic_supply => $main::locale->text('Intra-Community supply'),
statement => $main::locale->text('Statement'),
my ($self, $form) = @_;
return unless $::instance_conf->get_doc_storage;
my $type = $form->{type};
- $type = $form->{formname} if $form->{formname} && !$form->{type};
+ $type = $form->{formname} if $form->{formname} && !$form->{type};
+ $type = $form->{attachment_type} if $form->{attachment_type};
my $id = $form->{id};
$id = $form->{attachment_id} if $form->{attachment_id} && !$form->{id};
return if !$id || !$type;
$self->append_general_pdf_attachments(filepath => $pdf_filename, type => $form->{type}) if ( $ext_for_format eq 'pdf' );
#It is also used in MassPrint Helper
-#
+#
=head1 DESCRIPTION
=cut
-
'Dunning Description' => 'Mahnstufenbeschreibung',
'Dunning Description missing in row ' => 'Mahnstufenbeschreibung fehlt in Zeile ',
'Dunning Duedate' => 'Zahlbar bis',
+ 'Dunning Invoice' => 'Mahnrechnung',
'Dunning Level' => 'Mahnlevel',
'Dunning Level missing in row ' => 'Mahnlevel fehlt in ',
'Dunning Process Config saved!' => 'Mahnwesenkonfiguration gespeichert!',
'Last Cost' => 'Einkaufspreis',
'Last Credit Note Number' => 'Letzte Gutschriftnummer',
'Last Customer Number' => 'Letzte Kundennummer',
+ 'Last Dunning' => 'Letzte Mahnung',
'Last Invoice Number' => 'Letzte Rechnungsnummer',
'Last Purchase Delivery Order Number' => 'Letzte Lieferscheinnummer (Einkauf)',
'Last Purchase Order Number' => 'Letzte Lieferantenautragsnummer',