Revision 6c0095f1
Von Jan Büren vor mehr als 5 Jahren hinzugefügt
SL/DB/Helper/Payment.pm | ||
---|---|---|
461 | 461 |
|
462 | 462 |
sub amount_less_skonto { |
463 | 463 |
# amount that has to be paid if skonto applies, always return positive rounded values |
464 |
# no, rare case, but credit_notes and negative ap have negative amounts |
|
465 |
# and therefore this comment may be misguiding |
|
464 | 466 |
# the result is rounded so we can directly compare it with the user input |
465 | 467 |
my $self = shift; |
466 | 468 |
|
... | ... | |
650 | 652 |
|
651 | 653 |
|
652 | 654 |
# CAVEAT template code expects with_skonto_pt at position 1 for visual help |
655 |
# due to skonto_charts, we cannot offer skonto for credit notes and neg ap |
|
656 |
my $skontoable = $self->amount > 0 ? 1 : 0; |
|
653 | 657 |
my @options; |
654 | 658 |
if(!$self->skonto_date) { |
655 | 659 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto'), selected => 1 }); |
656 | 660 |
# wrong call to presenter or not implemented? disabled option is ignored |
657 | 661 |
# push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), disabled => 1 }); |
658 |
push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }); |
|
662 |
push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
|
|
659 | 663 |
return @options; |
660 | 664 |
} |
661 | 665 |
# valid skonto date, check if skonto is preferred |
662 | 666 |
my $bt = SL::DB::BankTransaction->new(id => $bt_id)->load; |
663 | 667 |
if ($self->skonto_date && $self->within_skonto_period($bt->transdate)) { |
664 | 668 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') }); |
665 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }); |
|
669 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt'), selected => 1 }) if $skontoable;
|
|
666 | 670 |
} else { |
667 | 671 |
push(@options, { payment_type => 'without_skonto', display => t8('without skonto') , selected => 1 }); |
668 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}); |
|
672 |
push(@options, { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt')}) if $skontoable;
|
|
669 | 673 |
} |
670 |
push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }); |
|
674 |
push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable;
|
|
671 | 675 |
return @options; |
672 | 676 |
} |
673 | 677 |
|
... | ... | |
783 | 787 |
The params C<transdate> and C<chart_id> are mandantory. |
784 | 788 |
If the default payment ('without_skonto') is used the param amount is also |
785 | 789 |
mandantory. |
786 |
If the payment type ('free_skonto') is used the number param skonto_amount |
|
787 |
is as well mandantory and has to be lower than the currently open invoice amount. |
|
790 |
If the payment type ('free_skonto') is used the number params skonto_amount and amount |
|
791 |
are as well mandantory and need to be positive. Furthermore the skonto amount has |
|
792 |
to be lower than the payment or open invoice amount. |
|
788 | 793 |
|
789 | 794 |
Transdate can either be a date object or a date string. |
790 | 795 |
Chart_id is the id of the payment booking chart. |
... | ... | |
1131 | 1136 |
when looking at open amount, maybe consider that there may already be queued |
1132 | 1137 |
amounts in SEPA Export |
1133 | 1138 |
|
1139 |
=item * C<skonto_charts> |
|
1140 |
|
|
1141 |
Cannot handle negative skonto amounts, will always calculate the skonto amount |
|
1142 |
for credit notes or negative ap transactions with a positive sign. |
|
1143 |
|
|
1144 |
|
|
1134 | 1145 |
=back |
1135 | 1146 |
|
1136 | 1147 |
=head1 AUTHOR |
Auch abrufbar als: Unified diff
Kontoauszug verbuchen: Neuen Skonto-Typ
Eingabe eines freien Skonto-Betrags in der Maske aktiv.
Ferner Anzeigen des Skonto-Betrags bei with_skonto_pt, damit
der Anwender besser visuell unterstützt wird.