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