$date_ = $invoice->document_date;
$charge_shipping =$invoice->freight_cost;
- begin_transaction();
+ begin_transaction(__FUNCTION__, func_get_args());
hook_db_prewrite($invoice, ST_SALESINVOICE);
$company_data = get_company_prefs();
}
$to_allocate = ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax);
+ $freight = get_item($invoice->ship_via);
+
if ($charge_shipping != 0) {
- $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], 0, 0,
+ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $freight["sales_account"], 0, 0,
-$invoice->get_tax_free_shipping()*$prepaid_factor, $invoice->customer_id);
}
// post all taxes
if ($trans_no == 0) {
$Refs->save(ST_SALESINVOICE, $invoice_no, $invoice->reference, null, $invoice->fixed_asset);
- if ($invoice->payment_terms['cash_sale'] && $invoice->pos['pos_account']) {
+ if ($invoice->payment_terms['type'] == PTT_CASH && $invoice->pos['pos_account']) {
$amount = $items_total + $items_added_tax + $invoice->freight_cost
+ $freight_added_tax;
function void_sales_invoice($type, $type_no)
{
- begin_transaction();
+ begin_transaction(__FUNCTION__, func_get_args());
hook_db_prevoid($type, $type_no);
void_bank_trans($type, $type_no, true);
." AND so.trans_type=".ST_SALESORDER
." AND inv.type=".ST_SALESINVOICE
." AND inv.order_=so.order_no"
- ." AND so.payment_terms=pt.terms_indicator"
- ." AND inv.payment_terms=pt.terms_indicator"
- ." AND pt.days_before_due = -1";
+ ." AND so.payment_terms=pt.id"
+ ." AND inv.payment_terms=pt.id"
+ ." AND pt.type = ".PTT_PREPAY;
$result = db_fetch(db_query($sql, "cannot find final invoice value"));
return $result[0] ? $result[0] : 0;