- 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 ||
- ( $bt->transaction_code eq "191" && 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')});
- };
- };
-
+ if(!$self->skonto_date) {
+ push(@options, { payment_type => 'without_skonto', display => t8('without skonto'), selected => 1 });
+ # wrong call to presenter or not implemented? disabled option is ignored
+ # push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), disabled => 1 });
+ push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
+ return @options;
+ }
+ # valid skonto date, check if skonto is preferred
+ my $bt = SL::DB::BankTransaction->new(id => $bt_id)->load;
+ 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 }) if $skontoable;
+ } 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')}) if $skontoable;
+ }
+ push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;