From: Jan Büren Date: Fri, 25 Mar 2022 08:15:24 +0000 (+0100) Subject: Payment-Helper: free_skonto erweitert: skonto_amount == open_amount X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~91 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=e04af795e8743267d6e9304ab9d99bdde7893cb9;p=kivitendo-erp.git Payment-Helper: free_skonto erweitert: skonto_amount == open_amount --- diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index a748ae004..6a8f34b72 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -51,13 +51,13 @@ sub pay_invoice { # we force caller input for amount and skonto amount Common::check_params(\%params, qw(amount skonto_amount)); # secondly we dont want to handle credit notes and purchase credit notes - croak("Cannot use 'free skonto' for credit or debit notes") if ($params{amount} <= 0 || $params{skonto_amount} <= 0); + croak("Cannot use 'free skonto' for credit or debit notes") if ($params{amount} < 0 || $params{skonto_amount} <= 0); # both amount have to be rounded $params{skonto_amount} = _round($params{skonto_amount}); $params{amount} = _round($params{amount}); - # lastly skonto_amount has to be smaller than the open invoice amount or payment amount ;-) - if ($params{skonto_amount} > abs($self->open_amount) || $params{skonto_amount} > $params{amount}) { - croak("Skonto amount higher than the payment or invoice amount"); + # lastly skonto_amount has to be smaller or equal than the open invoice amount + if ($params{skonto_amount} > _round($self->open_amount)) { + croak("Skonto amount:" . $params{skonto_amount} . " higher than the payment or open invoice amount:" . $self->open_amount); } } @@ -147,7 +147,7 @@ sub pay_invoice { # as long as there is no automatic tax, payments are always booked with # taxkey 0 - unless ( $params{payment_type} eq 'difference_as_skonto' ) { + unless ( $rounded_params_amount == 0 || $params{payment_type} eq 'difference_as_skonto' ) { # cases with_skonto_pt, free_skonto and without_skonto # for case with_skonto_pt we need to know the corrected amount at this