Prepare code to introduce different payment modes than BAN

This commit is contained in:
Laurent Destailleur 2018-03-08 22:33:40 +01:00
parent 489dde4db4
commit 9f42e1b172
3 changed files with 13 additions and 16 deletions

View File

@ -726,16 +726,12 @@ class BonPrelevement extends CommonObject
$sql = "SELECT count(f.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
//if ($banque || $agence) $sql.=", ".MAIN_DB_PREFIX."societe_rib as sr";
$sql.= " WHERE f.fk_statut = 1";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.rowid = pfd.fk_facture";
$sql.= " AND f.paye = 0";
$sql.= " AND pfd.traite = 0";
$sql.= " AND f.total_ttc > 0";
//if ($banque || $agence) $sql.= " AND f.fk_soc = sr.rowid";
//if ($banque) $sql.= " AND sr.code_banque = '".$conf->global->PRELEVEMENT_CODE_BANQUE."'";
//if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'";
dol_syslog(get_class($this)."::SommeAPrelever");
$resql = $this->db->query($sql);
@ -805,9 +801,8 @@ class BonPrelevement extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
//if ($banque || $agence) $sql.= ", ".MAIN_DB_PREFIX."societe_rib as sr";
$sql.= " WHERE f.rowid = pfd.fk_facture";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity IN (".getEntity('facture').')';
$sql.= " AND s.rowid = f.fk_soc";
//if ($banque || $agence) $sql.= " AND s.rowid = sr.fk_soc";
$sql.= " AND f.fk_statut = 1";
@ -1340,6 +1335,7 @@ class BonPrelevement extends CommonObject
$sql.= " AND soc.rowid = f.fk_soc";
$sql.= " AND rib.fk_soc = f.fk_soc";
$sql.= " AND rib.default_rib = 1";
$sql.= " AND rib.type = 'ban'";
//print $sql;
// Define $fileDebiteurSection. One section DrctDbtTxInf per invoice.

View File

@ -72,7 +72,7 @@ class CompanyBankAccount extends Account
$now = dol_now();
$error = 0;
// Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
$result = $this->db->query($sql);
if ($result)
{
@ -81,8 +81,8 @@ class CompanyBankAccount extends Account
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)";
$sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
$sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$resql=$this->db->query($sql);
if ($resql)
{
@ -204,7 +204,7 @@ class CompanyBankAccount extends Account
{
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 = "SELECT rowid, type, 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;
@ -220,6 +220,7 @@ class CompanyBankAccount extends Account
$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;
@ -321,7 +322,7 @@ class CompanyBankAccount extends Account
}
/**
* Set RIB as Default
* Set a BAN as Default
*
* @param int $rib RIB id
* @return int 0 if KO, 1 if OK
@ -345,13 +346,13 @@ class CompanyBankAccount extends Account
$this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0 ";
$sql2.= "WHERE fk_soc = ".$obj->fk_soc;
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
$sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result2 = $this->db->query($sql2);
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1 ";
$sql3.= "WHERE rowid = ".$obj->id;
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
$sql3.= " WHERE rowid = ".$obj->id;
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);

View File

@ -2433,7 +2433,7 @@ class Societe extends CommonObject
function get_all_rib()
{
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc = ".$this->id;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".$this->id;
$result = $this->db->query($sql);
if (!$result) {
$this->error++;