~singpolyma/jmp-schemas

jmp-schemas/verify/cdr_with_charge.sql -rw-r--r-- 611 bytes
395bb797Stephen Paul Weber Tag for notify on top up an expired account a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- Verify jmp:cdr_with_charge on pg

BEGIN;

SELECT rate, charge FROM cdr_with_charge;

INSERT INTO plan_log
	(customer_id, plan_name, date_range)
	VALUES
	('test', 'test_plan', tsrange(LOCALTIMESTAMP, LOCALTIMESTAMP + '10 seconds'));

INSERT INTO cdr
	(cdr_id, customer_id, start, billsec, disposition, tel)
	VALUES
	('test1', 'test', LOCALTIMESTAMP, 10000, 'VOICEMAIL', '+15551234567');

DO $$
DECLARE
	c numeric;
BEGIN
	SELECT charge INTO c FROM cdr_with_charge WHERE cdr_id='test1';
	IF c IS NULL or c <> 0 THEN
		RAISE EXCEPTION 'Expected VOICEMAIL to charge 0, but got: %', c;
	END IF;
END $$;

ROLLBACK;