Fix TYPE_SITUATION on sell journals

This commit is contained in:
Florian HENRY 2015-08-13 11:23:27 +02:00
parent 6806e2b36b
commit 2775250ce4
2 changed files with 22 additions and 10 deletions

View File

@ -89,8 +89,8 @@ $idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte, "; $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
$sql .= " ct.accountancy_code_sell as account_tva"; $sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
@ -143,11 +143,17 @@ 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->situation_percent == 0) { // Avoid divide by 0 if ($obj->type==5) {
// Avoid divide by 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 {
$situation_ratio = 1;
}
// Invoice lines // Invoice lines
$tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["date"] = $obj->df;

View File

@ -163,11 +163,17 @@ 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->situation_percent == 0) { // Avoid divide by 0 if ($obj->type==5) {
// Avoid divide by 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 {
$situation_ratio = 1;
}
//la ligne facture //la ligne facture
$tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["date"] = $obj->datef;