X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fsepa.pl;h=9f9f31a222044a0a79999df11ff855f41ef25622;hb=cdacfe1cb5156c4bde158f0592d1dd3c445be7dd;hp=2305cf850f3f2d4c49cc3716a2bba8a72c9c0b07;hpb=3ef69a72577387de69e446352b780ae922550633;p=kivitendo-erp.git diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index 2305cf850..9f9f31a22 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -8,6 +8,7 @@ use SL::BankAccount; use SL::Chart; use SL::CT; use SL::Form; +use SL::GenericTranslations; use SL::ReportGenerator; use SL::SEPA; use SL::SEPA::XML; @@ -41,6 +42,15 @@ sub bank_transfer_add { my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) }; + my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx'); + my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list }; + + foreach my $invoice (@{ $invoices }) { + my $prefix = $translations{ $invoice->{language_id} } || $translations{default} || $::locale->text('Invoice'); + $prefix .= ' ' unless $prefix =~ m/ $/; + $invoice->{reference_prefix} = $prefix; + } + $form->header(); print $form->parse_html_template('sepa/bank_transfer_add', { 'INVOICES' => $invoices, @@ -238,6 +248,7 @@ sub bank_transfer_list { 'attachment_basename' => $locale->text('banktransfers') . strftime('_%Y%m%d', localtime time), ); $report->set_options_from_form(); + $locale->set_numberformat_wo_thousands_separator(\%::myconfig) if lc($report->{options}->{output_format}) eq 'csv'; $report->set_columns(%column_defs); $report->set_column_order(@columns); @@ -425,6 +436,7 @@ sub bank_transfer_payment_list_as_pdf { $main::lxdebug->leave_sub(); } +# TODO sub bank_transfer_download_sepa_xml { $main::lxdebug->enter_sub(); @@ -432,11 +444,16 @@ sub bank_transfer_download_sepa_xml { my $myconfig = \%main::myconfig; my $locale = $main::locale; my $cgi = $main::cgi; + my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; if (!$myconfig->{company}) { $form->show_generic_error($locale->text('You have to enter a company name in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); } + if (($vc eq 'customer') && !$myconfig->{sepa_creditor_id}) { + $form->show_generic_error($locale->text('You have to enter the SEPA creditor ID in your user preferences (see the "Program" menu, "Preferences").'), 'back_button' => 1); + } + my @ids; if ($form->{mode} && ($form->{mode} eq 'multi')) { @ids = map $_->{id}, grep { $_->{selected} } @{ $form->{exports} || [] }; @@ -452,7 +469,7 @@ sub bank_transfer_download_sepa_xml { my @items = (); foreach my $id (@ids) { - my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1); + my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc); push @items, grep { !$_->{executed} } @{ $export->{items} } if ($export && !$export->{closed}); } @@ -463,9 +480,11 @@ sub bank_transfer_download_sepa_xml { my $message_id = strftime('MSG%Y%m%d%H%M%S', localtime) . sprintf('%06d', $$); my $sepa_xml = SL::SEPA::XML->new('company' => $myconfig->{company}, - 'src_charset' => $main::dbcharset || 'ISO-8859-15', + 'creditor_id' => $myconfig->{sepa_creditor_id}, + 'src_charset' => $::lx_office_conf{system}->{dbcharset} || 'ISO-8859-15', 'message_id' => $message_id, 'grouped' => 1, + 'collection' => $vc eq 'customer', ); foreach my $item (@items) { @@ -475,13 +494,19 @@ sub bank_transfer_download_sepa_xml { $requested_execution_date = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; } + if ($vc eq 'customer') { + my ($yy, $mm, $dd) = $locale->parse_date($myconfig, $item->{reference_date}); + $item->{reference_date} = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; + } + $sepa_xml->add_transaction({ 'src_iban' => $item->{our_iban}, 'src_bic' => $item->{our_bic}, - 'dst_iban' => $item->{vendor_iban}, - 'dst_bic' => $item->{vendor_bic}, - 'recipient' => $item->{vendor_name}, + 'dst_iban' => $item->{vc_iban}, + 'dst_bic' => $item->{vc_bic}, + 'company' => $item->{vc_name}, 'amount' => $item->{amount}, 'reference' => $item->{reference}, + 'reference_date' => $item->{reference_date}, 'execution_date' => $requested_execution_date, 'end_to_end_id' => $item->{end_to_end_id} }); } @@ -489,7 +514,7 @@ sub bank_transfer_download_sepa_xml { my $xml = $sepa_xml->to_xml(); print $cgi->header('-type' => 'application/octet-stream', - '-content-disposition' => 'attachment; filename="SEPA_' . $message_id . '.cct"', + '-content-disposition' => 'attachment; filename="SEPA_' . $message_id . ($vc eq 'customer' ? '.cdd' : '.cct') . '"', '-content-length' => length $xml); print $xml;