Fix PROJECT_ELEMENTS_FOR_MINUS_MARGIN
This commit is contained in:
parent
7c992eac5e
commit
0363717476
@ -535,7 +535,7 @@ if (! empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) {
|
|||||||
}
|
}
|
||||||
$newelementforplusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
|
$newelementforplusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN);
|
||||||
foreach($newelementforplusmargin as $value) {
|
foreach($newelementforplusmargin as $value) {
|
||||||
$listofreferent[$value]['margin']='add';
|
$listofreferent[trim($value)]['margin']='add';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
|
if (! empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
|
||||||
@ -546,7 +546,7 @@ if (! empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) {
|
|||||||
}
|
}
|
||||||
$newelementforminusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
|
$newelementforminusmargin = explode(',', $conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN);
|
||||||
foreach($newelementforminusmargin as $value) {
|
foreach($newelementforminusmargin as $value) {
|
||||||
$listofreferent[$value]['margin']='minus';
|
$listofreferent[trim($value)]['margin']='minus';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +651,8 @@ print '<td class="right" width="100">'.$langs->trans("AmountHT").'</td>';
|
|||||||
print '<td class="right" width="100">'.$langs->trans("AmountTTC").'</td>';
|
print '<td class="right" width="100">'.$langs->trans("AmountTTC").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
$total_revenue_ht = 0;
|
||||||
|
|
||||||
foreach ($listofreferent as $key => $value)
|
foreach ($listofreferent as $key => $value)
|
||||||
{
|
{
|
||||||
$name = $langs->trans($value['name']);
|
$name = $langs->trans($value['name']);
|
||||||
@ -780,7 +782,11 @@ foreach ($listofreferent as $key => $value)
|
|||||||
// Calculate margin
|
// Calculate margin
|
||||||
if ($qualifiedforfinalprofit)
|
if ($qualifiedforfinalprofit)
|
||||||
{
|
{
|
||||||
if ($margin != "add")
|
if ($margin == 'add') {
|
||||||
|
$total_revenue_ht += $total_ht;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($margin != "add") // Revert sign
|
||||||
{
|
{
|
||||||
$total_ht = -$total_ht;
|
$total_ht = -$total_ht;
|
||||||
$total_ttc = -$total_ttc;
|
$total_ttc = -$total_ttc;
|
||||||
@ -811,11 +817,20 @@ foreach ($listofreferent as $key => $value)
|
|||||||
}
|
}
|
||||||
// and the final balance
|
// and the final balance
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td class="right" colspan=2 >'.$langs->trans("Profit").'</td>';
|
print '<td class="right" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||||
print '<td class="right" >'.price(price2num($balance_ht, 'MT')).'</td>';
|
print '<td class="right">'.price(price2num($balance_ht, 'MT')).'</td>';
|
||||||
print '<td class="right" >'.price(price2num($balance_ttc, 'MT')).'</td>';
|
print '<td class="right">'.price(price2num($balance_ttc, 'MT')).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// and the margin (profit / revenues)
|
||||||
|
if ($total_revenue_ht) {
|
||||||
|
print '<tr class="liste_total">';
|
||||||
|
print '<td class="right" colspan="2">'.$langs->trans("Margin").'</td>';
|
||||||
|
print '<td class="right">'.price(price2num($balance_ht / $total_revenue_ht, 'MT')).'</td>';
|
||||||
|
print '<td class="right"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user