X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/69e03937db84180c261015cedb3a97c01c017477..dc78c22510c618deef355808393ecc7bcde319a3:/SL/DB/Helper/Payment.pm diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index dced3d713..3522e64f6 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -461,6 +461,8 @@ sub percent_skonto { sub amount_less_skonto { # amount that has to be paid if skonto applies, always return positive rounded values + # no, rare case, but credit_notes and negative ap have negative amounts + # and therefore this comment may be misguiding # the result is rounded so we can directly compare it with the user input my $self = shift; @@ -650,24 +652,26 @@ sub get_payment_select_options_for_bank_transaction { # CAVEAT template code expects with_skonto_pt at position 1 for visual help + # due to skonto_charts, we cannot offer skonto for credit notes and neg ap + my $skontoable = $self->amount > 0 ? 1 : 0; my @options; 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') }); + 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 }); + 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')}); + 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') }); + push(@options, { payment_type => 'free_skonto', display => t8('free skonto') }) if $skontoable; return @options; } @@ -783,8 +787,9 @@ This function deals with all the acc_trans entries and also updates paid and dat The params C and C are mandantory. If the default payment ('without_skonto') is used the param amount is also mandantory. -If the payment type ('free_skonto') is used the number param skonto_amount -is as well mandantory and has to be lower than the currently open invoice amount. +If the payment type ('free_skonto') is used the number params skonto_amount and amount +are as well mandantory and need to be positive. Furthermore the skonto amount has +to be lower than the payment or open invoice amount. Transdate can either be a date object or a date string. Chart_id is the id of the payment booking chart. @@ -881,6 +886,7 @@ invoice is assumed to be the payment currency. If successful the return value will be 1 in scalar context or in list context the two ids (acc_trans_id) of the newly created bookings. + =item C Returns a chart object which is the chart of the invoice with link AR or AP. @@ -1131,6 +1137,12 @@ Returns 1 if record uses a different currency, 0 if the default currency is used when looking at open amount, maybe consider that there may already be queued amounts in SEPA Export +=item * C + +Cannot handle negative skonto amounts, will always calculate the skonto amount +for credit notes or negative ap transactions with a positive sign. + + =back =head1 AUTHOR