Global change in naming convention from std_cost to unit_cost.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 28 Jun 2019 13:44:52 +0000 (15:44 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 19 Aug 2019 10:41:57 +0000 (12:41 +0200)
28 files changed:
admin/db/fiscalyears_db.inc
doc/dim_on_invoice.txt
includes/db/inventory_db.inc
includes/ui/items_cart.inc
inventory/includes/db/items_adjust_db.inc
inventory/includes/db/items_transfer_db.inc
inventory/includes/item_adjustments_ui.inc
inventory/includes/stock_transfers_ui.inc
inventory/manage/items.php
inventory/transfers.php
inventory/view/view_adjustment.php
manufacturing/includes/work_order_issue_ui.inc
purchasing/includes/db/grn_db.inc
purchasing/includes/po_class.inc
reporting/rep301.php
reporting/rep304.php
reporting/rep308.php
sales/includes/cart_class.inc
sales/includes/db/cust_trans_details_db.inc
sales/includes/db/sales_credit_db.inc
sales/includes/db/sales_delivery_db.inc
sales/includes/db/sales_invoice_db.inc
sales/includes/sales_db.inc
sql/alter2.5.php [new file with mode: 0644]
sql/alter2.5.sql [new file with mode: 0644]
sql/en_US-demo.sql
sql/en_US-new.sql
version.php

index 6281268ba897d0be203511edd2b801f00836badf..1d1d94a843aac8fdb4d490e8739ec9537d12bec2 100644 (file)
@@ -323,7 +323,7 @@ function delete_this_fiscalyear($selected_id)
                delete_attachments_and_comments(ST_WORKORDER, $row['id']);
        }
        $sql = "SELECT loc_code, stock_id, SUM(qty) AS qty,"
                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))
            ." 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))
@@ -331,9 +331,9 @@ function delete_this_fiscalyear($selected_id)
                $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'];
                $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'";
                db_query($sql, "Could not insert stock move");
        }               
        $sql = "DELETE FROM ".TB_PREF."voided WHERE date_ <= '$to'";
index ffd7932f32a4f343fa42a7d84f44a575876fada0..075b08a7af0c83fa5983289114ff528d364f002c 100644 (file)
@@ -16,7 +16,7 @@ set by item. And the dimension(s) are saved on the cust_trans table.
 To be used when going from delivery to invoice, so there is a match between the
 2 links.
 
 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 
 values they will show up on all COGS accounts.
 
 If invoicing the dimensions will go to the SALES accounts, so it is easy to 
