[0000101] More wonderful rounding issues. Rerun.
[fa-stable.git] / sales / includes / db / payment_db.inc
index 75392b6a2d303f368edec2ef1ff0cf59f1cc1120..e31c432d49db9d501780b1882966c57a064453d0 100644 (file)
@@ -36,12 +36,6 @@ 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_,
@@ -49,6 +43,13 @@ 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);