Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function UpdateCost() - No Labour/Overhead?
12-06-2018, 12:02 AM, (This post was last modified: 12-06-2018, 01:22 AM by VortecCPI.)
#1
Function UpdateCost() - No Labour/Overhead?
SQL_CommonFunctions.inc

Again I have to ask why are we rolling just material cost from the bottom to the top? Should we not also be rolling Labour and Overhead costs from the bottom to the top?
Something like this?

PHP Code:
/* Calculates the material cost of a bill of materials, given parent code*/
function BomMaterialCost($Parent$db) {
    
$SQL "SELECT labourcost+materialcost+overheadcost FROM stockmaster WHERE stockid='" $Parent "'";
    
$result1 DB_query($SQL);
    
$MyRow1 DB_fetch_row($result1);
    
$OldCost $MyRow1[0];
    
$SQL "SELECT sum(quantity) AS qoh from locstock where stockid='" $Parent "'";
    
$result1 DB_query($SQL);
    
$MyRow1 DB_fetch_row($result1);
    
$QOH $MyRow1[0];
    
$SQL "SELECT Sum(stockmaster.labourcost*bom.quantity) AS SumOfLaborCost,
                        Sum(stockmaster.materialcost*bom.quantity) AS SumOfMaterialCost,
                        Sum(stockmaster.overheadcost*bom.quantity) AS SumOfOverheadCost
                           FROM bom LEFT JOIN stockmaster
                        ON bom.component = stockmaster.stockid
                        WHERE bom.parent='"
$Parent "'
                        AND bom.effectiveafter <= '" 
date('Y-m-d') . "'
                        AND bom.effectiveto > '" 
date('Y-m-d') . "'";
    
$result DB_query($SQL);
    
$MyRow DB_fetch_row($result);
    
$LabourCost $MyRow[0];
    
$MaterialCost $MyRow[1];
    
$OverheadCost $MyRow[2];
    
$CombinedCost=$LabourCost+$MaterialCost+$OverheadCost;
    if (
abs($QOH*($CombinedCost-$OldCost))>0) {
        
ItemCostUpdateGL($Parent$CombinedCost$OldCost$QOH);
    }
    return array(
$OldCost$LabourCost$MaterialCost$OverheadCost);
}

/*Iterates through the levels of the bom, recalculating each bom it meets*/
function UpdateCost($db$Item) {
    
//update the items cost itself first;
    
BomMaterialCost(strtoupper($Item), $db);
    
$SQL "SELECT parent FROM bom where component = '" $Item "'";
    
$Result DB_query($SQL);
    while (
$MyRow=DB_fetch_array($Result)){
        
$NewParent $MyRow['parent'];
        
$TotalCost BomMaterialCost($NewParent$db);
        
$LastCost $TotalCost[0];
        
$LabourCost $TotalCost[1];
        
$MaterialCost $TotalCost[2];
        
$OverheadCost $TotalCost[3];
        
$SQL "UPDATE stockmaster SET 
                labourcost=" 
$LabourCost ",
                materialcost=" 
$MaterialCost ",
                overheadcost=" 
$OverheadCost ",
                lastcost=" 
$LastCost "
            WHERE stockid='" 
$NewParent "'";
        
$result1 DB_query($SQL);
        if (
DB_error_no()!=0) {
            return 
1;
        }
        
UpdateCost($db$NewParent);
    }
    return 
0;


in my case this is rolling Labour, material, and Overhead costs from the bottom all the way to the top.

Is this not what we want for BoM maintenance?
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-06-2018, 01:23 AM, (This post was last modified: 12-06-2018, 01:50 AM by VortecCPI.)
#2
RE: Function UpdateCost() - No Labour/Overhead?
Perhaps we need a system setting that enables this functionality as it would impact existing implementations.

In our case this is what the business owners are expecting -- That is all costs rolled from the bottom to the top.
In a way webERP does this now by viewing a costed BoM but the total value in the costed Bom does not match the cost value shown on the Stocks page if the children in the BoM have Labour and/or Overhead.

I think the costed BoM should show columns for Labour, Material, and Overhead. In this way if we have a mismatch we know there is either a problem or it is by our input.
Perhaps we should be rolling Labour and Overhead costs from the children up into the parent Material cost? this seems to be how we are doing things today in webERP but... What if the current Parent becomes a Child? in that case the Labour and Overhead costs have been rolled into the material cost and they are lost at the new child level.
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-06-2018, 02:26 AM,
#3
RE: Function UpdateCost() - No Labour/Overhead?
Something like this:

   
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-06-2018, 02:27 AM,
#4
RE: Function UpdateCost() - No Labour/Overhead?
Hi Paul, you are right it should roll up all the costs. This was one of the first bits of code I wrote for webERP and I am pretty sure back then it would have done - else somebody would have reported it before now, and it still seems to work as expected in my code, so I think a bug has crept in.

I am conscious you have posted a lot of stuff recently, and at the moment I can only devote a small amount of time to this. Is it possible you can create issues on github for things you need looking at so that it is easier for me to get an overview rather than ploughing through forum posts?

Tim
Reply
12-06-2018, 02:52 AM, (This post was last modified: 12-06-2018, 02:58 AM by VortecCPI.)
#5
RE: Function UpdateCost() - No Labour/Overhead?
I will see if I can get signed up with this project in a more formal nature.

I realize I throw a lot of stuff out there and my posts are sometimes a bit random in nature but I like to post what I am thinking at the time so people have a sort of trail of what I am seeing and thinking.

The cost rollup thing is something I have never been able to work out. If we don't use Labour or Overhead values all seems to work fine. If we represent Labour and/or Overhead values as Bom items all seems to work fine. The problem is in our case we need visibility as to these values at the parent level and in a costed BoM. We need the values to roll from bottom to top in every case.

The way webERP does it today by rolling children labor+material+overhead into parent material works in the contexts stated above but that is just not the way we want to do it. Also... If the parent becomes a child we lose Labour or Overhead values.

I have no problem tackling this but I am not familiar enough with webERP and its current user base to know how my changes may impact those current implementations.

This is what we want -- Subassembly costs rolled up to the top:
   
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-06-2018, 02:55 AM,
#6
RE: Function UpdateCost() - No Labour/Overhead?
Hi Paul, All I meant was create issues here (https://github.com/timschofield/webERP-svn/issues) so that I, or anybody else for that matter can see at a glance what needs doing, and then knock off the items one at a time. Otherwise I just get confused, an just a simple bean counter Smile

Tim
Reply
12-06-2018, 04:36 AM, (This post was last modified: 12-06-2018, 04:40 AM by VortecCPI.)
#7
RE: Function UpdateCost() - No Labour/Overhead?
Will do Tim.

This turns into a can of worms quickly. I think I see why we did not go down the path of including Labour and Overhead Std Cost values in cost rollups and why we address these values by using BoM items. There are so many use cases to consider...
For now I am thinking of creating a stock item of type labor just for a specific WC setup. That way when it changes all the associated BoMs and parent costs will update accordingly.
https://www.linkedin.com/in/eclipsepaulbecker
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)