[0000101] Roll back of yeasterday issues
[fa-stable.git] / sales / includes / db / payment_db.inc
index e31c432d49db9d501780b1882966c57a064453d0..cda2d68a4097372a1fa62dba01800b3e85800dd4 100644 (file)
@@ -36,6 +36,12 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
                $discount_account = $company_record["default_prompt_payment_act"];
        }
 
+       if (($discount + $amount) != 0) {
+       /* Now Credit Debtors account with receipts + discounts */
+       $total += add_gl_trans_customer(12, $payment_no, $date_,
+               $debtors_account, 0, 0, -($discount + $amount), $customer_id,
+               "Cannot insert a GL transaction for the debtors account credit", $rate);
+       }
        if ($discount != 0)     {
                /* Now Debit discount account with discounts allowed*/
                $total += add_gl_trans_customer(12, $payment_no, $date_,
@@ -43,13 +49,6 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou
                        "Cannot insert a GL transaction for the payment discount debit", $rate);
        }
 
-       if (($discount + $amount) != 0) {
-               /* Now Credit Debtors account with receipts + discounts */
-               $total += add_gl_trans(12, $payment_no, $date_, $debtors_account, 0, 0, "", 
-                       -$total, null, payment_person_types::customer(), $customer_id, 
-                       "Cannot insert a GL transaction for the debtors account credit");
-       }
-
        /*Post a balance post if $total != 0 */
        add_gl_balance(12, $payment_no, $date_, -$total, payment_person_types::customer(), $customer_id);