Fix regression

This commit is contained in:
Laurent Destailleur 2022-09-19 17:23:38 +02:00
parent cc99ba0114
commit 7d7a9597c1

View File

@ -269,8 +269,8 @@ if ($result) {
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$cum_ht[$obj->dm] = !empty($obj->amount) ? $obj->amount : 0; $cum_ht[$obj->dm] = empty($obj->amount) ? 0 : $obj->amount;
$cum[$obj->dm] = $obj->amount_ttc; $cum[$obj->dm] = empty($obj->amount_ttc) ? 0 : $obj->amount_ttc;
if ($obj->amount_ttc) { if ($obj->amount_ttc) {
$minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm); $minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm);
$maxyearmonth = max($maxyearmonth, $obj->dm); $maxyearmonth = max($maxyearmonth, $obj->dm);
@ -302,7 +302,11 @@ if ($modecompta == 'RECETTES-DEPENSES') {
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$cum[$obj->dm] += $obj->amount_ttc; if (empty($cum[$obj->dm])) {
$cum[$obj->dm] = $obj->amount_ttc;
} else {
$cum[$obj->dm] += $obj->amount_ttc;
}
if ($obj->amount_ttc) { if ($obj->amount_ttc) {
$minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm); $minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm);
$maxyearmonth = max($maxyearmonth, $obj->dm); $maxyearmonth = max($maxyearmonth, $obj->dm);
@ -404,12 +408,6 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) {
$case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m"); $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m");
$caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m"); $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m");
$total_ht[$annee]=0;
$total[$annee]=0;
$cum_ht[$case]=0;
$cum[$case]=0;
if ($annee >= $year_start) { // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. if ($annee >= $year_start) { // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output.
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
// Value turnover of month w/o VAT // Value turnover of month w/o VAT
@ -452,7 +450,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) {
print "</td>"; print "</td>";
// Percentage of month // Percentage of month
print '<td class="borderrightlight right">'; print '<td class="borderrightlight right"><span class="opacitymedium">';
//var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end); //var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end);
if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) { if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) {
if ($annee_decalage > $minyear && $case <= $casenow) { if ($annee_decalage > $minyear && $case <= $casenow) {
@ -482,7 +480,7 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) {
} }
} }
} }
print '</td>'; print '</span></td>';
if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) { if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) {
print '<td width="15">&nbsp;</td>'; print '<td width="15">&nbsp;</td>';