Skip to content
Snippets Groups Projects
Commit f345ff73 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix regression on vat calculation when invoice was not a situation

invoice
parent 1b30c1ad
No related branches found
No related tags found
No related merge requests found
...@@ -142,12 +142,13 @@ if ($result) { ...@@ -142,12 +142,13 @@ if ($result) {
// Situation invoices handling // Situation invoices handling
$line = new FactureLigne($db); $line = new FactureLigne($db);
$line->fetch($obj->fdid); // id of line $line->fetch($obj->fdid); // id of line
$prev_progress = $line->get_prev_progress($obj->rowid); // id of invoice $prev_progress = 0;
if ($obj->type == Facture::TYPE_SITUATION) { if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0 // Avoid divide by 0
if ($obj->situation_percent == 0) { if ($obj->situation_percent == 0) {
$situation_ratio = 0; $situation_ratio = 0;
} else { } else {
$prev_progress = $line->get_prev_progress($obj->rowid); // id of invoice
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
} }
} else { } else {
......
...@@ -167,12 +167,13 @@ if ($result) ...@@ -167,12 +167,13 @@ if ($result)
// Situation invoices handling // Situation invoices handling
$line = new FactureLigne($db); $line = new FactureLigne($db);
$line->fetch($obj->id); // id of line $line->fetch($obj->id); // id of line
$prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice $prev_progress = 0;
if ($obj->type==Facture::TYPE_SITUATION) { if ($obj->type==Facture::TYPE_SITUATION) {
// Avoid divide by 0 // Avoid divide by 0
if ($obj->situation_percent == 0) { if ($obj->situation_percent == 0) {
$situation_ratio = 0; $situation_ratio = 0;
} else { } else {
$prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
} }
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment