Revision 0d5b91f1
Von Jan Büren vor etwa 6 Jahren hinzugefügt
SL/DB/Helper/Payment.pm | ||
---|---|---|
630 | 630 |
my ($self, $bt_id, %params) = @_; |
631 | 631 |
|
632 | 632 |
my $bt = SL::DB::Manager::BankTransaction->find_by( id => $bt_id ); |
633 |
die unless $bt; |
|
633 |
croak ("Need bt_id to get a valid bank transaction") unless $bt; |
|
634 |
|
|
635 |
# user may overpay invoices and if not, this case should better be handled elsewhere |
|
636 |
#my $open_amount = $self->open_amount; |
|
637 |
#croak ("Need an open invoice") unless $open_amount; |
|
634 | 638 |
|
635 |
my $open_amount = $self->open_amount; |
|
636 |
#$main::lxdebug->message(LXDebug->DEBUG2(),"skonto_date=".$self->skonto_date." open amount=".$open_amount); |
|
637 | 639 |
my @options; |
638 |
if ( $open_amount && # invoice amount not 0 |
|
639 |
$self->skonto_date && # check whether skonto applies |
|
640 |
( abs(abs($self->amount_less_skonto) - abs($bt->amount)) < 0.01 || |
|
641 |
( abs($self->amount_less_skonto) < abs($bt->amount) )) && |
|
642 |
$self->check_skonto_configuration) { |
|
643 |
if ( $self->within_skonto_period($bt->transdate) ) { |
|
644 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') }); |
|
645 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }); |
|
646 |
} else { |
|
647 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 }); |
|
648 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}); |
|
649 |
}; |
|
650 |
}; |
|
651 | 640 |
|
652 |
return @options; |
|
641 |
if ($self->skonto_date && $self->within_skonto_period($bt->transdate)) { |
|
642 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') }); |
|
643 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }); |
|
644 |
} else { |
|
645 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 }); |
|
646 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}); |
|
647 |
} |
|
648 |
} |
|
653 | 649 |
|
654 |
}; |
|
650 |
return @options; |
|
651 |
} |
|
655 | 652 |
|
656 | 653 |
sub exchangerate { |
657 | 654 |
my ($self) = @_; |
Auch abrufbar als: Unified diff
fix #359 get_payment_select_options_for_bank_transaction vereinfachen