From 975300b90bb8e40eb52895d29f0c244c20dafe07 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Sat, 10 Mar 2018 11:23:35 +0100 Subject: [PATCH 1/6] Add execution date on prelevement --- .../class/bonprelevement.class.php | 14 ++++++--- htdocs/compta/prelevement/create.php | 31 ++++++++++--------- htdocs/langs/en_US/withdrawals.lang | 4 +++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e2517bdfada..f720d088b6d 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014-2016 Ferran Marcet + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -760,9 +761,10 @@ class BonPrelevement extends CommonObject * @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 * @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; @@ -776,6 +778,8 @@ class BonPrelevement extends CommonObject $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); @@ -1077,7 +1081,7 @@ class BonPrelevement extends CommonObject $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); } @@ -1276,7 +1280,7 @@ class BonPrelevement extends CommonObject * @param string $format FRST, RCUR or ALL * @return int 0 if OK, <0 if KO */ - function generate($format='ALL') + function generate($format='ALL',$executiondate='') { global $conf,$langs,$mysoc; @@ -1306,9 +1310,11 @@ class BonPrelevement extends CommonObject // SEPA Initialisation $CrLf = "\n"; $date_actu = dol_now(); + $dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S'); + + 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; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index cd3aebf62f4..c94a786917f 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -65,7 +66,9 @@ if ($action == 'create') { // $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'); @@ -90,6 +93,7 @@ if ($action == 'create') /* * View */ +$form = new Form($db); $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); @@ -144,23 +148,22 @@ print ''; if ($mesg) print $mesg; print "
\n"; +print '
'; +print ''; +if ($nb) { + if ($pricetowithdraw) { + print $langs->trans('ExecutionDate').' '; + print $form->select_date(); + if ($mysoc->isInEEC()) { + print ''; + print ''; + } else { + print '' . $langs->trans("CreateAll") . "\n"; + } -if ($nb) -{ - if ($pricetowithdraw) - { - if ($mysoc->isInEEC()) - { - print ''.$langs->trans("CreateForSepaFRST")."\n"; - print ''.$langs->trans("CreateForSepaRCUR")."\n"; } else { - print ''.$langs->trans("CreateAll")."\n"; - } - } - else - { if ($mysoc->isInEEC()) { print ''.$langs->trans("CreateForSepaFRST")."\n"; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7b33ad15947..8dd4e573e37 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -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 From d2dff92f26c4b75ab33cd9e906a186f0fd750c77 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Sat, 10 Mar 2018 11:28:12 +0100 Subject: [PATCH 2/6] Add execution date on prelevement --- htdocs/compta/prelevement/class/bonprelevement.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index f720d088b6d..be946d31a19 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1278,6 +1278,7 @@ class BonPrelevement extends CommonObject * File is generated with name this->filename * * @param string $format FRST, RCUR or ALL + * @param string $executiondate * @return int 0 if OK, <0 if KO */ function generate($format='ALL',$executiondate='') From 87b797bdec5b2ce2801c51cdc8034a983a3bbcce Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Sat, 10 Mar 2018 15:06:02 +0100 Subject: [PATCH 3/6] Fix unknow field --- .../class/paymentexpensereport.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 43fcacc8483..e269d9c7c3e 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -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 @@ -104,6 +108,9 @@ class PaymentExpenseReport extends CommonObject $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,"; @@ -505,7 +512,10 @@ class PaymentExpenseReport extends CommonObject $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 From 9e0c74ca2034784c14d80b3e81bf5379155d50e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 18:49:48 +0100 Subject: [PATCH 4/6] Update bonprelevement.class.php --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index be946d31a19..221c7cdeb93 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -761,7 +761,7 @@ class BonPrelevement extends CommonObject * @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 + * @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',$executiondate='') From f609547bc9091454967a43bd0055293f976255a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 18:50:41 +0100 Subject: [PATCH 5/6] Update bonprelevement.class.php --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 221c7cdeb93..166cfa2f68a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1278,7 +1278,7 @@ class BonPrelevement extends CommonObject * File is generated with name this->filename * * @param string $format FRST, RCUR or ALL - * @param string $executiondate + * @param string $executiondate Date to execute transfer * @return int 0 if OK, <0 if KO */ function generate($format='ALL',$executiondate='') From bb835d3633ec839af68c9746885d599320fb9dcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 22:09:32 +0100 Subject: [PATCH 6/6] Update bonprelevement.class.php --- .../compta/prelevement/class/bonprelevement.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 166cfa2f68a..57cf518db16 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1310,10 +1310,14 @@ class BonPrelevement extends CommonObject */ // SEPA Initialisation $CrLf = "\n"; - $date_actu = dol_now(); - $dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S'); + + $now = dol_now(); + + $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); - if(!empty($executiondate)) $date_actu=$executiondate; + $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'); $fileDebiteurSection = '';