Added db_write/db_void hooks.
[fa-stable.git] / sales / includes / db / sales_invoice_db.inc
index 3b540d55f2dea6d30a52abbef5a95e8f4d5632f8..95d5e396c9d2ad9a96cd42d503269c9cc373461c 100644 (file)
@@ -25,6 +25,7 @@ function write_sales_invoice(&$invoice)
 
        begin_transaction();
 
+       hook_db_prewrite($invoice, ST_SALESINVOICE);
        $company_data = get_company_prefs();
 
        $branch_data = get_branch_accounts($invoice->Branch);
@@ -164,7 +165,7 @@ function write_sales_invoice(&$invoice)
 
        if ($trans_no == 0) {
                $Refs->save(ST_SALESINVOICE, $invoice_no, $invoice->reference);
-               if ($invoice->cash) {
+               if ($invoice->payment_terms['cash_sale']) {
                        $amount = $items_total + $items_added_tax + $invoice->freight_cost 
                                + $freight_added_tax;
 
@@ -182,6 +183,7 @@ function write_sales_invoice(&$invoice)
                        update_debtor_trans_allocation(ST_CUSTPAYMENT, $pmtno, $amount);
                }
        }
+       hook_db_postwrite($invoice, ST_SALESINVOICE);
        commit_transaction();
 
        return $invoice_no;
@@ -193,6 +195,7 @@ function void_sales_invoice($type, $type_no)
 {
        begin_transaction();
 
+       hook_db_prevoid($type, $type_no);
        void_bank_trans($type, $type_no, true);
        void_gl_trans($type, $type_no, true);