From 0fcbc2c0c943a930466ef7def095cd2b00ca7329 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Fri, 3 Jan 2025 10:49:01 +0300 Subject: [PATCH] finish facture requirements (add nom defunt and sexe detunt add the last product in the table , add date to the last product in the table) --- gestion/lib/Db/Bdd.php | 1 + gestion/lib/Helpers/FileExportHelpers.php | 4 ++++ gestion/lib/Service/InvoicePdfHandler.php | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index 21f5516..eebdaaf 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -2322,6 +2322,7 @@ class Bdd { client.entreprise as client_entreprise, client.adresse as client_adresse, defunt.nom as defunt_nom, + defunt.sexe as defunt_sexe, lieu.nom as lieu_nom, lieu.adresse as lieu_adresse, thanato.nom as thanato_nom, diff --git a/gestion/lib/Helpers/FileExportHelpers.php b/gestion/lib/Helpers/FileExportHelpers.php index 0cde77f..1be25f9 100644 --- a/gestion/lib/Helpers/FileExportHelpers.php +++ b/gestion/lib/Helpers/FileExportHelpers.php @@ -27,4 +27,8 @@ class FileExportHelpers ]; } + public static function GetSexeLabel(string $sexeKey){ + return $sexeKey === 'f' ? 'Mme' : 'Mr'; + } + } diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 4ee99bf..a07a41e 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -28,6 +28,7 @@ namespace OCA\Gestion\Service; use DateTime; use \FPDF; +use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\PriceHelpers; class InvoicePdfHandler extends FPDF { @@ -133,17 +134,24 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod $totalHt = 0; $totalTtc = 0; - foreach($this->factureData["products"] as $product){ + $products = $this->factureData["products"]; + foreach($products as $product){ $valueHt = $product['produit_price']; $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); $totalHt+=$valueHt; $totalTtc+=$valueTtc; $descriptionLineNumber = $this->NbLines(90,$product["produit_description"]); - $articleListMaxHeight = $descriptionLineNumber * 10; + $productDescription = $product["produit_description"]; + $dateValue = ""; + if($product === end($products)){ + $dateValue = $devisDate; + $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' '. $this->factureData["defunt_nom"]; + } + $articleListMaxHeight = $descriptionLineNumber * 6; $tvaAmount = $valueTtc - $valueHt; $this->SetFont('Arial', '', 10); - $this->Cell(20, $articleListMaxHeight, $devisDate, 'LR',0); - $this->MultiAlignCell(90, $articleListMaxHeight, utf8_decode(html_entity_decode($product["produit_description"])),'LR','0',); + $this->Cell(20, $articleListMaxHeight, $dateValue, 'LR',0); + $this->MultiAlignCell(90, $articleListMaxHeight, utf8_decode(html_entity_decode($productDescription)),'LR','0',); $this->Cell(30, $articleListMaxHeight, number_format($valueHt,2,'.','').chr(128), 'LR', 0, 'C'); $this->Cell(20, $articleListMaxHeight, number_format($tvaAmount,2,'.','').chr(128), 'LR', 0, 'C'); $this->Cell(30, $articleListMaxHeight, number_format($valueTtc,2,'.','').chr(128), 'LR', 1, 'C');