]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/live_t/lp1793802-aged-billings-payments.pg
LP2061136 - Stamping 1405 DB upgrade script
[working/Evergreen.git] / Open-ILS / src / sql / Pg / live_t / lp1793802-aged-billings-payments.pg
1 -- Load the TAP functions.
2 BEGIN;
3
4 -- Activate "age money with circs" setting.
5 UPDATE config.global_flag SET enabled = TRUE
6     WHERE name = 'history.money.age_with_circs';
7
8 -- Plan the tests.
9 SELECT plan(8);
10
11 SELECT is(
12     (SELECT COUNT(*) FROM money.billing WHERE xact = 9),
13     1::BIGINT, 'Confirm billing for xact exists'
14 );
15
16 SELECT is(
17     (SELECT COUNT(*) FROM money.payment WHERE xact = 9),
18     1::BIGINT, 'Confirm payment for xact exists'
19 );
20
21 PREPARE age_circ AS DELETE FROM action.circulation WHERE id = 9;
22 SELECT lives_ok('age_circ', 'Age circulation without errors');
23
24 SELECT is(
25     (SELECT COUNT(*) FROM action.aged_circulation WHERE id = 9),
26     1::BIGINT, 'Confirm circ aged'
27 );
28
29 SELECT is(
30     (SELECT COUNT(*) FROM money.aged_billing WHERE xact = 9),
31     1::BIGINT, 'Confirm aged billing created'
32 );
33
34 SELECT is(
35     (SELECT COUNT(*) FROM money.aged_payment WHERE xact = 9),
36     1::BIGINT, 'Confirm aged payment created'
37 );
38
39 SELECT is(
40     (SELECT COUNT(*) FROM money.billing WHERE xact = 9),
41     0::BIGINT, 'Confirm source billing deleted'
42 );
43
44 SELECT is(
45     (SELECT COUNT(*) FROM money.payment WHERE xact = 9),
46     0::BIGINT, 'Confirm source payment deleted'
47 );
48
49 -- Finish the tests and clean up.
50 SELECT * FROM finish();
51 ROLLBACK;