index e46dd6de82e128ae7baf48d1e4f7848307a94735..fb1cb368d714b4100c595baebd9053f6f8efb067 100644 (file)
@@ -209,7 +209,7 @@ function get_deliveries_between($stock_id, $from, $to)
 {
        $from = date2sql($from);
        $to = date2sql($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";
 
                WHERE type=".ST_CUSTDELIVERY." AND stock_id=".db_escape($stock_id)." AND
                        tran_date>='$from' AND tran_date<='$to' GROUP BY stock_id";
 
@@ -224,14 +224,14 @@ function get_deliveries_from_trans($stock_id, $move_id)
 {
        // -ve qty is delivery either by ST_CUSTDELIVERY or inventory adjustment
     //Price for GRN and SUPPCREDIT and std_cost for other trans_types
 {
        // -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
        
         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'";
         FROM ".TB_PREF."stock_moves
         WHERE stock_id=".db_escape($stock_id)
             ." AND trans_id ='$move_id'";
@@ -259,7 +259,7 @@ function get_deliveries_from_trans($stock_id, $move_id)
 function get_purchases_from_trans($stock_id, $move_id)
 {
        // Calculate All inward stock moves i.e. qty > 0
 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";
                FROM ".TB_PREF."stock_moves
                WHERE stock_id=".db_escape($stock_id)." AND qty > 0 AND 
                        trans_id>'$move_id' GROUP BY stock_id";
@@ -359,7 +359,7 @@ function update_purchase_value($stock_id, $price)
 }      
 //-----------------------------------------------------------------------------------------
 
 }      
 //-----------------------------------------------------------------------------------------
 
-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
 {
        //If negative adjustment result in negative or zero inventory
        //then difference should be adjusted
@@ -371,7 +371,7 @@ function handle_negative_inventory($stock_id, $quantity, $standard_cost, $date_)
 
                $id = get_next_trans_no(ST_JOURNAL);
                $ref = $Refs->get_next(ST_JOURNAL, null, $date_);
 
                $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)
                {
 
                if ($diff != 0)
                {
@@ -407,16 +407,16 @@ function handle_negative_inventory($stock_id, $quantity, $standard_cost, $date_)
 // $price - in transaction currency
 
 function add_stock_move($type, $stock_id, $trans_no, $location,
 // $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,
 {
        $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($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");
 
 
        db_query($sql, "The stock movement record cannot be inserted");
 
@@ -425,11 +425,11 @@ function add_stock_move($type, $stock_id, $trans_no, $location,
 
 function update_stock_move($type, $trans_no, $stock_id, $cost)
 {
 
 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);
                        ." 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");
 }
 
 //--------------------------------------------------------------------------------------------------
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -467,12 +467,12 @@ function void_stock_move($type, $type_no)
                if (is_inventory_item($row["stock_id"]))
                {
                        // The cost has to be adjusted.
                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
                        $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"]));
 
                        update_average_material_cost($row["supplier_id"], $row["stock_id"],
                                $unit_cost, -$row["qty"], sql2date($row["tran_date"]));
index 0e32165b0be23c17dda2b8fc05fcd11cbd26330d..44fb14946bd33b86b89a22a127d851691c2b21f7 100644 (file)
@@ -52,13 +52,13 @@ class items_cart
 
        // --------------- line item functions
 
 
        // --------------- 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,
        {
 
                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 true;
                }
                else
@@ -79,10 +79,10 @@ class items_cart
                return null;
        }
 
                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]->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)
        }
 
        function remove_from_cart($line_no)
@@ -463,9 +463,9 @@ class line_item
 
        var $quantity;
        var $price;
 
        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);
 
        {
                $item_row = get_item($stock_id);
 
@@ -480,10 +480,10 @@ class line_item
                else
                        $this->item_description = $description;
 
                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
                else
-                       $this->standard_cost = $standard_cost;
+                       $this->unit_cost = $unit_cost;
 
                $this->stock_id = $stock_id;
                $this->quantity = $qty;
 
                $this->stock_id = $stock_id;
                $this->quantity = $qty;
index 9a45e0f7d02c077a10157a07d1e0a8ca7c02b33f..0085f98360b7b702b226bccd3421fc836ef3dc86 100644 (file)
@@ -40,7 +40,7 @@ function add_stock_adjustment($items, $location, $date_, $reference, $memo_)
                }
 
                add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $reference,
                }
 
                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_);
        }
 
        add_comments(ST_INVADJUST, $adj_id, $date_, $memo_);
@@ -83,7 +83,7 @@ function get_stock_adjustment_items($trans_no)
 //--------------------------------------------------------------------------------------------------
 
 function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $reference,
 //--------------------------------------------------------------------------------------------------
 
 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);
 
 {
        $mb_flag = get_mb_flag($stock_id);
 
@@ -92,7 +92,7 @@ function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $refer
        display_db_error("Cannot do inventory adjustment for Service item : $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
 
        if (is_fixed_asset($mb_flag)) {
                $sql = "UPDATE ".TB_PREF."stock_master SET inactive=1
@@ -101,19 +101,19 @@ function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $refer
        }
 
        add_stock_move(ST_INVADJUST, $stock_id, $adj_id, $location,
        }
 
        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;
 
        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);
        {
 
                $stock_gl_codes = get_stock_gl_code($stock_id);
@@ -127,6 +127,6 @@ function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $refer
        if (is_fixed_asset($mb_flag)) {
                // Additional gl entry for fixed asset.
                $grn_act = get_company_pref('default_loss_on_asset_disposal_act');
        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)));
        }
 }
        }
 }
index c9a845f9b3e6613d28f2c23b21687896acbe7811..f35bf3696c43439ca0bfcb6c26ba574a960e2a04 100644 (file)
@@ -61,7 +61,7 @@ function add_stock_transfer($Items, $location_from, $location_to, $date_, $refer
 // add 2 stock_moves entries for a stock transfer
 // $date_ is display date (not sql)
 // std_cost is in HOME currency
 // 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_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to,
        $date_, $reference, $quantity)
