Koha/misc/cronjobs
Jonathan Druart 0f4a831344 Bug 11120: FIX the --date option for overdue_notices cronjob
Bug 7447 introduces the --date option for overdue notices.
This option has never worked: the code is waiting for a value but the
option is defined as a boolean.

This patch fixes the option and change the way to calculate the range of
dates.
This range is now managed in Perl instead of in the SQL query. To do it
in Perl allows to build dates simply using the DateTime and
DateTime::Duration modules.

To test this patch you should have a DB with a lot of overdues, (I
tested on a DB with 512 overdues).
A test plan could be:
1/ Dump your message_queue table
2/ Verify the number of overdues in the database before applying the
  patch:
  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v -t
  (the triggered option will generate overdue for today)
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 2A

  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 2B

2/ Apply the patch
4/ Verify the number of overdues generated by the patched script:
  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v -t
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4A

  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4B

  mysql> DELETE FROM message_queue;
  # The date should be defined depending your dateformat preference
  # and should be the date of the current day
  perl misc/cronjobs/overdue_notices.pl -v -t --date="YYYY-MM-DD"
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4C

  mysql> DELETE FROM message_queue;
  # The date should be defined depending your dateformat preference
  # and should be the date of the current day
  perl misc/cronjobs/overdue_notices.pl -v --date="YYYY-MM-DD"
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4D

5/ Compare the values: All values generated with the -t options should
be equals. Same for values without the -t options.
=> 2A == 4A == 4C and 2B == 4B == 4D

6/ Go back to a normal activity for 3 days or manually change the
date_due for issues in the DB:
  mysql> update issues SET date_due = DATE_SUB(date_due, INTERVAL 3 DAY);
Do again step 4C and 4D with a date equals to today - 3 days.
Values should be the same as 4C and 4D.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested with my own test data, checked generating overdues
with and without the --date option.
All worked as expected.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-03-30 13:43:48 -03:00
..
holds
rss
social_data Bug 10156 - Fix usr/bin/perl path for get_report_social_data.pl 2013-05-08 09:52:21 -04:00
thirdparty
advance_notices.pl Bug 13240 [QA Followup] 2015-02-10 14:08:02 -03:00
automatic_renewals.pl Bug 13377: mark automatic_renewals.pl as executable 2014-12-03 09:35:24 -03:00
backup.sh
batch_anonymise.pl
build_browser_and_cloud.pl
cart_to_shelf.pl
check-url-quick.pl
check-url.pl
cleanup_database.pl
cloud-kw.pl
cloud-sample.conf
CONFIGURE.gmail
create_koc_db.pl
crontab.example
delete_expired_opac_registrations.pl
delete_patrons.pl
delete_unverified_opac_registrations.pl
fines.pl Bug 11872 - Lost overdue items should not generate fines 2015-01-07 20:15:55 -03:00
gather_print_notices.pl
import_webservice_batch.pl
j2a.pl
longoverdue.pl Bug 8337: Small typo in usage statement for longoverdue.pl 2014-11-21 18:55:52 -03:00
MARC21_parse_test.pl
nl-sync-from-koha.pl Bug 11401: QA followup 2014-11-14 09:42:45 -03:00
nl-sync-to-koha.pl Bug 11401: Add support for Norwegian national library card 2014-11-14 09:42:23 -03:00
overdue_notices.pl Bug 11120: FIX the --date option for overdue_notices cronjob 2015-03-30 13:43:48 -03:00
printoverdues.sh
process_message_queue.pl
purge_suggestions.pl
runreport.pl Bug 11944: use CGI( -utf8 ) everywhere 2015-01-13 13:07:21 -03:00
serialsUpdate.pl
services_throttle.pl
share_usage_with_koha_community.pl
staticfines.pl Bug 11872 - Lost overdue items should not generate fines 2015-01-07 20:15:55 -03:00
update_totalissues.pl