[0000252] Error during credit invoice processing for already allocated sales invoice.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 4 Oct 2010 10:28:22 +0000 (10:28 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 4 Oct 2010 10:28:22 +0000 (10:28 +0000)
CHANGELOG.txt
sales/includes/db/custalloc_db.inc

index c1bff027b3c283a7da19ce22aafc6bfc410633dc..7834fa37995d2b7a6a51feaea056e2ce530f84ed 100644 (file)
@@ -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
index f9fc78e7cc0a47e0d568dd5ff13a4a09eda8e0e9..4c92ad98b82586acaa75cc109758a5686f4dcd54 100644 (file)
@@ -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'],