Debug v21 - manufacturing cost

This commit is contained in:
Laurent Destailleur 2024-12-04 08:42:18 +01:00
parent 20002f20f6
commit 7a195e01b2
5 changed files with 41 additions and 20 deletions

View File

@ -425,10 +425,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array();
if (isModEnabled('bom')) {
$langs->load("mrp");
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
}
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
@ -453,10 +449,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array();
if (isModEnabled('bom')) {
$langs->load("mrp");
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
}
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
@ -482,10 +474,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (isModEnabled('bom')) {
$langs->load("mrp");
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$forcecombo = 0;
if ($conf->browser->name == 'ie') {
$forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
}
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
@ -580,9 +568,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Common attributes
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
$object->calculateCosts();
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">'.price($object->total_cost).'</span></td></tr>';
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
// Manufacturing cost
print '<tr><td>'.$form->textwithpicto($langs->trans("ManufacturingCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">';
print price($object->total_cost);
print '</span>';
if ($object->total_cost != $object->unit_cost) {
print '&nbsp; &nbsp; <span class="opacitymedium">('.$form->textwithpicto(price($object->unit_cost), $langs->trans("ManufacturingUnitCost"), 1, 'help', '').')</span>';
}
print '</td></tr>';
// Find sell price of generated product. We suppose we sell it to a company like ours (same country...).
$object->fetch_product();
$manufacturedvalued = '';
if (!empty($object->product)) {
$tmparray = $object->product->getSellPrice($mysoc, $mysoc);
$manufacturedvalued = $tmparray['pu_ht'] * $object->qty;
}
print '<tr><td>'.$langs->trans("ManufacturingGeneratedValue").'</td><td>'.price($manufacturedvalued).'</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@ -658,7 +661,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Services
$filtertype = 1;
$res = $object->fetchLinesbytypeproduct(1); // Load all lines services into ->lines
$res = $object->fetchLinesbytypeproduct($filtertype); // Load all lines services into ->lines
$object->calculateCosts();
print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service');

View File

@ -188,8 +188,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$keyforbreak = 'duration';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">'.price($object->total_cost).'</span></td></tr>';
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
// Manufacturing cost
print '<tr><td>'.$form->textwithpicto($langs->trans("ManufacturingCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">';
print price($object->total_cost);
print '</span>';
if ($object->total_cost != $object->unit_cost) {
print '&nbsp; &nbsp; <span class="opacitymedium">('.$form->textwithpicto(price($object->unit_cost), $langs->trans("ManufacturingUnitCost"), 1, 'help', '').')</span>';
}
print '</td></tr>';
// Find sell price of generated product. We suppose we sell it to a company like ours (same country...).
$object->fetch_product();
$manufacturedvalued = '';
if (!empty($object->product)) {
$tmparray = $object->product->getSellPrice($mysoc, $mysoc);
$manufacturedvalued = $tmparray['pu_ht'] * $object->qty;
}
print '<tr><td>'.$langs->trans("ManufacturingGeneratedValue").'</td><td>'.price($manufacturedvalued).'</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

View File

@ -1409,7 +1409,7 @@ class BOM extends CommonObject
*/
public function calculateCosts()
{
global $conf, $hookmanager;
global $hookmanager;
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$this->unit_cost = 0;

View File

@ -161,7 +161,7 @@ foreach ($object->fields as $key => $val) {
$value = $object->$key;
$rightpart .= '<tr><td';
$rightpart .= ' class="'.(empty($val['tdcss']) ? 'titlefield' : $val['tdcss']).' fieldname_'.$key;
$rightpart .= ' class="'.(empty($val['tdcss']) ? 'titlefieldmiddle' : $val['tdcss']).' fieldname_'.$key;
//if ($val['notnull'] > 0) $rightpart .= ' fieldrequired'; // No fieldrequired in the view output
if ($val['type'] == 'text' || $val['type'] == 'html') {
$rightpart .= ' tdtop';

View File

@ -95,6 +95,9 @@ ProductsToConsume=Products to consume
ProductsToProduce=Products to produce
UnitCost=Unit cost
TotalCost=Total cost
ManufacturingCost=Manufacturing cost
ManufacturingUnitCost=Unit manufacturing cost
ManufacturingGeneratedValue=Manufacturing value generated
BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price)
BOMTotalCostService=If the "Workstation" module is activated and a workstation is defined by default on the line, then the calculation is "quantity (converted into hours) x workstation ahr", otherwise "quantity x cost price of the service"
GoOnTabProductionToProduceFirst=You must first have started the production to close a Manufacturing Order (See tab '%s'). But you can Cancel it.