Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 7 Jun 2023 09:49:41 +0000 (11:49 +0200)
committerMatt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Wed, 12 Jul 2023 09:36:03 +0000 (09:36 +0000)
commit0efca288a2efc5461a4cf66bfc196512e63f50fe
tree03280d1c80ba2f0a40a8448bd2f773ef49f97564
parentfec8edbd3f8913bb055bef4524253d8529586ae8
Bug 33901: (bug 30718 follow-up) Predition pattern - don't set end date to today

If the end date is not set we should not set it to today.
On bug 30718 the following change was wrong:
-$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
+$enddate = dt_from_string($enddate)->ymd;

output_pref returns undef if str is empty
After the change we returned today's date.

Test plan:
1. Go to Serials > Manage numbering patterns
2. Click Edit next to one of the existing patterns (e.g. Number)
3. Enter information in the Test prediction pattern section
   -  Frequency: choose one (e.g. 1/month)
   -  First issue publication date: enter a date (e.g. 2023-06-01)
   -  Subscription length: issues + enter a number of issues (e.g. 12)
   -  Locale: leave empty
   -  Begins with: enter a number in the X column, e.g. 42
4. Click Test pattern
=> Without this patch only one issue is shown, no matter how many you enter in Subscription length
=> With this patch applied the end date is not set to today and the
prediction pattern list is correct

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c9a2cf948dc12d7f9ad6c7334232c2165857c4e1)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 50165d8e86294d415da053e1a7ab4c7e198a93da)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
serials/showpredictionpattern.pl