Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve bank card #32304

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions htdocs/compta/bank/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2022 Charlene Benke <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Sylvain Legrand <[email protected]>
*
* 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
Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -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"));

Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -370,6 +376,7 @@
*/

$form = new Form($db);
$formother = new FormOther($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
if (isModEnabled('accounting')) {
Expand Down Expand Up @@ -611,6 +618,14 @@
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. (empty(GETPOST('pti_in_ctti')) ? '' : ' checked ') . '>';
print '</td></tr>';
}
print '<tr><td>'.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).'</td>';
print '<td>';
$formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0, '');
print '</td></tr>';
print '<tr><td>'.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).'</td>';
print '<td>';
$formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0, '');
print '</td></tr>';
}
print '</table>';
print '<hr>';
Expand Down Expand Up @@ -869,6 +884,12 @@
print(empty($object->pti_in_ctti) ? $langs->trans("No") : $langs->trans("Yes"));
print "</td></tr>\n";
}
print '<tr><td>'.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).'</td><td>';
print $object->ctgypurp;
print "</td></tr>\n";
print '<tr><td>'.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).'</td><td>';
print $object->lclinstrm;
print "</td></tr>\n";
}

print '<tr><td>'.$langs->trans("BankAccountOwner").'</td><td>';
Expand Down Expand Up @@ -1211,6 +1232,14 @@
print '<tr><td>'.$form->textwithpicto($langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation"), $langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp")).'</td>';
print '<td><input type="checkbox" class="flat" name="pti_in_ctti"'. ($object->pti_in_ctti ? ' checked ' : '') . '>';
print '</td></tr>';
print '<tr><td>'.$form->textwithpicto($langs->trans("CtgyPurplabel"), $langs->trans("CtgyPurphelp")).'</td>';
print '<td>';
$formother->select_dictionary('ctgypurp', 'c_sepa_category_purpose', 'code', 'position', (GETPOST('ctgypurp') ? GETPOST('ctgypurp') : 'CORE'), 0, '');
print '</td></tr>';
print '<tr><td>'.$form->textwithpicto($langs->trans("LclInstrmlabel"), $langs->trans("LclInstrmhelp")).'</td>';
print '<td>';
$formother->select_dictionary('lclinstrm', 'c_sepa_community_instrument', 'code', 'position', (GETPOST('lclinstrm') ? GETPOST('lclinstrm') : 'CORE'), 0, '');
print '</td></tr>';
}
}

Expand Down
23 changes: 22 additions & 1 deletion htdocs/compta/bank/class/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Copyright (C) 2019 JC Prieto <[email protected]><[email protected]>
* Copyright (C) 2022-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Sylvain Legrand <[email protected]>
*
* 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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)."'";
Expand Down Expand Up @@ -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)."'";
Expand Down Expand Up @@ -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,";
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 20 additions & 6 deletions htdocs/compta/prelevement/class/bonprelevement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Copyright (C) 2019 JC Prieto <[email protected]><[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
* Copyright (C) 2024 Sylvain Legrand <[email protected]>
*
* 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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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>' . $instrprty . '</InstrPrty>' . $CrLf;
$XML_CREDITOR .= ' <SvcLvl>' . $CrLf;
$XML_CREDITOR .= ' <Cd>SEPA</Cd>' . $CrLf;
$XML_CREDITOR .= ' </SvcLvl>' . $CrLf;
$XML_CREDITOR .= ' <CtgyPurp>' . $CrLf;
$XML_CREDITOR .= ' <Cd>' . $categoryPurpose . '</Cd>' . $CrLf;
$XML_CREDITOR .= ' <Cd>' . $this->sepa_xml_ctgypurp . '</Cd>' . $CrLf;
$XML_CREDITOR .= ' </CtgyPurp>' . $CrLf;
$XML_CREDITOR .= ' </PmtTpInf>' . $CrLf;
}
Expand Down Expand Up @@ -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;

Expand All @@ -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, ".", "");
Expand All @@ -2601,7 +2615,7 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf;
$XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf;
$XML_SEPA_INFO .= ' <Cd>' . $localInstrument . '</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' <Cd>' . $this->sepa_xml_lclinstrm . '</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf;
$XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf;
$XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf;
Expand Down Expand Up @@ -2666,7 +2680,7 @@ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrL
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf;
$XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf;
$XML_SEPA_INFO .= ' <Cd>' . $localInstrument . '</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' <Cd>' . $this->sepa_xml_lclinstrm . '</Cd>' . $CrLf;
$XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf;
$XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf;
$XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf;
Expand Down
4 changes: 4 additions & 0 deletions htdocs/langs/en_US/banks.lang
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=SEPA fi
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Yes = Store 'Payment Type' in 'Credit Transfer' section of SEPA file<br><br>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...)
4 changes: 4 additions & 0 deletions htdocs/langs/fr_FR/banks.lang
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=Variant
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Oui = Stocker le « Type de paiement » dans la section « Virement de crédit » du fichier SEPA<br><br>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...)
Loading