add_or_update_purchase_data($po->supplier_id, $order_line->stock_id, $order_line->price,
$order_line->item_description);
- /*Need to insert a grn item */
-
+ /*Need to insert a grn item */ // also need to check for over-receive.(within allowance)
+ if ($order_line->receive_qty + $order_line->qty_received > $order_line->quantity)
+ $order_line->quantity = $order_line->receive_qty + $order_line->qty_received;
$grn_item = add_grn_detail_item($grn, $order_line->po_detail_rec,
$order_line->stock_id, $order_line->item_description,
- $order_line->standard_cost, $order_line->receive_qty, $order_line->price);
+ $order_line->standard_cost, $order_line->receive_qty, $order_line->price, $order_line->quantity);
$po->line_items[$line_no]->grn_item_id = $grn_item;
/* Update location stock records - NB a po cannot be entered for a service/kit parts done automatically */
//-------------------------------------------------------------------------------------------------------------
function add_grn_detail_item($grn_batch_id, $po_detail_item, $item_code, $description, $standard_unit_cost,
- $quantity_received, $price)
+ $quantity_received, $price, $quantity)
{
$sql = "UPDATE ".TB_PREF."purch_order_details
SET quantity_received = quantity_received + ".db_escape($quantity_received).",
std_cost_unit=".db_escape($standard_unit_cost).",
+ quantity_ordered=".db_escape($quantity).",
act_price=".db_escape($price)."
WHERE po_detail_item = ".db_escape($po_detail_item);
foreach ($po_obj->line_items as $po_line)
{
$sql = "INSERT INTO ".TB_PREF."purch_order_details (po_detail_item, order_no, item_code,
- description, delivery_date, unit_price, quantity_ordered) VALUES ("
+ description, delivery_date, unit_price, quantity_ordered, quantity_received) VALUES ("
.db_escape($po_line->po_detail_rec ? $po_line->po_detail_rec : 0). ","
.$po_obj->order_no . ","
.db_escape($po_line->stock_id). ","
.db_escape($po_line->item_description). ",'"
.date2sql($po_line->req_del_date) . "',"
.db_escape($po_line->price) . ", "
- .db_escape($po_line->quantity) . ")";
+ .db_escape($po_line->quantity) . ", "
+ .db_escape($po_line->qty_received) . ")";
db_query($sql, "One of the purchase order detail records could not be updated");
}
label_cell($_POST['units'], '', 'units');
if ($order->trans_type == ST_PURCHORDER)
date_cells(null, 'req_del_date', '', null, 0, 0, 0);
- if ($qty_rcvd > 0)
+ if ($qty_rcvd > 0)
+ {
amount_decimal_cell($_POST['price']);
+ hidden('price', $_POST['price']);
+ }
else
amount_cells(null, 'price', null, null, null, $dec2);