From 60b170eb823d19d211db6412d2137129113e5c84 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Wed, 19 Jul 2017 12:55:41 +0200 Subject: [PATCH] =?utf8?q?SEPA-Export=20r=C3=BCckg=C3=A4ngig=20machen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Noch nicht ausgeführte oder geschloßene SEPA-XML Exports können wieder rückgängig gemacht werden, sodass der Anwender hier die Chance hat Metadaten für die Banküberweisungen, z.B. IBAN oder andere Fehleinträge, z.B Betrag, Termin erneut zu setzen. --- SL/SEPA.pm | 70 +++++++++++++++++++++++++++++++++++++++++++++ bin/mozilla/sepa.pl | 23 ++++++++++++++- locale/de/all | 3 ++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/SL/SEPA.pm b/SL/SEPA.pm index 3231ac9e9..373711d47 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -11,6 +11,7 @@ use SL::DB::PurchaseInvoice; use SL::DB; use SL::Locale::String qw(t8); use DateTime; +use Carp; sub retrieve_open_invoices { $main::lxdebug->enter_sub(); @@ -291,6 +292,25 @@ sub close_export { $main::lxdebug->leave_sub(); } +sub undo_export { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(id)); + + my $sepa_export = SL::DB::Manager::SepaExport->find_by(id => $params{id}); + + croak "Not a valid SEPA Export id: $params{id}" unless $sepa_export; + croak "Cannot undo closed exports." if $sepa_export->closed; + croak "Cannot undo executed exports." if $sepa_export->executed; + + die "Could not undo $sepa_export->id" if !$sepa_export->delete(); + + $main::lxdebug->leave_sub(); +} + sub list_exports { $main::lxdebug->enter_sub(); @@ -525,3 +545,53 @@ sub _post_payment { } 1; + + +__END__ + +=head1 NAME + +SL::SEPA - Base class for SEPA objects + +=head1 SYNOPSIS + + # get all open invoices we like to pay via SEPA + my $invoices = SL::SEPA->retrieve_open_invoices(vc => 'vendor'); + + # add some IBAN and purposes for open transaction + # and assign this to a SEPA export + my $id = SL::SEPA->create_export('employee' => $::myconfig{login}, + 'bank_transfers' => \@bank_transfers, + 'vc' => 'vendor'); + +=head1 DESCRIPTIONS + +This is the base class for SEPA. SEPA and the underlying directories +(SEPA::XML etc) are used to genereate valid XML files for the SEPA +(Single European Payment Area) specification and offers this structure +as a download via a xml file. + +An export can have one or more transaction which have to +comply to the specification (IBAN, BIC, amount, purpose, etc). + +Furthermore kivitendo sepa exports have two +valid states: Open or closed and executed or not executed. + +The state closed can be set via a user interface and the +state executed is automatically assigned if the action payment +is triggered. + +=head1 FUNCTIONS + +=head2 C $sepa_export_id + +Needs a valid sepa_export id and deletes the sepa export if +the state of the export is neither executed nor closed. +Returns undef if the deletion was successfully. +Otherwise the function just dies with a short notice of the id. + +=cut + + + + diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index b373b8a59..36f2ff4c6 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -607,13 +607,28 @@ sub bank_transfer_mark_as_closed { $main::lxdebug->leave_sub(); } +sub bank_transfer_undo_sepa_xml { + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my $locale = $main::locale; + + map { SL::SEPA->undo_export('id' => $_); } @{ $form->{ids} || [] }; + + $form->{title} = $locale->text('Undo SEPA exports'); + $form->header(); + $form->show_generic_information($locale->text('The selected exports have been undone.')); + + $main::lxdebug->leave_sub(); +} + sub dispatcher { my $form = $main::form; 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_payment_list_as_pdf bank_transfer_undo_sepa_xml)) { if ($form->{"action_${action}"}) { call_sub($action); return; @@ -697,6 +712,12 @@ sub setup_sepa_list_transfers_action_bar { confirm => [ $params{is_vendor} ? t8('Do you really want to close the selected SEPA exports? No payment will be recorded for bank transfers that haven\'t been marked as executed yet.') : t8('Do you really want to close the selected SEPA exports? No payment will be recorded for bank collections that haven\'t been marked as executed yet.') ], ], + action => [ + t8('Undo SEPA exports'), + submit => [ '#form', { action => 'bank_transfer_undo_sepa_xml' } ], + checks => [ [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ], + confirm => [ t8('Do you really want to undo the selected SEPA exports? You have to reassign the export again.') ], + ], ], # end of combobox "Actions" ); } diff --git a/locale/de/all b/locale/de/all index dfc123cec..b1c3b3dcf 100755 --- a/locale/de/all +++ b/locale/de/all @@ -991,6 +991,7 @@ $self->{texts} = { 'Do you really want to delete this record template?' => 'Wollen Sie diese Belegvorlage wirklich löschen?', 'Do you really want to revert to this version?' => 'Wollen Sie wirklich auf diese Version zurücksetzen?', 'Do you really want to save?' => 'Wollen Sie wirklich speichern?', + 'Do you really want to undo the selected SEPA exports? You have to reassign the export again.' => 'Möchten Sie wirklich die ausgewählten SEPA-Exports rückgängig machen? Der Export muss anschließend neu erzeugt werden.', 'Do you really want to unimport the selected documents?' => 'Wollen Sie wirklich diese Dateien an die Quelle zurückgeben?', 'Do you want to limit your search?' => 'Wollen Sie Ihre Suche spezialisieren?', 'Do you want to carry this shipping address over to the new purchase order so that the vendor can deliver the goods directly to your customer?' => 'Wollen Sie diese Lieferadresse in den neuen Lieferantenauftrag übernehmen, damit der Händler die Waren direkt an Ihren Kunden liefern kann?', @@ -3107,6 +3108,7 @@ $self->{texts} = { 'The selected currency' => 'Die ausgewählte Währung', 'The selected database is still configured for client "#1". If you delete the database that client will stop working until you re-configure it. Do you still want to delete the database?' => 'Die auswählte Datenbank ist noch für Mandant "#1" konfiguriert. Wenn Sie die Datenbank löschen, wird der Mandanten nicht mehr funktionieren, bis er anders konfiguriert wurde. Wollen Sie die Datenbank trotzdem löschen?', 'The selected exports have been closed.' => 'Die ausgewählten Exporte wurden abgeschlossen.', + 'The selected exports have been undone.' => 'Die ausgwählten Exporte wurden rückgängig gemacht.', 'The selected warehouse does not exist.' => 'Das ausgewählte Lager existiert nicht.', 'The selected warehouse is empty, or no stocked items where found that match the filter settings.' => 'Das ausgewählte Lager ist leer, oder in ihm wurden keine zu den Sucheinstellungen passenden eingelagerten Artikel gefunden.', 'The session has expired. Please log in again.' => 'Die Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.', @@ -3374,6 +3376,7 @@ $self->{texts} = { 'UStVa Einstellungen' => 'UStVa Einstellungen', 'Unbalanced Ledger' => 'Bilanzfehler', 'Unchecked custom variables will not appear in orders and invoices.' => 'Unmarkierte Variablen werden für diesen Artikel nicht in Aufträgen und Rechnungen angezeigt.', + 'Undo SEPA exports' => 'SEPA-Exporte rückgängig machen', 'Unfinished follow-ups' => 'Nicht erledigte Wiedervorlagen', 'Unfortunately you have no warehouse defined.' => 'Leider, gibt es kein Lager in diesem Mandanten.', 'Unimport all' => 'Alle zurück zur Quelle', -- 2.20.1