From 9b0c7d0904e3b2b68b9ff80fe3e017a4b638681d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 13 May 2022 09:58:00 +0200 Subject: [PATCH 1/4] new: add hidden option to add export file with date time --- htdocs/exports/class/export.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index c87f03f3110..89d0caaa24f 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -615,6 +615,9 @@ class Export } else { $filename = "export_".$datatoexport; } + if (!empty($conf->global->EXPORT_NAME_WITH_DT)) { + $filename .= dol_print_date(dol_now(), '%Y%m%d%_%H%M'); + } $filename .= '.'.$objmodel->getDriverExtension(); $dirname = $conf->export->dir_temp.'/'.$user->id; From 82017d7a394bc2608ba637d06693f548524dae42 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 12 May 2022 14:42:55 +0200 Subject: [PATCH 2/4] allow to modify invoices that have been validated in the past --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7de827ff1d2..d3132a0cb4a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -305,7 +305,7 @@ if (empty($reshook)) { $object->fetch($id); if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $object->willBeLastOfSameType(); + $last_of_type = $object->willBeLastOfSameType($allow_validated_drafts = true); if (empty($object->date_validation) && !$last_of_type[0]) { setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); $action = ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9079e99dcf8..435b358ae32 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3009,7 +3009,7 @@ class Facture extends CommonInvoice return -1; } if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $this->willBeLastOfSameType(); + $last_of_type = $this->willBeLastOfSameType($allow_validated_drafts = true); if (!$last_of_type[0]) { $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); return -1; @@ -5567,9 +5567,10 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. + * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. * @return boolean */ - public function willBeLastOfSameType() + public function willBeLastOfSameType($allow_validated_drafts = false) { // get date of last validated invoices of same type $sql = "SELECT datef"; @@ -5586,7 +5587,12 @@ class Facture extends CommonInvoice $last_date = $this->db->jdate($obj->datef); $invoice_date = $this->date; - return [$invoice_date >= $last_date, $last_date]; + $is_last_of_same_type = $invoice_date >= $last_date; + if ($allow_validated_drafts) { + $is_last_of_same_type = $is_last_of_same_type || (!strpos($this->ref, 'PROV') && $this->status == self::STATUS_DRAFT); + } + + return [$is_last_of_same_type, $last_date]; } else { // element is first of type to be validated return [true]; From 7890d6f7f6b0571040e9ec4398a1a36a94bd0dda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 May 2022 21:01:48 +0200 Subject: [PATCH 3/4] Update card.php --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d3132a0cb4a..f2e57c8b536 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -305,7 +305,7 @@ if (empty($reshook)) { $object->fetch($id); if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $object->willBeLastOfSameType($allow_validated_drafts = true); + $last_of_type = $object->willBeLastOfSameType(true); if (empty($object->date_validation) && !$last_of_type[0]) { setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); $action = ''; From d13cb10c8bb253045d6cd59e70fffd75eab318e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 May 2022 21:02:09 +0200 Subject: [PATCH 4/4] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 435b358ae32..a5cb99c2260 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3009,7 +3009,7 @@ class Facture extends CommonInvoice return -1; } if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $this->willBeLastOfSameType($allow_validated_drafts = true); + $last_of_type = $this->willBeLastOfSameType(true); if (!$last_of_type[0]) { $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); return -1;