NEW Prelevement - Use structured payment data for Belgium (#31383)

This commit is contained in:
Alexandre SPANGARO 2024-10-14 12:00:09 +02:00 committed by GitHub
parent 39e021feba
commit 29303d0390
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 .= ' </Id>' . $CrLf;
$XML_DEBITOR .= ' </DbtrAcct>' . $CrLf;
$XML_DEBITOR .= ' <RmtInf>' . $CrLf;
// A string with some information on payment - 140 max
$XML_DEBITOR .= ' <Ustrd>' . getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '</Ustrd>' . $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 .= ' <strd>' . $invoicePaymentKey . '</strd>' . $CrLf;
} else {
// A string with some information on payment - 140 max
$XML_DEBITOR .= ' <Ustrd>' . getDolGlobalString('PRELEVEMENT_USTRD', dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($row_ref . ($row_comment ? ' - ' . $row_comment : '')), '', '', '', 1), 135, 'right', 'UTF-8', 1))) . '</Ustrd>' . $CrLf; // Free unstuctured data - 140 max
}
$XML_DEBITOR .= ' </RmtInf>' . $CrLf;
$XML_DEBITOR .= ' </DrctDbtTxInf>' . $CrLf;
return $XML_DEBITOR;