void_cust_allocations(10, $invoice_no); // ?
void_customer_trans_tax_details(10, $invoice_no);
}
-
+ $total = 0;
foreach ($invoice->line_items as $invoice_line) {
$line_taxfree_price = get_tax_free_price_for_item($invoice_line->stock_id,
($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"]));
$dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id :
($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"]));
- add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2,
(-$line_taxfree_price * $invoice_line->qty_dispatched),
$invoice->customer_id, "The sales price GL posting could not be inserted");
if ($invoice_line->discount_percent != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_,
$branch_data["sales_discount_account"], $dim, $dim2,
($line_taxfree_price * $invoice_line->qty_dispatched * $invoice_line->discount_percent),
$invoice->customer_id, "The sales discount GL posting could not be inserted");
} /*quantity dispatched is more than 0 */
} /*end of delivery_line loop */
- /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */
if (($items_total + $charge_shipping) != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
($items_total + $charge_shipping + $items_added_tax + $freight_added_tax),
$invoice->customer_id, "The total debtor GL posting could not be inserted");
}
+
if ($charge_shipping != 0) {
- add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
-$invoice->get_tax_free_shipping(), $invoice->customer_id,
"The freight GL posting could not be inserted");
}
add_customer_trans_tax_detail_item(10, $invoice_no, $taxitem['tax_type_id'],
$taxitem['rate'], $invoice->tax_included, $taxitem['Value']);
- add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
+ $total += add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
(-$taxitem['Value']), $invoice->customer_id,
"A tax GL posting could not be inserted");
}
}
+ /*Post a balance post if $total != 0 */
+ add_gl_balance(10, $invoice_no, $date_, -$total, payment_person_types::customer(), $invoice->customer_id);
+
add_comments(10, $invoice_no, $date_, $invoice->Comments);
if ($trans_no == 0) {