Bug 13035: Overdue notices send notices for due date in future.
authorRafal Kopaczka <rkk0@poczta.onet.pl>
Tue, 7 Oct 2014 12:43:36 +0000 (14:43 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Sun, 19 Oct 2014 14:37:44 +0000 (11:37 -0300)
Overdue notices, script uses method days_between which returns always
positive value of days, no mater if due_date is higher or lower from
date_to_run. This causes overdue notices to be send for real overdue and
for checkouts with due date in future, which have same days_between as
in notice triggers.

To reproduce:
1. Set up overdue notice triggers for eg. 2 day.
2. Checkout items for 2 borrowers first gets item with due date 2 days
in past and second gets 2 days in future.
3. run ./misc/cronjobs/overdue_notices.pl -n -t
4. watch that notices was generated for both of them.

To test:
1. Repeat steps 1,2
2. Apply patch
3. run ./misc/cronjobs/overdue_notices.pl -n -t
4. should be 1 notice for borrower with overdue item.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes tests and QA script, just adds an additional test.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
misc/cronjobs/overdue_notices.pl

index 942cb6a..51ce072 100755 (executable)
@@ -510,6 +510,8 @@ END_SQL
             my $borrowernumber;
             while ( my $data = $sth->fetchrow_hashref ) {
 
+                next unless ( DateTime->compare( $date_to_run,  dt_from_string($data->{date_due})) ) == 1;
+
                 # check the borrower has at least one item that matches
                 my $days_between;
                 if ( C4::Context->preference('OverdueNoticeCalendar') )