From 1c0c137c02044c84e31ea94dec7178d7ed987e7b Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 4 Oct 2010 10:28:22 +0000 Subject: [PATCH] [0000252] Error during credit invoice processing for already allocated sales invoice. --- CHANGELOG.txt | 4 ++++ sales/includes/db/custalloc_db.inc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c1bff027..7834fa37 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,10 @@ Legend: ! -> Note $ -> Affected files +04-Oct-2010 Janusz Dobrowolski +# [0000252] Error during credit invoice processing for already allocated sales invoice. +$ /sales/includes/db/custalloc_db.inc + 04-Oct-2010 Joe Hunt # Dimension Report doesn't show up with correct references $ /reporting/rep501.php diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index f9fc78e7..4c92ad98 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -244,8 +244,8 @@ function credit_sales_invoice_allocate($invoice_no, $credit_no, $amount, $date) AND trans_type_from <> ".ST_CUSTCREDIT; $result = db_query($sql, "can't retrieve invoice allocations"); - while($free < $amount && ($alloc = db_fetch($result))) { - $unalloc = min($alloc['amt'], $free); + while(($free < $amount) && ($alloc = db_fetch($result))) { + $unalloc = min($alloc['amt'], $amount-$free); update_debtor_trans_allocation($alloc['trans_type_to'], $alloc['trans_no_to'], -$unalloc); update_debtor_trans_allocation($alloc['trans_type_from'], $alloc['trans_no_from'], -- 2.30.2