From cac9a00bac0a522c2d54e7557c8c0a2912b66566 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 13 Feb 2023 16:19:00 +0100 Subject: [PATCH 1/6] fix loi de finance 525 --- htdocs/blockedlog/README-fr.md | 2 +- htdocs/blockedlog/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/blockedlog/README-fr.md b/htdocs/blockedlog/README-fr.md index e92bd5a09fe..a5d709ca7a7 100644 --- a/htdocs/blockedlog/README-fr.md +++ b/htdocs/blockedlog/README-fr.md @@ -4,7 +4,7 @@ LOG INALTERABLE ## Fonctionnalité Ce module trace, en temps réel, certains évènements métiers dans une log inaltérable (que vous ne pouvez pas modifier une fois enregistrés) de type blockchain. -Ce module est requis pour la compatibilité avec les exigences légales de certains pays (comme la France avec la loi Fincance 2016 - Norme NF535). +Ce module est requis pour la compatibilité avec les exigences légales de certains pays (comme la France avec la loi Finance 2016 - Norme NF525). **Les évènements tracés de manière inaltérables sont:** diff --git a/htdocs/blockedlog/README.md b/htdocs/blockedlog/README.md index ec3174fb847..7bd9b10787e 100644 --- a/htdocs/blockedlog/README.md +++ b/htdocs/blockedlog/README.md @@ -4,7 +4,7 @@ BLOCKED LOG ## Feature This module tracks, in real time, some events into a non reversible log (that you can't modify once recorded) into a block chain. -This module provides compatibility with requirements of laws of some countries (like France with the law Fincance 2016 - Norme NF535). +This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF525). **The tracked events are:** From 5217ae28f8159ace983f4ddfdf2f2cb0b7f4ef9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Feb 2023 21:35:48 +0100 Subject: [PATCH 2/6] Fix load of margin infos --- htdocs/compta/facture/list.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 40b672cbd9e..1fea36daf54 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1199,6 +1199,18 @@ if ($resql) { $i = 0; $totalarray = array(); + + $with_margin_info = false; + if (!empty($conf->margin->enabled) && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) + ) + ) { + $with_margin_info = true; + } + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -1281,7 +1293,7 @@ if ($resql) $facturestatic->alreadypaid = $paiement; $marginInfo = array(); - if (!empty($conf->margin->enabled)) { + if ($with_margin_info === true) { $facturestatic->fetch_lines(); $marginInfo = $formmargin->getMarginInfosArray($facturestatic); } From d04043f3d823e3a203501b792086b854cc5c06f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:19 +0100 Subject: [PATCH 3/6] FIX Profit calculation on project preview tab. --- htdocs/projet/element.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 80fccce7912..b8981dd07f2 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -579,9 +579,9 @@ $listofreferent = array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", 'class'=>'MouvementStock', - 'margin'=>'minus', 'table'=>'stock_mouvement', 'datefieldname'=>'datem', + 'margin'=>'minus', 'disableamount'=>0, 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), 'salaries'=>array( @@ -747,6 +747,7 @@ $total_revenue_ht = 0; $balance_ht = 0; $balance_ttc = 0; +// Loop on each element type (proposal, sale order, invoices, ...) foreach ($listofreferent as $key => $value) { $parameters = array( 'total_revenue_ht' =>& $total_revenue_ht, @@ -782,6 +783,7 @@ foreach ($listofreferent as $key => $value) { $total_ht = 0; $total_ttc = 0; + // Loop on each object for the current element type $num = count($elementarray); for ($i = 0; $i < $num; $i++) { $tmp = explode('_', $elementarray[$i]); @@ -866,7 +868,7 @@ foreach ($listofreferent as $key => $value) { $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } elseif ($key == 'loan') { - $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr } else { $total_ttc_by_line = $element->total_ttc; } @@ -887,19 +889,14 @@ foreach ($listofreferent as $key => $value) { } // Each element with at least one line is output - $qualifiedforfinalprofit = true; - if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) { - $qualifiedforfinalprofit = false; - } - //var_dump($key.' '.$qualifiedforfinalprofit); // Calculate margin - if ($qualifiedforfinalprofit) { - if ($margin == 'add') { + if ($margin) { + if ($margin === 'add') { $total_revenue_ht += $total_ht; } - if ($margin != "add") { // Revert sign + if ($margin === "minus") { // Revert sign $total_ht = -$total_ht; $total_ttc = -$total_ttc; } @@ -918,10 +915,10 @@ foreach ($listofreferent as $key => $value) { if ($key == 'intervention' && !$qualifiedforfinalprofit) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { - print price($total_ht); if ($key == 'propal') { print ''.$form->textwithpicto('', $langs->trans("SignedOnly")).''; } + print price($total_ht); } print ''; // Amount TTC @@ -929,10 +926,10 @@ foreach ($listofreferent as $key => $value) { if ($key == 'intervention' && !$qualifiedforfinalprofit) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { - print price($total_ttc); if ($key == 'propal') { print ''.$form->textwithpicto('', $langs->trans("SignedOnly")).''; } + print price($total_ttc); } print ''; print ''; From 32d27887b11e757ba00032c82da87a7c30bef5c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 18:11:25 +0100 Subject: [PATCH 4/6] Fix message for profit calculation --- htdocs/langs/en_US/interventions.lang | 2 +- htdocs/projet/element.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index ef5df43e546..bce9c04aeb3 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -50,7 +50,7 @@ UseDateWithoutHourOnFichinter=Hides hours and minutes off the date field for int InterventionStatistics=Statistics of interventions NbOfinterventions=No. of intervention cards NumberOfInterventionsByMonth=No. of intervention cards by month (date of validation) -AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. +AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). You can use PROJECT_ELEMENTS_FOR_ADD_MARGIN and PROJECT_ELEMENTS_FOR_MINUS_MARGIN option into home-setup-other to complete list of element included into profit. InterId=Intervention id InterRef=Intervention ref. InterDateCreation=Date creation intervention diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index b8981dd07f2..cebe109b0c5 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -469,7 +469,7 @@ $listofreferent = array( 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>0, - 'margin'=>'minus', + 'margin'=>'', 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', @@ -912,7 +912,7 @@ foreach ($listofreferent as $key => $value) { print ''.$i.''; // Amount HT print ''; - if ($key == 'intervention' && !$qualifiedforfinalprofit) { + if ($key == 'intervention' && !$margin) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { if ($key == 'propal') { @@ -923,7 +923,7 @@ foreach ($listofreferent as $key => $value) { print ''; // Amount TTC print ''; - if ($key == 'intervention' && !$qualifiedforfinalprofit) { + if ($key == 'intervention' && !$margin) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { if ($key == 'propal') { From b57d1ed26372b7cc6076531bb29ad912a7fee3d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:19 +0100 Subject: [PATCH 5/6] FIX Profit calculation on project preview tab. --- htdocs/projet/element.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c805552d7a5..7b1179ed597 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -581,9 +581,9 @@ $listofreferent = array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", 'class'=>'MouvementStock', - 'margin'=>'minus', 'table'=>'stock_mouvement', 'datefieldname'=>'datem', + 'margin'=>'minus', 'disableamount'=>0, 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), 'salaries'=>array( @@ -749,6 +749,7 @@ $total_revenue_ht = 0; $balance_ht = 0; $balance_ttc = 0; +// Loop on each element type (proposal, sale order, invoices, ...) foreach ($listofreferent as $key => $value) { $parameters = array( 'total_revenue_ht' =>& $total_revenue_ht, @@ -784,6 +785,7 @@ foreach ($listofreferent as $key => $value) { $total_ht = 0; $total_ttc = 0; + // Loop on each object for the current element type $num = count($elementarray); for ($i = 0; $i < $num; $i++) { $tmp = explode('_', $elementarray[$i]); @@ -868,7 +870,7 @@ foreach ($listofreferent as $key => $value) { $defaultvat = get_default_tva($mysoc, $mysoc); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); } elseif ($key == 'loan') { - $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr + $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr } else { $total_ttc_by_line = $element->total_ttc; } @@ -889,19 +891,14 @@ foreach ($listofreferent as $key => $value) { } // Each element with at least one line is output - $qualifiedforfinalprofit = true; - if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) { - $qualifiedforfinalprofit = false; - } - //var_dump($key.' '.$qualifiedforfinalprofit); // Calculate margin - if ($qualifiedforfinalprofit) { - if ($margin == 'add') { + if ($margin) { + if ($margin === 'add') { $total_revenue_ht += $total_ht; } - if ($margin != "add") { // Revert sign + if ($margin === "minus") { // Revert sign $total_ht = -$total_ht; $total_ttc = -$total_ttc; } @@ -920,10 +917,10 @@ foreach ($listofreferent as $key => $value) { if ($key == 'intervention' && !$qualifiedforfinalprofit) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { - print price($total_ht); if ($key == 'propal') { print ''.$form->textwithpicto('', $langs->trans("SignedOnly")).''; } + print price($total_ht); } print ''; // Amount TTC @@ -931,10 +928,10 @@ foreach ($listofreferent as $key => $value) { if ($key == 'intervention' && !$qualifiedforfinalprofit) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { - print price($total_ttc); if ($key == 'propal') { print ''.$form->textwithpicto('', $langs->trans("SignedOnly")).''; } + print price($total_ttc); } print ''; print ''; From 89817c8ead0cdb718e0d9bb44c16fef619e01d53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 18:11:25 +0100 Subject: [PATCH 6/6] Fix message for profit calculation --- htdocs/langs/en_US/interventions.lang | 2 +- htdocs/projet/element.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 51079fca278..513bfebd78f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -50,7 +50,7 @@ UseDateWithoutHourOnFichinter=Hides hours and minutes off the date field for int InterventionStatistics=Statistics of interventions NbOfinterventions=No. of intervention cards NumberOfInterventionsByMonth=No. of intervention cards by month (date of validation) -AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. +AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). You can use PROJECT_ELEMENTS_FOR_ADD_MARGIN and PROJECT_ELEMENTS_FOR_MINUS_MARGIN option into home-setup-other to complete list of element included into profit. InterId=Intervention id InterRef=Intervention ref. InterDateCreation=Date creation intervention diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 7b1179ed597..537215896a1 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -471,7 +471,7 @@ $listofreferent = array( 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>0, - 'margin'=>'minus', + 'margin'=>'', 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', @@ -914,7 +914,7 @@ foreach ($listofreferent as $key => $value) { print ''.$i.''; // Amount HT print ''; - if ($key == 'intervention' && !$qualifiedforfinalprofit) { + if ($key == 'intervention' && !$margin) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { if ($key == 'propal') { @@ -925,7 +925,7 @@ foreach ($listofreferent as $key => $value) { print ''; // Amount TTC print ''; - if ($key == 'intervention' && !$qualifiedforfinalprofit) { + if ($key == 'intervention' && !$margin) { print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; } else { if ($key == 'propal') {