- $invoice_alloc_balance = get_DebtorTrans_allocation_balance(10, $credit_invoice);
- update_customer_trans_version(get_parent_type(11), $credit_note->src_docs );
- if ($invoice_alloc_balance > 0) { //the invoice is not already fully allocated
- $total = $credit_note_total + $credit_note->freight_cost +
- $items_added_tax + $freight_added_tax;
-
- $allocate_amount = ($invoice_alloc_balance > $total) ? $total : $invoice_alloc_balance;
- /*Now insert the allocation record if > 0 */
- if ($allocate_amount != 0) {
- update_debtor_trans_allocation(10, $credit_invoice, $allocate_amount);
- update_debtor_trans_allocation(11, $credit_no, $allocate_amount); // ***
- add_cust_allocation($allocate_amount, 11, $credit_no, 10, $credit_invoice);
- // Exchange Variations Joe Hunt 2008-09-20 ////////////////////////////////////////
-
- exchange_variation(11, $credit_no, 10, $credit_invoice, $credit_date,
- $allocate_amount, payment_person_types::customer());
-
- ///////////////////////////////////////////////////////////////////////////
-
- }
- }
+ update_customer_trans_version(get_parent_type(ST_CUSTCREDIT), $credit_note->src_docs );
+
+ $total = $credit_note_total + $credit_note->freight_cost + $items_added_tax
+ + $freight_added_tax;
+
+ if (!credit_sales_invoice_allocate($credit_invoice, $credit_no, $total, $credit_date))
+ return false;