From ad4a0fc9c11ed0246a659950e1c8bbdd5ef5f396 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Tue, 12 Nov 2019 10:23:18 +0100 Subject: [PATCH] =?utf8?q?Bugfix=20#406=20Fehlerhafte=20abzurechnende=20We?= =?utf8?q?rte,=20falls=20Gutschriften=20h=C3=B6her=20als=20Auftragswert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/OE.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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}; -- 2.20.1