index 1e15ff950028494475aeda1843fc2a6a21c518e4..530ab12c2f0a4e4d5505d0f2aee2ab9f3c87dbf9 100644 (file)
@@ -14,12 +14,12 @@ include_once($path_to_root . "/includes/ui/items_cart.inc");
 
 //--------------------------------------------------------------------------------
 
 
 //--------------------------------------------------------------------------------
 
-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
 {
     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);
 }
 
 //--------------------------------------------------------------------------------
 }
 
 //--------------------------------------------------------------------------------
@@ -70,7 +70,7 @@ function display_adjustment_items($title, &$order)
        foreach ($order->line_items as $line_no=>$stock_item)
        {
 
        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)
                {
 
                if ($id != $line_no)
                {
@@ -87,13 +87,13 @@ function display_adjustment_items($title, &$order)
                        label_cell($stock_item->item_description);
                qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
                        label_cell($stock_item->units);
                        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
 
                        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)
 
                if (!$order->fixed_asset) {
                        if ($id == -1)
@@ -143,8 +143,8 @@ function adjustment_edit_item_controls(&$order, $line_no=-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['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']);
                }
                $_POST['units'] = $order->line_items[$line_no]->units;
                hidden('stock_id', $_POST['stock_id']);
index acc17772b75daf62c54a05be677cafcecc3da01c..d35207308a92dc85d8372d40d117d5d65d6b5d4f 100644 (file)
@@ -14,12 +14,12 @@ include_once($path_to_root . "/includes/ui/items_cart.inc");
 
 //--------------------------------------------------------------------------------
 
 
 //--------------------------------------------------------------------------------
 
-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
 {
     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);
 }
 
 //--------------------------------------------------------------------------------
 }
 
 //--------------------------------------------------------------------------------
index f95887e0f8c19f7b518c9a3a0bd952399c719169..dfaa25a0203834456bbf9db16e70ca2d35acd2e4 100644 (file)
@@ -580,7 +580,7 @@ $tabs = (get_post('fixed_asset'))
                '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)),
                '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) ? 
                '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) ? 
@@ -605,7 +605,7 @@ tabbed_content_start('tabs', $tabs);
                        $_GET['page_level'] = 1;
                        include_once($path_to_root."/inventory/purchasing_data.php");
                        break;
                        $_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");
                        $_GET['stock_id'] = $stock_id;
                        $_GET['page_level'] = 1;
                        include_once($path_to_root."/inventory/cost_update.php");
index 3cbc3c2c45d23478fde69917cb7844794322c9ee..d9f22c12f72694bf21d338c31425ca83531a4d6a 100644 (file)
@@ -171,7 +171,7 @@ function handle_update_item()
 {
        $id = $_POST['LineNo'];
        if (!isset($_POST['std_cost']))
 {
        $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();
 }
        $_SESSION['transfer_items']->update_cart_item($id, input_num('qty'), $_POST['std_cost']);
        line_start_focus();
 }
index ca3a7edc73a03a28eefd4e8e4d6365d99acc69a6..e762deb2cb4f9871c0f9224d88c74b03712e2807 100644 (file)
@@ -62,7 +62,7 @@ while ($adjustment = db_fetch($adjustment_items))
     label_cell($adjustment['description']);
     qty_cell($adjustment['qty'], false, get_qty_dec($adjustment['stock_id']));
     label_cell($adjustment['units']);
     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();
 }
 
     end_row();
 }
 
index 066f80d63a52050feea101fe96a8f7b81c04411f..a37ef0950aa97d16302ec763f7984f2c86ec8b0e 100644 (file)
@@ -14,12 +14,12 @@ include_once($path_to_root . "/includes/ui/items_cart.inc");
 
 //--------------------------------------------------------------------------------
 
 
 //--------------------------------------------------------------------------------
 
-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
 {
     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);
 }
 //---------------------------------------------------------------------------------
 
 }
 //---------------------------------------------------------------------------------
 
@@ -55,8 +55,8 @@ function display_issue_items($title, &$order)
                        label_cell($stock_item->item_description);
                qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
                        label_cell($stock_item->units);
                        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'));
 
                        edit_button_cell("Edit$line_no", _("Edit"),
                                _('Edit document line'));
@@ -92,7 +92,7 @@ function issue_edit_item_controls(&$order, $line_no=-1)
                $_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);
                $_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']);
                $_POST['units'] = $order->line_items[$id]->units;
 
                hidden('stock_id', $_POST['stock_id']);
