From: Joe Date: Wed, 16 Oct 2024 11:21:48 +0000 (+0200) Subject: 5745: Supplier Credit Note Issue: Stock Move Price Overstated Due to Included Tax. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=6b2b38d7b06afeedda57c7a5634856ea155f578d;p=fa-stable.git 5745: Supplier Credit Note Issue: Stock Move Price Overstated Due to Included Tax. --- diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index b12c1028..29452b77 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -215,10 +215,10 @@ function get_grn_batch($grn) return db_fetch($result); } -function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date) +function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date, $taxfree_line) { $mcost = update_average_material_cost($supplier, $entered_grn->item_code, - $entered_grn->chg_price, $entered_grn->this_quantity_inv, $date); + $taxfree_line, $entered_grn->this_quantity_inv, $date); $sql = "SELECT grn.*, item.* FROM ".TB_PREF."grn_batch grn," @@ -237,7 +237,7 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date) .db_escape($entered_grn->this_quantity_inv).", qty_invoiced = qty_invoiced + ".db_escape($entered_grn->this_quantity_inv).", std_cost_unit=".db_escape($mcost).", - act_price=".db_escape($entered_grn->chg_price)." + act_price=".db_escape($taxfree_line)." WHERE po_detail_item = ".$myrow["po_detail_item"]; db_query($sql, "a purchase order details record could not be updated. This receipt of goods has not been processed "); @@ -248,7 +248,7 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date) db_query($sql); add_stock_move(ST_SUPPCREDIT, $entered_grn->item_code, $transno, $myrow['loc_code'], $date, "", - $entered_grn->this_quantity_inv, $mcost, $entered_grn->chg_price); + $entered_grn->this_quantity_inv, $mcost, $taxfree_line); } function get_grn_items($grn_batch_id=0, $supplier_id="", $outstanding_only=false, diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index a0043279..f4338ca8 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -256,11 +256,13 @@ function add_supp_invoice(&$supp_trans) $clearing_act = get_company_pref('grn_clearing_act'); foreach ($supp_trans->grn_items as $line_no => $entered_grn) { - + // moved this line up to calculate the taxfree price. + $taxfree_line = get_tax_free_price_for_item($entered_grn->item_code, $entered_grn->this_quantity_inv * $entered_grn->chg_price, + $supp_trans->tax_group_id, $supp_trans->tax_included) - $net_diff; $net_diff = 0; if ($trans_type == ST_SUPPCREDIT) { $entered_grn->this_quantity_inv = -$entered_grn->this_quantity_inv; - set_grn_item_credited($entered_grn, $supp_trans->supplier_id, $invoice_id, $date_); + set_grn_item_credited($entered_grn, $supp_trans->supplier_id, $invoice_id, $date_, $taxfree_line); } // For tax included pricelist the net price is calculated down from tax_included price. @@ -270,9 +272,7 @@ function add_supp_invoice(&$supp_trans) // taxes and sales accounts, so we add net_diff just to first posted net value. This is _ugly_hack_ // which save us from rewriting whole routine, and works right only for small tax differences. - $taxfree_line = get_tax_free_price_for_item($entered_grn->item_code, $entered_grn->this_quantity_inv * $entered_grn->chg_price, - $supp_trans->tax_group_id, $supp_trans->tax_included) - $net_diff; $net_diff = 0; - + $line_tax = get_full_price_for_item($entered_grn->item_code, $entered_grn->this_quantity_inv * $entered_grn->chg_price, $supp_trans->tax_group_id, $supp_trans->tax_included) - $taxfree_line;