delete_attachments_and_comments(ST_WORKORDER, $row['id']);
}
$sql = "SELECT loc_code, stock_id, SUM(qty) AS qty,"
- ." SUM(-qty*IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost)) AS std_cost"
+ ." SUM(-qty*IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, unit_cost)) AS cost"
." FROM ".TB_PREF."stock_moves WHERE tran_date <= '$to' GROUP by loc_code, stock_id";
$result = db_query($sql, "Could not retrieve stock moves");
while ($row = db_fetch($result))
$sql = "DELETE FROM ".TB_PREF."stock_moves WHERE tran_date <= '$to' AND loc_code = '{$row['loc_code']}' AND stock_id = '{$row['stock_id']}'";
db_query($sql, "Could not delete stock moves");
$qty = $row['qty'];
- $std_cost = ($qty == 0 ? 0 : round2($row['std_cost'] / $qty, user_price_dec()));
- $sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, loc_code, tran_date, reference, qty, standard_cost) VALUES
- ('{$row['stock_id']}', '{$row['loc_code']}', '$to', '$ref', $qty, $std_cost)";
+ $std_cost = ($qty == 0 ? 0 : round2($row['cost'] / $qty, user_price_dec()));
+ $sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, loc_code, tran_date, reference, qty, unit_cost) VALUES
+ ('{$row['stock_id']}', '{$row['loc_code']}', '$to', '$ref', $qty, $cost)";
db_query($sql, "Could not insert stock move");
}
$sql = "DELETE FROM ".TB_PREF."voided WHERE date_ <= '$to'";
To be used when going from delivery to invoice, so there is a match between the
2 links.
-These dimension(s) goes to the GL trans. If delivery and there are standard_cost
+These dimension(s) goes to the GL trans. If delivery and there are unit_cost
values they will show up on all COGS accounts.
If invoicing the dimensions will go to the SALES accounts, so it is easy to
{
$from = date2sql($from);
$to = date2sql($to);
- $sql = "SELECT SUM(-qty), SUM(-qty*standard_cost) FROM ".TB_PREF."stock_moves
+ $sql = "SELECT SUM(-qty), SUM(-qty*unit_cost) FROM ".TB_PREF."stock_moves
WHERE type=".ST_CUSTDELIVERY." AND stock_id=".db_escape($stock_id)." AND
tran_date>='$from' AND tran_date<='$to' GROUP BY stock_id";
{
// -ve qty is delivery either by ST_CUSTDELIVERY or inventory adjustment
//Price for GRN and SUPPCREDIT and std_cost for other trans_types
- $sql = "SELECT SUM(-qty), SUM(-qty*IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost))
+ $sql = "SELECT SUM(-qty), SUM(-qty*IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, unit_cost))
FROM ".TB_PREF."stock_moves
WHERE stock_id=".db_escape($stock_id)." AND qty < 0 AND
trans_id>='$move_id' GROUP BY stock_id";
$result = db_query($sql, "The deliveries could not be updated");
$row = db_fetch_row($result); // fetch quantity and cost of all deliveries including move_id
- $sql = "SELECT IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost)
+ $sql = "SELECT IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, unit_cost)
FROM ".TB_PREF."stock_moves
WHERE stock_id=".db_escape($stock_id)
." AND trans_id ='$move_id'";
function get_purchases_from_trans($stock_id, $move_id)
{
// Calculate All inward stock moves i.e. qty > 0
- $sql = "SELECT SUM(qty), SUM(qty*standard_cost)
+ $sql = "SELECT SUM(qty), SUM(qty*unit_cost)
FROM ".TB_PREF."stock_moves
WHERE stock_id=".db_escape($stock_id)." AND qty > 0 AND
trans_id>'$move_id' GROUP BY stock_id";
}
//-----------------------------------------------------------------------------------------
-function handle_negative_inventory($stock_id, $quantity, $standard_cost, $date_)
+function handle_negative_inventory($stock_id, $quantity, $unit_cost, $date_)
{
//If negative adjustment result in negative or zero inventory
//then difference should be adjusted
$id = get_next_trans_no(ST_JOURNAL);
$ref = $Refs->get_next(ST_JOURNAL, null, $date_);
- $diff = round($qoh*get_unit_cost($stock_id) + $quantity*$standard_cost, user_price_dec());
+ $diff = round($qoh*get_unit_cost($stock_id) + $quantity*$unit_cost, user_price_dec());
if ($diff != 0)
{
// $price - in transaction currency
function add_stock_move($type, $stock_id, $trans_no, $location,
- $date_, $reference, $quantity, $std_cost, $price=0)
+ $date_, $reference, $quantity, $unit_cost, $price=0)
{
$date = date2sql($date_);
$sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, trans_no, type, loc_code,
- tran_date, reference, qty, standard_cost, price) VALUES ("
+ tran_date, reference, qty, unit_cost, price) VALUES ("
.db_escape($stock_id).", ".db_escape($trans_no).", "
.db_escape($type).", ".db_escape($location).", '$date', "
.db_escape($reference).", "
- .db_escape($quantity).", ".db_escape($std_cost)."," .db_escape($price).")";
+ .db_escape($quantity).", ".db_escape($unit_cost)."," .db_escape($price).")";
db_query($sql, "The stock movement record cannot be inserted");
function update_stock_move($type, $trans_no, $stock_id, $cost)
{
- $sql = "UPDATE ".TB_PREF."stock_moves SET standard_cost=".db_escape($cost)
+ $sql = "UPDATE ".TB_PREF."stock_moves SET unit_cost=".db_escape($cost)
." WHERE type=".db_escape($type)
." AND trans_no=".db_escape($trans_no)
." AND stock_id=".db_escape($stock_id);
- db_query($sql, "The stock movement standard_cost cannot be updated");
+ db_query($sql, "The stock movement unit_cost cannot be updated");
}
//--------------------------------------------------------------------------------------------------
if (is_inventory_item($row["stock_id"]))
{
// The cost has to be adjusted.
- // Transaction rates are stored either as price or standard_cost depending on types
+ // Transaction rates are stored either as price or unit_cost depending on types
$types = array(ST_SUPPCREDIT, ST_SUPPRECEIVE);
if (in_array($type, $types))
$unit_cost = $row["price"];
else
- $unit_cost = $row["standard_cost"];
+ $unit_cost = $row["unit_cost"];
update_average_material_cost($row["supplier_id"], $row["stock_id"],
$unit_cost, -$row["qty"], sql2date($row["tran_date"]));
// --------------- line item functions
- function add_to_cart($line_no, $stock_id, $qty, $standard_cost, $description=null)
+ function add_to_cart($line_no, $stock_id, $qty, $unit_cost, $description=null)
{
if (isset($stock_id) && $stock_id != "" && isset($qty))
{
$this->line_items[$line_no] = new line_item($stock_id, $qty,
- $standard_cost, $description);
+ $unit_cost, $description);
return true;
}
else
return null;
}
- function update_cart_item($line_no, $qty, $standard_cost)
+ function update_cart_item($line_no, $qty, $unit_cost)
{
$this->line_items[$line_no]->quantity = $qty;
- $this->line_items[$line_no]->standard_cost = $standard_cost;
+ $this->line_items[$line_no]->unit_cost = $unit_cost;
}
function remove_from_cart($line_no)
var $quantity;
var $price;
- var $standard_cost;
+ var $unit_cost;
- function __construct($stock_id, $qty, $standard_cost=null, $description=null)
+ function __construct($stock_id, $qty, $unit_cost=null, $description=null)
{
$item_row = get_item($stock_id);
else
$this->item_description = $description;
- if ($standard_cost == null)
- $this->standard_cost = $item_row["purchase_cost"];
+ if ($unit_cost == null)
+ $this->unit_cost = $item_row["purchase_cost"];
else
- $this->standard_cost = $standard_cost;
+ $this->unit_cost = $unit_cost;
$this->stock_id = $stock_id;
$this->quantity = $qty;
}
add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $reference,
- $line_item->quantity, $line_item->standard_cost, $memo_);
+ $line_item->quantity, $line_item->unit_cost, $memo_);
}
add_comments(ST_INVADJUST, $adj_id, $date_, $memo_);
//--------------------------------------------------------------------------------------------------
function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $reference,
- $quantity, $standard_cost, $memo_)
+ $quantity, $unit_cost, $memo_)
{
$mb_flag = get_mb_flag($stock_id);
display_db_error("Cannot do inventory adjustment for Service item : $stock_id", "");
}
- update_average_material_cost(null, $stock_id, $standard_cost, $quantity, $date_);
+ update_average_material_cost(null, $stock_id, $unit_cost, $quantity, $date_);
if (is_fixed_asset($mb_flag)) {
$sql = "UPDATE ".TB_PREF."stock_master SET inactive=1
}
add_stock_move(ST_INVADJUST, $stock_id, $adj_id, $location,
- $date_, $reference, $quantity, $standard_cost);
+ $date_, $reference, $quantity, $unit_cost);
- $inv_value = $standard_cost * $quantity;
- $adj_value = $standard_cost * -($quantity);
+ $inv_value = $unit_cost * $quantity;
+ $adj_value = $unit_cost * -($quantity);
if (is_fixed_asset($mb_flag)) {
// get the initial value of the fixed assset.
$row = get_fixed_asset_move($stock_id, ST_SUPPRECEIVE);
$inv_value = $row['price'] * $quantity;
- $adj_value = (-($row['price']) + $standard_cost) * $quantity;
+ $adj_value = (-($row['price']) + $unit_cost) * $quantity;
}
- if ($standard_cost > 0 || is_fixed_asset($mb_flag))
+ if ($unit_cost > 0 || is_fixed_asset($mb_flag))
{
$stock_gl_codes = get_stock_gl_code($stock_id);
if (is_fixed_asset($mb_flag)) {
// Additional gl entry for fixed asset.
$grn_act = get_company_pref('default_loss_on_asset_disposal_act');
- add_gl_trans_std_cost(ST_INVADJUST, $adj_id, $date_, $grn_act, 0, 0, $memo_, ($standard_cost * -($quantity)));
+ add_gl_trans_std_cost(ST_INVADJUST, $adj_id, $date_, $grn_act, 0, 0, $memo_, ($unit_cost * -($quantity)));
}
}
// add 2 stock_moves entries for a stock transfer
// $date_ is display date (not sql)
// std_cost is in HOME currency
-// it seems the standard_cost field is not used at all
+// it seems the unit_cost field is not used at all
function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to,
$date_, $reference, $quantity)
//--------------------------------------------------------------------------------
-function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost)
+function add_to_order(&$order, $new_item, $new_item_qty, $unit_cost)
{
if ($order->find_cart_item($new_item))
display_error(_("For Part :") . $new_item . " " . "This item is already on this document. You can change the quantity on the existing line if necessary.");
else
- $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
+ $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $unit_cost);
}
//--------------------------------------------------------------------------------
foreach ($order->line_items as $line_no=>$stock_item)
{
- $total += ($stock_item->standard_cost * $stock_item->quantity);
+ $total += ($stock_item->unit_cost * $stock_item->quantity);
if ($id != $line_no)
{
label_cell($stock_item->item_description);
qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
label_cell($stock_item->units);
- amount_decimal_cell($stock_item->standard_cost);
+ amount_decimal_cell($stock_item->unit_cost);
if ($order->fixed_asset) {
$price = get_purchase_value($stock_item->stock_id);
amount_cell($price);
} else
- amount_cell($stock_item->standard_cost * $stock_item->quantity);
+ amount_cell($stock_item->unit_cost * $stock_item->quantity);
if (!$order->fixed_asset) {
if ($id == -1)
$_POST['stock_id'] = $order->line_items[$line_no]->stock_id;
$_POST['qty'] = qty_format($order->line_items[$line_no]->quantity,
$order->line_items[$line_no]->stock_id, $dec);
- //$_POST['std_cost'] = price_format($order->line_items[$line_no]->standard_cost);
- $_POST['std_cost'] = price_decimal_format($order->line_items[$line_no]->standard_cost, $dec2);
+ //$_POST['std_cost'] = price_format($order->line_items[$line_no]->unit_cost);
+ $_POST['std_cost'] = price_decimal_format($order->line_items[$line_no]->unit_cost, $dec2);
}
$_POST['units'] = $order->line_items[$line_no]->units;
hidden('stock_id', $_POST['stock_id']);
//--------------------------------------------------------------------------------
-function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost)
+function add_to_order(&$order, $new_item, $new_item_qty, $unit_cost)
{
if ($order->find_cart_item($new_item))
display_error(_("For Part :") . $new_item . " " . "This item is already on this document. You can change the quantity on the existing line if necessary.");
else
- $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
+ $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $unit_cost);
}
//--------------------------------------------------------------------------------
'settings' => array(_('&General settings'), $stock_id),
'sales_pricing' => array(_('S&ales Pricing'), (user_check_access('SA_SALESPRICE') ? $stock_id : null)),
'purchase_pricing' => array(_('&Purchasing Pricing'), (user_check_access('SA_PURCHASEPRICING') ? $stock_id : null)),
- 'standard_cost' => array(_('Standard &Costs'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
+ 'unit_cost' => array(_('Unit &Cost'), (user_check_access('SA_STANDARDCOST') ? $stock_id : null)),
'reorder_level' => array(_('&Reorder Levels'), (is_inventory_item($stock_id) &&
user_check_access('SA_REORDER') ? $stock_id : null)),
'movement' => array(_('&Transactions'), (user_check_access('SA_ITEMSTRANSVIEW') && is_inventory_item($stock_id) ?
$_GET['page_level'] = 1;
include_once($path_to_root."/inventory/purchasing_data.php");
break;
- case 'standard_cost':
+ case 'unit_cost':
$_GET['stock_id'] = $stock_id;
$_GET['page_level'] = 1;
include_once($path_to_root."/inventory/cost_update.php");
{
$id = $_POST['LineNo'];
if (!isset($_POST['std_cost']))
- $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$id]->standard_cost;
+ $_POST['std_cost'] = $_SESSION['transfer_items']->line_items[$id]->unit_cost;
$_SESSION['transfer_items']->update_cart_item($id, input_num('qty'), $_POST['std_cost']);
line_start_focus();
}
label_cell($adjustment['description']);
qty_cell($adjustment['qty'], false, get_qty_dec($adjustment['stock_id']));
label_cell($adjustment['units']);
- amount_decimal_cell($adjustment['standard_cost']);
+ amount_decimal_cell($adjustment['unit_cost']);
end_row();
}
//--------------------------------------------------------------------------------
-function add_to_issue(&$order, $new_item, $new_item_qty, $standard_cost)
+function add_to_issue(&$order, $new_item, $new_item_qty, $unit_cost)
{
if ($order->find_cart_item($new_item))
display_error(_("For Part :") . $new_item . " " . "This item is already on this issue. You can change the quantity issued of the existing line if necessary.");
else
- $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
+ $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $unit_cost);
}
//---------------------------------------------------------------------------------
label_cell($stock_item->item_description);
qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
label_cell($stock_item->units);
- amount_cell($stock_item->standard_cost);
-// amount_cell($stock_item->standard_cost * $stock_item->quantity);
+ amount_cell($stock_item->unit_cost);
+// amount_cell($stock_item->unit_cost * $stock_item->quantity);
edit_button_cell("Edit$line_no", _("Edit"),
_('Edit document line'));
$_POST['stock_id'] = $order->line_items[$id]->stock_id;
$_POST['qty'] = qty_format($order->line_items[$id]->quantity,
$order->line_items[$id]->stock_id, $dec);
- $std_cost = $order->line_items[$id]->standard_cost;
+ $std_cost = $order->line_items[$id]->unit_cost;
$_POST['units'] = $order->line_items[$id]->units;
hidden('stock_id', $_POST['stock_id']);
{
/*This must be the first receipt of goods against this line */
/*Need to get the standard cost as it is now so we can process GL jorunals later*/
- $order_line->standard_cost = get_unit_cost($order_line->stock_id);
+ $order_line->unit_cost = get_unit_cost($order_line->stock_id);
}
// Update the purchase data table
add_or_update_purchase_data($po->supplier_id, $order_line->stock_id, $order_line->price,
$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->quantity);
+ $order_line->unit_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 */
add_stock_move(ST_SUPPRECEIVE, $order_line->stock_id, $grn, $po->Location, $date_, "",
- $order_line->receive_qty, $order_line->standard_cost, $order_line->taxfree_charge_value($po)/$order_line->receive_qty);
+ $order_line->receive_qty, $order_line->unit_cost, $order_line->taxfree_charge_value($po)/$order_line->receive_qty);
} /*quantity received is != 0 */
} /*end of order_line loop */
var $receive_qty; // current/entry GRN quantity
var $qty_received; // quantity already received against this line
- var $standard_cost;
+ var $unit_cost;
var $descr_editable;
function __construct($line_no, $stock_item, $item_descr, $qty, $prc, $uom, $req_del_date,
$this->qty_received = $qty_recd;
$this->qty_inv = $qty_inv;
$this->receive_qty = 0; /*initialise these last two only */
- $this->standard_cost =0;
+ $this->unit_cost =0;
$this->grn_item_id = $grn_item_id;
}
}
}
else
- $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries
+ $price = $myrow['unit_cost']; //pick unit_cost for sales deliveries
return $price;
}
LEFT JOIN ".TB_PREF."debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type
LEFT JOIN ".TB_PREF."debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no
WHERE stock_id=".db_escape($stock_id)."
- AND move.tran_date <= '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER;
+ AND move.tran_date <= '$to_date' AND unit_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER;
if ($location != 'all')
$sql .= " AND move.loc_code = ".db_escape($location);
move.tran_date,
SUM(-move.qty) AS qty,
SUM(-move.qty*move.price) AS amt,
- SUM(-IF(move.standard_cost <> 0, move.qty * move.standard_cost, move.qty *item.material_cost)) AS cost
+ SUM(-IF(move.unit_cost <> 0, move.qty * move.unit_cost, move.qty *item.material_cost)) AS cost
FROM ".TB_PREF."stock_master item,
".TB_PREF."stock_category category,
".TB_PREF."debtor_trans trans,
}
}
else
- $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries
+ $price = $myrow['unit_cost']; //pick unit_cost for sales deliveries
return $price;
}
$this->freight_cost = $freight_cost;
}
- function add_to_cart($line_no, $stock_id, $qty, $price, $disc, $qty_done=0, $standard_cost=0, $description=null, $id=0, $src_no=0,
+ function add_to_cart($line_no, $stock_id, $qty, $price, $disc, $qty_done=0, $unit_cost=0, $description=null, $id=0, $src_no=0,
$src_id=0)
{
$line = new line_details($stock_id, $qty, $price, $disc,
- $qty_done, $standard_cost, $description, $id, $src_no, $src_id);
+ $qty_done, $unit_cost, $description, $id, $src_no, $src_id);
if ($line->valid) {
$this->line_items[$line_no] = $line;
var $price;
var $discount_percent;
- var $standard_cost;
+ var $unit_cost;
var $descr_editable;
var $valid; // validation in constructor
function __construct($stock_id, $qty, $prc, $disc_percent,
- $qty_done, $standard_cost, $description, $id=0, $src_no=0, $src_id=0)
+ $qty_done, $unit_cost, $description, $id=0, $src_no=0, $src_id=0)
{
/* Constructor function to add a new LineDetail object with passed params */
$this->price = $prc;
$this->discount_percent = $disc_percent;
$this->qty_done = $qty_done;
- $this->standard_cost = $standard_cost;
+ $this->unit_cost = $unit_cost;
$this->valid = true;
}
function void_customer_trans_details($type, $type_no)
{
$sql = "UPDATE ".TB_PREF."debtor_trans_details SET quantity=0, unit_price=0,
- unit_tax=0, discount_percent=0, standard_cost=0, src_id=0
+ unit_tax=0, discount_percent=0, unit_cost=0, src_id=0
WHERE debtor_trans_no=".db_escape($type_no)."
AND debtor_trans_type=".db_escape($type);
//----------------------------------------------------------------------------------------
function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no, $stock_id, $description,
- $quantity, $unit_price, $unit_tax, $discount_percent, $std_cost, $src_id, $line_id=0)
+ $quantity, $unit_price, $unit_tax, $discount_percent, $unit_cost, $src_id, $line_id=0)
{
if ($line_id!=0)
$sql = "UPDATE ".TB_PREF."debtor_trans_details SET
unit_price=$unit_price,
unit_tax=$unit_tax,
discount_percent=$discount_percent,
- standard_cost=$std_cost,
+ unit_cost=$unit_cost,
src_id=".db_escape($src_id)." WHERE
id=".db_escape($line_id);
else
$sql = "INSERT INTO ".TB_PREF."debtor_trans_details (debtor_trans_no,
debtor_trans_type, stock_id, description, quantity, unit_price,
- unit_tax, discount_percent, standard_cost, src_id)
+ unit_tax, discount_percent, unit_cost, src_id)
VALUES (".db_escape($debtor_trans_no).", ".db_escape($debtor_trans_type).", ".db_escape($stock_id).
", ".db_escape($description).",
$quantity, $unit_price, $unit_tax,
- $discount_percent, $std_cost,".db_escape($src_id).")";
+ $discount_percent, $unit_cost,".db_escape($src_id).")";
db_query($sql, "The debtor transaction detail could not be written");
}
$line_tax = get_full_price_for_item($credit_line->stock_id, $credit_line->price,
0, $credit_note->tax_included, $credit_note->tax_group_array) - $line_taxfree_price;
- $credit_line->standard_cost = get_unit_cost($credit_line->stock_id);
+ $credit_line->unit_cost = get_unit_cost($credit_line->stock_id);
write_customer_trans_detail_item(ST_CUSTCREDIT, $credit_no, $credit_line->stock_id,
$credit_line->item_description, $credit_line->qty_dispatched,
$credit_line->line_price(), $line_tax, $credit_line->discount_percent,
- $credit_line->standard_cost, $credit_line->src_id, $trans_no==0 ? 0: $credit_line->id);
+ $credit_line->unit_cost, $credit_line->src_id, $trans_no==0 ? 0: $credit_line->id);
if ($credit_type == 'Return')
add_credit_movements_item($credit_note, $credit_line,
$line_tax = get_full_price_for_item($delivery_line->stock_id,
$delivery_line->price * $qty, 0, $delivery->tax_included, $delivery->tax_group_array) - $line_taxfree_price;
- $delivery_line->standard_cost = get_unit_cost($delivery_line->stock_id);
+ $delivery_line->unit_cost = get_unit_cost($delivery_line->stock_id);
/* add delivery details for all lines */
write_customer_trans_detail_item(ST_CUSTDELIVERY, $delivery_no, $delivery_line->stock_id,
$delivery_line->item_description, $delivery_line->qty_dispatched,
$delivery_line->line_price(), $qty ? $line_tax/$qty : 0,
- $delivery_line->discount_percent, $delivery_line->standard_cost, $delivery_line->src_id,
+ $delivery_line->discount_percent, $delivery_line->unit_cost, $delivery_line->src_id,
$trans_no ? $delivery_line->id : 0);
// Now update sales_order_details for the quantity delivered
if ($delivery_line->qty_dispatched != 0) {
add_stock_move(ST_CUSTDELIVERY, $delivery_line->stock_id, $delivery_no,
$delivery->Location, $delivery->document_date, $delivery->reference,
- -$delivery_line->qty_dispatched, $delivery_line->standard_cost,
+ -$delivery_line->qty_dispatched, $delivery_line->unit_cost,
$line_price*(1-$delivery_line->discount_percent));
$mb_flag = get_mb_flag($delivery_line->stock_id);
// Fixed Assets
if ($delivery->fixed_asset) {
$fa_purchase_cost = get_purchase_cost($delivery_line->stock_id);
- $fa_depreciation = $fa_purchase_cost - $delivery_line->standard_cost;
+ $fa_depreciation = $fa_purchase_cost - $delivery_line->unit_cost;
/*first remove depreciation*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no,
$delivery->document_date, $stock_gl_code["adjustment_account"], $dim, $dim2, "",
"The stock side of the cost of sales GL posting could not be inserted");
}
// Invetory Items
- else if ($delivery_line->standard_cost != 0) {
+ else if ($delivery_line->unit_cost != 0) {
/*first the cost of sales entry*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no,
$delivery->document_date, $stock_gl_code["cogs_account"], $dim, $dim2, "",
- $delivery_line->standard_cost * $delivery_line->qty_dispatched,
+ $delivery_line->unit_cost * $delivery_line->qty_dispatched,
PT_CUSTOMER, $delivery->customer_id,
"The cost of sales GL posting could not be inserted");
/*now the stock entry*/
add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date,
$stock_gl_code["inventory_account"], 0, 0, "",
- (-$delivery_line->standard_cost * $delivery_line->qty_dispatched),
+ (-$delivery_line->unit_cost * $delivery_line->qty_dispatched),
PT_CUSTOMER, $delivery->customer_id,
"The stock side of the cost of sales GL posting could not be inserted");
}
write_customer_trans_detail_item(ST_SALESINVOICE, $invoice_no, $invoice_line->stock_id,
$invoice_line->item_description, $invoice_line->qty_dispatched,
$invoice_line->line_price(), $qty ? $line_tax/$qty : 0, $invoice_line->discount_percent,
- $invoice_line->standard_cost, $invoice_line->src_id,
+ $invoice_line->unit_cost, $invoice_line->src_id,
$trans_no ? $invoice_line->id : 0);
// Update delivery items for the quantity invoiced
$cart->line_items[$line_no] = new line_details(
$myrow["stock_id"],$myrow["quantity"],
$myrow["unit_price"], $myrow["discount_percent"],
- $myrow["qty_done"], $myrow["standard_cost"],
+ $myrow["qty_done"], $myrow["unit_cost"],
$myrow["StockDescription"],$myrow["id"], $myrow["debtor_trans_no"],
@$myrow["src_id"]);
}
--- /dev/null
+<?php
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+
+class fa2_5 extends fa_patch {
+ var $previous = '2.4.1'; // applicable database version
+ var $version = '2.5.0'; // version installed
+ var $description;
+ var $sql = 'alter2.5.sql';
+ var $max_upgrade_time = 900;
+
+ function __construct() {
+ parent::__construct();
+ $this->description = _('Upgrade from version 2.4 to 2.5');
+ }
+
+ //
+ // Install procedure. All additional changes
+ // not included in sql file should go here.
+ //
+ function install($company, $force=false)
+ {
+ return true;
+ }
+
+ //
+ // optional procedure done after upgrade fail, before backup is restored
+ //
+ function post_fail($company)
+ {
+ }
+
+}
+
+$install = new fa2_5;
--- /dev/null
+# reliable cost change log in stock_moves
+ALTER TABLE `0_stock_moves` CHANGE COLUMN `standard_cost` `unit_cost` double NOT NULL DEFAULT '0';
+ALTER TABLE `0_debtor_trans_details` CHANGE COLUMN `standard_cost` `unit_cost` double NOT NULL DEFAULT '0';
+
-- MySQL dump of database 'en_US-demo' on host 'localhost'
-- Backup Date and Time: 2019-01-21 11:16
--- Built by FrontAccounting 2.4.6
+-- Built by FrontAccounting 2.5.0
-- http://frontaccounting.com
-- Company: Training Co.
-- User: Administrator
--- Compatibility: 2.4.1
+-- Compatibility: 2.5.0
SET NAMES latin1;
`unit_tax` double NOT NULL DEFAULT '0',
`quantity` double NOT NULL DEFAULT '0',
`discount_percent` double NOT NULL DEFAULT '0',
- `standard_cost` double NOT NULL DEFAULT '0',
+ `unit_cost` double NOT NULL DEFAULT '0',
`qty_done` double NOT NULL DEFAULT '0',
`src_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
`price` double NOT NULL DEFAULT '0',
`reference` char(40) NOT NULL DEFAULT '',
`qty` double NOT NULL DEFAULT '1',
- `standard_cost` double NOT NULL DEFAULT '0',
+ `unit_cost` double NOT NULL DEFAULT '0',
PRIMARY KEY (`trans_id`),
KEY `type` (`type`,`trans_no`),
KEY `Move` (`stock_id`,`loc_code`,`tran_date`)
('default_inv_sales_act', 'glsetup.items', 'varchar', 15, '4010'),
('default_wip_act', 'glsetup.items', 'varchar', 15, '1530'),
('default_workorder_required', 'glsetup.manuf', 'int', 11, '20'),
-('version_id', 'system', 'varchar', 11, '2.4.1'),
+('version_id', 'system', 'varchar', 11, '2.5.0'),
('auto_curr_reval', 'setup.company', 'smallint', 6, '1'),
('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550'),
('bcc_email', 'setup.company', 'varchar', 100, ''),
-- MySQL dump of database 'en_US-new' on host 'localhost'
-- Backup Date and Time: 2019-01-21 11:16
--- Built by FrontAccounting 2.4.6
+-- Built by FrontAccounting 2.5.0
-- http://frontaccounting.com
-- Company: Training Co.
-- User: Administrator
--- Compatibility: 2.4.1
+-- Compatibility: 2.5.0
SET NAMES latin1;
`unit_tax` double NOT NULL DEFAULT '0',
`quantity` double NOT NULL DEFAULT '0',
`discount_percent` double NOT NULL DEFAULT '0',
- `standard_cost` double NOT NULL DEFAULT '0',
+ `unit_cost` double NOT NULL DEFAULT '0',
`qty_done` double NOT NULL DEFAULT '0',
`src_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
`price` double NOT NULL DEFAULT '0',
`reference` char(40) NOT NULL DEFAULT '',
`qty` double NOT NULL DEFAULT '1',
- `standard_cost` double NOT NULL DEFAULT '0',
+ `unit_cost` double NOT NULL DEFAULT '0',
PRIMARY KEY (`trans_id`),
KEY `type` (`type`,`trans_no`),
KEY `Move` (`stock_id`,`loc_code`,`tran_date`)
('default_inv_sales_act', 'glsetup.items', 'varchar', 15, '4010'),
('default_wip_act', 'glsetup.items', 'varchar', 15, '1530'),
('default_workorder_required', 'glsetup.manuf', 'int', 11, '20'),
-('version_id', 'system', 'varchar', 11, '2.4.1'),
+('version_id', 'system', 'varchar', 11, '2.5.0'),
('auto_curr_reval', 'setup.company', 'smallint', 6, '1'),
('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550'),
('bcc_email', 'setup.company', 'varchar', 100, ''),
//
// Versions used by source/database version compatibility checks. Do not change.
-$db_version = "2.4.1";
-$src_version = "2.4.7";
+$db_version = "2.5.0";
+$src_version = "2.5.0";
// application version - can be overriden in config.php
$version = isset($SysPrefs->version) ? $SysPrefs->version : $src_version;