Bug 14918

Summary: Remove C4::Dates from circ/pendingreserves.pl
Product: Koha Reporter: Marc Véron <veron>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: enhancement    
Priority: P5 - low CC: hector.hecaxmmx, jonathan.druart, m.de.rooy, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 14870    
Attachments: Remove C4::Dates from circ/pendingreserves.pl
[SIGNED-OFF]Remove C4::Dates from circ/pendingreserves.pl
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl
[Signed-off] Bug 14918: Remove C4::Dates from circ/pendingreserves.pl
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl
Bug 14918: [QA Follow-up] Correct enddate and use constant
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl
Bug 14918: [QA Follow-up] Correct enddate and use constant

Description Marc Véron 2015-09-29 09:49:42 UTC
This patch removes C4::Dates from circ/pendingreserves.pl
Comment 1 Marc Véron 2015-09-29 09:55:24 UTC Comment hidden (obsolete)
Comment 2 Héctor Eduardo Castro Avalos 2015-09-29 19:56:27 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-10-01 09:14:42 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-10-01 09:16:00 UTC
I suggest this counter-patch, the badly formatted dates are caught and don't make Koha explodes with a software error.
Comment 5 Marc Véron 2015-10-01 11:18:57 UTC Comment hidden (obsolete)
Comment 6 Marcel de Rooy 2015-10-08 08:14:59 UTC
-    my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO ));
-    $startdate = format_date($pastdate);
+    $startdate = $today - DateTime::Duration->new( days => C4::Context->preference('HoldsToPullStartDate') || 2 );


Replacing a constant by a hardcoded value is not an improvement.
Comment 7 Jonathan Druart 2015-10-08 09:15:11 UTC
(In reply to Marcel de Rooy from comment #6)
> -    my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year,
> $month, $day, 0, 0,
> -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO ));
> -    $startdate = format_date($pastdate);
> +    $startdate = $today - DateTime::Duration->new( days =>
> C4::Context->preference('HoldsToPullStartDate') || 2 );
> 
> 
> Replacing a constant by a hardcoded value is not an improvement.

A constant named TWO_DAYS_AGO does not make really sense...
And is only used once.
Feel free to use TWO_DAYS instead, if you prefer.
Comment 8 Marc Véron 2015-10-10 09:57:13 UTC
I hope that is no blocker :-)
Comment 9 Marcel de Rooy 2015-10-16 11:22:48 UTC
(In reply to Marc Véron from comment #8)
> I hope that is no blocker :-)
No. I will fix it next week.
Comment 10 Marcel de Rooy 2015-10-23 06:53:12 UTC Comment hidden (obsolete)
Comment 11 Marcel de Rooy 2015-10-23 06:53:34 UTC Comment hidden (obsolete)
Comment 12 Marcel de Rooy 2015-10-23 06:58:02 UTC
Created attachment 43798 [details] [review]
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl

This patch uses Koha::DateUtils instead of C4::Dates and Date::Calc. It
also sent DateTime objects to the template, which use the TT plugin to
display them.
If an invalid dates is entered, the default date is picked.

Test plan:
1/ Go to Home > Circulation > Holds to pull
2/ Verify that the the filter and the list behave as before
3/ Enter invalid dates and confirm that you do not get a software error

Counter patch works as expected and is a much cleaner solution.
Signed-off-by: Marc Veron <veron@veron.ch>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Marcel de Rooy 2015-10-23 06:58:06 UTC
Created attachment 43799 [details] [review]
Bug 14918: [QA Follow-up] Correct enddate and use constant

Corrected enddate (subtraction in the revised code must be an addition).
Replaced hardcoded 2 days by a constant.
Renamed the constant TWO_DAYS to PULL_INTERVAL.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested all three date formats.
Comment 14 Tomás Cohen Arazi 2015-10-23 13:54:12 UTC
Patches pushed to master.

Thanks Jonathan and Marcel!