5 -- at the time of writing, user '2' has zero circulations
6 -- in the default sample data set.
9 -- activate circ history tracking for a patron
10 INSERT INTO actor.usr_setting (usr, name, value) VALUES
11 (:circ_usr, 'history.circ.retention_start', '"2015-01-01"');
13 INSERT INTO action.circulation (
14 usr, target_copy, circ_lib, circ_staff, renewal_remaining,
15 grace_period, duration, recurring_fine, max_fine, duration_rule,
16 recurring_fine_rule, max_fine_rule, due_date )
18 :circ_usr, 1, 4, 1, 2, '1 day', '14 days','0.10', '10',
19 'default','default','default', now() + '14 days'::interval
23 'SELECT * FROM action.usr_circ_history WHERE usr = ' || :circ_usr,
24 'Confirm a history row was inserted'
28 (SELECT checkin_time FROM action.usr_circ_history WHERE usr = :circ_usr),
30 'Confirm checkin_time is NULL'
34 UPDATE action.circulation
35 SET checkin_time = NOW(), stop_fines = 'RENEW'
36 WHERE usr = :circ_usr;
39 INSERT INTO action.circulation (
40 usr, target_copy, circ_lib, circ_staff, renewal_remaining,
41 grace_period, duration, recurring_fine, max_fine, duration_rule,
42 recurring_fine_rule, max_fine_rule, due_date, parent_circ )
44 :circ_usr, 1, 4, 1, 2, '1 day', '14 days','0.10', '10',
45 'default','default','default', '3001-01-01',
46 (SELECT id FROM action.circulation WHERE usr = :circ_usr)
49 -- confirm due_date on the history object is updated to match the
50 -- due date of the renewal circ.
52 (SELECT DATE(due_date) FROM action.usr_circ_history WHERE usr = :circ_usr),
54 'Confirm due_date matches renewal due date'
57 UPDATE action.circulation SET checkin_time = NOW()
58 WHERE usr = :circ_usr AND stop_fines IS NULL;
61 (SELECT checkin_time FROM action.usr_circ_history WHERE usr = :circ_usr),
63 'Confirm checkin_time is set'
66 -- Confirm no history is created users that are not opted in.
67 -- Assumes :circ_usr + 1 is a valid user id.
68 INSERT INTO action.circulation (
69 usr, target_copy, circ_lib, circ_staff, renewal_remaining,
70 grace_period, duration, recurring_fine, max_fine, duration_rule,
71 recurring_fine_rule, max_fine_rule, due_date )
73 :circ_usr + 1, 1, 4, 1, 2, '1 day', '14 days','0.10', '10',
74 'default','default','default', now() + '14 days'::interval
78 'SELECT * FROM action.usr_circ_history WHERE usr = ' || :circ_usr + 1,
79 'Confirm no history is created'
83 -- Finish the tests and clean up.
84 SELECT * FROM finish();