diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 6eac14d3eb3..0b419dacace 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -64,6 +64,7 @@ class BonPrelevement extends CommonObject
public $emetteur_numero_compte;
public $emetteur_code_banque;
public $emetteur_number_key;
+ public $sepa_xml_pti_in_ctti;
public $emetteur_iban;
public $emetteur_bic;
@@ -107,6 +108,7 @@ class BonPrelevement extends CommonObject
$this->emetteur_numero_compte = "";
$this->emetteur_code_banque = "";
$this->emetteur_number_key = "";
+ $this->sepa_xml_pti_in_ctti = false;
$this->emetteur_iban = "";
$this->emetteur_bic = "";
@@ -1038,10 +1040,11 @@ class BonPrelevement extends CommonObject
}
$account = new Account($this->db);
if ($account->fetch($id) > 0) {
- $this->emetteur_code_banque = $account->code_banque;
+ $this->emetteur_code_banque = $account->code_banque;
$this->emetteur_code_guichet = $account->code_guichet;
$this->emetteur_numero_compte = $account->number;
- $this->emetteur_number_key = $account->cle_rib;
+ $this->emetteur_number_key = $account->cle_rib;
+ $this->sepa_xml_pti_in_ctti = (bool) $account->pti_in_ctti;
$this->emetteur_iban = $account->iban;
$this->emetteur_bic = $account->bic;
@@ -1881,6 +1884,24 @@ class BonPrelevement extends CommonObject
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
$XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
$XML_CREDITOR .= ' '.$CrLf;
+ if ($this->sepa_xml_pti_in_ctti) {
+ $XML_CREDITOR .= ' ' . $CrLf;
+
+ // Can be 'NORM' for normal or 'HIGH' for high priority level
+ if (!empty($conf->global->PAYMENTBYBANKTRANSFER_FORCE_HIGH_PRIORITY)) {
+ $instrprty = 'HIGH';
+ } else {
+ $instrprty = 'NORM';
+ }
+ $XML_CREDITOR .= ' '.$instrprty.'' . $CrLf;
+ $XML_CREDITOR .= ' ' . $CrLf;
+ $XML_CREDITOR .= ' SEPA' . $CrLf;
+ $XML_CREDITOR .= ' ' . $CrLf;
+ $XML_CREDITOR .= ' ' . $CrLf;
+ $XML_CREDITOR .= ' CORE' . $CrLf;
+ $XML_CREDITOR .= ' ' . $CrLf;
+ $XML_CREDITOR .= ' ' . $CrLf;
+ }
$XML_CREDITOR .= ' '.$CrLf;
$XML_CREDITOR .= ' '.round($row_somme, 2).''.$CrLf;
$XML_CREDITOR .= ' '.$CrLf;
@@ -2031,6 +2052,7 @@ class BonPrelevement extends CommonObject
$this->emetteur_code_guichet = $account->code_guichet;
$this->emetteur_numero_compte = $account->number;
$this->emetteur_number_key = $account->cle_rib;
+ $this->sepa_xml_pti_in_ctti = (bool) $account->pti_in_ctti;
$this->emetteur_iban = $account->iban;
$this->emetteur_bic = $account->bic;
@@ -2125,17 +2147,17 @@ class BonPrelevement extends CommonObject
//$XML_SEPA_INFO .= ' False'.$CrLf;
$XML_SEPA_INFO .= ' '.$nombre.''.$CrLf;
$XML_SEPA_INFO .= ' '.$total.''.$CrLf;
- /*
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' SEPA'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' TRF'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' SECU'.$CrLf;
- $XML_SEPA_INFO .= ' '.$CrLf;
- */
+ if (!$this->sepa_xml_pti_in_ctti) {
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ $XML_SEPA_INFO .= ' SEPA' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ $XML_SEPA_INFO .= ' CORE' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $format . '' . $CrLf;
+ $XML_SEPA_INFO .= ' ' . $CrLf;
+ }
$XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf;