FIX generation of SEPA files for credit tranfer with several requests

This commit is contained in:
Laurent Destailleur 2026-05-04 21:54:22 +02:00
commit 4447fae459
4 changed files with 37 additions and 356 deletions

View file

@ -960,12 +960,6 @@ parameters:
count: 1
path: ../../../htdocs/bom/class/api_boms.class.php
-
message: '#^Method BOM\:\:getNetNeedsTree\(\) has parameter \$TNetNeeds with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/bom/class/bom.class.php
-
message: '#^Call to function is_object\(\) with BOMLine will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -1257,7 +1251,7 @@ parameters:
-
message: '#^Parameter \#16 \$usergroupid of function print_actions_filter expects array\<int\>\|int, string given\.$#'
identifier: argument.type
count: 3
count: 1
path: ../../../htdocs/comm/action/index.php
-
@ -1428,12 +1422,6 @@ parameters:
count: 2
path: ../../../htdocs/comm/action/peruser.php
-
message: '#^Variable \$labelbytype might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/comm/action/peruser.php
-
message: '#^Right side of && is always true\.$#'
identifier: booleanAnd.rightAlwaysTrue
@ -1458,12 +1446,6 @@ parameters:
count: 6
path: ../../../htdocs/comm/card.php
-
message: '#^Variable \$label might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/comm/contact.php
-
message: '#^Right side of && is always false\.$#'
identifier: booleanAnd.rightAlwaysFalse
@ -1536,12 +1518,6 @@ parameters:
count: 4
path: ../../../htdocs/comm/mailing/targetemailing.php
-
message: '#^Variable \$filter might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/comm/mailing/targetemailing.php
-
message: '#^Call to function property_exists\(\) with Propal and ''module'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -1560,12 +1536,6 @@ parameters:
count: 1
path: ../../../htdocs/comm/propal/card.php
-
message: '#^Variable \$classname might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/comm/propal/card.php
-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
@ -1584,18 +1554,6 @@ parameters:
count: 1
path: ../../../htdocs/commande/card.php
-
message: '#^Variable \$classname might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../../htdocs/commande/card.php
-
message: '#^Variable \$socid might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/commande/customer.php
-
message: '#^Call to function is_array\(\) with array\<mixed, mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -1620,12 +1578,6 @@ parameters:
count: 5
path: ../../../htdocs/compta/accounting-files.php
-
message: '#^Variable \$modulepart might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/accounting-files.php
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -1728,18 +1680,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/bank/class/paymentvarious.class.php
-
message: '#^Variable \$id might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/bank/graph.php
-
message: '#^Variable \$max might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../../htdocs/compta/bank/graph.php
-
message: '#^Right side of && is always true\.$#'
identifier: booleanAnd.rightAlwaysTrue
@ -1758,18 +1698,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/bank/line.php
-
message: '#^Variable \$filepath might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/bank/line.php
-
message: '#^Variable \$oldfilepath might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/bank/line.php
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
@ -1794,12 +1722,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/bank/list.php
-
message: '#^Variable \$num might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../../htdocs/compta/bank/list.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -1818,12 +1740,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/bank/treso.php
-
message: '#^Variable \$id might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/bank/treso.php
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -2028,12 +1944,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/facture/card.php
-
message: '#^Variable \$classname might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/compta/facture/card.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -2748,12 +2658,6 @@ parameters:
count: 1
path: ../../../htdocs/contact/card.php
-
message: '#^Property Contact\:\:\$roles \(array\<int, array\{id\: int, socid\: int, element\: string, source\: string, code\: string, label\: string\}\>\|null\) does not accept array\<string\>\.$#'
identifier: assign.propertyType
count: 2
path: ../../../htdocs/contact/card.php
-
message: '#^Ternary operator condition is always true\.$#'
identifier: ternary.alwaysTrue
@ -2979,54 +2883,6 @@ parameters:
-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$dolibarr_main_data_root might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$section might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$showonrightsize might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$sortfield might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$sortorder might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirpreview.php
-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirtree.php
-
message: '#^Variable \$dolibarr_main_data_root might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/core/ajax/ajaxdirtree.php
-
message: '#^Variable \$module might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/ajaxdirtree.php
@ -3036,12 +2892,6 @@ parameters:
count: 1
path: ../../../htdocs/core/ajax/ajaxdirtree.php
-
message: '#^Variable \$section might not be defined\.$#'
identifier: variable.undefined
count: 5
path: ../../../htdocs/core/ajax/ajaxdirtree.php
-
message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -3084,12 +2934,6 @@ parameters:
count: 1
path: ../../../htdocs/core/ajax/selectobject.php
-
message: '#^Variable \$filter might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/ajax/selectobject.php
-
message: '#^Call to function is_array\(\) with array\<int\<0, max\>, mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -3972,88 +3816,10 @@ parameters:
count: 1
path: ../../../htdocs/core/class/utils_diff.class.php
-
message: '#^Cannot access property \$db on mixed\.$#'
identifier: property.nonObject
count: 2
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Cannot access property \$export_TypeFields_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Cannot access property \$export_entities_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Cannot access property \$export_fields_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Cannot access property \$export_help_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Variable \$r might not be defined\.$#'
identifier: variable.undefined
count: 4
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 6
path: ../../../htdocs/core/commonfieldsinexport.inc.php
-
message: '#^Cannot access property \$db on mixed\.$#'
identifier: property.nonObject
count: 2
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Cannot access property \$import_TypeFields_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Cannot access property \$import_entities_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Cannot access property \$import_fields_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Cannot access property \$import_help_array on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Variable \$r might not be defined\.$#'
identifier: variable.undefined
count: 4
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 6
path: ../../../htdocs/core/commonfieldsinimport.inc.php
-
@ -5076,12 +4842,6 @@ parameters:
count: 2
path: ../../../htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php
-
message: '#^Method ModeleProductCode\:\:liste_modeles\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/core/modules/product/modules_product.class.php
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -5376,12 +5136,6 @@ parameters:
count: 1
path: ../../../htdocs/core/tpl/filemanager.tpl.php
-
message: '#^Variable \$websitekey might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/tpl/filemanager.tpl.php
-
message: '#^Variable \$sql might not be defined\.$#'
identifier: variable.undefined
@ -6552,12 +6306,6 @@ parameters:
count: 1
path: ../../../htdocs/hrm/class/skillrank.class.php
-
message: '#^Method SkillRank\:\:getLinesArray\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/hrm/class/skillrank.class.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -6648,12 +6396,6 @@ parameters:
count: 2
path: ../../../htdocs/hrm/skill_tab.php
-
message: '#^PHPDoc tag @var for variable \$objects has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/hrm/skill_tab.php
-
message: '#^Variable \$object might not be defined\.$#'
identifier: variable.undefined
@ -7212,12 +6954,6 @@ parameters:
count: 1
path: ../../../htdocs/modulebuilder/template/admin/myobject_extrafields.php
-
message: '#^Negated boolean expression is always false\.$#'
identifier: booleanNot.alwaysFalse
count: 1
path: ../../../htdocs/modulebuilder/template/admin/setup.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -7596,12 +7332,6 @@ parameters:
count: 1
path: ../../../htdocs/mrp/class/mo.class.php
-
message: '#^Method Mo\:\:fetchAll\(\) has parameter \$filter with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/mrp/class/mo.class.php
-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
@ -7674,12 +7404,6 @@ parameters:
count: 1
path: ../../../htdocs/opensurvey/class/opensurveysondage.class.php
-
message: '#^Offset int\<0, max\> on array\<int\<0, max\>, int\<0, max\>\> in isset\(\) always exists and is not nullable\.$#'
identifier: isset.offset
count: 1
path: ../../../htdocs/opensurvey/results.php
-
message: '#^Variable \$erreur_ajout_date in isset\(\) always exists and is not nullable\.$#'
identifier: isset.variable
@ -7878,24 +7602,6 @@ parameters:
count: 1
path: ../../../htdocs/product/admin/product_tools.php
-
message: '#^Property ActionsCardProduct\:\:\$field_list has no type specified\.$#'
identifier: missingType.property
count: 1
path: ../../../htdocs/product/canvas/product/actions_card_product.class.php
-
message: '#^Property ActionsCardService\:\:\$field_list has no type specified\.$#'
identifier: missingType.property
count: 1
path: ../../../htdocs/product/canvas/service/actions_card_service.class.php
-
message: '#^Property ActionsCardService\:\:\$tpl has no type specified\.$#'
identifier: missingType.property
count: 1
path: ../../../htdocs/product/canvas/service/actions_card_service.class.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -8310,12 +8016,6 @@ parameters:
count: 1
path: ../../../htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
-
message: '#^Method StockTransferLine\:\:fetchAll\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/product/stock/stocktransfer/class/stocktransferline.class.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -8598,18 +8298,6 @@ parameters:
count: 1
path: ../../../htdocs/projet/ganttview.php
-
message: '#^Variable \$colorseries might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/projet/graph_opportunities.inc.php
-
message: '#^Variable \$mine might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/projet/graph_opportunities.inc.php
-
message: '#^Comparison operation "\>" between 0 and 0 is always false\.$#'
identifier: greater.alwaysFalse
@ -9372,12 +9060,6 @@ parameters:
count: 1
path: ../../../htdocs/public/stripe/ipn.php
-
message: '#^Dead catch \- Exception is never thrown in the try block\.$#'
identifier: catch.neverThrown
count: 1
path: ../../../htdocs/public/stripe/ipn.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@ -10026,12 +9708,6 @@ parameters:
count: 2
path: ../../../htdocs/societe/class/societe.class.php
-
message: '#^Method Societe\:\:getContacts\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/societe/class/societe.class.php
-
message: '#^Property Contact\:\:\$roles \(array\<int, array\{id\: int, socid\: int, element\: string, source\: string, code\: string, label\: string\}\>\|null\) does not accept non\-empty\-list\<string\>\.$#'
identifier: assign.propertyType
@ -10110,12 +9786,6 @@ parameters:
count: 1
path: ../../../htdocs/societe/paymentmodes.php
-
message: '#^Variable \$sql might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/societe/paymentmodes.php
-
message: '#^Loose comparison using \=\= between ''add_customer_price'' and ''add_customer_price'' will always evaluate to true\.$#'
identifier: equal.alwaysTrue
@ -10134,12 +9804,6 @@ parameters:
count: 2
path: ../../../htdocs/societe/price.php
-
message: '#^Variable \$prodcustprice might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../../htdocs/societe/price.php
-
message: '#^Variable \$massaction might not be defined\.$#'
identifier: variable.undefined
@ -10458,12 +10122,6 @@ parameters:
count: 1
path: ../../../htdocs/ticket/class/cticketcategory.class.php
-
message: '#^Method CTicketCategory\:\:fetchAll\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/ticket/class/cticketcategory.class.php
-
message: '#^Call to function array_key_exists\(\) with ''paths'' and array\{paths\: mixed, names\: mixed, mimes\: mixed\} will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -10728,12 +10386,6 @@ parameters:
count: 1
path: ../../../htdocs/variants/class/ProductCombination.class.php
-
message: '#^Property ProductCombination\:\:\$variation_price_percentage type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../../../htdocs/variants/class/ProductCombination.class.php
-
message: '#^Call to function is_array\(\) with array\<mixed, mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType

