fix change intracommu

This commit is contained in:
Tolotsoa 2025-08-27 20:42:04 +03:00
parent 9d29beecfb
commit 25b27a7f32
3 changed files with 62 additions and 21 deletions

View File

@ -5465,11 +5465,12 @@ COMMENTAIRES: ".$comment;
if($isFactureForSingleClient) {
$client = $this->getClientById($factureData['fk_client_id']);
$hasTva = ($client && isset($client['tva'])) ? ($client['tva'] == 1) : true;
$groupClient = $this->getTvaItracomuIdClient($factureData['fk_client_id']);
} else {
$client = $this->getClientById($devis['id_client']);
$hasTva = ($client && isset($client['tva'])) ? ($client['tva'] == 1) : true;
$groupClient = $this->getTvaItracomuIdClient($devis['id_client']);
}
// Déterminer le taux de TVA global pour l'affichage
$globalTvaValue = $defaultTvaValue;
@ -5498,7 +5499,6 @@ COMMENTAIRES: ".$comment;
} else {
$factureDevisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters);
}
$factureIncrement = 0;
$productsCount = 0;
$totalHt = 0;
@ -5610,6 +5610,7 @@ COMMENTAIRES: ".$comment;
$factureData["productsCount"] = $productsCount;
$factureData["totalPrices"] = $totaPricesArray;
$factureData["template_type_key"] = $templateType;
$factureData["client_tva_intracommu"] = $groupClient["tva_intracommu"];
return $factureData;
}
@ -5701,4 +5702,25 @@ COMMENTAIRES: ".$comment;
}
return null;
}
public function getTvaItracomuIdClient($clientId)
{
$sql = "SELECT
gf.tva_intracommu
FROM ".$this->tableprefix."client_group_facturation AS gf
LEFT JOIN ".$this->tableprefix."client AS gc
ON gc.fk_client_group_facturation_id = gf.id
WHERE gc.id = ?;";
$data = $this->execSQLNoJsonReturn(
$sql,
[$clientId]
);
if(!empty($data)) {
return $data[0];
}
return null;
}
}

View File

