switch ($item['depreciation_method']) {
case 'D':
- $line_value = $item['actual_cost']*$item['depreciation_rate']/100/12;
+ $line_value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
$value = $item['material_cost'] * $item['depreciation_rate'] * $item['depreciation_factor']/100/12;
if ($value < $line_value)
$value = $line_value;
break;
case 'S': // actual_cost stores start cost of item
- $value = $item['actual_cost']*$item['depreciation_rate']/100/12;
+ $value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
break;
case 'N':
$N = $item['depreciation_rate'];
$done_years = months_between_dates($item['depreciation_start'], $item['depreciation_date'])/12;
- $value = $item['material_cost']* ($N-$done_years)/($N*($N+1)/2)/12;
+ $value = $item['purchase_cost']* ($N-$done_years)/($N*($N+1)/2)/12;
break;
case 'O':
if (empty($memo_))
$cart->memo_ = sprintf(_("Fixed asset has been deprecated by the value of %s"),
- number_format2($value_of_change, 2));
+ number_format2($value_of_change, user_price_dec()));
else
$cart->memo_ = $memo_;
//--------------------------------------------------------------------------------------------------
-function get_initial_price($stock_id) {
- $row = get_fixed_asset_move($stock_id, ST_SUPPRECEIVE);
- return $row['price'];
-}
-
-//--------------------------------------------------------------------------------------------------
-
function get_fixed_asset_class($id)
{
$sql="SELECT * FROM ".TB_PREF."stock_fa_class WHERE fa_class_id=".db_escape($id);
{
$sql = "SELECT s.stock_id, c.description, s.units, s.description as name,
s.depreciation_rate, s.depreciation_method, s.inactive, rcv.tran_date as purchase_date, rcv.trans_no as purchase_no,
- adj.tran_date as disposal_date, adj.type as disposal_type, adj.trans_no as disposal_no, s.material_cost, s.last_cost, s.depreciation_factor
+ adj.tran_date as disposal_date, adj.type as disposal_type, adj.trans_no as disposal_no, s.material_cost, s.purchase_cost, s.depreciation_factor
FROM ".TB_PREF."stock_master s"
." LEFT JOIN ".TB_PREF."stock_moves rcv ON rcv.stock_id=s.stock_id AND rcv.type=".ST_SUPPRECEIVE
." LEFT JOIN ".TB_PREF."stock_moves adj ON adj.stock_id=s.stock_id AND adj.type IN(".ST_INVADJUST.",".ST_CUSTDELIVERY.")"
function amount_link($row)
{
- return price_format($row['last_cost']);
+ return price_format($row['purchase_cost']);
}
function depr_link($row)
{
- return price_format($row['last_cost'] - $row['material_cost']);
+ return price_format($row['purchase_cost'] - $row['material_cost']);
}
function balance_link($row)
_("Method") => array('fun' => 'depr_method_title'),
_("Status") => array('fun' => 'status_title'),
_("Purchased") => array('fun' => 'purchase_link'),
- _("Amount") => array('align'=>'right', 'fun' => 'amount_link'),
+ _("Initial") => array('align'=>'right', 'fun' => 'amount_link'),
_("Depreciations") => array('align'=>'right', 'fun' => 'depr_link'),
- _("Balance") => array('align'=>'right', 'fun' => 'balance_link'),
+ _("Current") => array('align'=>'right', 'fun' => 'balance_link'),
_("Liquidation or Sale") => array('align' => 'center', 'fun' => 'disposal_link'),
//array('insert'=>true, 'fun'=>'gl_view'),
//array('insert'=>true, 'fun'=>'rm_link'),
return db_fetch($get);
}
+function get_purchase_value($stock_id)
+{
+ $sql = "SELECT purchase_cost FROM
+ ".TB_PREF."stock_master WHERE stock_id = ".db_escape($stock_id);
+
+ $result = db_query($sql,"retreive stock purchase price");
+ $row = db_fetch_row($result);
+ return $row[0];
+}
+
+function update_purchase_value($stock_id, $price)
+{
+ $price = round2($price, user_price_dec());
+ $sql = "UPDATE ".TB_PREF."stock_master SET purchase_cost=".db_escape($price)
+ ." WHERE stock_id=".db_escape($stock_id);
+ db_query($sql, "The stock master purchase_cost cannot be updated");
+}
//-----------------------------------------------------------------------------------------
function handle_negative_inventory($stock_id, $quantity, $standard_cost, $date_)
);
$fa_systypes_array = array (
- ST_INVADJUST => _("FA Disposal"),
- ST_COSTUPDATE => _("FA Revaluation"),
+ ST_INVADJUST => _("Fixed Assets Disposal"),
+ ST_COSTUPDATE => _("Fixed Assets Revaluation"),
);
$type_shortcuts = array(
$this->item_description = $description;
if ($standard_cost == null)
- $this->standard_cost = $item_row["actual_cost"];
+ $this->standard_cost = $item_row["purchase_cost"];
else
$this->standard_cost = $standard_cost;
$row = db_fetch($result);
if (is_fixed_asset($row['mb_flag'])) {
- display_notification_centered(_("FA disposal has been processed"));
+ display_notification_centered(_("Fixed Assets disposal has been processed"));
display_note(get_trans_view_str($trans_type, $trans_no, _("&View this disposal")));
display_note(get_gl_view_str($trans_type, $trans_no, _("View the GL &Postings for this Disposal")), 1, 0);
amount_decimal_cell($stock_item->standard_cost);
if ($order->fixed_asset) {
- $price = get_initial_price($stock_item->stock_id);
+ $price = get_purchase_value($stock_item->stock_id);
amount_cell($price);
} else
amount_cell($stock_item->standard_cost * $stock_item->quantity);
}
if ($order->fixed_asset) {
- hidden('qty', 1);
+ hidden('qty', -1);
qty_cell(1, false, 0);
} else
qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
that still has to be submitted in the form */
hidden('std_cost');
label_cell($_POST['std_cost'], "nowrap align=right ", 'std_cost_view');
- $price = get_initial_price($_POST['stock_id']);
+ $price = get_purchase_value($_POST['stock_id']);
amount_cell($price, false, '', 'initial_price');
} else {
//amount_cells(null, 'std_cost', $_POST['std_cost']);
if (isset($_GET['FixedAsset'])) {
$page_security = 'SA_ASSETSTRANSVIEW';
$_POST['fixed_asset'] = 1;
- $_SESSION['page_title'] = _($help_context = "FA Item Movement");
+ $_SESSION['page_title'] = _($help_context = "Fixed Assets Movement");
} else {
$_SESSION['page_title'] = _($help_context = "Inventory Item Movement");
}
if (isset($_GET['FixedAsset'])) {
$page_security = 'SA_ASSET';
- $_SESSION['page_title'] = _($help_context = "FA Items");
+ $_SESSION['page_title'] = _($help_context = "Fixed Assets");
$_POST['mb_flag'] = 'F';
$_POST['fixed_asset'] = 1;
}
$_POST['depreciation_date'] = sql2date($myrow['depreciation_date']);
$_POST['fa_class_id'] = $myrow['fa_class_id'];
$_POST['material_cost'] = $myrow['material_cost'];
- $_POST['last_cost'] = $myrow['last_cost'];
+ $_POST['purchase_cost'] = $myrow['purchase_cost'];
$_POST['sales_account'] = $myrow['sales_account'];
$_POST['inventory_account'] = $myrow['inventory_account'];
table_section_title(_("Values"));
if (!$new_item) {
hidden('material_cost');
- hidden('last_cost');
- label_row(_("Amount").":", price_format($_POST['last_cost']), "", "align='right'");
- label_row(_("Depreciations").":", price_format($_POST['last_cost'] - $_POST['material_cost']), "", "align='right'");
+ hidden('purchase_cost');
+ label_row(_("Initial Value").":", price_format($_POST['purchase_cost']), "", "align='right'");
+ label_row(_("Depreciations").":", price_format($_POST['purchase_cost'] - $_POST['material_cost']), "", "align='right'");
label_row(_("Current Value").':', price_format($_POST['material_cost']), "", "align='right'");
}
}
if (isset($_GET['NewTransfer'])) {
if (isset($_GET['FixedAsset'])) {
$page_security = 'SA_ASSETTRANSFER';
- $_SESSION['page_title'] = _($help_context = "FA Location Transfers");
+ $_SESSION['page_title'] = _($help_context = "Fixed Assets Location Transfers");
}
else {
$_SESSION['page_title'] = _($help_context = "Inventory Location Transfers");
$itm = db_fetch(get_stock_transfer_items($_GET['AddedID']));
if (is_fixed_asset($itm['mb_flag']))
- hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another FA Item Transfer"), "NewTransfer=1&FixedAsset=1");
+ hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another Fixed Assets Transfer"), "NewTransfer=1&FixedAsset=1");
else
hyperlink_params($_SERVER['PHP_SELF'], _("Enter &Another Inventory Transfer"), "NewTransfer=1");
}
add_or_update_purchase_data($supp_trans->supplier_id, $entered_grn->item_code, $entered_grn->chg_price);
}
-
+ update_purchase_value($entered_grn->item_code, $entered_grn->chg_price * $ex_rate);
add_supp_invoice_item($trans_type, $invoice_id, $entered_grn->item_code,
$entered_grn->item_description, 0, $entered_grn->chg_price, $line_tax/$entered_grn->this_quantity_inv,
$entered_grn->this_quantity_inv, $entered_grn->id, $entered_grn->po_detail_item, "");
$cols = array(0, 75, 225, 250, 350, 450, 515);
- $headers = array(_('Class'), '', _('UOM'), _('Amount'), _('Depreciations'), _('Balance'));
+ $headers = array(_('Class'), '', _('UOM'), _('Initial'), _('Depreciations'), _('Current'));
$aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
if ($detail)
$rep->NewLine();
}
- $UnitCost = $trans['last_cost'];
- $Depreciation = $trans['last_cost'] - $trans['material_cost'];;
+ $UnitCost = $trans['purchase_cost'];
+ $Depreciation = $trans['purchase_cost'] - $trans['material_cost'];;
$Balance = $trans['material_cost'];
if ($detail)
{
create_cart(ST_SALESINVOICE, $_GET['NewInvoice']);
if (isset($_GET['FixedAsset'])) {
- $_SESSION['page_title'] = _($help_context = "FA Sale");
+ $_SESSION['page_title'] = _($help_context = "Fixed Assets Sale");
$_SESSION['Items']->fixed_asset = true;
} else
$_SESSION['page_title'] = _($help_context = "Direct Sales Invoice");
ALTER TABLE `0_stock_master` ADD COLUMN `depreciation_start` date NOT NULL DEFAULT '0000-00-00' AFTER `depreciation_factor`;
ALTER TABLE `0_stock_master` ADD COLUMN `depreciation_date` date NOT NULL DEFAULT '0000-00-00' AFTER `depreciation_start`;
ALTER TABLE `0_stock_master` ADD COLUMN `fa_class_id` varchar(20) NOT NULL DEFAULT '' AFTER `depreciation_date`;
+ALTER TABLE `0_stock_master` CHANGE `actual_cost` `purchase_cost` double NOT NULL default 0;
INSERT INTO `0_sys_prefs` VALUES ('default_loss_on_asset_disposal_act', 'glsetup.items', 'varchar', '15', '5660');
INSERT INTO `0_sys_prefs` VALUES ('depreciation_period', 'glsetup.company', 'tinyint', '1', '1');