From 767ad3e366d1cc7fc5cce75070b37bc87417a440 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Mar 2023 20:49:38 +0100 Subject: [PATCH] Debug v17 --- .../accountancy/journal/purchasesjournal.php | 27 ++++++++++---- htdocs/accountancy/journal/sellsjournal.php | 35 +++++++++++++------ htdocs/compta/facture/class/facture.class.php | 1 + 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 746383fef0b..d00a968571f 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -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 '
'; - $i = 0; print '
'; print ""; print ""; @@ -837,7 +837,7 @@ if (empty($action) || $action == 'view') { print '"; print "\n"; - $r = ''; + $i = 0; $invoicestatic = new FactureFournisseur($db); $companystatic = new Fournisseur($db); @@ -887,6 +887,7 @@ if (empty($action) || $action == 'view') { print ''; print ""; + $i++; continue; } if ($errorforinvoice[$key] == 'somelinesarenotbound') { @@ -906,6 +907,8 @@ if (empty($action) || $action == 'view') { print ''; print ''; print ""; + + $i++; } // Third party @@ -936,6 +939,8 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } // Product / Service @@ -972,6 +977,8 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } // VAT @@ -1009,6 +1016,8 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } } } @@ -1037,11 +1046,17 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } } } } + if (!$i) { + print ''; + } + print "
'.$langs->trans("AccountingCredit")."
'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'.$langs->trans("NoRecordFound").'
"; print '
'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 2854ba67606..2ae5bd77ab2 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -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 '
'; - $i = 0; print '
'; print ""; print ""; @@ -788,7 +788,7 @@ if (empty($action) || $action == 'view') { print '"; print "\n"; - $r = ''; + $i = 0; $companystatic = new Client($db); $invoicestatic = new Facture($db); @@ -836,6 +836,7 @@ if (empty($action) || $action == 'view') { print ''; print ""; + $i++; continue; } if ($errorforinvoice[$key] == 'somelinesarenotbound') { @@ -855,6 +856,8 @@ if (empty($action) || $action == 'view') { print ''; print ''; print ""; + + $i++; } // Third party @@ -885,6 +888,8 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } // Product / Service @@ -921,6 +926,8 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } // VAT @@ -957,11 +964,17 @@ if (empty($action) || $action == 'view') { print '"; print '"; print ""; + + $i++; } } } } + if (!$i) { + print ''; + } + print "
'.$langs->trans("AccountingCredit")."
'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'.$langs->trans("NoRecordFound").'
"; print '
'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2447db6af5d..045048e7395 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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 {