diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 6fd40cf2825..56e1e7f2039 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -80,6 +80,16 @@ if ($action == "set")
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
+ if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END")=="")
+ {
+ $res = dolibarr_set_const($db, "END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"),'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
+ if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD")=="")
+ {
+ $res = dolibarr_set_const($db, "USTRD", GETPOST("PRELEVEMENT_USTRD"),'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
if (! $error)
{
@@ -221,6 +231,18 @@ print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER'
print '';
print '';
+//EntToEnd
+print '
| '.$langs->trans("END_TO_END").' | ';
+print '';
+print ' | ';
+print '
';
+
+//USTRD
+print '| '.$langs->trans("USTRD").' | ';
+print '';
+print ' | ';
+print '
';
+
print '';
print '
';
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 245b25be3b6..a6b0ec84317 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1575,7 +1575,8 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR ='';
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
- $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
+ $XML_DEBITOR .=' '.(($conf->global->END_TO_END != "" ) ? $conf->global->END_TO_END : ('AS-'.dol_trunc($row_facnumber,20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
@@ -1607,7 +1608,8 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
// $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).''.$CrLf;
- $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max
+ // $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max
+ $XML_DEBITOR .=' '.(($conf->global->USTRD != "" ) ? $conf->global->USTRD : dol_trunc($row_facnumber, 135) ).''.$CrLf; // 140 max
$XML_DEBITOR .=' '.$CrLf;
$XML_DEBITOR .=' '.$CrLf;
return $XML_DEBITOR;
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 2b355b56eb7..0922c8cfa11 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -997,6 +997,179 @@ class Thirdparties extends DolibarrApi
return $result;
}
+ /**
+ * Get CompanyBankAccount objects for thirdparty
+ *
+ * @param int $socid Thirdparty id
+ *
+ * @return array
+ */
+ function getCompanyBankAccount($socid){
+
+ global $db, $conf;
+
+ if(! DolibarrApiAccess::$user->rights->facture->lire) {
+ throw new RestException(401);
+ }
+ if(empty($socid)) {
+ throw new RestException(400, 'Thirdparty ID is mandatory');
+ }
+
+ if( ! DolibarrApi::_checkAccessToResource('societe',$socid)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ /**
+ * We select all the records that match the socid
+ */
+
+ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
+ $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
+ if ($socid) $sql.= " WHERE fk_soc = ".$socid." ";
+
+
+ $result = $db->query($sql);
+
+ if($result->num_rows == 0 ){
+ throw new RestException(404, 'Account not found');
+ }
+
+ $i=0;
+
+ $accounts =[];
+
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($result);
+ $account = new CompanyBankAccount($db);
+ if($account->fetch($obj->rowid)) {
+ $accounts[] = $account;
+ }
+ $i++;
+ }
+ }
+ else{
+ throw new RestException(404, 'Account not found');
+ }
+
+
+ $fields = ['socid', 'default_rib', 'frstrecur', '1000110000001', 'datec', 'datem', 'label', 'bank', 'bic', 'iban', 'id'];
+
+ $returnAccounts = [];
+
+ foreach($accounts as $account){
+ $object= [];
+ foreach($account as $key => $value)
+ if(in_array($key, $fields)){
+ $object[$key] = $value;
+
+ }
+ $returnAccounts[] = $object;
+ }
+
+ return $returnAccounts;
+ }
+
+
+ /**
+ * Create CompanyBankAccount object for thirdparty
+ * @param int $socid thirdparty id
+ * @param array $request_data Request datas
+ *
+ * @return object ID of thirdparty
+ *
+ * @url POST {socid}/CompanyBankAccount
+ */
+ function createCompanyBankAccount($socid, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->societe->creer) {
+ throw new RestException(401);
+ }
+
+ $account = new CompanyBankAccount($this->db);
+
+ $account->socid = $socid;
+
+ foreach($request_data as $field => $value) {
+ $account->$field = $value;
+ }
+
+ if ($account->create(DolibarrApiAccess::$user) < 0)
+ throw new RestException(500, 'Error creating Company Bank account');
+
+
+ if ($account->update(DolibarrApiAccess::$user) < 0)
+ throw new RestException(500, 'Error updating values');
+
+ return $account;
+ }
+
+
+ /**
+ * Update CompanyBankAccount object for thirdparty
+ *
+ * @param int $socid Thirdparty id
+ * @param int $id CompanyBankAccount's id
+ * @param array $request_data Request datas
+ *
+ * @return object ID of thirdparty
+ *
+ * @url PUT {socid}/CompanyBankAccount/{id}
+ */
+ function updateCompanyBankAccount($socid, $id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->societe->creer) {
+ throw new RestException(401);
+ }
+
+ $account = new CompanyBankAccount($this->db);
+
+ $account->fetchFromApi($id, $socid);
+
+
+
+ if($account->socid != $socid){
+ throw new RestException(401);
+ }
+
+
+ foreach($request_data as $field => $value) {
+ $account->$field = $value;
+ }
+
+ if ($account->update(DolibarrApiAccess::$user) < 0)
+ throw new RestException(500, 'Error updating values');
+
+ return $account;
+ }
+
+ /**
+ * @param int $id CompanyBankAccount's id
+ * @param int $socid Thirdparty id
+ *
+ * @return int -1 if error 1 if correct deletion
+ *
+ * @url DELETE {socid}/CompanyBankAccount/{id}
+ */
+ function deleteCompanyBankAccount($id, $socid){
+
+ if(! DolibarrApiAccess::$user->rights->societe->creer) {
+ throw new RestException(401);
+ }
+
+ $account = new CompanyBankAccount($this->db);
+
+ $account->fetch($id);
+
+ if(!$account->socid == $socid)
+ throw new RestException(401);
+
+ return $account->delete(DolibarrApiAccess::$user);
+ }
/**
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index 187f7c5ec65..68dd8f51c3b 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -250,6 +250,63 @@ class CompanyBankAccount extends Account
}
}
+ /**
+ * Load record from database for the API
+ *
+ * @param int $id Id of record
+ * @param int $socid Id of company. If this is filled, function will return the first default RIB of company
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetchFromApi($id, $socid=0)
+ {
+ if (empty($id) && empty($socid)) return -1;
+
+ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
+ $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
+ if ($id) $sql.= " WHERE rowid = ".$id;
+ if ($socid) $sql.= " AND fk_soc = ".$socid;
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
+
+ $this->id = $obj->rowid;
+ $this->type = $obj->type;
+ $this->socid = $obj->fk_soc;
+ $this->bank = $obj->bank;
+ $this->code_banque = $obj->code_banque;
+ $this->code_guichet = $obj->code_guichet;
+ $this->number = $obj->number;
+ $this->cle_rib = $obj->cle_rib;
+ $this->bic = $obj->bic;
+ $this->iban = $obj->iban;
+ $this->domiciliation = $obj->domiciliation;
+ $this->proprio = $obj->proprio;
+ $this->owner_address = $obj->owner_address;
+ $this->label = $obj->label;
+ $this->default_rib = $obj->default_rib;
+ $this->datec = $this->db->jdate($obj->datec);
+ $this->datem = $this->db->jdate($obj->datem);
+ $this->rum = $obj->rum;
+ $this->frstrecur = $obj->frstrecur;
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
/**
* Delete a rib from database
*