Skip to content

Commit

Permalink
Beim SEPA-Lauf für Überweisungen auch eine Liste der hinterlegten PDF…
Browse files Browse the repository at this point in the history
…s anbieten
  • Loading branch information
kivijan committed Jan 19, 2024
1 parent f337e7b commit 7ad2ba0
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
65 changes: 64 additions & 1 deletion bin/mozilla/sepa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,68 @@ sub bank_transfer_download_sepa_xml {

$main::lxdebug->leave_sub();
}
sub bank_transfer_download_sepa_docs {
$main::lxdebug->enter_sub();

my $form = $main::form;
my $defaults = SL::DB::Default->get;
my $locale = $main::locale;
my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor';

if (!$defaults->doc_storage) {
$form->show_generic_error($locale->text('Doc Storage is not enabled'));
}

my @ids;
if ($form->{mode} && ($form->{mode} eq 'multi')) {
@ids = @{ $form->{ids} || [] };
} else {
@ids = ($form->{id});
}

if (!@ids) {
$form->show_generic_error($locale->text('You have not selected any export.'));
}

my @items = ();

foreach my $id (@ids) {
my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc);
push @items, @{ $export->{items} } if ($export);
}
my @files;
foreach my $item (@items) {

# check if there is already a file for the invoice
# File::get_all and converting to scalar is a tiny bit stupid, see Form.pm,
# but there is no get_latest_version (but sorts objects by itime!)
# check if already resynced
my ( $file_object ) = SL::File->get_all(object_id => $item->{ap_id} ? $item->{ap_id} : $item->{ar_id},
object_type => $item->{ap_id} ? 'purchase_invoice' : 'invoice',
file_type => 'document',
);
next if (ref $file_object ne 'SL::File::Object');
next unless $file_object->mime_type eq 'application/pdf';

my $file = $file_object->get_file;
die "No file" unless -e $file;
push @files, $file;
}
my $inputfiles = join " ", @files;
my $downloadname = $locale->text('SEPA XML Docs for Exports ') . (join " ", @ids) . ".pdf";
my $in = IO::File->new($::lx_office_conf{applications}->{ghostscript} . " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |");

$form->error($main::locale->text('Could not spawn ghostscript.')) unless $in;

print $::form->create_http_response(content_type => 'Application/PDF',
content_disposition => 'attachment; filename="'. $downloadname . '"');

$::locale->with_raw_io(\*STDOUT, sub { print while <$in> });
$in->close;

$main::lxdebug->leave_sub();
}


