3 function add_customer_payment($customer_id, $branch_id, $bank_account, $date_, $receipt_type, $ref,
4 $amount, $discount, $memo_)
8 $company_record = get_company_prefs();
10 $payment_no = add_customer_trans(systypes::cust_payment(), $customer_id, $branch_id, $date_,
11 $ref, -($amount), -($discount));
13 /* Bank account entry first */
14 add_gl_trans_customer(systypes::cust_payment(), $payment_no, $date_,
15 $bank_account, 0, 0, $amount, $customer_id,
16 "Cannot insert a GL transaction for the bank account debit");
18 if ($branch_id != reserved_words::get_any_numeric())
20 $branch_data = get_branch_accounts($branch_id);
22 $debtors_account = $branch_data["receivables_account"];
23 $discount_account = $branch_data["payment_discount_account"];
28 $debtors_account = $company_record["debtors_act"];
29 $discount_account = $company_record["default_prompt_payment_act"];
32 if (($discount + $amount) != 0)
34 /* Now Credit Debtors account with receipts + discounts */
35 add_gl_trans_customer(systypes::cust_payment(), $payment_no, $date_,
36 $debtors_account, 0, 0, -($discount + $amount), $customer_id,
37 "Cannot insert a GL transaction for the debtors account credit");
42 /* Now Debit discount account with discounts allowed*/
43 add_gl_trans_customer(systypes::cust_payment(), $payment_no, $date_,
44 $discount_account, 0, 0, $discount, $customer_id,
45 "Cannot insert a GL transaction for the payment discount debit");
48 /*now enter the bank_trans entry */
49 add_bank_trans(systypes::cust_payment(), $payment_no, $bank_account, $ref,
50 $date_, $receipt_type, $amount, payment_person_types::customer(), $customer_id,
51 get_customer_currency($customer_id));
53 add_comments(systypes::cust_payment(), $payment_no, $date_, $memo_);
55 add_forms_for_sys_type(systypes::cust_payment(), $payment_no, payment_person_types::customer(), $customer_id);
57 references::save_last($ref, systypes::cust_payment());
64 //-------------------------------------------------------------------------------------------------
66 function void_customer_payment($type, $type_no)
70 void_bank_trans($type, $type_no, true);
71 void_gl_trans($type, $type_no, true);
72 void_cust_allocations($type, $type_no);
73 void_customer_trans($type, $type_no);