index 62f29ed87d60766fe331530791281447ecc4f631..af51c0d8125127000364a24215c135b8eab21337 100644 (file)
@@ -126,7 +126,7 @@ function add_grn(&$po)
                        {
                                /*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*/
                        {
                                /*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, 
                        }
                        // Update the purchase data table
                        add_or_update_purchase_data($po->supplier_id, $order_line->stock_id, $order_line->price, 
@@ -137,12 +137,12 @@ function add_grn(&$po)
                                $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->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_, "",
 
                        $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 */
 
                } /*quantity received is != 0 */
        } /*end of order_line loop */
index c24119d2b9d26bd226e7c149a83a468cfbfb4db5..d6f244dad5676b5bcda57fa57c43d2e1b1a194de 100644 (file)
@@ -213,7 +213,7 @@ class po_line_details
        var $receive_qty;       // current/entry GRN quantity
        var $qty_received;      // quantity already received against this line
 
        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, 
        var $descr_editable;
 
        function __construct($line_no, $stock_item, $item_descr, $qty, $prc, $uom, $req_del_date, 
@@ -242,7 +242,7 @@ class po_line_details
                $this->qty_received = $qty_recd;
                $this->qty_inv = $qty_inv;
                $this->receive_qty = 0; /*initialise these last two only */
                $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;
        }
        
                $this->grn_item_id = $grn_item_id;
        }
        
index 16e96191c34b243031e0e23681ec24ea53b1e54a..b00a5a9a98ceafab539aa21791c13b4f4bbb38ec 100644 (file)
@@ -43,7 +43,7 @@ function get_domestic_price($myrow, $stock_id)
         }
     }
     else
         }
     }
     else
-        $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries
+        $price = $myrow['unit_cost']; //pick unit_cost for sales deliveries
 
     return $price;
 }
 
     return $price;
 }
@@ -63,7 +63,7 @@ function getAverageCost($stock_id, $location, $to_date)
                                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)."
                                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);
 
        if ($location != 'all')
                $sql .= " AND move.loc_code = ".db_escape($location);
index 971c7e20553c246bd79625f6e9724f27e23f9125..c3f570f0de33e0c5f41cbac16043535c65b57479 100644 (file)
@@ -45,7 +45,7 @@ function getTransactions($category, $location, $fromcust, $from, $to, $show_serv
                        move.tran_date,
                        SUM(-move.qty) AS qty,
                        SUM(-move.qty*move.price) AS amt,
                        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,
                FROM ".TB_PREF."stock_master item,
                        ".TB_PREF."stock_category category,
                        ".TB_PREF."debtor_trans trans,
index 0981c2ad64276153b9e67943192ad18a9e34547a..0837704d37bda96a4d1c23df5103e16959e62b1c 100644 (file)
@@ -45,7 +45,7 @@ function get_domestic_price($myrow, $stock_id)
         }
     }
     else
         }
     }
     else
-        $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries
+        $price = $myrow['unit_cost']; //pick unit_cost for sales deliveries
 
     return $price;
 }
 
     return $price;
 }
