From a4bbff925a569d6a901dcd49d0a5121503165173 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 7 Mar 2019 13:20:01 +0100 Subject: [PATCH] Payment Kosmetik/Konvention MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit POD aktualisiert. Pflicht-Parameter am Anfang der Methode prüfen --- SL/DB/Helper/Payment.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 31795cccb..2f67945d2 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -39,6 +39,10 @@ sub pay_invoice { # check for required parameters Common::check_params(\%params, qw(chart_id transdate)); + if ( $params{'payment_type'} eq 'without_skonto' && abs($params{'amount'}) < 0) { + croak "invalid amount for payment_type 'without_skonto': $params{'amount'}\n"; + } + my $transdate_obj; if (ref($params{transdate} eq 'DateTime')) { @@ -84,11 +88,6 @@ sub pay_invoice { $exchangerate = 1; }; - # input checks: - if ( $params{'payment_type'} eq 'without_skonto' ) { - croak "invalid amount for payment_type 'without_skonto': $params{'amount'}\n" unless abs($params{'amount'}) > 0; - }; - # options with_skonto_pt and difference_as_skonto don't require the parameter # amount, but if amount is passed, make sure it matches the expected value if ( $params{'payment_type'} eq 'difference_as_skonto' ) { @@ -756,6 +755,14 @@ Create a payment booking for an existing invoice object (type ar/ap/is/ir) via a configured bank account. This function deals with all the acc_trans entries and also updates paid and datepaid. +The params C and C are mandantory. +If the default payment ('without_skonto') is used the param amount is also +mandantory. + +Transdate can either be a date object or a date string. +Chart_id is the id of the payment booking chart. +Amount is either a postive or negative number, but never 0. + Example: -- 2.20.1