Revision c1716dbd
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
bin/mozilla/sepa.pl | ||
---|---|---|
425 | 425 |
$main::lxdebug->leave_sub(); |
426 | 426 |
} |
427 | 427 |
|
428 |
# TODO |
|
428 | 429 |
sub bank_transfer_download_sepa_xml { |
429 | 430 |
$main::lxdebug->enter_sub(); |
430 | 431 |
|
... | ... | |
432 | 433 |
my $myconfig = \%main::myconfig; |
433 | 434 |
my $locale = $main::locale; |
434 | 435 |
my $cgi = $main::cgi; |
436 |
my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor'; |
|
435 | 437 |
|
436 | 438 |
if (!$myconfig->{company}) { |
437 | 439 |
$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); |
438 | 440 |
} |
439 | 441 |
|
442 |
if (($vc eq 'customer') && !$myconfig->{sepa_creditor_id}) { |
|
443 |
$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); |
|
444 |
} |
|
445 |
|
|
440 | 446 |
my @ids; |
441 | 447 |
if ($form->{mode} && ($form->{mode} eq 'multi')) { |
442 | 448 |
@ids = map $_->{id}, grep { $_->{selected} } @{ $form->{exports} || [] }; |
... | ... | |
452 | 458 |
my @items = (); |
453 | 459 |
|
454 | 460 |
foreach my $id (@ids) { |
455 |
my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1); |
|
461 |
my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc);
|
|
456 | 462 |
push @items, grep { !$_->{executed} } @{ $export->{items} } if ($export && !$export->{closed}); |
457 | 463 |
} |
458 | 464 |
|
... | ... | |
463 | 469 |
my $message_id = strftime('MSG%Y%m%d%H%M%S', localtime) . sprintf('%06d', $$); |
464 | 470 |
|
465 | 471 |
my $sepa_xml = SL::SEPA::XML->new('company' => $myconfig->{company}, |
472 |
'creditor_id' => $myconfig->{sepa_creditor_id}, |
|
466 | 473 |
'src_charset' => $main::dbcharset || 'ISO-8859-15', |
467 | 474 |
'message_id' => $message_id, |
468 | 475 |
'grouped' => 1, |
476 |
'collection' => $vc eq 'customer', |
|
469 | 477 |
); |
470 | 478 |
|
471 | 479 |
foreach my $item (@items) { |
... | ... | |
475 | 483 |
$requested_execution_date = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; |
476 | 484 |
} |
477 | 485 |
|
486 |
if ($vc eq 'customer') { |
|
487 |
my ($yy, $mm, $dd) = $locale->parse_date($myconfig, $item->{reference_date}); |
|
488 |
$item->{reference_date} = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; |
|
489 |
} |
|
490 |
|
|
478 | 491 |
$sepa_xml->add_transaction({ 'src_iban' => $item->{our_iban}, |
479 | 492 |
'src_bic' => $item->{our_bic}, |
480 |
'dst_iban' => $item->{vendor_iban},
|
|
481 |
'dst_bic' => $item->{vendor_bic},
|
|
482 |
'recipient' => $item->{vendor_name},
|
|
493 |
'dst_iban' => $item->{vc_iban},
|
|
494 |
'dst_bic' => $item->{vc_bic},
|
|
495 |
'company' => $item->{vc_name},
|
|
483 | 496 |
'amount' => $item->{amount}, |
484 | 497 |
'reference' => $item->{reference}, |
498 |
'reference_date' => $item->{reference_date}, |
|
485 | 499 |
'execution_date' => $requested_execution_date, |
486 | 500 |
'end_to_end_id' => $item->{end_to_end_id} }); |
487 | 501 |
} |
... | ... | |
489 | 503 |
my $xml = $sepa_xml->to_xml(); |
490 | 504 |
|
491 | 505 |
print $cgi->header('-type' => 'application/octet-stream', |
492 |
'-content-disposition' => 'attachment; filename="SEPA_' . $message_id . '.cct"',
|
|
506 |
'-content-disposition' => 'attachment; filename="SEPA_' . $message_id . ($vc eq 'customer' ? '.cdd' : '.cct') . '"',
|
|
493 | 507 |
'-content-length' => length $xml); |
494 | 508 |
print $xml; |
495 | 509 |
|
Auch abrufbar als: Unified diff
Unterstützung für die XML-Ausgabe von Lastschriften