From cac9a00bac0a522c2d54e7557c8c0a2912b66566 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 13 Feb 2023 16:19:00 +0100 Subject: [PATCH 01/15] 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 02/15] 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 55eb800bebad99cca58a8199ac911c4d7c3334b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 15:58:10 +0100 Subject: [PATCH 03/15] trans --- htdocs/langs/en_US/errors.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 5d262f54200..164bfc3911c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -308,7 +308,7 @@ ErrorExistingPermission = Permission %s for object %s already exis ErrorFieldExist=The value for %s already exist ErrorEqualModule=Module invalid in %s ErrorFieldValue=Value for %s is incorrect -ErrorCoherenceMenu=%s is required when % equal LEFT +ErrorCoherenceMenu=%s is required when %s is 'left' # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. From 6c2d08b9f8959c9b743f97da5dafdc0bb59ede93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:19 +0100 Subject: [PATCH 04/15] 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 8f548685631..e25997f2957 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -585,9 +585,9 @@ $listofreferent = array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", 'class'=>'MouvementStock', - 'margin'=>'minus', 'table'=>'stock_mouvement', 'datefieldname'=>'datem', + 'margin'=>'minus', 'disableamount'=>0, 'test'=>!empty($conf->stock->enabled) && $user->hasRight('stock', 'mouvement', 'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)), 'salaries'=>array( @@ -752,6 +752,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, @@ -787,6 +788,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]); @@ -871,7 +873,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; } @@ -892,19 +894,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; } @@ -923,10 +920,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 @@ -934,10 +931,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 bfd48d44ad9b2f3ce91b66af28f93ccbac7a3e05 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:33 +0100 Subject: [PATCH 05/15] Fix fields were lost after changing the thirdparty --- htdocs/compta/facture/card.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7af0f7046f9..c2469655df6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -80,8 +80,6 @@ if (isModEnabled('margin')) { } // General $Variables -$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); - $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -100,6 +98,7 @@ $fac_rec = GETPOST('fac_rec', 'int'); $facid = GETPOST('facid', 'int'); $ref_client = GETPOST('ref_client', 'int'); $rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; +$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -3150,7 +3149,7 @@ if ($action == 'create') { print '
'; print ''; - print ''; + print ''; if ($soc->id > 0) { print ''."\n"; } @@ -3216,11 +3215,10 @@ if ($action == 'create') { $(\'input[name="force_fk_account"]\').val(\'1\'); $("#formtocreate").submit(); */ - // For company change, we must reuse data of comany, not input already done, so we call a GET with action=create, not a POST submit. - console.log("We have changed the company - Reload page"); - var socid = $(this).val(); - var fac_rec = $(\'#fac_rec\').val(); - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; + // For company change, we must submit page with action=create instead of action=add + console.log("We have changed the company - Resubmit page"); + jQuery("#formtocreateaction").val("create"); + jQuery("#formtocreate").submit(); }); }); '; From 1b925ec53f152585ffba83cab3ca387f4e60c034 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:19 +0100 Subject: [PATCH 06/15] 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 16b67dd4876..858e64cfced 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -584,9 +584,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( @@ -752,6 +752,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, @@ -787,6 +788,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]); @@ -871,7 +873,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; } @@ -892,19 +894,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; } @@ -923,10 +920,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 @@ -934,10 +931,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 d04043f3d823e3a203501b792086b854cc5c06f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 17:57:19 +0100 Subject: [PATCH 07/15] 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 08/15] 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 09/15] 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 10/15] 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') { From ec1f6de6ac78cd5bbc798e0c632efd1aaad1b6fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 18:23:02 +0100 Subject: [PATCH 11/15] Fix message --- htdocs/projet/element.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index e25997f2957..a0af70095f6 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -917,7 +917,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') { @@ -928,7 +928,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 6a7c5d2715de32e11dde1eae028b1ab560368f37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 18:52:36 +0100 Subject: [PATCH 12/15] Fix format of stock qty --- htdocs/product/list.php | 6 +++--- htdocs/product/reassort.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 14d43e038f1..3f26c3bade6 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1268,7 +1268,7 @@ if (!empty($arrayfields['p.stock']['checked'])) { print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"], "p.stock", "", $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['stock_virtual']['checked'])) { - print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ', 'VirtualStockDesc'); } if (!empty($arrayfields['p.tobatch']['checked'])) { print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"], "p.tobatch", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1828,7 +1828,7 @@ while ($i < min($num, $limit)) { print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; } if ($usercancreadprice) { - print price(price2num($product_static->stock_reel, 'MS')); + print price(price2num($product_static->stock_reel, 'MS'), 0, $langs, 1, 0); } } print ''; @@ -1844,7 +1844,7 @@ while ($i < min($num, $limit)) { print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; } if ($usercancreadprice) { - print price(price2num($product_static->stock_theorique, 'MS')); + print price(price2num($product_static->stock_theorique, 'MS'), 0, $langs, 1, 0); } } print ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b91ae62f663..f3c354b88a4 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -487,7 +487,7 @@ if ($resql) { if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) { print img_warning($langs->trans("StockTooLow")).' '; } - print price2num($objp->stock_physique, 'MS'); + print price(price2num($objp->stock_physique, 'MS'), 0, $langs, 1, 0); print ''; // Details per warehouse @@ -495,7 +495,7 @@ if ($resql) { if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print ''; - print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real; + print price(empty($product->stock_warehouse[$wh['id']]->real) ? 0 : $product->stock_warehouse[$wh['id']]->real, 0, $langs, 1, 0); print ''; } } @@ -504,10 +504,10 @@ if ($resql) { // Virtual stock if ($virtualdiffersfromphysical) { print ''; - if ($objp->seuil_stock_alerte != '' && ($product->stock_theorique < $objp->seuil_stock_alerte)) { + if ($objp->seuil_stock_alerte != '' && ($product->stock_theorique < (float) $objp->seuil_stock_alerte)) { print img_warning($langs->trans("StockTooLow")).' '; } - print price2num($product->stock_theorique, 'MS'); + print price(price2num($product->stock_theorique, 'MS'), 0, $langs, 1, 0); print ''; } // Units From c259ca09b8c20d492ae0cc783df5fa0494d80574 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 20:14:48 +0100 Subject: [PATCH 13/15] Enhance script to repair database when stock by lot differ from stock --- htdocs/install/repair.php | 99 +++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 802711f4ff3..1e912b54f95 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -903,9 +903,8 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { $sql = "SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb ON ps.rowid = pb.fk_product_stock"; $sql .= " WHERE p.rowid = ps.fk_product"; - $sql .= " AND p.tobatch > 0"; $sql .= " GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; - $sql .= " HAVING reel != SUM(pb.qty) or SUM(pb.qty) IS NULL"; + $sql .= " HAVING (SUM(pb.qty) IS NOT NULL AND reel != SUM(pb.qty)) OR (SUM(pb.qty) IS NULL AND p.tobatch > 0)"; print $sql; $resql = $db->query($sql); if ($resql) { @@ -915,53 +914,73 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - print 'Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch ? $obj->reelbatch : '0').' (sum product_batch)'; + print 'Product '.$obj->rowid.'-'.$obj->ref.' in warehouse id='.$obj->fk_entrepot.' -> product_stock.id='.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch ? $obj->reelbatch : '0').' (sum product_batch)'; - // Fix + // Fix is required if ($obj->reel != $obj->reelbatch) { - if ($methodtofix == 'updatebatch') { - // Method 1 - print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; + if (empty($obj->tobatch)) { + // If product is not a product that support batches, we can clean stock by deleting the product batch lines + print ' -> Delete qty '.$obj->reelbatch.' for any lot linked to fk_product_stock='.$obj->psrowid; + $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."product_batch"; + $sql2 .= " WHERE fk_product_stock = ".$obj->psrowid; + print '
'.$sql2; + if (GETPOST('clean_product_stock_batch') == 'confirmed') { - $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; - $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; $resql2 = $db->query($sql2); if (!$resql2) { - // TODO If it fails, we must make update - //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; - //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; - //$sql2.=" WHERE fk_product_stock = ".((int) $obj->psrowid) - } - } - } - if ($methodtofix == 'updatestock') { - // Method 2 - print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? ((float) $obj->reelbatch) : '0').' for ps.rowid = '.((int) $obj->psrowid); - if (GETPOST('clean_product_stock_batch') == 'confirmed') { - $error = 0; - - $db->begin(); - - $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; - $sql2 .= " SET reel = ".($obj->reelbatch ? ((float) $obj->reelbatch) : '0')." WHERE rowid = ".((int) $obj->psrowid); - $resql2 = $db->query($sql2); - if ($resql2) { - // We update product_stock, so we must fill p.stock into product too. - $sql3 = 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; - $resql3 = $db->query($sql3); - if (!$resql3) { - $error++; - dol_print_error($db); - } - } else { $error++; dol_print_error($db); } + } + } else { + if ($methodtofix == 'updatebatch') { + // Method 1 + print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; + $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + print '
'.$sql2; - if (!$error) { - $db->commit(); - } else { - $db->rollback(); + if (GETPOST('clean_product_stock_batch') == 'confirmed') { + $resql2 = $db->query($sql2); + if (!$resql2) { + // TODO If it fails, we must make update + //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; + //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + //$sql2.=" WHERE fk_product_stock = ".((int) $obj->psrowid) + } + } + } + if ($methodtofix == 'updatestock') { + // Method 2 + print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? ((float) $obj->reelbatch) : '0').' for ps.rowid = '.((int) $obj->psrowid); + $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; + $sql2 .= " SET reel = ".($obj->reelbatch ? ((float) $obj->reelbatch) : '0')." WHERE rowid = ".((int) $obj->psrowid); + print '
'.$sql2; + + if (GETPOST('clean_product_stock_batch') == 'confirmed') { + $error = 0; + + $db->begin(); + + $resql2 = $db->query($sql2); + if ($resql2) { + // We update product_stock, so we must fill p.stock into product too. + $sql3 = 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; + $resql3 = $db->query($sql3); + if (!$resql3) { + $error++; + dol_print_error($db); + } + } else { + $error++; + dol_print_error($db); + } + + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } } } } From 94002bf85c5299f4d02c129f388a2b0332c93e81 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 20:38:38 +0100 Subject: [PATCH 14/15] Fix sql --- htdocs/install/repair.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 1e912b54f95..11f94ac00d6 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -922,7 +922,7 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { // If product is not a product that support batches, we can clean stock by deleting the product batch lines print ' -> Delete qty '.$obj->reelbatch.' for any lot linked to fk_product_stock='.$obj->psrowid; $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."product_batch"; - $sql2 .= " WHERE fk_product_stock = ".$obj->psrowid; + $sql2 .= " WHERE fk_product_stock = ".((int) $obj->psrowid); print '
'.$sql2; if (GETPOST('clean_product_stock_batch') == 'confirmed') { @@ -937,7 +937,7 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { // Method 1 print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; - $sql2 .= "VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + $sql2 .= "VALUES(".((int) $obj->psrowid).", '000000', ".((float) ($obj->reel - $obj->reelbatch)).")"; print '
'.$sql2; if (GETPOST('clean_product_stock_batch') == 'confirmed') { From dc9109ea63eebe4ef11304821348f2e5a7838793 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Feb 2023 20:40:08 +0100 Subject: [PATCH 15/15] Fix merge --- htdocs/langs/fr_FR/errors.lang | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 803bebf310e..939c070008d 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -348,11 +348,7 @@ WarningPaypalPaymentNotCompatibleWithStrict=La valeur 'Strict' fait que les fonc WarningThemeForcedTo=Attention, le choix du thème a été forcé à %s par la constante cachée MAIN_FORCETHEME WarningPagesWillBeDeleted=Attention, cela supprimera également toutes les pages/conteneurs existants du site. Vous devriez exporter votre site Web avant, afin d'avoir une sauvegarde pour le réimporter plus tard. WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal=La validation automatique est désactivée lorsque l'option de diminution du stock est définie sur "Validation de la facture". -<<<<<<< HEAD -WarningModuleNeedRefrech = Module %s desactivé. N'oublier pas de le réactivé -======= WarningModuleNeedRefrech = Le module %s a été désactivé. N'oubliez pas de le réactiver ->>>>>>> branch '17.0' of git@github.com:Dolibarr/dolibarr.git # Validate RequireValidValue = Valeur non valide