From: Dan Wells <dbw2@calvin.edu> Date: Fri, 17 Jul 2015 20:45:16 +0000 (-0400) Subject: LP 1198465: Make conditional negative balances test sql re-runnable X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=14836cc346774182dc187a24356c392c1cd942fa;p=evergreen%2Fmasslnc.git LP 1198465: Make conditional negative balances test sql re-runnable Add some DELETEs and some more explicit setting of a few DB pieces such that running the test SQL a second time will get everything back to state where the tests will again proceed as expected (hopefully successfully!). Signed-off-by: Dan Wells <dbw2@calvin.edu> Signed-off-by: Kathy Lussier <klussier@masslnc.org> Signed-off-by: Ben Shum <bshum@biblio.org> --- diff --git a/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql b/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql index b257b859a9..c578cad64d 100644 --- a/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql +++ b/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql @@ -11,6 +11,19 @@ BEGIN; -- user id: 4, name: Gregory Jones +-- clear bills and payments for our test circs +DELETE FROM money.billing WHERE xact <= 9; +DELETE FROM money.payment WHERE xact <= 9; + +-- clear any non-stock settings +-- XXX This will need adjusting if new stock settings are added, so +-- TODO: Pad out org_unit_settings with a SETVAL like we do for other +-- settings +DELETE FROM actor.org_unit_setting WHERE id >= 14; + +-- clear out the test workstation (just in case) +DELETE FROM actor.workstation WHERE name = 'BR1-test-09-lp1198465_neg_balances.t'; + -- Setup all LOST circs UPDATE action.circulation SET xact_start = '2014-05-14 08:39:13.070326-04', @@ -18,7 +31,11 @@ UPDATE action.circulation SET stop_fines_time = '2014-05-28 08:39:13.070326-04', create_time = '2014-05-14 08:39:13.070326-04', max_fine = '3.00', - stop_fines = 'LOST' + stop_fines = 'LOST', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL WHERE id >= 1 AND id <= 6; UPDATE asset.copy SET status = 3 WHERE id >= 2 AND id <= 7; @@ -65,7 +82,11 @@ UPDATE action.circulation SET due_date = NOW() + '1 day'::interval, stop_fines_time = NOW() - '3 hours'::interval, max_fine = '3.00', - stop_fines = 'LOST' + stop_fines = 'LOST', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL WHERE id IN (8, 9); UPDATE asset.copy SET status = 3 WHERE id IN (9, 10); @@ -77,5 +98,12 @@ INSERT INTO money.payment (id, xact, payment_ts, voided, amount, note) VALUES (DEFAULT, 8, NOW() - '30 minutes'::interval, false, 50.00, 'LOST payment'), (DEFAULT, 9, NOW() - '2 hours'::interval, false, 50.00, 'LOST payment'); +-- if rerunning, make sure our mangled bills have the right total in the summary +UPDATE money.materialized_billable_xact_summary SET balance_owed = 50.00 + WHERE id >=1 AND id <= 6; +UPDATE money.materialized_billable_xact_summary SET balance_owed = 0.70 + WHERE id = 7; +UPDATE money.materialized_billable_xact_summary SET balance_owed = 0.00 + WHERE id IN (8, 9); COMMIT;