Removed sparse parameter in write_customer()
[fa-stable.git] / sales / includes / sales_db.inc
index e870b83356c20110d4f03d10a6d9ed4bf5604cfb..2fd0bb9fa55a38b6d3dd9abe69499a86ea6f7e2a 100644 (file)
@@ -388,10 +388,15 @@ function write_sales_trans($cart, $policy = 0)
 }
 
 function save_cust_payment($cart, $customer_id, $branch_id,
-               $bank_account, $trans_date, $ref, $amount, $discount, $memo, $charge, $bank_amount)
+               $bank_account, $trans_date, $ref, $amount, $memo, $charge, $bank_amount)
 {
        begin_transaction(__FUNCTION__, func_get_args());
 
+       $discount = 0;
+       foreach($cart->allocs as $alloc)
+               if ($alloc->discount_confirmed)
+                       $discount += $alloc->early_discount*$alloc->amount;
+
        $payment_no = write_customer_payment($cart->trans_no, $customer_id, $branch_id,
                $bank_account, $trans_date, $ref, $amount, $discount, $memo, 0, $charge, $bank_amount);
 
@@ -465,8 +470,8 @@ function write_recurrent_invoice($invoice_id, $description, $order_no, $debtor_n
 }
 
 function write_customer($customer_id, $name, $ref, $address, $tax_id, $curr_code, $dim1, $dim2, $credit_status,
-        $payment_terms, $discount, $pymt_discount, $credit_limit, $sales_type, $notes, $inactive, $salesman, $area, 
-        $tax_group, $location, $address, $ship_via, $notes, $bank_account, $address, $phone, $phone2, $fax, $email)
+        $payment_terms, $discount, $credit_limit, $sales_type, $notes, $inactive, $salesman, $area, 
+        $tax_group, $location, $address, $ship_via, $notes, $bank_account, $phone, $phone2, $fax, $email)
 {
        global $SysPrefs;
 
@@ -474,13 +479,13 @@ function write_customer($customer_id, $name, $ref, $address, $tax_id, $curr_code
 
        if ($customer_id) {
                update_customer($customer_id, $name, $ref, $address, $tax_id, $curr_code, $dim1, $dim2, $credit_status,
-                        $payment_terms, $discount/100, $pymt_discount/100, $credit_limit, $sales_type, $notes, $inactive);
+                        $payment_terms, $discount/100, $credit_limit, $sales_type, $notes, $inactive);
 
                update_record_status($customer_id, $inactive, 'debtors_master', 'debtor_no');
 
        } else {
                add_customer($name, $ref, $address,     $tax_id, $curr_code, $dim1, $dim2, $credit_status, $payment_terms,
-                       $discount / 100, $pymt_discount / 100, $credit_limit, $sales_type, $notes);
+                       $discount / 100, $credit_limit, $sales_type, $notes);
 
                $customer_id = db_insert_id();