3 Write/update customer payment.
5 function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account,
6 $date_, $receipt_type, $ref, $amount, $discount, $memo_)
10 $company_record = get_company_prefs();
12 $payment_no = write_customer_trans(12, $trans_no,
13 $customer_id, $branch_id, $date_, $ref, $amount, $discount);
16 delete_comments(12, $invoice_no);
17 void_bank_trans(12, $type_no, true);
18 void_gl_trans(12, $trans_no, true);
19 void_cust_allocations(12, $trans_no);
22 /* Bank account entry first */
23 add_gl_trans_customer(12, $payment_no, $date_,
24 $bank_account, 0, 0, $amount, $customer_id,
25 "Cannot insert a GL transaction for the bank account debit");
27 if ($branch_id != reserved_words::get_any_numeric()) {
29 $branch_data = get_branch_accounts($branch_id);
31 $debtors_account = $branch_data["receivables_account"];
32 $discount_account = $branch_data["payment_discount_account"];
35 $debtors_account = $company_record["debtors_act"];
36 $discount_account = $company_record["default_prompt_payment_act"];
39 if (($discount + $amount) != 0) {
40 /* Now Credit Debtors account with receipts + discounts */
41 add_gl_trans_customer(12, $payment_no, $date_,
42 $debtors_account, 0, 0, -($discount + $amount), $customer_id,
43 "Cannot insert a GL transaction for the debtors account credit");
47 /* Now Debit discount account with discounts allowed*/
48 add_gl_trans_customer(12, $payment_no, $date_,
49 $discount_account, 0, 0, $discount, $customer_id,
50 "Cannot insert a GL transaction for the payment discount debit");
53 /*now enter the bank_trans entry */
54 add_bank_trans(12, $payment_no, $bank_account, $ref,
55 $date_, $receipt_type, $amount, payment_person_types::customer(), $customer_id,
56 get_customer_currency($customer_id));
58 add_comments(12, $payment_no, $date_, $memo_);
60 references::save_last($ref, 12);
67 //-------------------------------------------------------------------------------------------------
69 function void_customer_payment($type, $type_no)
73 void_bank_trans($type, $type_no, true);
74 void_gl_trans($type, $type_no, true);
75 void_cust_allocations($type, $type_no);
76 void_customer_trans($type, $type_no);