From b0ba7b77c055cf8f1376845586699b8fdcb67b1f Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 14 Apr 2011 01:19:18 +0200 Subject: [PATCH] [0000714] Bug creating GL trans on inventory items in supplier invoice when tax included. --- purchasing/includes/db/grn_db.inc | 2 +- purchasing/includes/db/invoice_db.inc | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 1e9f71b..09d68ff 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -125,7 +125,7 @@ function add_grn(&$po) $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"], $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id); - update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price, + update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->taxfree_charge_price($po), $order_line->receive_qty, $date_); } //---------------------------------------------------------------------------------------------------------------- diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index 411a7a0..4f8024a 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -225,13 +225,16 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b //$old_price = $old[0]; $old_price = $old[2]; + // adjust for tax included. + $old_price = get_tax_free_price_for_item($entered_grn->item_code, $old_price, + $supp_trans->tax_group_id, $entered_grn->tax_included); /* If statement is removed. Should always check for deliveries nomatter if there has been a price change. */ - //if ($old_price != $entered_grn->chg_price) // price-change, so update + //if ($old_price != $line_taxfree) // price-change, so update //{ - //$diff = $entered_grn->chg_price - $old_price; + //$diff = $line_taxfree - $old_price; $old_date = sql2date($old[1]); if (!is_inventory_item($entered_grn->item_code)) $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $iv_act, @@ -245,7 +248,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $entered_grn->this_quantity_inv * $old_price, $supp_trans->supplier_id, "", $ex_rate); $diff = get_diff_in_home_currency($supp_trans->supplier_id, $old_date, $date_, $old_price, - $entered_grn->chg_price); + $line_taxfree); // always return due to change in currency. /*$mat_cost = update_average_material_cost(null, $entered_grn->item_code, -- 2.30.2