Fix regression on vat calculation when invoice was not a situation

invoice
This commit is contained in:
Laurent Destailleur 2016-03-13 01:11:42 +01:00
parent 1b30c1adb4
commit f345ff7300
2 changed files with 7 additions and 5 deletions

View File

@ -142,13 +142,14 @@ if ($result) {
// Situation invoices handling
$line = new FactureLigne($db);
$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) {
// Avoid divide by 0
// Avoid divide by 0
if ($obj->situation_percent == 0) {
$situation_ratio = 0;
} else {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
$prev_progress = $line->get_prev_progress($obj->rowid); // id of invoice
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
} else {
$situation_ratio = 1;

View File

@ -167,13 +167,14 @@ if ($result)
// Situation invoices handling
$line = new FactureLigne($db);
$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) {
// Avoid divide by 0
if ($obj->situation_percent == 0) {
$situation_ratio = 0;
} else {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
$prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
} else {
$situation_ratio = 1;