From 7b9a7d52c4e0c693603db1631fa861c27c4efa03 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 27 May 2014 20:56:31 +0200 Subject: [PATCH] Customer Credit Note: fixed payments allocation after crediting sales invoice. --- sales/includes/db/custalloc_db.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index 1e58c2b1..a3abb44b 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -286,16 +286,14 @@ function credit_sales_invoice_allocate($invoice_no, $credit_no, $amount, $date) 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'], - -$unalloc); delete_cust_allocation($alloc['id']); if ($unalloc < $alloc['amt']) add_cust_allocation($alloc['amt']-$unalloc, $alloc['trans_type_from'], $alloc['trans_no_from'], ST_SALESINVOICE, $invoice_no); + update_debtor_trans_allocation($alloc['trans_type_to'], $alloc['trans_no_to']); + update_debtor_trans_allocation($alloc['trans_type_from'], $alloc['trans_no_from']); $free += $unalloc; } } @@ -306,9 +304,9 @@ function credit_sales_invoice_allocate($invoice_no, $credit_no, $amount, $date) Check all credit notes allocated to this invoice for summarized freight charges.")); return false; } - update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no, $amount); - update_debtor_trans_allocation(ST_CUSTCREDIT, $credit_no, $amount); add_cust_allocation($amount, ST_CUSTCREDIT, $credit_no, ST_SALESINVOICE, $invoice_no); + update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no); + update_debtor_trans_allocation(ST_CUSTCREDIT, $credit_no); exchange_variation(ST_CUSTCREDIT, $credit_no, ST_SALESINVOICE, $invoice_no, $date, $amount, PT_CUSTOMER); -- 2.30.2