if (is_array($trans_no)) $trans_no = key($trans_no);
begin_transaction();
+ $delivery->bo_policy = $bo_policy;
+ hook_db_prewrite($delivery, ST_CUSTDELIVERY);
$customer = get_customer($delivery->customer_id);
$delivery_items_total = $delivery->get_items_total_dispatch();
$delivery->tax_included ? 0 : $tax_total-$freight_tax,
$delivery->freight_cost,
$delivery->tax_included ? 0 : $freight_tax,
- $delivery->sales_type, $delivery->order_no, 0,
+ $delivery->sales_type, $delivery->order_no,
$delivery->ship_via, $delivery->due_date, 0, 0, $delivery->dimension_id,
$delivery->dimension2_id, $delivery->payment);
write_customer_trans_detail_item(ST_CUSTDELIVERY, $delivery_no, $delivery_line->stock_id,
$delivery_line->item_description, $delivery_line->qty_dispatched,
$delivery_line->line_price(), $line_tax,
- $delivery_line->discount_percent, $delivery_line->standard_cost,
+ $delivery_line->discount_percent, $delivery_line->standard_cost, $delivery_line->src_id,
$trans_no ? $delivery_line->id : 0);
// Now update sales_order_details for the quantity delivered
$stock_gl_code = get_stock_gl_code($delivery_line->stock_id);
/* insert gl_trans to credit stock and debit cost of sales at standard cost*/
- if ($delivery_line->standard_cost != 0) {
+ if (is_inventory_item($delivery_line->stock_id) && $delivery_line->standard_cost != 0) {
/*first the cost of sales entry*/
// 2008-08-01. If there is a Customer Dimension, then override with this,
$Refs->save(ST_CUSTDELIVERY, $delivery_no, $delivery->reference);
}
+ hook_db_postwrite($delivery, ST_CUSTDELIVERY);
commit_transaction();
return $delivery_no;
if ($transactions)
begin_transaction();
+ hook_db_prevoid($type, $type_no);
+
void_gl_trans($type, $type_no, true);
// reverse all the changes in the sales order