Fix margin calculation on credit not when price is 0
This commit is contained in:
parent
8c4a590548
commit
befdd967f7
@ -98,13 +98,18 @@ class FormMargin
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pv = $line->total_ht;
|
$pv = $line->total_ht;
|
||||||
$pa_ht = ($pv < 0 ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
|
$pa_ht = (($pv < 0 || ($pv == 0 && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
|
||||||
|
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { // Special case for old situation mode
|
||||||
if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION)
|
if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION)
|
||||||
|| ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) {
|
|| ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) {
|
||||||
|
// We need a compensation relative to $line->situation_percent
|
||||||
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
|
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
|
||||||
} else {
|
} else {
|
||||||
$pa = $line->qty * $pa_ht;
|
$pa = $line->qty * $pa_ht;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$pa = $line->qty * $pa_ht;
|
||||||
|
}
|
||||||
|
|
||||||
// calcul des marges
|
// calcul des marges
|
||||||
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
|
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
|
||||||
@ -233,8 +238,8 @@ class FormMargin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '<!-- displayMarginInfos() - Show margin table -->' . "\n";
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<!-- Margin table -->' . "\n";
|
|
||||||
|
|
||||||
print '<table class="noborder margintable centpercent" id="margintable">';
|
print '<table class="noborder margintable centpercent" id="margintable">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user