3 Write/update customer payment.
5 function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account,
6 $date_, $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);
15 $bank_gl_account = get_bank_gl_account($bank_account);
18 delete_comments(12, $trans_no);
19 void_bank_trans(12, $trans_no, true);
20 void_gl_trans(12, $trans_no, true);
21 void_cust_allocations(12, $trans_no, $date_);
24 /* Bank account entry first */
25 add_gl_trans_customer(12, $payment_no, $date_,
26 $bank_gl_account, 0, 0, $amount, $customer_id,
27 "Cannot insert a GL transaction for the bank account debit");
29 if ($branch_id != reserved_words::get_any_numeric()) {
31 $branch_data = get_branch_accounts($branch_id);
33 $debtors_account = $branch_data["receivables_account"];
34 $discount_account = $branch_data["payment_discount_account"];
37 $debtors_account = $company_record["debtors_act"];
38 $discount_account = $company_record["default_prompt_payment_act"];
41 if (($discount + $amount) != 0) {
42 /* Now Credit Debtors account with receipts + discounts */
43 add_gl_trans_customer(12, $payment_no, $date_,
44 $debtors_account, 0, 0, -($discount + $amount), $customer_id,
45 "Cannot insert a GL transaction for the debtors account credit");
49 /* Now Debit discount account with discounts allowed*/
50 add_gl_trans_customer(12, $payment_no, $date_,
51 $discount_account, 0, 0, $discount, $customer_id,
52 "Cannot insert a GL transaction for the payment discount debit");
55 /*now enter the bank_trans entry */
56 add_bank_trans(12, $payment_no, $bank_account, $ref,
57 $date_, $amount, payment_person_types::customer(), $customer_id,
58 get_customer_currency($customer_id));
60 add_comments(12, $payment_no, $date_, $memo_);
62 references::save_last($ref, 12);
69 //-------------------------------------------------------------------------------------------------
71 function void_customer_payment($type, $type_no)
75 void_bank_trans($type, $type_no, true);
76 void_gl_trans($type, $type_no, true);
77 void_cust_allocations($type, $type_no);
78 void_customer_trans($type, $type_no);