forked from Wavyzz/dolibarr
NEW: ICS fields moved into bank account table
This commit is contained in:
@@ -71,10 +71,10 @@ if ($action == "set")
|
||||
if (! $res > 0) $error++;
|
||||
*/
|
||||
} else $error++;
|
||||
|
||||
/* Moved to account
|
||||
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ICS", GETPOST("PAYMENTBYBANKTRANSFER_ICS"), 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
*/
|
||||
if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0)
|
||||
{
|
||||
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity);
|
||||
@@ -156,11 +156,13 @@ print '<td class="left">';
|
||||
$form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1);
|
||||
print '</td></tr>';
|
||||
|
||||
/* Moved to bank account data
|
||||
// ICS
|
||||
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ICS").'</td>';
|
||||
print '<td class="left">';
|
||||
print '<input type="text" name="PAYMENTBYBANKTRANSFER_ICS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.'" size="15" ></td>';
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
//User
|
||||
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';
|
||||
|
||||
@@ -70,11 +70,14 @@ if ($action == "set")
|
||||
$res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
*/
|
||||
|
||||
} else $error++;
|
||||
|
||||
/* Moved to account
|
||||
|
||||
$res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity);
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
*/
|
||||
if (GETPOST("PRELEVEMENT_USER") > 0)
|
||||
{
|
||||
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity);
|
||||
@@ -149,13 +152,16 @@ print '<td class="titlefieldcreate">'.$langs->trans("Parameter").'</td>';
|
||||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print "</tr>";
|
||||
|
||||
|
||||
// Bank account (from Banks module)
|
||||
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("BankToReceiveWithdraw").'</td>';
|
||||
print '<td class="left">';
|
||||
$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1);
|
||||
print '</td></tr>';
|
||||
|
||||
/* Moved to bank account data
|
||||
// ICS
|
||||
|
||||
print '<tr class="oddeven"><td class="fieldrequired">';
|
||||
$htmltext = $langs->trans("AskThisIDToYourBank");
|
||||
print $form->textwithpicto($langs->trans("ICS"), $htmltext);
|
||||
@@ -164,6 +170,7 @@ print '<td class="left">';
|
||||
print '<input type="text" name="PRELEVEMENT_ICS" value="'.$conf->global->PRELEVEMENT_ICS.'" size="15" >';
|
||||
print '</td>';
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
//User
|
||||
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';
|
||||
|
||||
@@ -94,6 +94,9 @@ if ($action == 'add')
|
||||
|
||||
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
|
||||
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
|
||||
|
||||
$object->ics = trim($_POST["ics"]);
|
||||
$object->ics_transfer = trim($_POST["ics_transfer"]);
|
||||
|
||||
$account_number = GETPOST('account_number', 'alphanohtml');
|
||||
if (empty($account_number) || $account_number == '-1')
|
||||
@@ -195,6 +198,9 @@ if ($action == 'update')
|
||||
|
||||
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
|
||||
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
|
||||
|
||||
$object->ics = trim($_POST["ics"]);
|
||||
$object->ics_transfer = trim($_POST["ics_transfer"]);
|
||||
|
||||
$account_number = GETPOST('account_number', 'alpha');
|
||||
if (empty($account_number) || $account_number == '-1')
|
||||
@@ -730,6 +736,14 @@ if ($action == 'create')
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ICS").'</td>';
|
||||
print '<td>'.$object->ics.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ICSTransfer").'</td>';
|
||||
print '<td>'.$object->ics_transfer.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
|
||||
print nl2br($object->domiciliation);
|
||||
@@ -1010,7 +1024,13 @@ if ($action == 'create')
|
||||
|
||||
print '<tr><td>'.$langs->trans($bickey).'</td>';
|
||||
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.$object->bic.'"></td></tr>';
|
||||
|
||||
|
||||
print '<tr><td>'.$langs->trans("ICS").'</td>';
|
||||
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="ics" value="'.$object->ics.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ICSTransfer").'</td>';
|
||||
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="ics_transfer" value="'.$object->ics_transfer.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
|
||||
print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
|
||||
print $object->domiciliation;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -213,6 +214,14 @@ class Account extends CommonObject
|
||||
* @var int
|
||||
*/
|
||||
public $date_solde;
|
||||
|
||||
/**
|
||||
* Creditor Identifier CI and Transfer ICS. Some banks use different ICS for direct debit and bank tranfer
|
||||
* @var string
|
||||
*/
|
||||
public $ics;
|
||||
public $ics_transfer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -652,6 +661,8 @@ class Account extends CommonObject
|
||||
$sql .= ", comment";
|
||||
$sql .= ", state_id";
|
||||
$sql .= ", fk_pays";
|
||||
$sql .= ", ics";
|
||||
$sql .= ", ics_transfer";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->idate($now)."'";
|
||||
$sql .= ", '".$this->db->escape($this->ref)."'";
|
||||
@@ -676,6 +687,8 @@ class Account extends CommonObject
|
||||
$sql .= ", '".$this->db->escape($this->comment)."'";
|
||||
$sql .= ", ".($this->state_id > 0 ? $this->state_id : "null");
|
||||
$sql .= ", ".$this->country_id;
|
||||
$sql .= ", ".$this->db->escape($this->ics);
|
||||
$sql .= ", ".$this->db->escape($this->ics_transfer);
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
@@ -804,6 +817,8 @@ class Account extends CommonObject
|
||||
|
||||
$sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null");
|
||||
$sql .= ",fk_pays = ".$this->country_id;
|
||||
$sql .= ",ics='".$this->db->escape($this->ics)."'";
|
||||
$sql .= ",ics_transfer='".$this->db->escape($this->ics_transfer)."'";
|
||||
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
@@ -922,7 +937,7 @@ class Account extends CommonObject
|
||||
$sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
|
||||
$sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
|
||||
$sql .= " ba.min_allowed, ba.min_desired, ba.comment,";
|
||||
$sql .= " ba.datec as date_creation, ba.tms as date_update,";
|
||||
$sql .= " ba.datec as date_creation, ba.tms as date_update, ba.ics, ba.ics_transfer,";
|
||||
$sql .= ' c.code as country_code, c.label as country,';
|
||||
$sql .= ' d.code_departement as state_code, d.nom as state';
|
||||
$sql .= ' , aj.code as accountancy_journal';
|
||||
@@ -983,6 +998,9 @@ class Account extends CommonObject
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->date_update = $this->db->jdate($obj->date_update);
|
||||
|
||||
$this->ics = $obj->ics;
|
||||
$this->ics_transfer = $obj->ics_transfer;
|
||||
|
||||
// Retrieve all extrafield
|
||||
// fetch optionals attributes and labels
|
||||
|
||||
@@ -55,7 +55,7 @@ $result = restrictedArea($user, 'paymentbybanktransfer', '', '');
|
||||
|
||||
llxHeader('', $langs->trans("SuppliersStandingOrdersArea"));
|
||||
|
||||
if (prelevement_check_config() < 0)
|
||||
if (prelevement_check_config('bank-transfer') < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -1154,7 +1155,7 @@ class BonPrelevement extends CommonObject
|
||||
$this->emetteur_iban = $account->iban;
|
||||
$this->emetteur_bic = $account->bic;
|
||||
|
||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||
$this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics);
|
||||
|
||||
$this->raison_sociale = $account->proprio;
|
||||
}
|
||||
@@ -1585,7 +1586,7 @@ class BonPrelevement extends CommonObject
|
||||
fputs($this->file, ' <Id>'.$CrLf);
|
||||
fputs($this->file, ' <PrvtId>'.$CrLf);
|
||||
fputs($this->file, ' <Othr>'.$CrLf);
|
||||
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
|
||||
fputs($this->file, ' <Id>'.$this->emetteur_ics.'</Id>'.$CrLf);
|
||||
fputs($this->file, ' </Othr>'.$CrLf);
|
||||
fputs($this->file, ' </PrvtId>'.$CrLf);
|
||||
fputs($this->file, ' </Id>'.$CrLf);
|
||||
@@ -2126,7 +2127,7 @@ class BonPrelevement extends CommonObject
|
||||
$this->emetteur_iban = $account->iban;
|
||||
$this->emetteur_bic = $account->bic;
|
||||
|
||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||
$this->emetteur_ics = $account->ics; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||
|
||||
$this->raison_sociale = $account->proprio;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ $type = GETPOST('type', 'aZ09');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
|
||||
$format = GETPOST('format', 'aZ09');
|
||||
$id_bankaccount = GETPOST ( 'id_bankaccount','int' );
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
@@ -77,11 +78,28 @@ if (empty($reshook))
|
||||
}
|
||||
if ($action == 'create')
|
||||
{
|
||||
$default_account=($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
|
||||
|
||||
if($id_bankaccount != $conf->global->{$default_account}){
|
||||
$res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default
|
||||
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$bank = new Account($db);
|
||||
$bank->fetch($conf->global->{$default_account});
|
||||
if (empty($bank->ics) || empty($bank->ics_transfer)){
|
||||
setEventMessages($langs->trans("ErrorICSmissing", $bank->getNomUrl(1)), null, 'errors');
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$delayindays = 0;
|
||||
if ($type != 'bank-transfer') {
|
||||
$conf->global->PRELEVEMENT_ADDDAYS;
|
||||
$delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
|
||||
} else {
|
||||
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
|
||||
$delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
|
||||
}
|
||||
$bprev = new BonPrelevement($db);
|
||||
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
|
||||
@@ -128,12 +146,13 @@ $bprev = new BonPrelevement($db);
|
||||
|
||||
llxHeader('', $langs->trans("NewStandingOrder"));
|
||||
|
||||
if (prelevement_check_config() < 0)
|
||||
if (prelevement_check_config($type) < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php';
|
||||
$head[$h][1] = $langs->trans("NewStandingOrder");
|
||||
@@ -188,10 +207,16 @@ print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
if ($nb) {
|
||||
if ($pricetowithdraw) {
|
||||
print $langs->trans('ExecutionDate').' ';
|
||||
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
print $form->selectDate($datere, 're');
|
||||
|
||||
if ($pricetowithdraw) {
|
||||
print $langs->trans('BankToReceiveWithdraw').': ';
|
||||
$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1");
|
||||
print ' - ';
|
||||
|
||||
print $langs->trans('ExecutionDate').' ';
|
||||
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
print $form->selectDate($datere, 're');
|
||||
|
||||
|
||||
if ($mysoc->isInEEC()) {
|
||||
$title = $langs->trans("CreateForSepa");
|
||||
|
||||
@@ -78,13 +78,21 @@ function prelevement_prepare_head(BonPrelevement $object)
|
||||
/**
|
||||
* Check need data to create standigns orders receipt file
|
||||
*
|
||||
* @param string $type 'bank-transfer' or 'direct-debit'
|
||||
*
|
||||
* @return int -1 if ko 0 if ok
|
||||
*/
|
||||
function prelevement_check_config()
|
||||
function prelevement_check_config($type='direct-debit')
|
||||
{
|
||||
global $conf;
|
||||
if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
|
||||
if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
|
||||
if (empty($conf->global->PRELEVEMENT_USER)) return -1;
|
||||
global $conf, $db;
|
||||
if ($type == 'bank-transfer'){
|
||||
if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1;
|
||||
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
|
||||
if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1;
|
||||
}else{
|
||||
if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
|
||||
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
|
||||
if (empty($conf->global->PRELEVEMENT_USER)) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
|
||||
$posY += 2;
|
||||
$pdf->SetXY($this->marge_gauche, $posY);
|
||||
$ics = '';
|
||||
if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS;
|
||||
if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS;
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").') : '.$ics, 0, 'L');
|
||||
|
||||
$posY = $pdf->GetY();
|
||||
|
||||
@@ -131,7 +131,8 @@ SEPARCUR=SEPA CUR
|
||||
SEPAFRST=SEPA FRST
|
||||
ExecutionDate=Execution date
|
||||
CreateForSepa=Create direct debit file
|
||||
ICS=Creditor Identifier CI
|
||||
ICS=Creditor Identifier CI for direct debit
|
||||
ICSTransfer=Creditor Identifier CI for bank transfer
|
||||
END_TO_END="EndToEndId" SEPA XML tag - Unique id assigned per transaction
|
||||
USTRD="Unstructured" SEPA XML tag
|
||||
ADDDAYS=Add days to Execution Date
|
||||
@@ -145,4 +146,5 @@ InfoTransData=Amount: %s<br>Method: %s<br>Date: %s
|
||||
InfoRejectSubject=Direct debit payment order refused
|
||||
InfoRejectMessage=Hello,<br><br>the direct debit payment order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.<br><br>--<br>%s
|
||||
ModeWarning=Option for real mode was not set, we stop after this simulation
|
||||
ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use.
|
||||
ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use.
|
||||
ErrorICSmissing=Missing ICS in Bank account %s
|
||||
Reference in New Issue
Block a user