From 29303d03901afed8533ee0deef3a5bc08ddf85b7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 14 Oct 2024 12:00:09 +0200 Subject: [PATCH] NEW Prelevement - Use structured payment data for Belgium (#31383) --- .../prelevement/class/bonprelevement.class.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 979c9541416..89919a8b1d5 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -2267,7 +2267,7 @@ class BonPrelevement extends CommonObject public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum, $type = 'direct-debit', $row_comment = '') { // phpcs:enable - global $conf; + global $conf, $mysoc; if (getDolGlobalString('SEPA_FORCE_TWO_DECIMAL')) { $row_somme = number_format((float) price2num($row_somme, 'MT'), 2, ".", ""); @@ -2330,8 +2330,20 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' ' . $CrLf; $XML_DEBITOR .= ' ' . $CrLf; $XML_DEBITOR .= ' ' . $CrLf; - // A string with some information on payment - 140 max - $XML_DEBITOR .= ' ' . getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '' . $CrLf; // Free unstuctured data - 140 max + + // Structured data for Belgium + if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION') && $mysoc->country_code == 'BE') { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php'; + + $invoicestatic = new Facture($this->db); + $invoicestatic->fetch($row_idfac); + + $invoicePaymentKey = dolBECalculateStructuredCommunication($invoicestatic->ref, $invoicestatic->type); + $XML_DEBITOR .= ' ' . $invoicePaymentKey . '' . $CrLf; + } else { + // A string with some information on payment - 140 max + $XML_DEBITOR .= ' ' . getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '' . $CrLf; // Free unstuctured data - 140 max + } $XML_DEBITOR .= ' ' . $CrLf; $XML_DEBITOR .= ' ' . $CrLf; return $XML_DEBITOR;