$is_invoiced_only=false, $invoice_no=0, $begin="", $end="")
{
$sql = "SELECT ".TB_PREF."grn_batch.*, ".TB_PREF."grn_items.*, "
- .TB_PREF."purch_order_details.unit_price,
- ".TB_PREF."purch_order_details.std_cost_unit, units
+ .TB_PREF."purch_order_details.unit_price,"
+ .TB_PREF."purch_order_details.quantity_ordered,"
+ .TB_PREF."purch_order_details.std_cost_unit, units
FROM ".TB_PREF."grn_batch, ".TB_PREF."grn_items, "
.TB_PREF."purch_order_details, ".TB_PREF."stock_master";
if ($invoice_no != 0)
}
$order->add_to_order($order->lines_on_order, $myrow["item_code"],
- 1,$myrow["description"], $myrow["unit_price"],$units,
+ $myrow["qty_recd"],$myrow["description"], $myrow["unit_price"],$units,
sql2date($myrow["delivery_date"]), $myrow["quantity_inv"],
$myrow["qty_recd"]);
if ($result)
{
+ $order->trans_type = ST_SUPPRECEIVE;
$order->orig_order_date = sql2date($row["delivery_date"]);
$order->location = $row["loc_code"];
$order->reference = $row["reference"];
}
return 0;
}
-
- function get_taxes($shipping_cost=null)
+
+ //
+ // Returns taxes for PO/GRN.
+ // $receival=true in purchase receive context.
+ //
+ function get_taxes($shipping_cost=null, $receival=false)
{
$items = array();
$prices = array();
foreach ($this->line_items as $ln_itm) {
$items[] = $ln_itm->stock_id;
- $prices[] = round($ln_itm->quantity * $ln_itm->price, user_price_dec());
+ $prices[] = round($ln_itm->price * ($receival ? $ln_itm->receive_qty : $ln_itm->quantity), user_price_dec());
}
$taxes = get_tax_for_items($items, $prices, $shipping_cost,
$this->tax_group_id, $this->tax_included, $this->tax_group_array);
$display_sub_total = price_format($total/* + input_num('freight_cost')*/);
label_row(_("Sub-total"), $display_sub_total, "colspan=$colspan align=right","align=right");
- $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost'));
+ $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost'), true);
$tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['PO']->tax_included);