Dimension wise balance sheet items (A/C Payable and Receivables) implemented.
[fa-stable.git] / sales / includes / db / payment_db.inc
index 766648533351281e718ebcde127902624c4722e8..e15318666d254c2beeda87d99f546af63b22e691 100644 (file)
        $charge - in bank currency
 */
 function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_account,
-       $date_, $ref, $amount, $discount, $memo_, $rate=0, $charge=0, $bank_amount=0)
+       $date_, $ref, $amount, $discount, $memo_, $rate=0, $charge=0, $bank_amount=0, $dim1=0, $dim2=0)
 {
        global $Refs;
 
        begin_transaction();
-       $args = func_get_args(); while (count($args) < 12) $args[] = 0;
+       $args = func_get_args(); while (count($args) < 14) $args[] = 0;
        $args = (object)array_combine(array('trans_no', 'customer_id', 'branch_id', 'bank_account', 
-               'date_', 'ref', 'amount', 'discount', 'memo_','rate','charge', 'bank_amount'), $args);
+               'date_', 'ref', 'amount', 'discount', 'memo_','rate','charge', 'bank_amount', 'dim1', 'dim2'), $args);
        hook_db_prewrite($args, ST_CUSTPAYMENT);
 
        $company_record = get_company_prefs();
@@ -61,7 +61,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
 
        /* Bank account entry first */
        $total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,
-               $bank_gl_account, 0, 0, '', ($bank_amount - $charge),  $bank['bank_curr_code'], PT_CUSTOMER, $customer_id);
+               $bank_gl_account, $dim1, $dim2, '', ($bank_amount - $charge),  $bank['bank_curr_code'], PT_CUSTOMER, $customer_id);
 
        if ($branch_id != ANY_NUMERIC) {
 
@@ -78,20 +78,20 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
        if (($discount + $amount) != 0) {
        /* Now Credit Debtors account with receipts + discounts */
        $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_,
-               $debtors_account, 0, 0, -($discount + $amount), $customer_id,
+               $debtors_account, $dim1, $dim2, -($discount + $amount), $customer_id,
                "Cannot insert a GL transaction for the debtors account credit");
        }
        if ($discount != 0)     {
                /* Now Debit discount account with discounts allowed*/
                $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_,
-                       $discount_account, 0, 0, $discount, $customer_id,
+                       $discount_account, $dim1, $dim2, $discount, $customer_id,
                        "Cannot insert a GL transaction for the payment discount debit");
        }
 
        if ($charge != 0)       {
                /* Now Debit bank charge account with charges */
                $charge_act = get_bank_charge_account($bank_account);
-               $total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,     $charge_act, 0, 0, '', 
+               $total += add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,     $charge_act, $dim1, $dim2, '', 
                        $charge, $bank['bank_curr_code'], PT_CUSTOMER,  $customer_id);
        }
 
@@ -100,7 +100,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
        if ($total != 0)
        {
                $variance_act = get_company_pref('exchange_diff_act');
-               add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,       $variance_act, 0, 0, '',
+               add_gl_trans(ST_CUSTPAYMENT, $payment_no, $date_,       $variance_act, $dim1, $dim2, '',
                        -$total, null, PT_CUSTOMER,  $customer_id);
        }