From 1536524090918922accd468acde3c6f21c253485 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Thu, 2 Jan 2025 21:17:20 +0300 Subject: [PATCH] fix number format on price , recap facture switch position defunt and article, remove hour on invoice handler, date format on invoice --- gestion/lib/Controller/PageController.php | 25 +++++++++---------- gestion/lib/Service/InvoicePdfHandler.php | 29 +++++++++++++++-------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index eac8a97..a4bd6a2 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -754,12 +754,13 @@ class PageController extends Controller { 'montant_ttc' => 0, ); $produits = json_decode($this->getProduitsById($facture->id_devis)); - $produitsReferenceAsString = ""; + $produitsReferenceArray = []; foreach ($produits as $key => $produit) { $facture_temp['montant_htc'] += $produit->prix_unitaire * $produit->quantite; - $produitsReferenceAsString .= $produit->reference."-"; + $produitsReferenceArray[] = $produit->reference; }; - $produitsReferenceAsString = rtrim($produitsReferenceAsString, "-"); + $produitsReferenceArray = array_unique($produitsReferenceArray); + $produitsReferenceAsString = implode("-", $produitsReferenceArray); $facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva'])/100; $facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc']; $facture_temp['produit_references'] = $produitsReferenceAsString; @@ -925,11 +926,11 @@ class PageController extends Controller { $pdf->SetXY( 6, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 28, 8, $client[$index_facture_position]['num'], 0, 0, ''); $pdf->SetXY( 32, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 18, 8, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, ''); - $pdf->SetXY( 50, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 38, 8, utf8_decode(html_entity_decode($client[$index_facture_position]['defunt'])), 0, 0, ''); - $pdf->SetXY( 90, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 28, 8, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, ''); - $pdf->SetXY( 147, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 13, 8, $client[$index_facture_position]['montant_htc'].chr(128), 0, 0, 'C'); - $pdf->SetXY( 168, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 10, 8, $client[$index_facture_position]['montant_tva'].chr(128), 0, 0, 'C'); - $pdf->SetXY( 183, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 22, 8, $client[$index_facture_position]['montant_ttc'].chr(128), 0, 0, 'C'); + $pdf->SetXY( 50, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 28, 8, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, ''); + $pdf->SetXY( 100, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 38, 8, utf8_decode(html_entity_decode($client[$index_facture_position]['defunt'])), 0, 0, ''); + $pdf->SetXY( 147, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 13, 8, number_format($client[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C'); + $pdf->SetXY( 168, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 10, 8, number_format($client[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C'); + $pdf->SetXY( 183, $y_facture ); $pdf->SetFont('Arial','',8); $pdf->Cell( 22, 8, number_format($client[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C'); $montant_ht_total = $montant_ht_total+$client[$index_facture_position]['montant_htc']; $montant_tva_total = $montant_tva_total+$client[$index_facture_position]['montant_tva']; @@ -947,13 +948,13 @@ class PageController extends Controller { { $pdf->Line(5, 225, 205, 225); $pdf->SetFont('Arial','B',8); $pdf->SetXY( 5, 225 ); $pdf->Cell( 140, 8, 'TOTAL', 0, 0, 'C'); - $pdf->SetFont('Arial','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, $montant_ht_total.chr(128), 0, 0, 'C'); - $pdf->SetFont('Arial','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, $montant_tva_total.chr(128), 0, 0, 'C'); - $pdf->SetFont('Arial','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, $montant_ttc_total.chr(128), 0, 0, 'C'); + $pdf->SetFont('Arial','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, number_format($montant_ht_total,2,'.','').chr(128), 0, 0, 'C'); + $pdf->SetFont('Arial','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, number_format($montant_tva_total,2,'.','').chr(128), 0, 0, 'C'); + $pdf->SetFont('Arial','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->Rect(145, 233, 60, 7, "D"); $pdf->SetFont('Arial','B',8); $pdf->SetXY( 147, 233 ); $pdf->Cell( 30, 6.5, 'TOTAL TTC', 0, 0, 'C'); - $pdf->SetFont('Arial','B',8); $pdf->SetXY( 183, 233 ); $pdf->SetFillColor(255, 255, 0); $pdf->SetTextColor(255, 0, 0); $pdf->Cell( 22, 6.5, $montant_ttc_total.chr(128), 0, 0, 'C', true); + $pdf->SetFont('Arial','B',8); $pdf->SetXY( 183, 233 ); $pdf->Cell( 22, 6.5, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C', true); } $y1 = 245; diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 918c78d..3d1f53a 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Gestion\Service; +use DateTime; use \FPDF; use OCA\Gestion\Helpers\PriceHelpers; @@ -78,6 +79,13 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod public function GetFactureContent(){ $this->AddPage(); + + $factureDate = $this->factureData['date']; + $factureDate = DateTime::createFromFormat('Y-m-d',$factureDate); + $factureDate = $factureDate->format('d-m-Y'); + $factureDatePaiement = $this->factureData['date_paiement']; + $factureDatePaiement = DateTime::createFromFormat('Y-m-d',$factureDatePaiement); + $factureDatePaiement = $factureDatePaiement->format('d-m-Y'); $this->SetFont('Arial', '', 12); $this->Cell(0, 7, utf8_decode(html_entity_decode($this->factureData['configuration']->entreprise)), 0, 0); $this->Cell(0, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'] . ' ' . $this->factureData['client_entreprise'])), 0, 1,'R'); @@ -98,24 +106,24 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod $this->Cell(40, 7, 'ECHEANCE', 1, 1, 'C'); $this->SetFont('Arial', '', 10); - $this->Cell(30, 7, $this->factureData['date'], 1, 0, 'C'); + $this->Cell(30, 7, $factureDate, 1, 0, 'C'); $this->Cell(70, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C'); $this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(40, 7, $this->factureData['date_paiement'], 1, 1, 'C'); + $this->Cell(40, 7, $factureDatePaiement, 1, 1, 'C'); $this->Ln(8); //Articles info + $tvaValue = $this->factureData["configuration"]->tva_default; $this->SetFont('Arial', 'B', 11); $this->Cell(20, 8, 'Date', 1, 0); - $this->Cell(20, 8, 'Heure', 1, 0,'C'); $this->Cell(80, 8, 'Description', 1, 0,'C'); $this->Cell(30, 8, 'Prix Uni. HT', 1, 0, 'C'); + $this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 1, 0, 'C'); $this->Cell(30, 8, 'Prix Uni. TTC', 1, 1, 'C'); $totalHt = 0; $totalTtc = 0; - $tvaValue = $this->factureData["configuration"]->tva_default; foreach($this->factureData["products"] as $product){ $valueHt = $product['produit_price']; $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); @@ -123,12 +131,13 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod $totalTtc+=$valueTtc; $descriptionLineNumber = $this->NbLines(80,$product["produit_description"]); $articleListMaxHeight = $descriptionLineNumber * 10; + $tvaAmount = $valueTtc - $valueHt; $this->SetFont('Arial', '', 10); - $this->Cell(20, $articleListMaxHeight, $this->factureData['date'], 'LR',0); - $this->Cell(20, $articleListMaxHeight, $this->factureData['startTime'], 'LR',0,'C'); + $this->Cell(20, $articleListMaxHeight, $factureDate, 'LR',0); $this->MultiAlignCell(80, $articleListMaxHeight, utf8_decode(html_entity_decode($product["produit_description"])),'LR','0',); - $this->Cell(30, $articleListMaxHeight, $valueHt, 'LR', 0, 'C'); - $this->Cell(30, $articleListMaxHeight, $valueTtc, 'LR', 1, 'C'); + $this->Cell(30, $articleListMaxHeight, number_format($valueHt,2,'.',''), 'LR', 0, 'C'); + $this->Cell(20, $articleListMaxHeight, number_format($tvaAmount,2,'.',''), 'LR', 0, 'C'); + $this->Cell(30, $articleListMaxHeight, number_format($valueTtc,2,'.',''), 'LR', 1, 'C'); } $this->Cell(180,0,'','T'); $this->Ln(8); @@ -154,7 +163,7 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod $this->Cell($totalHtArrayWidth, 7, 'TOTAL HT', 1, 1, 'C'); $this->SetXY($ibanLastPositionX,$ibanCursorY); $this->SetFont('Arial', '', 11); - $this->Cell($totalHtArrayWidth, 20, $totalHt, 1, 1, 'C'); + $this->Cell($totalHtArrayWidth, 20, number_format($totalHt,2,'.',''), 1, 1, 'C'); $tableHTLastPostionX = $ibanLastPositionX + $totalHtArrayWidth + 10; //TABLE TTC @@ -163,7 +172,7 @@ sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du cod $this->Cell(30, 7, 'TOTAL TTC', 1, 1, 'C'); $this->SetXY($tableHTLastPostionX,$ibanCursorY+14); $this->SetFont('Arial', '', 11); - $this->Cell(30, 7, $totalTtc, 1, 1, 'C'); + $this->Cell(30, 7, number_format($totalTtc,2,'.',''), 1, 1, 'C'); $pdfContent = $this->Output('','S');