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,"
.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 ");
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,
$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.
// 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;