From 59adfa36c82c4e021011c84c70b9384badea33aa Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 18 Jan 2017 10:57:54 +0100 Subject: [PATCH] =?utf8?q?Alle=20Rechnungen:=20=C2=BBals=20bezahlt=20marki?= =?utf8?q?eren=C2=AB=20auf=20neue=20Funktionen=20in=20SL::DB::(Purchase)In?= =?utf8?q?voice=20umgestellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/ap.pl | 11 ++----- bin/mozilla/ar.pl | 11 ++----- bin/mozilla/common.pl | 43 -------------------------- bin/mozilla/ir.pl | 11 ++----- bin/mozilla/is.pl | 12 +++---- locale/de/all | 2 +- templates/webpages/ap/form_footer.html | 2 +- templates/webpages/ar/form_footer.html | 2 +- templates/webpages/ir/form_footer.html | 2 +- templates/webpages/is/form_footer.html | 2 +- 10 files changed, 18 insertions(+), 80 deletions(-) diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 765c2c06d..dc02d137b 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -470,16 +470,11 @@ sub form_footer { } sub mark_as_paid { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('ap_transactions'); + $::auth->assert('ap_transactions'); - &mark_as_paid_common(\%myconfig,"ap"); + SL::DB::PurchaseInvoice->new(id => $::form->{id})->load->mark_as_paid; - $main::lxdebug->leave_sub(); + $::form->redirect($::locale->text("Marked as paid")); } sub show_draft { diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 9416ac703..dc7074c61 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -443,16 +443,11 @@ sub form_footer { } sub mark_as_paid { - $main::lxdebug->enter_sub(); + $::auth->assert('ar_transactions'); - $main::auth->assert('ar_transactions'); + SL::DB::Invoice->new(id => $::form->{id})->load->mark_as_paid; - my $form = $main::form; - my %myconfig = %main::myconfig; - - &mark_as_paid_common(\%myconfig,"ar"); - - $main::lxdebug->leave_sub(); + $::form->redirect($::locale->text("Marked as paid")); } sub show_draft { diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 52366a0e3..8e77f6309 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -333,49 +333,6 @@ sub retrieve_partunits { # ------------------------------------------------------------------------- -sub mark_as_paid_common { - $main::lxdebug->enter_sub(); - - my ($myconfig, $db_name) = @_; - - my $form = $main::form; - my $locale = $main::locale; - - if($form->{mark_as_paid}) { - SL::DB->client->with_transaction(sub { - my $dbh ||= SL::DB->client->dbh; - my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|; - do_query($form, $dbh, $query, $form->{id}); - 1; - }) or do { $::form->error(SL::DB->client->error) }; - $form->redirect($locale->text("Marked as paid")); - - } else { - my $referer = $ENV{HTTP_REFERER}; - my $script; - my $callback; - if ($referer =~ /action/) { - $referer =~ /^(.*)\?action\=[^\&]*(\&.*)$/; - $script = $1; - $callback = $2; - } elsif ($referer =~ /RESTORE_FORM_FROM_SESSION_ID/){ - $referer =~ /^(.*)\?RESTORE_FORM_FROM_SESSION_ID\=(.*)$/; - $script = $1; - $callback = ""; - } else { - $script = $referer; - $callback = ""; - } - $referer = $script . "?action=mark_as_paid&mark_as_paid=1&id=$form->{id}" . $callback; - $form->header(); - print qq|

|.$locale->text('Mark as paid?').qq|

|; - print qq| |; - print qq||; - } - - $main::lxdebug->leave_sub(); -} - sub cov_selection_internal { $main::lxdebug->enter_sub(); diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 19b4f74a1..d4a42a78d 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -468,16 +468,11 @@ sub form_footer { } sub mark_as_paid { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('vendor_invoice_edit'); + $::auth->assert('vendor_invoice_edit'); - &mark_as_paid_common(\%myconfig,"ap"); + SL::DB::PurchaseInvoice->new(id => $::form->{id})->load->mark_as_paid; - $main::lxdebug->leave_sub(); + $::form->redirect($::locale->text("Marked as paid")); } sub show_draft { diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 4007f8d3b..5db9b9cf1 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -45,6 +45,7 @@ use English qw(-no_match_vars); use SL::DB::Default; use SL::DB::Customer; +use SL::DB::Invoice; use SL::DB::PaymentTerm; require "bin/mozilla/io.pl"; @@ -535,16 +536,11 @@ sub form_footer { } sub mark_as_paid { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('invoice_edit'); + $::auth->assert('invoice_edit'); - &mark_as_paid_common(\%myconfig,"ar"); + SL::DB::Invoice->new(id => $::form->{id})->load->mark_as_paid; - $main::lxdebug->leave_sub(); + $::form->redirect($::locale->text("Marked as paid")); } sub show_draft { diff --git a/locale/de/all b/locale/de/all index 688086ae4..f74e59bd7 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1711,7 +1711,6 @@ $self->{texts} = { 'Margetotal' => 'Ertrag', 'Margins' => 'Seitenränder', 'Mark as closed' => 'Abschließen', - 'Mark as paid?' => 'Als bezahlt markieren?', 'Mark as shop article if column missing' => 'Als Shopartikel setzen, falls Spalte nicht vorhanden', 'Mark closed' => 'Als geschlossen markieren', 'Marked as paid' => 'Als bezahlt markiert', @@ -3230,6 +3229,7 @@ $self->{texts} = { 'This will be treated as a discount in percent points.' => 'Diese Option schlägt den Wert in Prozentpunkten als Rabatt vor.', 'This will happen before the price is offered, and the reduction will not be printed in documents.' => 'Das passiert, bevor der Preis vorgeschlagen wird, und der Abschlag wird nicht in Belegen ausgewiesen.', 'This will reduce the appropriate Master Data price by this in percent points.' => 'Diese Option reduziert den zugehörigen Stammdatenpreis um den angegebenen Wert in Prozentpunkten.', + 'This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?' => 'Dies wird die Rechnung nicht mehr als offen anzeigen, auch wenn der unbezahlte Betrag nicht dem Rechnungsbetrag entspricht. Fortfahren?', 'This will set an exact price.' => 'Diese Option setzt einen festen Preis.', 'Three Options:' => 'Drei Optionen:', 'Time' => 'Zeit', diff --git a/templates/webpages/ap/form_footer.html b/templates/webpages/ap/form_footer.html index c3611a207..0d948d2a5 100644 --- a/templates/webpages/ap/form_footer.html +++ b/templates/webpages/ap/form_footer.html @@ -38,7 +38,7 @@ [%- IF id %] [% IF INSTANCE_CONF.get_ap_show_mark_as_paid %] - + [% L.submit_tag("action", LxERP.t8('mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %] [% END %] [%- END %] diff --git a/templates/webpages/ar/form_footer.html b/templates/webpages/ar/form_footer.html index 5ce251c39..484985cae 100644 --- a/templates/webpages/ar/form_footer.html +++ b/templates/webpages/ar/form_footer.html @@ -40,7 +40,7 @@ [% END %] [% IF ( show_mark_as_paid_button ) %] - + [% L.submit_tag("action", LxERP.t8('mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %] [% END %] diff --git a/templates/webpages/ir/form_footer.html b/templates/webpages/ir/form_footer.html index 67a49a5a2..f07a2b810 100644 --- a/templates/webpages/ir/form_footer.html +++ b/templates/webpages/ir/form_footer.html @@ -146,7 +146,7 @@ [% IF INSTANCE_CONF.get_ir_show_mark_as_paid %] - + [% L.submit_tag("action", LxERP.t8('mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %] [% END %] [% END %] diff --git a/templates/webpages/is/form_footer.html b/templates/webpages/is/form_footer.html index caadf3e85..912218a48 100644 --- a/templates/webpages/is/form_footer.html +++ b/templates/webpages/is/form_footer.html @@ -190,7 +190,7 @@ [%#- button for saving history %] [% IF INSTANCE_CONF.get_is_show_mark_as_paid %] - + [% L.submit_tag("action_mark_as_paid", LxERP.t8('mark as paid'), confirm=LxERP.t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?')) %] [% END %] [% END %] -- 2.20.1