X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Finvoice_db.inc;h=707704cf2abf21780b80cf9b8754b896ae4d9ca4;hb=4568f3745a4a9e6efd6d796baccc0e9b23b81764;hp=dd172395ef803e21ff414aaa1807d79634bb987b;hpb=ae7f824b56286a83b547afc89ab3bbc26c5cc23c;p=fa-stable.git diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index dd172395..707704cf 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -126,7 +126,8 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan //$company_currency = get_company_currency(); $trans_no = $supp_trans->trans_no; $trans_type = $supp_trans->trans_type; - /*Start an sql transaction */ + $supplier = get_supplier($supp_trans->supplier_id); + begin_transaction(); hook_db_prewrite($supp_trans, $trans_type); $tax_total = 0; @@ -138,8 +139,6 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan } else $allocs = get_po_prepayments($supp_trans); - $supplier = get_supplier($supp_trans->supplier_id); - add_new_exchange_rate($supplier['curr_code'], $supp_trans->tran_date, $supp_trans->ex_rate); foreach ($taxes as $n => $taxitem) @@ -234,8 +233,8 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $entered_gl_code->gl_code, $entered_gl_code->gl_dim, $entered_gl_code->gl_dim2, $entered_gl_code->amount, $supp_trans->supplier_id, "", 0, $memo_); - add_supp_invoice_gl_item($trans_type, $invoice_id, $entered_gl_code->gl_code, - $entered_gl_code->amount, $memo_); + add_supp_invoice_gl_item($trans_type, $invoice_id, $entered_gl_code->gl_code, $entered_gl_code->amount, $memo_, + $entered_gl_code->gl_dim, $entered_gl_code->gl_dim2); // store tax details if the gl account is a tax account if ($trans_type == ST_SUPPCREDIT) @@ -270,8 +269,10 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan $stock_gl_code = get_stock_gl_code($entered_grn->item_code); - $dim = $supplier['dimension_id'] ? $supplier['dimension_id'] : $stock_gl_code['dimension_id']; - $dim2 = $supplier['dimension2_id'] ? $supplier['dimension2_id'] : $stock_gl_code['dimension2_id']; + $dim = !empty($supp_trans->dimension) ? $supp_trans->dimension : + ($supplier['dimension_id'] ? $supplier['dimension_id'] : $stock_gl_code['dimension_id']); + $dim2 = !empty($supp_trans->dimension2) ? $supp_trans->dimension2 : + ($supplier['dimension2_id'] ? $supplier['dimension2_id'] : $stock_gl_code['dimension2_id']); if ($trans_type == ST_SUPPCREDIT) { $iv_act = (is_inventory_item($entered_grn->item_code) ? $stock_gl_code["inventory_account"] : @@ -490,7 +491,7 @@ function read_supp_invoice($trans_no, $trans_type, &$supp_trans) else { $supp_trans->add_gl_codes_to_trans($details_row["gl_code"], get_gl_account_name($details_row["gl_code"]), 0, 0, - $details_row["FullUnitPrice"], $details_row["memo_"]); + $details_row["FullUnitPrice"], $details_row["memo_"], $details_row["dimension_id"], $details_row["dimension2_id"]); } } $supp_trans->tax_overrides = get_tax_overrides($trans_type, $trans_no);