Hi,
We are making a business challenge with our sales team. We have : - 2 kinds of customers : new and old. - 2 kinds of sales people : commercial and ACC - 2 importants values : marge and recurrent
So we would calculate the value like this :
If the customer is new : marge + 12 recurrent if the customer is old : (marge + 12 recurrent) * 1,1
And to finish, if the sales is made by an ACC, here is the equation 2,5(marge + 12 recurrent) * 1,1
So here is a part of my function (which is working) :
//
// CALCUL PO
//
$this->src('sales')
->pipe(new CalculatedColumn(array(
"PO"=>function($data){
if($data["Marge"]!=null && $data["Recurrent"]!=null )
{
if ($data["Customer"]=='old' ){
return 1.1 * ($data["Marge"] + 12 * $data["Recurrent"]);
}
else { return ($data["Marge"] + 12 * $data["Recurrent"]); }
}
else
{
return 0;
}
}
)))
->pipe(new Group(array(
"by"=>"commercial",
"sum"=>"PO",
)))
->pipe(new Sort(array(
"PO"=>"desc"
)))
->pipe($this->dataStore("PO"));
My problem is that I just group with commercial, and dont take ACC column. So how could I create a new column that mix both, and then add another if to check if its an ACC ?
Thanks !!