Debug credit transfer module
This commit is contained in:
parent
636f1e642d
commit
e256ce5c4b
@ -819,7 +819,7 @@ class BonPrelevement extends CommonObject
|
|||||||
* @param string $executiondate Date to execute the transfer
|
* @param string $executiondate Date to execute the transfer
|
||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @param string $type 'direct-debit' or 'bank-transfer'
|
* @param string $type 'direct-debit' or 'bank-transfer'
|
||||||
* @return int <0 if KO, nbre of invoice withdrawed if OK
|
* @return int <0 if KO, No of invoice included into file if OK
|
||||||
*/
|
*/
|
||||||
public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit')
|
public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit')
|
||||||
{
|
{
|
||||||
@ -831,7 +831,12 @@ class BonPrelevement extends CommonObject
|
|||||||
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';
|
if ($type != 'bank-transfer') {
|
||||||
|
if (empty($format)) {
|
||||||
|
$this->error = 'ErrorBadParametersForDirectDebitFileCreate';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
@ -1091,6 +1096,7 @@ class BonPrelevement extends CommonObject
|
|||||||
// Fetch invoice
|
// Fetch invoice
|
||||||
$fact = new Facture($this->db);
|
$fact = new Facture($this->db);
|
||||||
$fact->fetch($fac[0]);
|
$fact->fetch($fac[0]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add standing order
|
* Add standing order
|
||||||
*
|
*
|
||||||
@ -1163,14 +1169,15 @@ class BonPrelevement extends CommonObject
|
|||||||
$this->context['factures_prev'] = $factures_prev;
|
$this->context['factures_prev'] = $factures_prev;
|
||||||
|
|
||||||
// Generation of SEPA file $this->filename
|
// Generation of SEPA file $this->filename
|
||||||
$result = $this->generate($format, $executiondate);
|
// This also the the property $this->total that is included into file
|
||||||
|
$result = $this->generate($format, $executiondate, $type);
|
||||||
}
|
}
|
||||||
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
|
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
|
||||||
}
|
}
|
||||||
//var_dump($factures_prev);exit;
|
//var_dump($factures_prev);exit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update total
|
* Update total defined after generation of file
|
||||||
*/
|
*/
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
|
||||||
$sql .= " SET amount = ".price2num($this->total);
|
$sql .= " SET amount = ".price2num($this->total);
|
||||||
@ -1455,7 +1462,7 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a withdrawal file.
|
* Generate a direct debit or credit transfer file.
|
||||||
* Generation Formats:
|
* Generation Formats:
|
||||||
* - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled)
|
* - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled)
|
||||||
* - Others countries: Warning message
|
* - Others countries: Warning message
|
||||||
@ -1463,9 +1470,10 @@ class BonPrelevement extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $format FRST, RCUR or ALL
|
* @param string $format FRST, RCUR or ALL
|
||||||
* @param string $executiondate Date to execute transfer
|
* @param string $executiondate Date to execute transfer
|
||||||
|
* @param string $type 'direct-debit' or 'credit-transfer'
|
||||||
* @return int >=0 if OK, <0 if KO
|
* @return int >=0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function generate($format = 'ALL', $executiondate = '')
|
public function generate($format = 'ALL', $executiondate = '', $type = 'direct-debit')
|
||||||
{
|
{
|
||||||
global $conf, $langs, $mysoc;
|
global $conf, $langs, $mysoc;
|
||||||
|
|
||||||
@ -1473,7 +1481,7 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::generate build file ".$this->filename);
|
dol_syslog(get_class($this)."::generate build file=".$this->filename." type=".$type);
|
||||||
|
|
||||||
$this->file = fopen($this->filename, "w");
|
$this->file = fopen($this->filename, "w");
|
||||||
if (empty($this->file))
|
if (empty($this->file))
|
||||||
@ -1483,12 +1491,17 @@ class BonPrelevement extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$found = 0;
|
$found = 0;
|
||||||
|
$this->total = 0;
|
||||||
|
|
||||||
// Build file for European countries
|
// Build file for European countries
|
||||||
if ($mysoc->isInEEC())
|
if ($mysoc->isInEEC())
|
||||||
{
|
{
|
||||||
$found++;
|
$found++;
|
||||||
|
|
||||||
|
if ($type == 'bank-transfer') {
|
||||||
|
print 'TODO';
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
/**
|
/**
|
||||||
* SECTION CREATION FICHIER SEPA
|
* SECTION CREATION FICHIER SEPA
|
||||||
*/
|
*/
|
||||||
@ -1507,7 +1520,6 @@ class BonPrelevement extends CommonObject
|
|||||||
$fileDebiteurSection = '';
|
$fileDebiteurSection = '';
|
||||||
$fileEmetteurSection = '';
|
$fileEmetteurSection = '';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$this->total = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Section Debitor (sepa Debiteurs bloc lines)
|
* Section Debitor (sepa Debiteurs bloc lines)
|
||||||
@ -1599,11 +1611,42 @@ class BonPrelevement extends CommonObject
|
|||||||
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
|
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
|
||||||
fputs($this->file, '</Document>'.$CrLf);
|
fputs($this->file, '</Document>'.$CrLf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build file for Other Countries with unknow format
|
// Build file for Other Countries with unknow format
|
||||||
if (!$found)
|
if (!$found)
|
||||||
{
|
{
|
||||||
$this->total = 0;
|
if ($type == 'bank-transfer') {
|
||||||
|
$sql = "SELECT pl.amount";
|
||||||
|
$sql .= " FROM";
|
||||||
|
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
|
||||||
|
$sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
|
||||||
|
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
||||||
|
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
|
||||||
|
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
|
||||||
|
$sql .= " AND pf.fk_facture_fourn = f.rowid";
|
||||||
|
|
||||||
|
// Lines
|
||||||
|
$i = 0;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$this->total = $this->total + $obj->amount;
|
||||||
|
|
||||||
|
// TODO Write record into file
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = -2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$sql = "SELECT pl.amount";
|
$sql = "SELECT pl.amount";
|
||||||
$sql .= " FROM";
|
$sql .= " FROM";
|
||||||
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
|
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
|
||||||
@ -1624,6 +1667,8 @@ class BonPrelevement extends CommonObject
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$this->total = $this->total + $obj->amount;
|
$this->total = $this->total + $obj->amount;
|
||||||
|
|
||||||
|
// TODO Write record into file
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1631,6 +1676,7 @@ class BonPrelevement extends CommonObject
|
|||||||
{
|
{
|
||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$langs->load('withdrawals');
|
$langs->load('withdrawals');
|
||||||
|
|
||||||
|
|||||||
@ -191,7 +191,8 @@ print '<input type="hidden" name="type" value="'.$type.'">';
|
|||||||
if ($nb) {
|
if ($nb) {
|
||||||
if ($pricetowithdraw) {
|
if ($pricetowithdraw) {
|
||||||
print $langs->trans('ExecutionDate').' ';
|
print $langs->trans('ExecutionDate').' ';
|
||||||
print $form->selectDate();
|
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||||
|
print $form->selectDate($datere, 're');
|
||||||
|
|
||||||
if ($mysoc->isInEEC()) {
|
if ($mysoc->isInEEC()) {
|
||||||
$title = $langs->trans("CreateForSepa");
|
$title = $langs->trans("CreateForSepa");
|
||||||
@ -200,7 +201,10 @@ if ($nb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($type != 'bank-transfer') {
|
if ($type != 'bank-transfer') {
|
||||||
print '<select name="format"><option value="FRST">'.$langs->trans('SEPAFRST').'</option><option value="RCUR">'.$langs->trans('SEPARCUR').'</option></select>';
|
print '<select name="format">';
|
||||||
|
print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
|
||||||
|
print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
|
||||||
|
print '</select>';
|
||||||
}
|
}
|
||||||
print '<input class="butAction" type="submit" value="'.$title.'"/>';
|
print '<input class="butAction" type="submit" value="'.$title.'"/>';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user