diff --git a/dev/resources/sepa/sample-credit-transfer.xml b/dev/resources/sepa/sample-credit-transfer.xml
new file mode 100644
index 00000000000..087fd2f57d7
--- /dev/null
+++ b/dev/resources/sepa/sample-credit-transfer.xml
@@ -0,0 +1,172 @@
+
+
+
+
+ message-id-001
+ 2010-09-28T14:07:00
+ 1
+ 10.1
+
+ Bedrijfsnaam
+
+
+
+ 123456789123456
+
+
+
+
+
+
+ minimaal gevuld
+ TRF
+ 1
+ 10.1
+ 2009-11-01
+
+ Naam
+
+
+
+ NL44RABO0123456789
+
+
+
+
+ RABONL2U
+
+
+
+
+ non ref
+
+
+ 10.1
+
+ SLEV
+
+
+ ABNANL2A
+
+
+
+ Naam creditor
+
+
+
+ NL90ABNA0111111111
+
+
+
+ vrije tekst
+
+
+
+
+ maximaal gevuld
+ TRF
+ true
+ 1
+ 20.2
+
+ NORM
+
+ SEPA
+
+
+ IDEAL
+
+
+ SECU
+
+
+ 2009-11-01
+
+ Naam
+
+ NL
+ Debtor straat 1
+ 9999 XX Plaats debtor
+
+
+
+
+ NL44RABO0123456789
+
+
+
+
+ RABONL2U
+
+
+
+
+
+
+ 12345678
+
+ klantnummer
+
+ klantnummer uitgifte instantie
+
+
+
+
+ SLEV
+
+
+ debtor-to-debtor-bank-01
+ End-to-end-id-debtor-to-creditor-01
+
+
+ 20.2
+
+
+
+ ABNANL2A
+
+
+
+ Naam creditor
+
+ NL
+ Straat creditor 1
+ 9999 XX Plaats creditor
+
+
+
+
+ NL90ABNA0111111111
+
+
+
+
+
+
+ 1969-07-03
+ PLAATS
+ NL
+
+
+
+
+
+ CHAR
+
+
+
+
+
+
+ SCOR
+
+ CUR
+
+ [1234567]
+
+
+
+
+
+
+
diff --git a/dev/resources/sepa/test.xml b/dev/resources/sepa/sample-direct-debit.xml
similarity index 100%
rename from dev/resources/sepa/test.xml
rename to dev/resources/sepa/sample-direct-debit.xml
diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php
index 1fc6c53cf99..79bb2f6e7fb 100644
--- a/htdocs/compta/paymentbybanktransfer/index.php
+++ b/htdocs/compta/paymentbybanktransfer/index.php
@@ -94,7 +94,7 @@ print ' ';
*/
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql .= " pfd.date_demande, pfd.amount,";
-$sql .= " s.nom as name, s.email, s.rowid as socid";
+$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -138,13 +138,14 @@ if ($resql)
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
+ $thirdpartystatic->tva_intra = $obj->tva_intra;
print '
';
print $invoicestatic->getNomUrl(1, 'withdraw');
print ' ';
print '';
- print $thirdpartystatic->getNomUrl(1, 'customer');
+ print $thirdpartystatic->getNomUrl(1, 'supplier');
print ' ';
print '';
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index 3ad145e2f56..23b6fdac500 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -31,10 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'bills', 'withdrawals'));
-
-if (!$user->rights->prelevement->bons->lire)
-accessforbidden();
+$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Security check
if ($user->socid > 0) accessforbidden();
@@ -44,7 +41,6 @@ $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
-
$type = GETPOST('type', 'aZ09');
// Load variable for pagination
@@ -67,6 +63,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+ accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+ accessforbidden();
+}
+
/*
* Actions
@@ -174,7 +177,7 @@ if ($id > 0 || $ref)
}*/
- $linkback = ''.$langs->trans("BackToList").' ';
+ $linkback = ''.$langs->trans("BackToList").' ';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@@ -200,7 +203,7 @@ if ($id > 0 || $ref)
print ' '.$langs->trans("TransData").' ';
print dol_print_date($object->date_trans, 'day');
- print ' '.$langs->trans("By").' '.$muser->getFullName($langs).' ';
+ print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'';
print ''.$langs->trans("TransMetod").' ';
print $object->methodes_trans[$object->method_trans];
print ' ';
@@ -223,7 +226,9 @@ if ($id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '';
- print $langs->trans("BankToReceiveWithdraw");
+ $labelofbankfield = "BankToReceiveWithdraw";
+ if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+ print $langs->trans($labelofbankfield);
print ' ';
print '';
if ($acc->id > 0)
@@ -232,9 +237,13 @@ if ($id > 0 || $ref)
print ' ';
print '';
- print $langs->trans("WithdrawalFile").' ';
+ $labelfororderfield = 'WithdrawalFile';
+ if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+ print $langs->trans($labelfororderfield).' ';
$relativepath = 'receipts/'.$object->ref.'.xml';
- print ''.$relativepath.' ';
+ $modulepart = 'prelevement';
+ if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+ print ''.$relativepath.' ';
print ' ';
print '';
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 8cf77667a62..29c70ba8fab 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -295,6 +295,7 @@ class BonPrelevement extends CommonObject
$sql .= ", p.method_trans, p.fk_user_trans";
$sql .= ", p.date_credit as date_credit";
$sql .= ", p.fk_user_credit";
+ $sql .= ", p.type";
$sql .= ", p.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.entity IN (".getEntity('invoice').")";
@@ -322,6 +323,8 @@ class BonPrelevement extends CommonObject
$this->date_credit = $this->db->jdate($obj->date_credit);
$this->user_credit = $obj->fk_user_credit;
+ $this->type = $obj->type;
+
$this->status = $obj->status;
$this->statut = $obj->status; // For backward compatibility
@@ -930,14 +933,14 @@ class BonPrelevement extends CommonObject
foreach ($factures as $key => $fac)
{
if ($type != 'bank-transfer') {
- $fact = new Facture($this->db);
+ $tmpinvoice = new Facture($this->db);
} else {
- $fact = new FactureFournisseur($this->db);
+ $tmpinvoice = new FactureFournisseur($this->db);
}
- $resfetch = $fact->fetch($fac[0]);
+ $resfetch = $tmpinvoice->fetch($fac[0]);
if ($resfetch >= 0) // Field 0 of $fac is rowid of invoice
{
- if ($soc->fetch($fact->socid) >= 0)
+ if ($soc->fetch($tmpinvoice->socid) >= 0)
{
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0, $soc->id);
@@ -963,9 +966,9 @@ class BonPrelevement extends CommonObject
}
else
{
- dol_syslog(__METHOD__."::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING);
- $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
- $this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
+ dol_syslog(__METHOD__."::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$tmpinvoice->socid." ".$soc->name, LOG_WARNING);
+ $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
+ $this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
}
}
else
@@ -1142,7 +1145,7 @@ class BonPrelevement extends CommonObject
* Create file of direct debit order or credit transfer into a XML file
*/
- dol_syslog(__METHOD__."::Init direct debit file for ".count($factures_prev)." invoices", LOG_DEBUG);
+ dol_syslog(__METHOD__."::Init direct debit or credit transfer file for ".count($factures_prev)." invoices", LOG_DEBUG);
if (count($factures_prev) > 0)
{
@@ -1168,8 +1171,8 @@ class BonPrelevement extends CommonObject
$this->factures = $factures_prev_id;
$this->context['factures_prev'] = $factures_prev;
- // Generation of SEPA file $this->filename
- // This also the the property $this->total that is included into file
+ // Generation of direct debit or credti transfer file $this->filename (May be a SEPA file for european countries)
+ // This also set the property $this->total with amount that is included into file
$result = $this->generate($format, $executiondate, $type);
}
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
@@ -1499,8 +1502,110 @@ class BonPrelevement extends CommonObject
$found++;
if ($type == 'bank-transfer') {
- print 'TODO';
- exit;
+ /**
+ * SECTION CREATION FICHIER SEPA - CREDIT TRANSFER
+ */
+ // SEPA Initialisation
+ $CrLf = "\n";
+
+ $now = dol_now();
+
+ $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
+
+ $date_actu = $now;
+ if (!empty($executiondate)) $date_actu = $executiondate;
+
+ $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
+ $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
+ $fileCrediteurSection = '';
+ $fileEmetteurSection = '';
+ $i = 0;
+
+ /*
+ * Section Creditor (sepa Crediteurs bloc lines)
+ */
+
+ $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
+ $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
+ $sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
+ $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 .= " ".MAIN_DB_PREFIX."societe as soc,";
+ $sql .= " ".MAIN_DB_PREFIX."c_country as c,";
+ $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
+ $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
+ $sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
+ $sql .= " AND pf.fk_facture_fourn = f.rowid";
+ $sql .= " AND soc.fk_pays = c.rowid";
+ $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 $fileCrediteurSection. One section DrctDbtTxInf per invoice.
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
+ $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
+ $this->total = $this->total + $obj->somme;
+ $i++;
+ }
+ $nbtotalDrctDbtTxInf = $i;
+ }
+ else
+ {
+ fputs($this->file, 'ERROR CREDITOR '.$sql.$CrLf); // CREDITORS = Suppliers
+ $result = -2;
+ }
+
+ // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
+ if ($result != -2)
+ {
+ $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
+ }
+
+ /**
+ * SECTION CREATION SEPA FILE - CREDTI TRANSFER - ISO200022
+ */
+ // SEPA File Header
+ fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
+ fputs($this->file, ''.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ // SEPA Group header
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.('CREDTRANS'.$dateTime_YMD.'/REF'.$this->id).' '.$CrLf);
+ fputs($this->file, ' '.$dateTime_ECMA.' '.$CrLf);
+ fputs($this->file, ' '.$i.' '.$CrLf);
+ fputs($this->file, ' '.$this->total.' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ // SEPA File Emetteur (mycompany)
+ if ($result != -2)
+ { fputs($this-> file, $fileEmetteurSection); }
+ // SEPA File Creditors
+ if ($result != -2)
+ { fputs($this-> file, $fileCrediteurSection); }
+ // SEPA FILE FOOTER
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
+ fputs($this->file, ' '.$CrLf);
} else {
/**
* SECTION CREATION FICHIER SEPA
@@ -1566,18 +1671,14 @@ class BonPrelevement extends CommonObject
$result = -2;
}
- // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf
+ // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
if ($result != -2)
{
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
}
- else
- {
- fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company
- }
/**
- * SECTION CREATION SEPA FILE
+ * SECTION CREATION SEPA FILE - ISO200022
*/
// SEPA File Header
fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index ff25af5e0e9..fdbb6189c5c 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -104,7 +104,11 @@ if (empty($reshook))
}
else
{
- setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+ if ($type != 'bank-transfer') {
+ setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+ } else {
+ setEventMessages($langs->trans("CreditTransferOrderCreated", $bprev->getNomUrl(1)), null);
+ }
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id);
exit;
diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php
index b92df4e446c..2d2be116aaf 100644
--- a/htdocs/compta/prelevement/demandes.php
+++ b/htdocs/compta/prelevement/demandes.php
@@ -192,6 +192,14 @@ print ' ';
$param = '';
+$label = 'NewStandingOrder';
+$typefilter = '';
+if ($type == 'bank-transfer') {
+ $label = 'NewPaymentByBankTransfer';
+ $typefilter = 'type='.$type;
+}
+$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'.($typefilter ? '?'.$typefilter : ''));
+
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
print '';
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 556f40de9be..816795bfdbd 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -32,21 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'companies', 'withdrawals', 'bills'));
+$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Securite acces client
if ($user->socid > 0) accessforbidden();
// Get supervariables
$id = GETPOST('id', 'int');
-$socid = GETPOST('socid', 'int');
$ref = GETPOST('ref', 'alpha');
-
+$socid = GETPOST('socid', 'int');
$type = GETPOST('type', 'aZ09');
+// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
@@ -57,6 +57,17 @@ if (!$sortorder) $sortorder = 'DESC';
$object = new BonPrelevement($db);
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
+
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+ accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+ accessforbidden();
+}
/*
@@ -75,19 +86,17 @@ if ($id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
- $linkback = ''.$langs->trans("BackToList").' ';
+ $linkback = ''.$langs->trans("BackToList").' ';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
print '';
print '
';
- print '
';
+ print ''."\n";
//print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
print ''.$langs->trans("Amount").' '.price($object->amount).' ';
- // Status
- //print ''.$langs->trans('Status').' '.$object->getLibStatut(1).' ';
if ($object->date_trans <> 0)
{
@@ -119,7 +128,9 @@ if ($id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '';
- print $langs->trans("BankToReceiveWithdraw");
+ $labelofbankfield = "BankToReceiveWithdraw";
+ if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+ print $langs->trans($labelofbankfield);
print ' ';
print '';
if ($acc->id > 0)
@@ -128,9 +139,13 @@ if ($id > 0 || $ref)
print ' ';
print '';
- print $langs->trans("WithdrawalFile").' ';
+ $labelfororderfield = 'WithdrawalFile';
+ if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+ print $langs->trans($labelfororderfield).' ';
$relativepath = 'receipts/'.$object->ref.'.xml';
- print ''.$relativepath.' ';
+ $modulepart = 'prelevement';
+ if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+ print ''.$relativepath.' ';
print '
';
print '';
@@ -151,13 +166,25 @@ $sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_reques
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
-$sql .= ", ".MAIN_DB_PREFIX."facture as f";
+if ($object->type != 'bank-transfer') {
+ $sql .= ", ".MAIN_DB_PREFIX."facture as f";
+} else {
+ $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
+}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid";
-$sql .= " AND pf.fk_facture = f.rowid";
-$sql .= " AND f.entity IN (".getEntity('invoice').")";
+if ($object->type != 'bank-transfer') {
+ $sql .= " AND pf.fk_facture = f.rowid";
+} else {
+ $sql .= " AND pf.fk_facture_fourn = f.rowid";
+}
+if ($object->type != 'bank-transfer') {
+ $sql .= " AND f.entity IN (".getEntity('invoice').")";
+} else {
+ $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
+}
if ($object->id > 0) $sql .= " AND p.rowid=".$object->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= $db->order($sortfield, $sortorder);
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index 75cff74da8a..10abbcf5166 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/compta/prelevement/fiche-rejet.php
* \ingroup prelevement
- * \brief Withdraw reject
+ * \brief Debit order or credit transfer reject
*/
require '../../main.inc.php';
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
-// Securite acces client
+// Security check
if ($user->socid > 0) accessforbidden();
// Get supervariables
@@ -55,6 +55,15 @@ $pagenext = $page + 1;
$object = new BonPrelevement($db);
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+ accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+ accessforbidden();
+}
@@ -71,7 +80,7 @@ if ($prev_id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
- $linkback = ''.$langs->trans("BackToList").' ';
+ $linkback = ''.$langs->trans("BackToList").' ';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@@ -83,13 +92,6 @@ if ($prev_id > 0 || $ref)
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
print ''.$langs->trans("Amount").' '.price($object->amount).' ';
- // Status
- /*
- print ''.$langs->trans('Status').' ';
- print ''.$object->getLibStatut(1).' ';
- print ' ';
- */
-
if ($object->date_trans <> 0)
{
$muser = new User($db);
@@ -120,7 +122,9 @@ if ($prev_id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '';
- print $langs->trans("BankToReceiveWithdraw");
+ $labelofbankfield = "BankToReceiveWithdraw";
+ if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+ print $langs->trans($labelofbankfield);
print ' ';
print '';
if ($acc->id > 0)
@@ -129,9 +133,13 @@ if ($prev_id > 0 || $ref)
print ' ';
print '';
- print $langs->trans("WithdrawalFile").' ';
+ $labelfororderfield = 'WithdrawalFile';
+ if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+ print $langs->trans($labelfororderfield).' ';
$relativepath = 'receipts/'.$object->ref.'.xml';
- print ''.$relativepath.' ';
+ $modulepart = 'prelevement';
+ if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+ print ''.$relativepath.' ';
print '
';
print '
';
@@ -144,6 +152,7 @@ if ($prev_id > 0 || $ref)
}
}
+
$rej = new RejetPrelevement($db, $user);
/*
diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php
index 899ff69fea1..49508cdde46 100644
--- a/htdocs/compta/prelevement/fiche-stat.php
+++ b/htdocs/compta/prelevement/fiche-stat.php
@@ -20,7 +20,7 @@
/**
* \file htdocs/compta/prelevement/fiche-stat.php
* \ingroup prelevement
- * \brief Prelevement statistics
+ * \brief Debit order or credit transfer statistics
*/
require '../../main.inc.php';
@@ -54,6 +54,17 @@ $pagenext = $page + 1;
$object = new BonPrelevement($db);
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+ accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+ accessforbidden();
+}
+
+
/*
* View
@@ -68,7 +79,7 @@ if ($prev_id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
- $linkback = ''.$langs->trans("BackToList").' ';
+ $linkback = ''.$langs->trans("BackToList").' ';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@@ -80,13 +91,6 @@ if ($prev_id > 0 || $ref)
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
print ''.$langs->trans("Amount").' '.price($object->amount).' ';
- // Status
- /*
- print ''.$langs->trans('Status').' ';
- print ''.$object->getLibStatut(1).' ';
- print ' ';
- */
-
if ($object->date_trans <> 0)
{
$muser = new User($db);
@@ -117,7 +121,9 @@ if ($prev_id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '';
- print $langs->trans("BankToReceiveWithdraw");
+ $labelofbankfield = "BankToReceiveWithdraw";
+ if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+ print $langs->trans($labelofbankfield);
print ' ';
print '';
if ($acc->id > 0)
@@ -126,9 +132,13 @@ if ($prev_id > 0 || $ref)
print ' ';
print '';
- print $langs->trans("WithdrawalFile").' ';
+ $labelfororderfield = 'WithdrawalFile';
+ if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+ print $langs->trans($labelfororderfield).' ';
$relativepath = 'receipts/'.$object->ref.'.xml';
- print ''.$relativepath.' ';
+ $modulepart = 'prelevement';
+ if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+ print ''.$relativepath.' ';
print '
';
print '';
@@ -137,14 +147,13 @@ if ($prev_id > 0 || $ref)
}
else
{
- $langs->load("errors");
- print $langs->trans("Error");
+ dol_print_error($db);
}
/*
* Stats
*/
- $ligne = new LignePrelevement($db);
+ $line = new LignePrelevement($db);
$sql = "SELECT sum(pl.amount), pl.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@@ -170,7 +179,7 @@ if ($prev_id > 0 || $ref)
print '';
- print $ligne->LibStatut($row[1], 1);
+ print $line->LibStatut($row[1], 1);
print ' ';
print price($row[0]);
diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php
index a404e19184e..8008c9fd51f 100644
--- a/htdocs/core/lib/prelevement.lib.php
+++ b/htdocs/core/lib/prelevement.lib.php
@@ -39,8 +39,13 @@ function prelevement_prepare_head(BonPrelevement $object)
$h = 0;
$head = array();
+ $titleoftab = "WithdrawalsReceipts";
+ if ($object->type == 'bank-transfer') {
+ $titleoftab = "BankTransferReceipts";
+ }
+
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$object->id;
- $head[$h][1] = $langs->trans("WithdrawalsReceipts");
+ $head[$h][1] = $langs->trans($titleoftab);
$head[$h][2] = 'prelevement';
$h++;
diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang
index 841a9c2d480..662c587108a 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -77,12 +77,12 @@ StatusMotif8=Other reason
CreateForSepaFRST=Create direct debit file (SEPA FRST)
CreateForSepaRCUR=Create direct debit file (SEPA RCUR)
CreateAll=Create direct debit file (all)
-CreateFileForPaymentByBankTransfer=Create credit transfer (all)
+CreateFileForPaymentByBankTransfer=Create file for credit transfer (all)
CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA)
CreateGuichet=Only office
CreateBanque=Only bank
OrderWaiting=Waiting for treatment
-NotifyTransmision=Withdrawal Transmission
+NotifyTransmision=File transmission
NotifyCredit=Withdrawal Credit
NumeroNationalEmetter=National Transmitter Number
WithBankUsingRIB=For bank accounts using RIB
@@ -95,7 +95,8 @@ ShowWithdraw=Show Direct Debit Order
IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one direct debit payment order not yet processed, it won't be set as paid to allow prior withdrawal management.
DoStandingOrdersBeforePayments=This tab allows you to request a direct debit payment order. Once done, go into menu Bank->Payment by direct debit to generate and manage the direct debit order. When direct debit order is closed, payment on invoices will be automatically recorded, and invoices closed if remainder to pay is null.
DoCreditTransferBeforePayments=This tab allows you to request a credit transfer order. Once done, go into menu Bank->Payment by credit transfer to generate and manage the credit transfer order. When credit transfer order is closed, payment on invoices will be automatically recorded, and invoices closed if remainder to pay is null.
-WithdrawalFile=Withdrawal file
+WithdrawalFile=Debit order file
+CreditTransferFile=Credit transfer file
SetToStatusSent=Set to status "File Sent"
ThisWillAlsoAddPaymentOnInvoice=This will also record payments on invoices and will classify them as "Paid" if remain to pay is null
StatisticsByLineStatus=Statistics by status of lines
@@ -121,6 +122,7 @@ SEPAFrstOrRecur=Type of payment
ModeRECUR=Recurring payment
ModeFRST=One-off payment
PleaseCheckOne=Please check one only
+CreditTransferOrderCreated=Credit transfer order %s created
DirectDebitOrderCreated=Direct debit order %s created
AmountRequested=Amount requested
SEPARCUR=SEPA CUR