mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 17:13:03 +01:00
Fix margin calculation on credit not when price is 0
This commit is contained in:
@@ -98,10 +98,15 @@ class FormMargin
|
||||
}
|
||||
|
||||
$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
|
||||
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)) {
|
||||
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
|
||||
$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)
|
||||
|| ($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);
|
||||
} else {
|
||||
$pa = $line->qty * $pa_ht;
|
||||
}
|
||||
} else {
|
||||
$pa = $line->qty * $pa_ht;
|
||||
}
|
||||
@@ -213,7 +218,7 @@ class FormMargin
|
||||
|
||||
$marginInfo = $this->getMarginInfosArray($object, $force_price);
|
||||
|
||||
$parameters=array('marginInfo'=>&$marginInfo);
|
||||
$parameters=array('marginInfo' => &$marginInfo);
|
||||
$reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
@@ -233,8 +238,8 @@ class FormMargin
|
||||
}
|
||||
}
|
||||
|
||||
print '<!-- displayMarginInfos() - Show margin table -->' . "\n";
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<!-- Margin table -->' . "\n";
|
||||
|
||||
print '<table class="noborder margintable centpercent" id="margintable">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
Reference in New Issue
Block a user