Debug v17

This commit is contained in:
Laurent Destailleur 2023-03-02 20:49:38 +01:00
parent 3578adc3e6
commit 767ad3e366
3 changed files with 46 additions and 17 deletions

View File

@ -104,7 +104,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
}
$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur,";
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
$sql .= " spe.accountancy_code_customer as code_compta,";
@ -200,8 +200,8 @@ if ($result) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
$line = new SupplierInvoiceLine($db);
$line->fetch($obj->fdid);
//$line = new SupplierInvoiceLine($db);
//$line->fetch($obj->fdid);
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
@ -233,7 +233,8 @@ if ($result) {
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
if (!empty($line->tva_npr)) { // Add an entry for counterpart
$tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
if ($tva_npr) { // If NPR, we add an entry for counterpartWe into tabother
$tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
}
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
@ -824,7 +825,6 @@ if (empty($action) || $action == 'view') {
*/
print '<br>';
$i = 0;
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
@ -837,7 +837,7 @@ if (empty($action) || $action == 'view') {
print '<td class="center">'.$langs->trans("AccountingCredit")."</td>";
print "</tr>\n";
$r = '';
$i = 0;
$invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
@ -887,6 +887,7 @@ if (empty($action) || $action == 'view') {
print '<td class="right"></td>';
print "</tr>";
$i++;
continue;
}
if ($errorforinvoice[$key] == 'somelinesarenotbound') {
@ -906,6 +907,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right"></td>';
print '<td class="right"></td>';
print "</tr>";
$i++;
}
// Third party
@ -936,6 +939,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
$i++;
}
// Product / Service
@ -972,6 +977,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
$i++;
}
// VAT
@ -1009,6 +1016,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
$i++;
}
}
}
@ -1037,11 +1046,17 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
$i++;
}
}
}
}
if (!$i) {
print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print "</table>";
print '</div>';

View File

@ -107,7 +107,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
}
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
$sql .= " spe.accountancy_code_customer as code_compta,";
@ -205,17 +205,17 @@ if ($result) {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
$line = new FactureLigne($db);
$line->fetch($obj->fdid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($obj->rowid);
if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0
if ($obj->situation_percent == 0) {
$situation_ratio = 0;
} else {
$line = new FactureLigne($db);
$line->fetch($obj->fdid);
// Situation invoices handling
$prev_progress = $line->get_prev_progress($obj->rowid);
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
} else {
@ -255,8 +255,9 @@ if ($result) {
// For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes.
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
if (empty($line->tva_npr)) {
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
$tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
if (!$tva_npr) { // We ignore line if VAT is a NPR
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
}
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
@ -775,7 +776,6 @@ if (empty($action) || $action == 'view') {
*/
print '<br>';
$i = 0;
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
@ -788,7 +788,7 @@ if (empty($action) || $action == 'view') {
print '<td class="center">'.$langs->trans("AccountingCredit")."</td>";
print "</tr>\n";
$r = '';
$i = 0;
$companystatic = new Client($db);
$invoicestatic = new Facture($db);
@ -836,6 +836,7 @@ if (empty($action) || $action == 'view') {
print '<td class="right"></td>';
print "</tr>";
$i++;
continue;
}
if ($errorforinvoice[$key] == 'somelinesarenotbound') {
@ -855,6 +856,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right"></td>';
print '<td class="right"></td>';
print "</tr>";
$i++;
}
// Third party
@ -885,6 +888,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
$i++;
}
// Product / Service
@ -921,6 +926,8 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
$i++;
}
// VAT
@ -957,11 +964,17 @@ if (empty($action) || $action == 'view') {
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
$i++;
}
}
}
}
if (!$i) {
print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print "</table>";
print '</div>';

View File

@ -6412,6 +6412,7 @@ class FactureLigne extends CommonInvoiceLine
{
// phpcs:enable
global $invoicecache;
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0;
} else {