From a4a66e60f8dbdc4bccf37fcad14362e950940cfe Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 09:26:10 +0100 Subject: [PATCH 1/5] Add a substitution Category Of Operations into ODT generation for Invoices --- .../doc/doc_generic_invoice_odt.modules.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index f5dcfb86936..8a10f2d53b8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -338,6 +338,35 @@ class doc_generic_invoice_odt extends ModelePDFFactures $propal_object = $object->linkedObjects['propal'][0]; + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; + foreach ($object->lines as $line) { + + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $line->product_type; + if ($lineProductType == Product::TYPE_PRODUCT) { + $nbProduct++; + } elseif ($lineProductType == Product::TYPE_SERVICE) { + $nbService++; + } + if ($nbProduct > 0 && $nbService > 0) { + // mixed products and services + $categoryOfOperation = 2; + } + } + } + + // determine category of operation + if ($categoryOfOperation <= 0) { + // only services + if ($nbProduct == 0 && $nbService > 0) { + $categoryOfOperation = 1; + } + } + // Make substitution $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, @@ -420,6 +449,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); From 11da2351df75609d3c4b7139e6625a3f76525bd0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 08:32:22 +0000 Subject: [PATCH 2/5] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 8a10f2d53b8..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 0671ec697fda7ea6e6b1ee083370d4745d47cece Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Tue, 3 Jan 2023 10:06:58 +0100 Subject: [PATCH 3/5] Add a substitution Category Of Operations into ODT generation for Invoices --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..907808f3479 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,6 +343,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { + // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 25bfd4d855fce4e754968e78ba34a602c784f128 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Jan 2023 09:08:32 +0000 Subject: [PATCH 4/5] Fixing style errors. --- .../core/modules/facture/doc/doc_generic_invoice_odt.modules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 907808f3479..d8bfab8d255 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -343,7 +343,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures $nbProduct = 0; $nbService = 0; foreach ($object->lines as $line) { - // determine category of operation if ($categoryOfOperation < 2) { $lineProductType = $line->product_type; From 78b383efa4b6257ec63df665ba12d99c8ef83fc2 Mon Sep 17 00:00:00 2001 From: Warner Bryce Date: Wed, 4 Jan 2023 08:59:34 +0100 Subject: [PATCH 5/5] Corrections added by Eldy --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d8bfab8d255..ba1a64f29f6 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -448,7 +448,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($this->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - $tmparray['object_category_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);