X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fsepa.pl;h=0f5a242a8f5d241cae18422c251b5096fec27db2;hb=fc4e61993d9234665db7391ed5aec7aa1b6d6ea9;hp=f2170ae8908de447275698e2b0e423726de44bb5;hpb=a87694dc525b4eabff11029f1e5401621e2bd3bc;p=kivitendo-erp.git diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index f2170ae89..0f5a242a8 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -6,6 +6,7 @@ use POSIX qw(strftime); use Data::Dumper; use SL::DB::BankAccount; +use SL::DB::SepaExport; use SL::Chart; use SL::CT; use SL::Form; @@ -23,6 +24,7 @@ sub bank_transfer_add { my $form = $main::form; my $locale = $main::locale; my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; + my $vc_no = $form->{vc} eq 'customer' ? $::locale->text('VN') : $::locale->text('CN'); $form->{title} = $vc eq 'customer' ? $::locale->text('Prepare bank collection via SEPA XML') : $locale->text('Prepare bank transfer via SEPA XML'); @@ -55,6 +57,13 @@ sub bank_transfer_add { my $prefix = $translations{ $invoice->{language_id} } || $translations{default} || $::locale->text('Invoice'); $prefix .= ' ' unless $prefix =~ m/ $/; $invoice->{reference_prefix} = $prefix; + + # add c_vendor_id or v_vendor_id as a prefix if a entry exists + next unless $invoice->{vc_vc_id}; + + my $prefix_vc_number = $translations{ $invoice->{language_id} } || $translations{default} || $vc_no; + $prefix_vc_number .= ' ' unless $prefix_vc_number =~ m/ $/; + $invoice->{reference_prefix_vc} = ' ' . $prefix_vc_number unless $prefix_vc_number =~ m/^ /; } $form->header(); @@ -208,7 +217,7 @@ sub bank_transfer_list { my %filter = map +( $_ => $form->{"f_${_}"} ), grep { $form->{"f_${_}"} } - (qw(vc invnumber), + (qw(vc invnumber message_id), map { ("${_}_date_from", "${_}_date_to") } qw(export requested_execution execution)); $filter{executed} = $form->{l_executed} ? 1 : 0 if ($form->{l_executed} != $form->{l_not_executed}); @@ -234,9 +243,13 @@ sub bank_transfer_list { 'employee' => { 'text' => $locale->text('Employee'), }, 'executed' => { 'text' => $locale->text('Executed'), }, 'closed' => { 'text' => $locale->text('Closed'), }, + num_invoices => { 'text' => $locale->text('Number of invoices'), }, + sum_amounts => { 'text' => $locale->text('Sum of all amounts'), }, + message_ids => { 'text' => $locale->text('SEPA message IDs'), }, ); - my @columns = qw(selected id export_date employee executed closed); + my @columns = qw(selected id export_date employee executed closed num_invoices sum_amounts message_ids); + my %column_alignment = map { ($_ => 'right') } qw(num_invoices sum_amounts); foreach my $name (qw(id export_date employee executed closed)) { my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; @@ -246,10 +259,12 @@ sub bank_transfer_list { $column_defs{selected}->{visible} = $open_available ? 'HTML' : 0; $column_defs{executed}->{visible} = $form->{l_executed} && $form->{l_not_executed} ? 1 : 0; $column_defs{closed}->{visible} = $form->{l_closed} && $form->{l_open} ? 1 : 0; + $column_defs{$_}->{align} = $column_alignment{$_} for keys %column_alignment; my @options = (); push @options, ($vc eq 'customer' ? $::locale->text('Customer') : $locale->text('Vendor')) . ' : ' . $form->{f_vc} if ($form->{f_vc}); push @options, $locale->text('Invoice number') . ' : ' . $form->{f_invnumber} if ($form->{f_invnumber}); + push @options, $locale->text('SEPA message ID') . ' : ' . $form->{f_message_id} if (length $form->{f_message_id}); push @options, $locale->text('Export date from') . ' : ' . $form->{f_export_date_from} if ($form->{f_export_date_from}); push @options, $locale->text('Export date to') . ' : ' . $form->{f_export_date_to} if ($form->{f_export_date_to}); push @options, $locale->text('Requested execution date from') . ' : ' . $form->{f_requested_execution_date_from} if ($form->{f_requested_execution_date_from}); @@ -278,12 +293,14 @@ sub bank_transfer_list { my $edit_url = build_std_url('action=bank_transfer_edit', 'callback'); foreach my $export (@{ $exports }) { - my $row = { map { $_ => { 'data' => $export->{$_} } } keys %{ $export } }; + my $row = { map { $_ => { 'data' => $export->{$_}, 'align' => $column_alignment{$_} } } keys %{ $export } }; map { $row->{$_}->{data} = $export->{$_} ? $locale->text('yes') : $locale->text('no') } qw(executed closed); $row->{id}->{link} = $edit_url . '&id=' . E($export->{id}) . '&vc=' . E($vc); + $row->{$_}->{data} = $::form->format_amount(\%::myconfig, $row->{$_}->{data}, 2) for qw(sum_amounts); + if (!$export->{closed}) { $row->{selected}->{raw_data} = $cgi->hidden(-name => "exports[+].id", -value => $export->{id}) @@ -540,6 +557,15 @@ sub bank_transfer_download_sepa_xml { 'date_of_signature' => $item->{mandate_date_of_signature}, }); } + # Store the message ID used in each of the entries in order to + # facilitate finding them by looking at bank statements. + foreach my $id (@ids) { + SL::DB::SepaExportMessageId->new( + sepa_export_id => $id, + message_id => $message_id, + )->save; + } + my $xml = $sepa_xml->to_xml(); print $cgi->header('-type' => 'application/octet-stream',