@ -67,6 +67,16 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable();
}
public function SafeTextForPdf($text)
{
if (empty($text)) {
return '';
}
$text = html_entity_decode($text, ENT_QUOTES | ENT_HTML401, 'UTF-8');
return iconv('UTF-8', 'ISO-8859-1//IGNORE', $text);
}
public function AddWatermark()
{
try {
@ -117,16 +127,16 @@ class InvoiceGroupPdfHandler extends FPDF
$this->SetY(-34);
$this->SetFont('Arial', '', 7);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ')));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('(Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.')));
$this->MultiCell(0, 4, $this->SafeTextForPdf('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal '));
$this->MultiCell(0, 4, $this->SafeTextForPdf('(Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'));
$this->Ln(1);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire')));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('sera due sur présentation de justificatifs (articles L.441-3 et L.441-6 du code de commerce).')));
$this->MultiCell(0, 4, $this->SafeTextForPdf('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire'));
$this->MultiCell(0, 4, $this->SafeTextForPdf('sera due sur présentation de justificatifs (articles L.441-3 et L.441-6 du code de commerce).'));
$this->SetY(-10);
$this->SetFont('Arial', '', 7);
$this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C');
$this->Cell(0, 10, $this->SafeTextForPdf($this->factureData['configuration']->legal_one), 0, 0, 'C');
}
public function InvoicePdfFactory(array $factureData, $logo = null)
@ -266,7 +276,7 @@ class InvoiceGroupPdfHandler extends FPDF
// Sans TVA : afficher N° TVA intracommunautaire
$clientInfoYAxis += $this->interLigneHeader;
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
$tvaIntracommu = isset($this->factureData['group_tva_intracommu']) ? $this->factureData['group_tva_intracommu'] : '';
$tvaIntracommu = isset($this->factureData['client_tva_intracommu']) ? $this->factureData['client_tva_intracommu'] : '';
$this->Cell(0, $this->interLigneHeader, 'TVA intracom : ' . $tvaIntracommu);
}
}
@ -293,7 +303,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->SetFont('Arial', '', 10);
$this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C');
$this->Cell(104, 7, $this->SafeTextForPdf($this->factureData['group_name']), 1, 0, 'C');
$this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C');
@ -460,8 +470,8 @@ class InvoiceGroupPdfHandler extends FPDF
$startOfYAfterMainTable = 239;
$this->SetY($startOfYAfterMainTable);
$this->SetFont('Arial', '', 8);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise)));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :")));
$this->MultiCell(0, 4, $this->SafeTextForPdf("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise));
$this->MultiCell(0, 4, $this->SafeTextForPdf("en indiquant le numéro de facture, ou par virement :"));
$this->Ln(1);
//Table IBAN

View File

@ -57,6 +57,15 @@ class InvoicePdfHandler extends FPDF
}
}
public function SafeTextForPdf($text)
{
if (empty($text)) {
return '';
}
$text = html_entity_decode($text, ENT_QUOTES | ENT_HTML401, 'UTF-8');
return iconv('UTF-8', 'ISO-8859-1//IGNORE', $text);
}
public function AddWatermark()
{
$this->SetAlpha(0.2);
@ -96,15 +105,15 @@ class InvoicePdfHandler extends FPDF
$this->SetY(-34);
$this->SetFont('ComicSans', '', 7);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ')));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('(Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.')));
$this->MultiCell(0, 4, $this->SafeTextForPdf('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal '));
$this->MultiCell(0, 4, $this->SafeTextForPdf('(Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'));
$this->Ln(1);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire')));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode('sera due sur présentation de justificatifs (articles L.441-3 et L.441-6 du code de commerce).')));
$this->MultiCell(0, 4, $this->SafeTextForPdf('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire'));
$this->MultiCell(0, 4, $this->SafeTextForPdf('sera due sur présentation de justificatifs (articles L.441-3 et L.441-6 du code de commerce).'));
$this->SetY(-10);
$this->SetFont('ComicSans', '', 7);
$this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C');
$this->Cell(0, 10, $this->SafeTextForPdf($this->factureData['configuration']->legal_one), 0, 0, 'C');
}
public function InvoicePdfFactory(array $factureData, $logo = null)
@ -212,7 +221,7 @@ class InvoicePdfHandler extends FPDF
$this->Cell(0, $this->interLigneHeader, 'Siret: ' . $this->factureData['siret']);
} else {
// Sans TVA : afficher N° TVA intracommunautaire
$tvaIntracommu = isset($this->factureData['group_tva_intracommu']) ? $this->factureData['group_tva_intracommu'] : '';
$tvaIntracommu = isset($this->factureData['client_tva_intracommu']) ? $this->factureData['client_tva_intracommu'] : '';
$this->Cell(0, $this->interLigneHeader, 'TVA intracom : ' . $tvaIntracommu);
}
@ -248,7 +257,7 @@ class InvoicePdfHandler extends FPDF
$this->SetFont('ComicSans', '', 10);
$this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C');
$this->Cell(104, 7, $this->SafeTextForPdf($this->factureData['client_nom']), 1, 0, 'C');
$this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C');
@ -362,7 +371,7 @@ class InvoicePdfHandler extends FPDF
$this->Cell(5, 6, $dateValue, 0, 0);
$this->SetXY(30, $yValue);
$this->MultiAlignCell($maxDescriptionWidth, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', );
$this->MultiAlignCell($maxDescriptionWidth, 6, $this->SafeTextForPdf($productDescription), 0, '0', );
$this->SetXY(144, $yValue);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
@ -401,8 +410,8 @@ class InvoicePdfHandler extends FPDF
$startOfYAfterMainTable = 236;
$this->SetY($startOfYAfterMainTable);
$this->SetFont('ComicSans', '', 8);
$this->MultiCell(0, 4, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise)));
$this->MultiCell(0, 4, utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :")));
$this->MultiCell(0, 4, $this->SafeTextForPdf("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise));
$this->MultiCell(0, 4, $this->SafeTextForPdf("en indiquant le numéro de facture, ou par virement :"));
$this->Ln(1);
$startOftable = 3;