Skip to content

Commit

Permalink
Merge pull request #8325 from inoveaconseil/develop
Browse files Browse the repository at this point in the history
Add execution date on direct debit
  • Loading branch information
eldy committed Mar 10, 2018
2 parents ce13fa5 + bb835d3 commit dfb3d1b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
21 changes: 16 additions & 5 deletions htdocs/compta/prelevement/class/bonprelevement.class.php
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* 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>
*
* 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
Expand Down Expand Up @@ -760,9 +761,10 @@ function NbFactureAPrelever($banque=0,$agence=0)
* @param int $agence dolibarr mysoc bank office (guichet)
* @param string $mode real=do action, simu=test only
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute the transfer
* @return int <0 if KO, nbre of invoice withdrawed if OK
*/
function Create($banque=0, $agence=0, $mode='real', $format='ALL')
function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='')
{
global $conf,$langs;

Expand All @@ -776,6 +778,8 @@ function Create($banque=0, $agence=0, $mode='real', $format='ALL')
$error = 0;

$datetimeprev = time();
//Choice the date of the execution direct debit
if(!empty($executiondate)) $datetimeprev = $executiondate;

$month = strftime("%m", $datetimeprev);
$year = strftime("%Y", $datetimeprev);
Expand Down Expand Up @@ -1077,7 +1081,7 @@ function Create($banque=0, $agence=0, $mode='real', $format='ALL')
$this->factures = $factures_prev_id;

// Generation of SEPA file $this->filename
$this->generate($format);
$this->generate($format,$executiondate);
}
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
}
Expand Down Expand Up @@ -1274,9 +1278,10 @@ function AddNotification($db, $user, $action)
* File is generated with name this->filename
*
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute transfer
* @return int 0 if OK, <0 if KO
*/
function generate($format='ALL')
function generate($format='ALL',$executiondate='')
{
global $conf,$langs,$mysoc;

Expand Down Expand Up @@ -1305,10 +1310,16 @@ function generate($format='ALL')
*/
// SEPA Initialisation
$CrLf = "\n";
$date_actu = dol_now();

$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');
$dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S');
$fileDebiteurSection = '';
$fileEmetteurSection = '';
$i = 0;
Expand Down
31 changes: 17 additions & 14 deletions htdocs/compta/prelevement/create.php
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.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
Expand Down Expand Up @@ -65,7 +66,9 @@
{
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
$bprev = new BonPrelevement($db);
$result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));

$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format,$executiondate);
if ($result < 0)
{
setEventMessages($bprev->error, $bprev->errors, 'errors');
Expand All @@ -90,6 +93,7 @@
/*
* View
*/
$form = new Form($db);

$thirdpartystatic=new Societe($db);
$invoicestatic=new Facture($db);
Expand Down Expand Up @@ -144,23 +148,22 @@
if ($mesg) print $mesg;

print "<div class=\"tabsAction\">\n";
print '<form action="' . $_SERVER['PHP_SELF'] . '?action=create" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
if ($nb) {
if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' ';
print $form->select_date();
if ($mysoc->isInEEC()) {
print '<select name="format"><option value="FRST">'.$langs->trans('SEPAFRST').'</option><option value="RCUR">'.$langs->trans('SEPARCUR').'</option></select>';
print '<input class="butAction" type="submit" value="' . $langs->trans("CreateForSepa") . '"/>';
} else {
print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL">' . $langs->trans("CreateAll") . "</a>\n";
}

if ($nb)
{
if ($pricetowithdraw)
{
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";
Expand Down
12 changes: 11 additions & 1 deletion htdocs/expensereport/class/paymentexpensereport.class.php
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.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
Expand Down Expand Up @@ -46,6 +47,9 @@ class PaymentExpenseReport extends CommonObject
var $fk_bank;
var $fk_user_creat;
var $fk_user_modif;
//Unknow field
var $chid;
var $total;

/**
* Constructor
Expand Down Expand Up @@ -104,6 +108,9 @@ function create($user)

$this->db->begin();

//Fix me fields
$this->chid = $this->fk_expensereport;

if ($totalamount != 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,";
Expand Down Expand Up @@ -505,7 +512,10 @@ function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_
$acc = new Account($this->db);
$acc->fetch($accountid);

$total=$this->total;
//Fix me field
$this->total = $this->amount;
$total = $this->total;

if ($mode == 'payment_expensereport') $amount=$total;

// Insert payment into llx_bank
Expand Down
4 changes: 4 additions & 0 deletions htdocs/langs/en_US/withdrawals.lang
Expand Up @@ -98,6 +98,10 @@ ModeFRST=One-off payment
PleaseCheckOne=Please check one only
DirectDebitOrderCreated=Direct debit order %s created
AmountRequested=Amount requested
SEPARCUR=SEPA CUR
SEPAFRST=SEPA FRST
ExecutionDate=Execution date
CreateForSepa=Create direct debit file

### Notifications
InfoCreditSubject=Payment of direct debit payment order %s by the bank
Expand Down

0 comments on commit dfb3d1b

Please sign in to comment.