From 280cf111b1d31986331236729ca859a45fd6cff1 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Mon, 9 Dec 2024 20:30:42 +0100 Subject: [PATCH 1/3] Improve bank card Prepare improvements regarding SEPA transfers. 3 - Add select to bank card Users should be able to choose the value of these two parameters for each bank account as they may be different from one bank to another. --- htdocs/compta/bank/card.php | 29 +++++++++++++++++++ htdocs/compta/bank/class/account.class.php | 23 ++++++++++++++- .../class/bonprelevement.class.php | 26 +++++++++++++---- htdocs/langs/en_US/banks.lang | 4 +++ htdocs/langs/fr_FR/banks.lang | 4 +++ 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 31f7fc7ca20f1..08032d9e5e97e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Charlene Benke * Copyright (C) 2024 MDW + * Copyright (C) 2024 Sylvain Legrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (isModEnabled('category')) { @@ -152,6 +154,8 @@ $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; + $object->ctgypurp = trim(GETPOST("ctgypurp", "alphanohtml")); + $object->lclinstrm = trim(GETPOST("lclinstrm", "alphanohtml")); $object->address = trim(GETPOST("account_address", "alphanohtml")); @@ -269,6 +273,8 @@ $object->bic = trim(GETPOST("bic")); $object->iban = trim(GETPOST("iban")); $object->pti_in_ctti = empty(GETPOST("pti_in_ctti")) ? 0 : 1; + $object->ctgypurp = trim(GETPOST("ctgypurp", "alphanohtml")); + $object->lclinstrm = trim(GETPOST("lclinstrm", "alphanohtml")); $object->owner_name = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'alphanohtml')); @@ -370,6 +376,7 @@ */ $form = new Form($db); +$formother = new FormOther($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); if (isModEnabled('accounting')) { @@ -611,6 +618,14 @@ print ''; print ''; } + print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; + print ''; + $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0,''); + print ''; + print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; + print ''; + $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0,''); + print ''; } print ''; print '
'; @@ -869,6 +884,12 @@ print(empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes")); print "\n"; } + print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; + print $object->ctgypurp; + print "\n"; + print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; + print $object->lclinstrm; + print "\n"; } print ''.$langs->trans("BankAccountOwner").''; @@ -1211,6 +1232,14 @@ print ''.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).''; print 'pti_in_ctti ? ' checked ' : '') . '>'; print ''; + print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; + print ''; + $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0,''); + print ''; + print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; + print ''; + $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0,''); + print ''; } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 73ee30a83fec0..a97ce4761926e 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2019 JC Prieto * Copyright (C) 2022-2024 Frédéric France * Copyright (C) 2024 MDW + * Copyright (C) 2024 Sylvain Legrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -167,6 +168,18 @@ class Account extends CommonObject */ public $proprio; + /** + * XML SEPA type: Category purpose of the Credit transfer for SEPA file + * @var string + */ + public $ctgypurp; + + /** + * XML SEPA type: User community specific instrument for SEPA file + * @var string + */ + public $lclinstrm; + /** * Name of account holder * @var string @@ -783,6 +796,8 @@ public function create($user, $notrigger = 0) $sql .= ", iban_prefix"; $sql .= ", domiciliation"; $sql .= ", pti_in_ctti"; + $sql .= ", ctgypurp"; + $sql .= ", lclinstrm"; $sql .= ", proprio"; $sql .= ", owner_address"; $sql .= ", owner_zip"; @@ -813,6 +828,8 @@ public function create($user, $notrigger = 0) $sql .= ", '".$this->db->escape($this->iban)."'"; $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", ".((int) $this->pti_in_ctti); + $sql .= ", '".$this->db->escape($this->ctgypurp)."'"; + $sql .= ", '".$this->db->escape($this->lclinstrm)."'"; $sql .= ", '".$this->db->escape($this->owner_name)."'"; $sql .= ", '".$this->db->escape($this->owner_address)."'"; $sql .= ", '".$this->db->escape($this->owner_zip)."'"; @@ -937,6 +954,8 @@ public function update($user, $notrigger = 0) $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; $sql .= ",domiciliation='".$this->db->escape($this->address)."'"; $sql .= ",pti_in_ctti=".((int) $this->pti_in_ctti); + $sql .= ",ctgypurp='".$this->db->escape($this->ctgypurp)."'"; + $sql .= ",lclinstrm='".$this->db->escape($this->lclinstrm)."'"; $sql .= ",proprio = '".$this->db->escape($this->owner_name)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; $sql .= ",owner_zip = '".$this->db->escape($this->owner_zip)."'"; @@ -1084,7 +1103,7 @@ public function fetch($id, $ref = '') $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant as type, ba.clos as status, ba.rappro, ba.url,"; $sql .= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; - $sql .= " ba.domiciliation as address, ba.pti_in_ctti, ba.proprio as owner_name, ba.owner_address, ba.owner_zip, ba.owner_town, ba.owner_country_id, ba.state_id, ba.fk_pays as country_id,"; + $sql .= " ba.domiciliation as address, ba.pti_in_ctti, ba.ctgypurp, ba.lclinstrm, ba.proprio as owner_name, ba.owner_address, ba.owner_zip, ba.owner_town, ba.owner_country_id, ba.state_id, ba.fk_pays as country_id,"; $sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; $sql .= " ba.min_allowed, ba.min_desired, ba.comment,"; $sql .= " ba.datec as date_creation, ba.tms as date_modification, ba.ics, ba.ics_transfer,"; @@ -1137,6 +1156,8 @@ public function fetch($id, $ref = '') $this->owner_country_id = $obj->owner_country_id; $this->pti_in_ctti = $obj->pti_in_ctti; + $this->ctgypurp = $obj->ctgypurp; + $this->lclinstrm = $obj->lclinstrm; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 24ce4487aed6b..cd05266e5d19a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2019 JC Prieto * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 Sylvain Legrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +96,16 @@ class BonPrelevement extends CommonObject */ public $sepa_xml_pti_in_ctti; + /** + * @var string + */ + public $sepa_xml_ctgypurp; + + /** + * @var string + */ + public $sepa_xml_lclinstrm; + /** * @var string */ @@ -299,6 +310,8 @@ public function __construct($db) $this->emetteur_code_banque = ""; $this->emetteur_number_key = ""; $this->sepa_xml_pti_in_ctti = false; + $this->sepa_xml_ctgypurp = "CORE"; + $this->sepa_xml_lclinstrm = "CORE"; $this->emetteur_iban = ""; $this->emetteur_bic = ""; @@ -1472,6 +1485,8 @@ public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL' $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->sepa_xml_ctgypurp = $account->ctgypurp; + $this->sepa_xml_lclinstrm = $account->lclinstrm; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; @@ -2395,15 +2410,13 @@ public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $instrprty = 'NORM'; } - // Set $categoryPurpose: CORE, TREA, SUPP, ... - $categoryPurpose = getDolGlobalString('PAYMENTBYBANKTRANSFER_CUSTOM_CATEGORY_PURPOSE', 'CORE'); $XML_CREDITOR .= ' ' . $instrprty . '' . $CrLf; $XML_CREDITOR .= ' ' . $CrLf; $XML_CREDITOR .= ' SEPA' . $CrLf; $XML_CREDITOR .= ' ' . $CrLf; $XML_CREDITOR .= ' ' . $CrLf; - $XML_CREDITOR .= ' ' . $categoryPurpose . '' . $CrLf; + $XML_CREDITOR .= ' ' . $this->sepa_xml_ctgypurp . '' . $CrLf; $XML_CREDITOR .= ' ' . $CrLf; $XML_CREDITOR .= ' ' . $CrLf; } @@ -2562,6 +2575,8 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL $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->sepa_xml_ctgypurp = $account->ctgypurp; + $this->sepa_xml_lclinstrm = $account->lclinstrm; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; @@ -2582,7 +2597,6 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL $country = explode(':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY); $IdBon = sprintf("%05d", $obj->rowid); $RefBon = $obj->ref; - $localInstrument = getDolGlobalString('PAYMENTBYBANKTRANSFER_CUSTOM_LOCAL_INSTRUMENT', 'CORE'); if (!empty($configuration->global->SEPA_FORCE_TWO_DECIMAL)) { $total = number_format((float) price2num($total, 'MT'), 2, ".", ""); @@ -2601,7 +2615,7 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL $XML_SEPA_INFO .= ' SEPA' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; - $XML_SEPA_INFO .= ' ' . $localInstrument . '' . $CrLf; + $XML_SEPA_INFO .= ' ' . $this->sepa_xml_lclinstrm . '' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; $XML_SEPA_INFO .= ' ' . $format . '' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; @@ -2666,7 +2680,7 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL $XML_SEPA_INFO .= ' SEPA' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; - $XML_SEPA_INFO .= ' ' . $localInstrument . '' . $CrLf; + $XML_SEPA_INFO .= ' ' . $this->sepa_xml_lclinstrm . '' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; $XML_SEPA_INFO .= ' ' . $format . '' . $CrLf; $XML_SEPA_INFO .= ' ' . $CrLf; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index c382df055c0c8..07df1d3046279 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -195,3 +195,7 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=SEPA fi SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Yes = Store 'Payment Type' in 'Credit Transfer' section of SEPA file

When generating a SEPA XML file for Credit transfers, the section "PaymentTypeInformation" can now be placed inside the "CreditTransferTransactionInformation" section (instead of "Payment" section). We strongly recommend to keep this unchecked to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level. ToCreateRelatedRecordIntoBank=To create missing related bank record XNewLinesConciliated=%s new line(s) conciliated +CtgyPurplabel=Category purpose of the Credit transfer +CtgyPurphelp=Following the prerequisites of the banking establishment (CORE, CASH, SUPP, TREA, etc...) +LclInstrmlabel=User community specific instrument +LclInstrmhelp=Following the prerequisites of the banking establishment (CORE, CTR, FAE, INST, etc...) diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index 2b045e646b07e..88e2aa3067e8f 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -195,3 +195,7 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=Variant SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Oui = Stocker le « Type de paiement » dans la section « Virement de crédit » du fichier SEPA

Lors de la génération d'un fichier XML SEPA pour les virements, la section "PaymentTypeInformation" peut désormais être placée dans la section "CreditTransferTransactionInformation" (au lieu de la section "Payment"). Nous vous recommandons fortement de laisser cette case décochée pour placer PaymentTypeInformation au niveau Payment, car toutes les banques ne l'accepteront pas nécessairement au niveau CreditTransferTransactionInformation. Contactez votre banque avant de placer PaymentTypeInformation au niveau CreditTransferTransactionInformation. ToCreateRelatedRecordIntoBank=Pour créer un enregistrement bancaire associé manquant XNewLinesConciliated=%s nouvelle(s) ligne(s) rapprochée(s) +CtgyPurplabel=Catégorie de l'objet du virement +CtgyPurphelp=Suivant les prérequis de l'établissement bancaire (CORE, CASH, SUPP, TREA, etc...) +LclInstrmlabel=Code d'instrument local +LclInstrmhelp=Suivant les prérequis de l'établissement bancaire (CORE, CTR, FAE, INST, etc...) From f5fb7bf6c456f8dd72d022e467a91666d92df9e7 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Mon, 9 Dec 2024 22:09:47 +0100 Subject: [PATCH 2/3] Update card.php Signed-off-by: Sylvain Legrand --- htdocs/compta/bank/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 08032d9e5e97e..9b73b16e5df04 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -620,11 +620,11 @@ } print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; print ''; - $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0,''); + $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0, ''); print ''; print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; print ''; - $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0,''); + $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0, ''); print ''; } print ''; From 1d4965a6ab74eb1c3cd8545ca47c35ea1c4aa3e6 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Mon, 9 Dec 2024 22:16:17 +0100 Subject: [PATCH 3/3] Update card.php Signed-off-by: Sylvain Legrand --- htdocs/compta/bank/card.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 9b73b16e5df04..af1494e82dc5d 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1232,14 +1232,14 @@ print ''.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).''; print 'pti_in_ctti ? ' checked ' : '') . '>'; print ''; - print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; - print ''; - $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0,''); - print ''; - print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; - print ''; - $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0,''); - print ''; + print ''.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).''; + print ''; + $formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0, ''); + print ''; + print ''.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).''; + print ''; + $formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0, ''); + print ''; } }