index 1bc3db242f5b0528d2f98a2a65bde6275125bd14..c6b6f353ef9479925d7af0e73e03880eef00df57 100644 (file)
@@ -394,11 +394,11 @@ class Cart
                        $this->freight_cost = $freight_cost;
        }
 
                        $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,
                $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;
 
                if ($line->valid) {
                        $this->line_items[$line_no] = $line;
@@ -669,7 +669,7 @@ class line_details
        var $price;
        var $discount_percent;
        
        var $price;
        var $discount_percent;
        
-       var $standard_cost;
+       var $unit_cost;
        var $descr_editable;
 
        var $valid; // validation in constructor
        var $descr_editable;
 
        var $valid; // validation in constructor
@@ -701,7 +701,7 @@ class line_details
 
 
        function __construct($stock_id, $qty, $prc, $disc_percent,
 
 
        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 */
 
        {
        /* Constructor function to add a new LineDetail object with passed params */
 
@@ -728,7 +728,7 @@ class line_details
                $this->price = $prc;
                $this->discount_percent = $disc_percent;
                $this->qty_done = $qty_done;
                $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;
        }
 
                $this->valid = true;
        }
 
index b4b9331450bf4d0f50d26992b17bc1992d519a2a..fabcfe073961a7fe3b661208a9f9876fc296e442 100644 (file)
@@ -44,7 +44,7 @@ if (!is_array($debtor_trans_no))
 function void_customer_trans_details($type, $type_no)
 {
        $sql = "UPDATE ".TB_PREF."debtor_trans_details SET quantity=0, unit_price=0,
 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);
 
                WHERE debtor_trans_no=".db_escape($type_no)."
                AND debtor_trans_type=".db_escape($type);
 
@@ -56,7 +56,7 @@ function void_customer_trans_details($type, $type_no)
 //----------------------------------------------------------------------------------------
 
 function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no, $stock_id, $description,
 //----------------------------------------------------------------------------------------
 
 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
 {
        if ($line_id!=0)
                $sql = "UPDATE ".TB_PREF."debtor_trans_details SET
@@ -66,17 +66,17 @@ function write_customer_trans_detail_item($debtor_trans_type, $debtor_trans_no,
                        unit_price=$unit_price,
                        unit_tax=$unit_tax,
                        discount_percent=$discount_percent,
                        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,
                        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, 
                        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");
 }
 
        db_query($sql, "The debtor transaction detail could not be written");
 }
index 5f0382a6ad82d38358324e3ca5e87726c3dcdf2e..999624f067ab61696a85d852acb5a7d5c5713aa4 100644 (file)
@@ -114,12 +114,12 @@ function write_credit_note(&$credit_note, $write_off_acc)
                $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;
 
                $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,
                
                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,
 
                if ($credit_type == 'Return')
                        add_credit_movements_item($credit_note, $credit_line,
index 3a000103adb4d253361dc2354b79f34e8c737d24..e5ef67565b38407a09781308c96f9d9ddb185a4c 100644 (file)
@@ -79,13 +79,13 @@ function write_sales_delivery(&$delivery,$bo_policy)
                $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;
 
                $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,
 
                /* 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
                        $trans_no ? $delivery_line->id : 0);
 
        // Now update sales_order_details for the quantity delivered
@@ -96,7 +96,7 @@ function write_sales_delivery(&$delivery,$bo_policy)
                if ($delivery_line->qty_dispatched != 0) {
                        add_stock_move(ST_CUSTDELIVERY, $delivery_line->stock_id, $delivery_no,
                                $delivery->Location, $delivery->document_date, $delivery->reference,
                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);
                                 $line_price*(1-$delivery_line->discount_percent));
 
                        $mb_flag = get_mb_flag($delivery_line->stock_id);
@@ -128,7 +128,7 @@ function write_sales_delivery(&$delivery,$bo_policy)
                                // Fixed Assets
                                if ($delivery->fixed_asset) {
                                    $fa_purchase_cost = get_purchase_cost($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, "",
                                        /*first remove depreciation*/
                                        add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no,
                                                $delivery->document_date, $stock_gl_code["adjustment_account"], $dim, $dim2, "",
@@ -149,18 +149,18 @@ function write_sales_delivery(&$delivery,$bo_policy)
                                                "The stock side of the cost of sales GL posting could not be inserted");
                                }
                                // Invetory Items
                                                "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, "",
                                        /*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, "",
                                                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");
                                }                               
                                                PT_CUSTOMER, $delivery->customer_id,
                                                "The stock side of the cost of sales GL posting could not be inserted");
                                }                               
index a072076940326041f532f1cec17225b167b83d04..901cdd0840d9279a2b2ad46cd4991ed339958a7e 100644 (file)
@@ -115,7 +115,7 @@ function write_sales_invoice(&$invoice)
                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,
                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
                        $trans_no ? $invoice_line->id : 0);
 
                // Update delivery items for the quantity invoiced
index bdc449d83623f0d1a5973767189acbbfcacdf4d3..d1cabba5ccf83fd32f19895ad2212f4cbadbb7e6 100644 (file)
@@ -274,7 +274,7 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
                                $cart->line_items[$line_no] = new line_details(
                                        $myrow["stock_id"],$myrow["quantity"],
                                        $myrow["unit_price"], $myrow["discount_percent"],
                                $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"]);
                        }
                                        $myrow["StockDescription"],$myrow["id"], $myrow["debtor_trans_no"],
                                        @$myrow["src_id"]);
                        }
diff --git a/sql/alter2.5.php b/sql/alter2.5.php
new file mode 100644 (file)
index 0000000..f79dde5
--- /dev/null
@@ -0,0 +1,43 @@
+<?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;
diff --git a/sql/alter2.5.sql b/sql/alter2.5.sql
new file mode 100644 (file)
index 0000000..5e7680c
--- /dev/null
@@ -0,0 +1,4 @@
+# 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';
+
index d536e000ee7605c42b1a1b6ec91f73c148804c9d..3d3ee277140483a329f444d0051d508513b5a7cf 100644 (file)
@@ -1,11 +1,11 @@
 -- MySQL dump of database 'en_US-demo' on host 'localhost'
 -- Backup Date and Time: 2019-01-21 11:16
 -- 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
 
 -- http://frontaccounting.com
 -- Company: Training Co.
 -- User: Administrator
 
--- Compatibility: 2.4.1
+-- Compatibility: 2.5.0
 
 
 SET NAMES latin1;
 
 
 SET NAMES latin1;
@@ -644,7 +644,7 @@ CREATE TABLE `0_debtor_trans_details` (
   `unit_tax` double NOT NULL DEFAULT '0',
   `quantity` double NOT NULL DEFAULT '0',
   `discount_percent` double NOT NULL DEFAULT '0',
   `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`),
   `qty_done` double NOT NULL DEFAULT '0',
   `src_id` int(11) NOT NULL,
   PRIMARY KEY (`id`),
@@ -1703,7 +1703,7 @@ CREATE TABLE `0_stock_moves` (
   `price` double NOT NULL DEFAULT '0',
   `reference` char(40) NOT NULL DEFAULT '',
   `qty` double NOT NULL DEFAULT '1',
   `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`)
   PRIMARY KEY (`trans_id`),
   KEY `type` (`type`,`trans_no`),
   KEY `Move` (`stock_id`,`loc_code`,`tran_date`)
@@ -1915,7 +1915,7 @@ INSERT INTO `0_sys_prefs` VALUES
 ('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'),
 ('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, ''),
 ('auto_curr_reval', 'setup.company', 'smallint', 6, '1'),
 ('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550'),
 ('bcc_email', 'setup.company', 'varchar', 100, ''),
index e1ddc2d709842c6241957d22d5200fc8e5253f41..f597b8fa19f9abc3f535b9b273537fd5bf5cdab1 100644 (file)
@@ -1,11 +1,11 @@
 -- MySQL dump of database 'en_US-new' on host 'localhost'
 -- Backup Date and Time: 2019-01-21 11:16
 -- 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
 
 -- http://frontaccounting.com
 -- Company: Training Co.
 -- User: Administrator
 
--- Compatibility: 2.4.1
+-- Compatibility: 2.5.0
 
 
 SET NAMES latin1;
 
 
 SET NAMES latin1;
@@ -544,7 +544,7 @@ CREATE TABLE `0_debtor_trans_details` (
   `unit_tax` double NOT NULL DEFAULT '0',
   `quantity` double NOT NULL DEFAULT '0',
   `discount_percent` double NOT NULL DEFAULT '0',
   `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`),
   `qty_done` double NOT NULL DEFAULT '0',
   `src_id` int(11) NOT NULL,
   PRIMARY KEY (`id`),
@@ -1407,7 +1407,7 @@ CREATE TABLE `0_stock_moves` (
   `price` double NOT NULL DEFAULT '0',
   `reference` char(40) NOT NULL DEFAULT '',
   `qty` double NOT NULL DEFAULT '1',
   `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`)
   PRIMARY KEY (`trans_id`),
   KEY `type` (`type`,`trans_no`),
   KEY `Move` (`stock_id`,`loc_code`,`tran_date`)
@@ -1588,7 +1588,7 @@ INSERT INTO `0_sys_prefs` VALUES
 ('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'),
 ('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, ''),
 ('auto_curr_reval', 'setup.company', 'smallint', 6, '1'),
 ('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550'),
 ('bcc_email', 'setup.company', 'varchar', 100, ''),
index 68fd95f268264c162c5d77fb026949070c476074..59030992ebe70a7af0abf369682e0828f41f0f5a 100644 (file)
@@ -5,8 +5,8 @@
 //
 
 // Versions used by source/database version compatibility checks. Do not change.
 //
 
 // 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;
 
 // application version - can be overriden in config.php
 $version = isset($SysPrefs->version) ? $SysPrefs->version : $src_version;