From: Jan Büren Date: Tue, 12 Nov 2019 09:23:18 +0000 (+0100) Subject: Bugfix #406 Fehlerhafte abzurechnende Werte, falls Gutschriften höher als Auftragswert X-Git-Tag: release-3.5.6.1~441 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ad4a0fc9c11ed0246a659950e1c8bbdd5ef5f396;p=kivitendo-erp.git Bugfix #406 Fehlerhafte abzurechnende Werte, falls Gutschriften höher als Auftragswert --- diff --git a/SL/OE.pm b/SL/OE.pm index 1d064505b..5665b04bd 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -377,8 +377,13 @@ SQL while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { $ref->{billed_amount} = $billed_amount{$ref->{id}}; $ref->{billed_netamount} = $billed_netamount{$ref->{id}}; - $ref->{remaining_amount} = $ref->{amount} - $ref->{billed_amount}; - $ref->{remaining_netamount} = $ref->{netamount} - $ref->{billed_netamount}; + if ($ref->{billed_amount} < 0) { # case: credit note(s) higher than invoices + $ref->{remaining_amount} = $ref->{amount} + $ref->{billed_amount}; + $ref->{remaining_netamount} = $ref->{netamount} + $ref->{billed_netamount}; + } else { + $ref->{remaining_amount} = $ref->{amount} - $ref->{billed_amount}; + $ref->{remaining_netamount} = $ref->{netamount} - $ref->{billed_netamount}; + } $ref->{exchangerate} = 1 unless $ref->{exchangerate}; push @{ $form->{OE} }, $ref if $ref->{id} != $id{ $ref->{id} }; $id{ $ref->{id} } = $ref->{id};