View file

@ -1558,7 +1558,7 @@ class BOM extends CommonObject
/**
* Get/add Net needs Tree by product or bom
*
* @param array<int,array{product:array,bom:BOM,parentid:int,qty:float,level:int,position:int,fk_unit:?int}> $TNetNeeds Array of ChildBom and infos linked to
* @param array<int,array{product:array<int,array{fk_unit:int,qty:float,level:int,position:int}>,bom:BOM,parentid:int,qty:float,level:int,position:int,fk_unit:?int}> $TNetNeeds Array of ChildBom and infos linked to
* @param float $qty qty needed (used as a factor to produce 1 unit)
* @param int<0,1000> $level level of recursivity
* @return void

View file

@ -1272,6 +1272,9 @@ if ($action == 'create') { // aaa
if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test', 'editevenunsubscribe'))) {
print "\n\n<div class=\"tabsAction\">\n";
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
if (($object->status == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation_id == $user->id)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=settodraft&token='.newToken().'&id='.$object->id.'">'.$langs->trans("SetToDraft").'</a>';
}

View file

@ -1566,7 +1566,7 @@ class BonPrelevement extends CommonObject
if ($sourcetype == 'salary') {
$userid = $this->context['factures_prev'][0][2];
}
$result = $this->generate($format, $executiondate, $type, $fk_bank_account, $userid, (int) $thirdpartyBANId);
$result = $this->generate($format, $executiondate, $type, $fk_bank_account, $userid, 0);
if ($result < 0) {
//var_dump($this->error);
//var_dump($this->invoice_in_error);
@ -1881,7 +1881,7 @@ class BonPrelevement extends CommonObject
* @param string $type 'direct-debit' or 'bank-transfer'
* @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0.
* @param int $forsalary If the SEPA is to pay salaries
* @param int $thirdpartyBANId If defined, will use this ID to get the RIB. Otherwise, the first default BAN of thirdparty will be taken.
* @param int $thirdpartyBANId If defined, will use this ID to get the RIB. Otherwise, the BAN of request will be used. If not defined, the first default BAN of thirdparty will be taken.
* @return int >=0 if OK, <0 if KO
*/
public function generate(string $format = 'ALL', int $executiondate = 0, string $type = 'direct-debit', int $fk_bank_account = 0, int $forsalary = 0, int $thirdpartyBANId = 0)
@ -1940,7 +1940,8 @@ class BonPrelevement extends CommonObject
$sql = "SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as reffac, p.fk_facture as idfac,";
$sql .= " f.ref as reffac,";
$sql .= " p.fk_facture as idfac, p.rowid as pid,";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";
@ -2068,7 +2069,8 @@ class BonPrelevement extends CommonObject
if (!empty($forsalary)) {
$sql = "SELECT u.rowid as userId, u.address, u.zip, u.town, c.code as country_code, CONCAT(u.firstname,' ',u.lastname) as nom,";
$sql .= " pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " s.ref as reffac, p.fk_salary as idfac,";
$sql .= " s.ref as reffac,";
$sql .= " p.fk_salary as idfac, p.rowid as pid, '' as forced_rib";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, '' as rum, '' as date_rum";
$sql .= " FROM";
$sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";
@ -2085,7 +2087,8 @@ class BonPrelevement extends CommonObject
} else {
$sql = "SELECT soc.rowid as socid, soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as reffac, f.ref_supplier as fac_ref_supplier, p.fk_facture_fourn as idfac,";
$sql .= " f.ref as reffac, f.ref_supplier as fac_ref_supplier,";
$sql .= " p.fk_facture_fourn as idfac, p.rowid as pid, p.fk_societe_rib as forced_rib";
$sql .= " rib.rowid, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " " . MAIN_DB_PREFIX . "prelevement_lignes as pl,";
@ -2109,6 +2112,8 @@ class BonPrelevement extends CommonObject
// Define $fileCrediteurSection. One section DrctDbtTxInf per invoice.
$nbtotalDrctDbtTxInf = -1;
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$resql = $this->db->query($sql);
if ($resql) {
$cachearraytotestduplicate = array();
@ -2116,22 +2121,43 @@ class BonPrelevement extends CommonObject
$num = $this->db->num_rows($resql);
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// Test to avoid duplicate default IBAN, to ask user to clean its data
if (!empty($cachearraytotestduplicate[$obj->idfac])) {
$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
$this->invoice_in_error[$obj->idfac] = $this->error;
$result = -2;
break;
}
$cachearraytotestduplicate[$obj->idfac] = $obj->rowid;
// Get the default value
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$iban = dolDecrypt($obj->iban);
$bic = $obj->bic;
$drum = $obj->drum;
$rum = $obj->rum;
// But if a force bank account is defined, we use it instead
if (!empty($obj->forced_rib)) {
$bankaccount = new CompanyBankAccount($this->db);
$bankaccount->fetch((int) $obj->forced_rib);
if ($bankaccount->id > 0) {
$daterum = $bankaccount->date_rum;
$iban = $bankaccount->iban;
$bic = $bankaccount->bic;
$drum = $bankaccount->id;
$rum = $bankaccount->rum;
}
}
$refobj = $obj->reffac;
if (empty($refobj) && !empty($forsalary)) { // If ref of salary not defined, we force a value
$refobj = "SAL" . $obj->idfac;
}
$fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier);
$fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $iban, $bic, $daterum, $drum, $rum, $type, $obj->fac_ref_supplier);
$this->total += $obj->somme;
$i++;