$items_added_tax = 0;
$freight_added_tax = 0;
}
+ // 2006-06-14. If the Customer Branch AR Account is set to a Bank Account,
+ // the transaction will be settled at once.
+ if (is_bank_account($branch_data['receivables_account']))
+ $alloc = $credit_note_total + $items_added_tax + $credit_note->freight_cost + $freight_added_tax;
+ else
+ $alloc = 0;
// $sales_order=$invoice->order_no; //?
// if (is_array($sales_order)) $sales_order = $sales_order[0]; //?
$credit_note_total, 0, $items_added_tax,
$credit_note->freight_cost, $freight_added_tax,
$credit_note->sales_type,
- $credit_note->order_no, $credit_invoice, $credit_note->ship_via
- //, $credit_note->due_date
- );
+ $credit_note->order_no, $credit_invoice, $credit_note->ship_via,
+ null, $alloc); // 2008-06-14 extra $alloc
if ($trans_no==0) {
$credit_note->trans_no = array($credit_no=>0);
//Post sales transaction to GL credit sales
- add_gl_trans_customer(11, $credit_no, $date_, $stock_gl_codes["sales_account"], 0, 0,
+ // 2008-06-14. If there is a Branch Sales Account, then override with this,
+ // else take the Item Sales Account
+ if ($branch_data['sales_account'] != "")
+ $sales_account = $branch_data['sales_account'];
+ else
+ $sales_account = $stock_gl_codes['sales_account'];
+ add_gl_trans_customer(11, $credit_no, $date_, $sales_account, $stock_gl_codes["dimension_id"],
+ $stock_gl_codes["dimension2_id"],
($line_taxfree_price * $order_line->qty_dispatched), $order->customer_id,
"The credit note GL posting could not be inserted");
if ($order_line->discount_percent != 0) {
- add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"], 0, 0,
+ add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"],
+ $stock_gl_codes["dimension_id"], $stock_gl_codes["dimension2_id"],
-($line_taxfree_price * $order_line->qty_dispatched * $order_line->discount_percent),
$order->customer_id,
"The credit note discount GL posting could not be inserted");