- $Refs->get_next(ST_CUSTPAYMENT), $amount-$discount, $discount,
- _('Cash invoice').' '.$invoice_no);
- add_cust_allocation($amount, ST_CUSTPAYMENT, $pmtno, ST_SALESINVOICE, $invoice_no);
-
- update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no);
- update_debtor_trans_allocation(ST_CUSTPAYMENT, $pmtno);
+ $Refs->get_next(ST_CUSTPAYMENT, null, array('customer' => $invoice->customer_id,
+ 'branch' => $invoice->Branch, 'date' => $date_)),
+ $amount-$discount, $discount,
+ $invoice->pos['pos_name'].' #'.$invoice_no);
+ add_cust_allocation($amount, ST_CUSTPAYMENT, $pmtno, ST_SALESINVOICE, $invoice_no, $invoice->customer_id, $date_);
+
+ update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no, $invoice->customer_id);
+ update_debtor_trans_allocation(ST_CUSTPAYMENT, $pmtno, $invoice->customer_id);