mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
BOM : calculate total cost of lines
This commit is contained in:
parent
5573b88df8
commit
7c352c9cef
|
|
@ -1073,7 +1073,8 @@ class BOM extends CommonObject
|
|||
if ($res>0) {
|
||||
$bom_child->calculateCosts();
|
||||
$line->childBom[] = $bom_child;
|
||||
$this->total_cost += $bom_child->total_cost * $line->qty;
|
||||
$line->total_cost = price2num( $bom_child->total_cost * $line->qty, 'MT');
|
||||
$this->total_cost += $line->total_cost;
|
||||
} else {
|
||||
$this->error = $bom_child->error;
|
||||
return -2;
|
||||
|
|
|
|||
|
|
@ -239,13 +239,13 @@ if ($resql) {
|
|||
// Cost
|
||||
if (!empty($sub_bom->id)) {
|
||||
$sub_bom->calculateCosts();
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT').'</span></td>';
|
||||
$total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
|
||||
} elseif ($sub_bom_product->cost_price > 0) {
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT').'</span></td>';
|
||||
$total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
|
||||
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT').'</span></td>';
|
||||
$total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
|
||||
} else { // Minimum purchase price if cost price and PMP aren't defined
|
||||
$sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
|
||||
|
|
@ -255,7 +255,7 @@ if ($resql) {
|
|||
$obj = $object->db->fetch_object($resql_supplier_price);
|
||||
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
|
||||
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($line_cost).'</span></td>';
|
||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($line_cost, 'MT').'</span></td>';
|
||||
$total_cost+= $line_cost;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user