From 0d5b91f1e71d914fea9d006e64c63665f011b1ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Fri, 7 Sep 2018 10:18:32 +0200 Subject: [PATCH] fix #359 get_payment_select_options_for_bank_transaction vereinfachen --- SL/DB/Helper/Payment.pm | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 9555f001a..17b24f8f6 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -630,28 +630,25 @@ sub get_payment_select_options_for_bank_transaction { my ($self, $bt_id, %params) = @_; my $bt = SL::DB::Manager::BankTransaction->find_by( id => $bt_id ); - die unless $bt; + croak ("Need bt_id to get a valid bank transaction") unless $bt; + + # user may overpay invoices and if not, this case should better be handled elsewhere + #my $open_amount = $self->open_amount; + #croak ("Need an open invoice") unless $open_amount; - my $open_amount = $self->open_amount; - #$main::lxdebug->message(LXDebug->DEBUG2(),"skonto_date=".$self->skonto_date." open amount=".$open_amount); my @options; - if ( $open_amount && # invoice amount not 0 - $self->skonto_date && # check whether skonto applies - ( abs(abs($self->amount_less_skonto) - abs($bt->amount)) < 0.01 || - ( abs($self->amount_less_skonto) < abs($bt->amount) )) && - $self->check_skonto_configuration) { - if ( $self->within_skonto_period($bt->transdate) ) { - push(@options, { payment_type => 'without_skonto', display => t8('without skonto') }); - push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }); - } else { - push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 }); - push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}); - }; - }; - return @options; + if ($self->skonto_date && $self->within_skonto_period($bt->transdate)) { + push(@options, { payment_type => 'without_skonto', display => t8('without skonto') }); + push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }); + } else { + push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 }); + push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}); + } + } -}; + return @options; +} sub exchangerate { my ($self) = @_; -- 2.20.1