From: Dan Scott Date: Wed, 21 Nov 2012 16:37:06 +0000 (-0500) Subject: Test data: avoid crazy transactions for expired patrons X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=25429d51619641bb12d68e1cd8f4116469aa0e37;p=evergreen%2Fpines.git Test data: avoid crazy transactions for expired patrons Rather than creating brand new circ transactions for patrons who expired in 1999, make things a little more realistic by filtering out the patrons to those whose account expired in the past month or later, and creating xact_start / due_date values based on their account expiry date if expired, or NOW() if still active. Oh, and add some patrons who expired over the past month. :) Signed-off-by: Dan Scott Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/tests/datasets/sql/env_create.sql b/Open-ILS/tests/datasets/sql/env_create.sql index e38e709e5a..4a2970d6df 100644 --- a/Open-ILS/tests/datasets/sql/env_create.sql +++ b/Open-ILS/tests/datasets/sql/env_create.sql @@ -72,6 +72,8 @@ RETURNS void AS $$ DECLARE duration config.rule_circ_duration%ROWTYPE; DECLARE recurring config.rule_recurring_fine%ROWTYPE; DECLARE max_fine config.rule_max_fine%ROWTYPE; + DECLARE patron actor.usr%ROWTYPE; + DECLARE xact_base_date TIMESTAMP; DECLARE due_date TIMESTAMP; DECLARE xact_start TIMESTAMP; BEGIN @@ -79,15 +81,22 @@ BEGIN SELECT INTO duration * FROM config.rule_circ_duration WHERE name = duration_rule; SELECT INTO recurring * FROM config.rule_recurring_fine WHERE name = recurring_fine_rule; SELECT INTO max_fine * FROM config.rule_max_fine WHERE name = max_fine_rule; + SELECT INTO patron * FROM actor.usr WHERE id = patron_id; + + IF patron.expire_date < NOW() THEN + xact_base_date = patron.expire_date; + ELSE + xact_base_date = NOW(); + END IF; IF overdue THEN -- if duration is '7 days', the overdue item was due 7 days ago - due_date := NOW() - duration.normal; + due_date := xact_base_date - duration.normal; -- make overdue circs appear as if they were created two durations ago - xact_start := NOW() - duration.normal - duration.normal; + xact_start := xact_base_date - duration.normal - duration.normal; ELSE - due_date := NOW() + duration.normal; - xact_start := NOW(); + due_date := xact_base_date + duration.normal; + xact_start := xact_base_date; END IF; IF duration.normal >= '1 day'::INTERVAL THEN diff --git a/Open-ILS/tests/datasets/sql/transactions.sql b/Open-ILS/tests/datasets/sql/transactions.sql index ed27bbb6d1..e95b0d60d0 100644 --- a/Open-ILS/tests/datasets/sql/transactions.sql +++ b/Open-ILS/tests/datasets/sql/transactions.sql @@ -39,6 +39,7 @@ BEGIN FOR recipient IN SELECT * FROM actor.usr WHERE NOT deleted AND profile = grp + AND expire_date > NOW() - '1 month'::interval ORDER BY id LIMIT user_count LOOP -- find a suitable circulator/requestor for these transactions @@ -47,6 +48,7 @@ BEGIN WHERE home_ou = recipient.home_ou AND profile = 5 AND -- Circulators NOT deleted + AND expire_date > NOW() ORDER BY id LIMIT 1; -- regular circs -------------------------------- diff --git a/Open-ILS/tests/datasets/sql/users_patrons_100.sql b/Open-ILS/tests/datasets/sql/users_patrons_100.sql index 65d64addcc..668b539415 100644 --- a/Open-ILS/tests/datasets/sql/users_patrons_100.sql +++ b/Open-ILS/tests/datasets/sql/users_patrons_100.sql @@ -43,10 +43,11 @@ UPDATE actor.usr SET WHERE id=CURRVAL('actor.usr_id_seq'); +-- Soon to expire patron INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, second_given_name, expire_date, dob, suffix) VALUES (2, 3, '99999355250', 5, 'Jones', 'gregoryj1234', - 'Gregory', '', NOW() + '3 years'::INTERVAL, NULL, NULL); + 'Gregory', '', NOW() + '1 day'::INTERVAL, NULL, NULL); INSERT INTO actor.usr_address (country, within_city_limits, post_code, street1, valid, state, city, street2, county, usr) @@ -64,10 +65,11 @@ UPDATE actor.usr SET WHERE id=CURRVAL('actor.usr_id_seq'); +-- Soon to expire patron INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, second_given_name, expire_date, dob, suffix) VALUES (2, 1, '99999387993', 9, 'Moran', 'vincentm1234', - 'Vincent', 'Kenneth', NOW() + '3 years'::INTERVAL, NULL, NULL); + 'Vincent', 'Kenneth', NOW() + '1 week'::INTERVAL, NULL, NULL); INSERT INTO actor.usr_address (country, within_city_limits, post_code, street1, valid, state, city, street2, county, usr) @@ -85,10 +87,11 @@ UPDATE actor.usr SET WHERE id=CURRVAL('actor.usr_id_seq'); +-- Soon to expire patron INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, second_given_name, expire_date, dob, suffix) VALUES (2, 1, '99999335859', 8, 'Jones', 'gregoryj1234', - 'Gregory', 'Adam', NOW() + '3 years'::INTERVAL, NULL, NULL); + 'Gregory', 'Adam', NOW() + '3 weeks'::INTERVAL, NULL, NULL); INSERT INTO actor.usr_address (country, within_city_limits, post_code, street1, valid, state, city, street2, county, usr) @@ -106,10 +109,11 @@ UPDATE actor.usr SET WHERE id=CURRVAL('actor.usr_id_seq'); +-- Recently expired patron INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, second_given_name, expire_date, dob, suffix) VALUES (2, 1, '99999373186', 7, 'Walker', 'brittanyw1234', - 'Brittany', 'Geraldine', NOW() + '3 years'::INTERVAL, NULL, NULL); + 'Brittany', 'Geraldine', NOW() - '1 week'::INTERVAL, NULL, NULL); INSERT INTO actor.usr_address (country, within_city_limits, post_code, street1, valid, state, city, street2, county, usr) @@ -127,10 +131,11 @@ UPDATE actor.usr SET WHERE id=CURRVAL('actor.usr_id_seq'); +-- Recently expired patron INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, second_given_name, expire_date, dob, suffix) VALUES (2, 1, '99999384262', 9, 'Miller', 'ernestom1234', - 'Ernesto', 'Robert', NOW() + '3 years'::INTERVAL, '1997-02-02', 'II'); + 'Ernesto', 'Robert', NOW() - '3 weeks'::INTERVAL, '1997-02-02', 'II'); INSERT INTO actor.usr_address (country, within_city_limits, post_code, street1, valid, state, city, street2, county, usr)