Fix must use differently FRST and SEPA
This commit is contained in:
parent
5f401839d6
commit
7c29bb5818
@ -60,6 +60,7 @@ class BonPrelevement extends CommonObject
|
|||||||
var $labelstatut=array();
|
var $labelstatut=array();
|
||||||
|
|
||||||
var $invoice_in_error=array();
|
var $invoice_in_error=array();
|
||||||
|
var $thirdparty_in_error=array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -756,17 +757,20 @@ class BonPrelevement extends CommonObject
|
|||||||
* @param int $banque dolibarr mysoc bank
|
* @param int $banque dolibarr mysoc bank
|
||||||
* @param int $agence dolibarr mysoc bank office (guichet)
|
* @param int $agence dolibarr mysoc bank office (guichet)
|
||||||
* @param string $mode real=do action, simu=test only
|
* @param string $mode real=do action, simu=test only
|
||||||
|
* @param string $format FRST, RCUR or ALL
|
||||||
* @return int <0 if KO, nbre of invoice withdrawed if OK
|
* @return int <0 if KO, nbre of invoice withdrawed if OK
|
||||||
*/
|
*/
|
||||||
function Create($banque=0, $agence=0, $mode='real')
|
function Create($banque=0, $agence=0, $mode='real', $format='ALL')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence, LOG_DEBUG);
|
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG);
|
||||||
|
|
||||||
require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||||
require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||||
|
|
||||||
|
if (empty($format)) return 'ErrorBadParametersForDirectDebitFileCreate';
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$datetimeprev = time();
|
$datetimeprev = time();
|
||||||
@ -776,9 +780,10 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
$puser = new User($this->db, $conf->global->PRELEVEMENT_USER);
|
$puser = new User($this->db, $conf->global->PRELEVEMENT_USER);
|
||||||
|
|
||||||
/*
|
$this->invoice_in_error = array();
|
||||||
* Read invoices
|
$this->thirdparty_in_error = array();
|
||||||
*/
|
|
||||||
|
// Read invoices
|
||||||
$factures = array();
|
$factures = array();
|
||||||
$factures_prev = array();
|
$factures_prev = array();
|
||||||
$factures_result = array();
|
$factures_result = array();
|
||||||
@ -851,6 +856,9 @@ class BonPrelevement extends CommonObject
|
|||||||
$bac = new CompanyBankAccount($this->db);
|
$bac = new CompanyBankAccount($this->db);
|
||||||
$bac->fetch(0, $soc->id);
|
$bac->fetch(0, $soc->id);
|
||||||
|
|
||||||
|
if ($format == 'FRST' && $bac->frstrecur != 'FRST') continue;
|
||||||
|
if ($format == 'RCUR' && $bac->frstrecur != 'RCUR') continue;
|
||||||
|
|
||||||
if ($bac->verif() >= 1)
|
if ($bac->verif() >= 1)
|
||||||
{
|
{
|
||||||
$factures_prev[$i] = $fac;
|
$factures_prev[$i] = $fac;
|
||||||
@ -890,13 +898,13 @@ class BonPrelevement extends CommonObject
|
|||||||
dol_syslog($out);
|
dol_syslog($out);
|
||||||
|
|
||||||
// Return warning
|
// Return warning
|
||||||
$i=0;
|
/*$i=0;
|
||||||
foreach ($this->thirdparty_in_error as $key => $val)
|
foreach ($this->thirdparty_in_error as $key => $val)
|
||||||
{
|
{
|
||||||
if ($i < 10) setEventMessages($val, null, 'warnings');
|
if ($i < 10) setEventMessages($val, null, 'warnings');
|
||||||
else setEventMessages('More error were discarded...', null, 'warnings');
|
else setEventMessages('More error were discarded...', null, 'warnings');
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (count($factures_prev) > 0)
|
if (count($factures_prev) > 0)
|
||||||
{
|
{
|
||||||
@ -1060,7 +1068,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$this->factures = $factures_prev_id;
|
$this->factures = $factures_prev_id;
|
||||||
|
|
||||||
// Generation of SEPA file $this->filename
|
// Generation of SEPA file $this->filename
|
||||||
$this->generate();
|
$this->generate($format);
|
||||||
}
|
}
|
||||||
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
|
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
|
||||||
}
|
}
|
||||||
@ -1255,14 +1263,16 @@ class BonPrelevement extends CommonObject
|
|||||||
* - Others countries: Warning message
|
* - Others countries: Warning message
|
||||||
* File is generated with name this->filename
|
* File is generated with name this->filename
|
||||||
*
|
*
|
||||||
* @return int 0 if OK, <0 if KO
|
* @param string $format FRST, RCUR or ALL
|
||||||
|
* @return int 0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
//TODO: Optimize code to read lines in a single function
|
function generate($format='ALL')
|
||||||
function generate()
|
|
||||||
{
|
{
|
||||||
global $conf,$langs,$mysoc;
|
global $conf,$langs,$mysoc;
|
||||||
|
|
||||||
$result = 0;
|
//TODO: Optimize code to read lines in a single function
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::generate build file ".$this->filename);
|
dol_syslog(get_class($this)."::generate build file ".$this->filename);
|
||||||
|
|
||||||
@ -1340,7 +1350,7 @@ class BonPrelevement extends CommonObject
|
|||||||
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf
|
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf
|
||||||
if ($result != -2)
|
if ($result != -2)
|
||||||
{
|
{
|
||||||
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf);
|
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1663,9 +1673,10 @@ class BonPrelevement extends CommonObject
|
|||||||
* @param int $nombre 0 or 1
|
* @param int $nombre 0 or 1
|
||||||
* @param float $total Total
|
* @param float $total Total
|
||||||
* @param string $CrLf End of line character
|
* @param string $CrLf End of line character
|
||||||
|
* @param string $format FRST or RCUR or ALL
|
||||||
* @return string String with SEPA Sender
|
* @return string String with SEPA Sender
|
||||||
*/
|
*/
|
||||||
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
|
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n', $format='FRST')
|
||||||
{
|
{
|
||||||
// SEPA INITIALISATION
|
// SEPA INITIALISATION
|
||||||
global $conf;
|
global $conf;
|
||||||
@ -1706,7 +1717,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$country = explode(':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY);
|
$country = explode(':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY);
|
||||||
$IdBon = sprintf("%05d", $obj->rowid);
|
$IdBon = sprintf("%05d", $obj->rowid);
|
||||||
$RefBon = $obj->ref;
|
$RefBon = $obj->ref;
|
||||||
$type = ($nombre == 1) ? 'FRST' : 'RCUR' ;
|
|
||||||
// SEPA Paiement Information
|
// SEPA Paiement Information
|
||||||
$XML_SEPA_INFO = '';
|
$XML_SEPA_INFO = '';
|
||||||
$XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;
|
$XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;
|
||||||
@ -1721,7 +1732,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf;
|
$XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf;
|
$XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf;
|
$XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <SeqTp>'.$type.'</SeqTp>'.$CrLf;
|
$XML_SEPA_INFO .= ' <SeqTp>'.$format.'</SeqTp>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf;
|
$XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <ReqdColltnDt>'.$dateTime_ETAD.'</ReqdColltnDt>'.$CrLf;
|
$XML_SEPA_INFO .= ' <ReqdColltnDt>'.$dateTime_ETAD.'</ReqdColltnDt>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <Cdtr>'.$CrLf;
|
$XML_SEPA_INFO .= ' <Cdtr>'.$CrLf;
|
||||||
|
|||||||
@ -45,6 +45,8 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
|||||||
|
|
||||||
// Get supervariables
|
// Get supervariables
|
||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
|
$mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real';
|
||||||
|
$format = GETPOST('format','alpha');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -63,7 +65,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
|
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
|
||||||
$bprev = new BonPrelevement($db);
|
$bprev = new BonPrelevement($db);
|
||||||
$result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET);
|
$result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
setEventMessages($bprev->error, $bprev->errors, 'errors');
|
setEventMessages($bprev->error, $bprev->errors, 'errors');
|
||||||
@ -76,7 +78,7 @@ if ($action == 'create')
|
|||||||
$mesg.='<br>'."\n";
|
$mesg.='<br>'."\n";
|
||||||
foreach($bprev->invoice_in_error as $key => $val)
|
foreach($bprev->invoice_in_error as $key => $val)
|
||||||
{
|
{
|
||||||
$mesg.=$val."<br>\n";
|
$mesg.='<span class="warning">'.$val."</span><br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -146,8 +148,30 @@ print "<div class=\"tabsAction\">\n";
|
|||||||
|
|
||||||
if ($nb)
|
if ($nb)
|
||||||
{
|
{
|
||||||
if ($pricetowithdraw) print '<a class="butAction" href="create.php?action=create">'.$langs->trans("CreateAll")."</a>\n";
|
if ($pricetowithdraw)
|
||||||
else print '<a class="butActionRefused" href="#">'.$langs->trans("CreateAll")."</a>\n";
|
{
|
||||||
|
if ($mysoc->isInEEC())
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="create.php?action=create&format=FRST">'.$langs->trans("CreateForSepaFRST")."</a>\n";
|
||||||
|
print '<a class="butAction" href="create.php?action=create&format=RCUR">'.$langs->trans("CreateForSepaRCUR")."</a>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="create.php?action=create&format=ALL">'.$langs->trans("CreateAll")."</a>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($mysoc->isInEEC())
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#">'.$langs->trans("CreateForSepaFRST")."</a>\n";
|
||||||
|
print '<a class="butActionRefused" href="#">'.$langs->trans("CreateForSepaRCUR")."</a>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#">'.$langs->trans("CreateAll")."</a>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -220,6 +244,8 @@ if ($resql)
|
|||||||
// RUM
|
// RUM
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $thirdpartystatic->display_rib('rum');
|
print $thirdpartystatic->display_rib('rum');
|
||||||
|
$format = $thirdpartystatic->display_rib('format');
|
||||||
|
if ($format) print ' ('.$format.')';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Amount
|
// Amount
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
|||||||
@ -55,7 +55,9 @@ StatusMotif5=RIB unusable
|
|||||||
StatusMotif6=Account without balance
|
StatusMotif6=Account without balance
|
||||||
StatusMotif7=Judicial Decision
|
StatusMotif7=Judicial Decision
|
||||||
StatusMotif8=Other reason
|
StatusMotif8=Other reason
|
||||||
CreateAll=Withdraw all
|
CreateForSepaFRST=Create direct debit file (SEPA FRST)
|
||||||
|
CreateForSepaRCUR=Create direct debit file (SEPA RCUR)
|
||||||
|
CreateAll=Create direct debit file (all)
|
||||||
CreateGuichet=Only office
|
CreateGuichet=Only office
|
||||||
CreateBanque=Only bank
|
CreateBanque=Only bank
|
||||||
OrderWaiting=Waiting for treatment
|
OrderWaiting=Waiting for treatment
|
||||||
|
|||||||
@ -2254,7 +2254,7 @@ class Societe extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Return bank number property of thirdparty (label or rum)
|
* Return bank number property of thirdparty (label or rum)
|
||||||
*
|
*
|
||||||
* @param string $mode 'label' or 'rum'
|
* @param string $mode 'label' or 'rum' or 'format'
|
||||||
* @return string Bank number
|
* @return string Bank number
|
||||||
*/
|
*/
|
||||||
function display_rib($mode='label')
|
function display_rib($mode='label')
|
||||||
@ -2279,6 +2279,10 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
return $bac->rum;
|
return $bac->rum;
|
||||||
}
|
}
|
||||||
|
elseif ($mode == 'format')
|
||||||
|
{
|
||||||
|
return $bac->frstrecur;
|
||||||
|
}
|
||||||
|
|
||||||
return 'BadParameterToFunctionDisplayRib';
|
return 'BadParameterToFunctionDisplayRib';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user