X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fdb%2Fcustalloc_db.inc;h=a3abb44bdb93119746ec8c87d82cfcf55049b30f;hb=61fb69cf679671e44d7aaa10fab553c059e6f62e;hp=3010931d59ead0b720cae0fc00f605b2b4084362;hpb=5ea4d80a91017eadba9db43a0f26242c57bc4c9e;p=fa-stable.git diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index 3010931d..a3abb44b 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -78,7 +78,7 @@ function clear_cust_alloctions($type, $type_no, $date="") // 2014-01-16 Joe Hunt. Fix for voiding allocated currency sales_invoices. elseif ($type == ST_SALESINVOICE && $row['trans_type_to'] == $type && $row['trans_no_to'] == $type_no) exchange_variation($row['trans_type_from'], $row['trans_no_from'], $row['trans_type_to'], $row['trans_no_to'], - sql2date($row['date_alloc']), $row['amt'], PT_SUPPLIER, true); + sql2date($row['date_alloc']), $row['amt'], PT_CUSTOMER, true); ////////////////////// } @@ -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);