Fix signed only in margin calculation of project

This commit is contained in:
Laurent Destailleur 2020-06-24 12:58:10 +02:00
parent 1762e10e69
commit de62037ba5
4 changed files with 21 additions and 11 deletions

View File

@ -1537,7 +1537,9 @@ class Propal extends CommonObject
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->statut = (int) $obj->fk_statut;
$this->status = (int) $obj->fk_statut;
$this->statut = $this->status; // deprecated
$this->statut_libelle = $obj->statut_label;
$this->datec = $this->db->jdate($obj->datec); // TODO deprecated

View File

@ -4264,7 +4264,7 @@ class Form
elseif ($input['type'] == 'select')
{
$more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">';
if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd tdtop left">';
if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd left">';
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
$more .= '</div></div>'."\n";
}

View File

@ -84,3 +84,4 @@ DefaultModelPropalClosed=Default template when closing a business proposal (unbi
ProposalCustomerSignature=Written acceptance, company stamp, date and signature
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only

View File

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
@ -635,10 +635,10 @@ foreach($listofreferent as $key => $value)
if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add')
{
if ($margin == 'add') {
$tooltiponprofitplus.=' + '.$name."<br>\n";
$tooltiponprofitplus.=' &gt; '.$name." (+)<br>\n";
}
if ($margin == 'minus') {
$tooltiponprofitminus.=' - '.$name."<br>\n";
$tooltiponprofitminus.=' &gt; '.$name." (-)<br>\n";
}
}
}
@ -693,7 +693,7 @@ foreach ($listofreferent as $key => $value)
}
if ($key == 'propal')
{
if ($element->statut == Propal::STATUS_NOTSIGNED) $qualifiedfortotal = false; // Refused proposal must not be included in total
if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedfortotal = false; // Only signed proposal must not be included in total
}
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
@ -777,7 +777,8 @@ foreach ($listofreferent as $key => $value)
// Each element with at least one line is output
$qualifiedforfinalprofit = true;
if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit = false;
//var_dump($key);
if ($key == 'propal' && $element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedforfinalprofit = false;
//var_dump($key.' '.$qualifiedforfinalprofit);
// Calculate margin
if ($qualifiedforfinalprofit)
@ -803,13 +804,19 @@ foreach ($listofreferent as $key => $value)
print '<td class="right">'.$i.'</td>';
// Amount HT
print '<td class="right">';
if (!$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>';
else print price($total_ht);
if ($key == 'intervention' && !$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>';
else {
print price($total_ht);
if ($key == 'propal') print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>';
}
print '</td>';
// Amount TTC
print '<td class="right">';
if (!$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>';
else print price($total_ttc);
if ($key == 'intervention' && !$qualifiedforfinalprofit) print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).'</span>';
else {
print price($total_ttc);
if ($key == 'propal') print '<span class="opacitymedium">'.$form->textwithpicto('', $langs->trans("SignedOnly")).'</span>';
}
print '</td>';
print '</tr>';
}