Skip to content
Snippets Groups Projects
Commit a916b75a authored by Florian Henry's avatar Florian Henry
Browse files

FIX : Better const usage in accountancy module

parent 2775250c
No related branches found
No related tags found
No related merge requests found
...@@ -102,10 +102,12 @@ if (! empty($conf->multicompany->enabled)) { ...@@ -102,10 +102,12 @@ if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
} }
$sql .= " AND f.fk_statut > 0"; $sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)"; $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
else }
$sql .= " AND f.type IN (0,1,2,3,5)"; else {
$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
$sql .= " AND fd.product_type IN (0,1)"; $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
...@@ -143,15 +145,14 @@ if ($result) { ...@@ -143,15 +145,14 @@ if ($result) {
$line = new FactureLigne($db); $line = new FactureLigne($db);
$line->fetch($obj->rowid); $line->fetch($obj->rowid);
$prev_progress = $line->get_prev_progress(); $prev_progress = $line->get_prev_progress();
if ($obj->type==5) { 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 {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
} }
} } else {
else {
$situation_ratio = 1; $situation_ratio = 1;
} }
......
...@@ -114,8 +114,13 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; ...@@ -114,8 +114,13 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
$sql.= " WHERE f.entity = ".$conf->entity; $sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut > 0"; $sql.= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
}
else {
$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
$sql.= " AND fd.product_type IN (0,1)"; $sql.= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " ORDER BY f.rowid"; $sql.= " ORDER BY f.rowid";
...@@ -163,15 +168,14 @@ if ($result) ...@@ -163,15 +168,14 @@ if ($result)
$line = new FactureLigne($db); $line = new FactureLigne($db);
$line->fetch($obj->id); $line->fetch($obj->id);
$prev_progress = $line->get_prev_progress(); $prev_progress = $line->get_prev_progress();
if ($obj->type==5) { 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 {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
} }
} } else {
else {
$situation_ratio = 1; $situation_ratio = 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment