[0000101] Roll back of yeasterday issues
[fa-stable.git] / sales / includes / db / sales_invoice_db.inc
index 0dc6de5655a76bf1a8a860095a7309e28304144c..87b9eb7ec580bc0b78f5da9971d903423e670ab4 100644 (file)
@@ -122,6 +122,12 @@ function write_sales_invoice(&$invoice)
                } /*quantity dispatched is more than 0 */
        } /*end of delivery_line loop */
 
+       if (($items_total + $charge_shipping) != 0) {
+               $total += add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0,
+                       ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax),
+                       $invoice->customer_id, "The total debtor GL posting could not be inserted");
+       }
+
        if ($charge_shipping != 0) {
                $total += add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
                        -$invoice->get_tax_free_shipping(), $invoice->customer_id,
@@ -139,11 +145,6 @@ function write_sales_invoice(&$invoice)
                }
        }
 
-       if (($items_total + $charge_shipping) != 0) {
-               $total += add_gl_trans(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, "", 
-                       -$total, null, payment_person_types::customer(), $invoice->customer_id, "The total debtor GL posting could not be inserted");
-       }
-
        /*Post a balance post if $total != 0 */
        add_gl_balance(10, $invoice_no, $date_, -$total, payment_person_types::customer(), $invoice->customer_id);