Stable merged into unstable again (due to failure on binary file during previous...
[fa-stable.git] / sales / includes / db / sales_invoice_db.inc
index 558b2159aba0159fd9a1bad9c8e0a000ad275cfd..ecaf4466f9bb5f6d1b42c195d56cad1bcac13613 100644 (file)
@@ -64,7 +64,7 @@ function write_sales_invoice(&$invoice)
                $items_added_tax, $invoice->freight_cost, $freight_added_tax,
                $invoice->sales_type, $sales_order, $invoice->ship_via, 
                $invoice->due_date, 0, 0, $invoice->dimension_id, 
-               $invoice->dimension2_id, $invoice->payment); 
+               $invoice->dimension2_id, $invoice->payment, $invoice->tax_included); 
                // 2008-06-14 extra $alloc, 2008-11-12 added dimension_id Joe Hunt
 
        if ($trans_no == 0) {
@@ -146,9 +146,10 @@ function write_sales_invoice(&$invoice)
                                $taxitem['rate'], $invoice->tax_included, $taxitem['Value'],
                                 $taxitem['Net'], $ex_rate, $date_, $invoice->reference);
 
-                       $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
-                               (-$taxitem['Value']), $invoice->customer_id,
-                               "A tax GL posting could not be inserted");
+                       if (isset($taxitem['sales_gl_code']))
+                               $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0,
+                                       (-$taxitem['Value']), $invoice->customer_id,
+                                       "A tax GL posting could not be inserted");
                }
        }