sub bank_transfer_mark_as_closed {
$main::lxdebug->enter_sub();
Expand Down Expand Up @@ -643,7 +705,8 @@ sub dispatcher {
foreach my $action (qw(bank_transfer_create bank_transfer_edit bank_transfer_list
bank_transfer_post_payments bank_transfer_download_sepa_xml
bank_transfer_mark_as_closed_step1 bank_transfer_mark_as_closed_step2
bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml)) {
bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml
bank_transfer_download_sepa_docs)) {
if ($form->{"action_${action}"}) {
call_sub($action);
return;
Expand Down
3 changes: 3 additions & 0 deletions locale/de/all
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,7 @@ $self->{texts} = {
'Do you want to overwrite your current title?' => 'Möchten Sie den aktuellen Titel überschreiben?',
'Do you want to set the account number "#1" to "#2" and the name "#3" to "#4"?' => 'Soll die Kontonummer "#1" zu "#2" und den Name "#3" zu "#4" geändert werden?',
'Do you want to store the existing onhand values into a new warehouse?' => 'Möchten Sie die vorhandenen Mengendaten in ein Lager übertragen?',
'Doc Storage is not enabled' => 'DMS Funktion ist nicht aktiviert',
'Document' => 'Dokument',
'Document Count' => 'Anz. PDF Belege',
'Document Project (database ID)' => 'Projektnummer des Belegs (Datenbank-ID)',
Expand All @@ -1329,6 +1330,7 @@ $self->{texts} = {
'Done.' => 'Fertig.',
'Double partnumbers' => 'Doppelte Artikelnummern',
'Download' => 'Download',
'Download Documents for exported bookings' => 'Download hinterlegte PDFs zum aktuellen SEPA-Lauf',
'Download PDF' => 'PDF herunterladen',
'Download PDF, do not print' => 'Nicht drucken, sondern PDF herunterladen',
'Download SEPA XML export file' => 'SEPA-XML-Exportdatei herunterladen',
Expand Down Expand Up @@ -3341,6 +3343,7 @@ $ ./scripts/installation_check.pl',
'SCREENED' => 'Angezeigt',
'SEPA' => 'SEPA',
'SEPA Transfer Amount' => 'Betrag in offenen SEPA Exporten',
'SEPA XML Docs for Exports ' => 'SEPA-XML-Dokumente Export-Nummer',
'SEPA XML download' => 'SEPA-XML-Download',
'SEPA creditor ID' => 'SEPA-Kreditoren-Identifikation',
'SEPA exports' => 'SEPA-Exporte',
Expand Down
3 changes: 3 additions & 0 deletions locale/en/all
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ $self->{texts} = {
'Do you want to overwrite your current title?' => '',
'Do you want to set the account number "#1" to "#2" and the name "#3" to "#4"?' => '',
'Do you want to store the existing onhand values into a new warehouse?' => '',
'Doc Storage is not enabled' => '',
'Document' => '',
'Document Count' => '',
'Document Project (database ID)' => '',
Expand All @@ -1328,6 +1329,7 @@ $self->{texts} = {
'Done.' => '',
'Double partnumbers' => '',
'Download' => '',
'Download Documents for exported bookings' => '',
'Download PDF' => '',
'Download PDF, do not print' => '',
'Download SEPA XML export file' => '',
Expand Down Expand Up @@ -3339,6 +3341,7 @@ $self->{texts} = {
'SCREENED' => '',
'SEPA' => '',
'SEPA Transfer Amount' => '',
'SEPA XML Docs for Exports ' => '',
'SEPA XML download' => '',
'SEPA creditor ID' => '',
'SEPA exports' => '',
Expand Down
3 changes: 3 additions & 0 deletions templates/design40_webpages/sepa/bank_transfer_created.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ <h1>[% title %]</h1>
<p>[% 'The SEPA export has been created.' | $T8 %]</p>
<ul>
<li><a href="sepa.pl?action=bank_transfer_download_sepa_xml&id=[% HTML.url(id) %]&vc=[% HTML.url(vc) %]"> [% 'Download SEPA XML export file' | $T8 %] </a></li>
[%- IF INSTANCE_CONF.get_doc_storage %]
<li><a href="sepa.pl?action=bank_transfer_download_sepa_docs&id=[% HTML.url(id) %]&vc=[% HTML.url(vc) %]"> [% 'Download Documents for exported bookings' | $T8 %] </a></li>
[% END %]
<li><a href="sepa.pl?action=bank_transfer_list&l_open=1&l_not_executed=1&vc=[% HTML.url(vc) %]"> [% 'List open SEPA exports' | $T8 %] </a></li>
</ul>
4 changes: 3 additions & 1 deletion templates/webpages/sepa/bank_transfer_created.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ <h1>[% title %]</h1>
[% 'Download SEPA XML export file' | $T8 %]
</a>
</li>

[%- IF INSTANCE_CONF.get_doc_storage %]
<li><a href="sepa.pl?action=bank_transfer_download_sepa_docs&id=[% HTML.url(id) %]&vc=[% HTML.url(vc) %]"> [% 'Download Documents for exported bookings' | $T8 %] </a></li>
[% END %]
<li>
<a href="sepa.pl?action=bank_transfer_list&l_open=1&l_not_executed=1&vc=[% HTML.url(vc) %]">
[% 'List open SEPA exports' | $T8 %]
Expand Down

0 comments on commit 7ad2ba0

Please sign in to comment.