File: Reconciliation.sql

package info (click to toggle)
ledgersmb 1.6.33%2Bds-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 33,000 kB
  • sloc: perl: 52,612; sql: 43,562; xml: 36,194; javascript: 2,428; sh: 1,099; makefile: 361; pascal: 25
file content (66 lines) | stat: -rw-r--r-- 7,547 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- To run from other transaction test scripts!

INSERT INTO account(id, accno, description, category, heading, contra)
values (-200, '-11111', 'Test Act 1', 'A', (select id from account_heading WHERE accno  = '000000000000000000000'), false);

INSERT INTO account(id, accno, description, category, heading, contra)
values (-201, '-11112', 'Test Act 1', 'A', (select id from account_heading WHERE accno  = '000000000000000000000'), false);

INSERT INTO entity (id, control_code, name, entity_class, country_id) values (-201, '-11111', 'Test 1', 1, 242);

INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class, ar_ap_account_id) values (-201, -200, 'T-11111', 1, -1000);
INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class, ar_ap_account_id) values (-201, -201, 'T-11112', 1, -1000);


INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-200, '-2000', '10', '10', -200, '1000-01-01', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-201, '-2001', '10', '10', -200, '1000-01-03', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-204, '-2002', '10', '10', -200, '1000-01-01', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-205, '-2003', '10', '10', -200, '1000-01-03', 'USD');

INSERT INTO ar (id, invnumber, amount, netamount,  entity_credit_account, transdate, curr) values (-206, '-2004', '10', '10', -201, '1000-01-01', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-207, '-2005', '10', '10', -201, '1000-01-03', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-208, '-2006', '10', '10', -201, '1000-01-01', 'USD');
INSERT INTO ar (id, invnumber, amount, netamount, entity_credit_account, transdate, curr) values (-209, '-2007', '10', '10', -201, '1000-01-03', 'USD');

INSERT INTO gl (id, reference, transdate) values (-202, 'Recon gl test 1', '1000-01-01');
INSERT INTO gl (id, reference, transdate) values (-203, 'Recon gl test 2', '1000-01-01');
INSERT INTO gl (id, reference, transdate) values (-210, 'Recon gl test 3', '1000-01-03');
INSERT INTO gl (id, reference, transdate) values (-211, 'Recon gl test 4', '1000-01-03');
INSERT INTO gl (id, reference, transdate, approved) values (-212, 'Cleared gl trans', '1000-01-03', true);
INSERT INTO gl (id, reference, transdate, approved) values (-213, 'Unapproved gl trans', '1000-01-03', false);
INSERT INTO gl (id, reference, transdate, approved) values (-214, 'gl trans, unapproved lines', '1000-01-03', false);

CREATE OR REPLACE FUNCTION test_get_account_id(in_accno text) returns int as $$ SELECT id FROM account WHERE accno = $1; $$ language sql;

INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, test_get_account_id('-11111'), '1000-01-01', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, test_get_account_id('-11111'), '1000-01-01', -10, '1', true, false);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared, approved) values (-200, test_get_account_id('-11112'), '1000-01-01', 10, '1', true, false);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-200, test_get_account_id('-11112'), '1000-01-01', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, test_get_account_id('-11111'), '1000-01-03', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-201, test_get_account_id('-11112'), '1000-01-03', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, test_get_account_id('-11111'), '1000-01-01', -10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-202, test_get_account_id('-11112'), '1000-01-01', 10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, test_get_account_id('-11111'), '1000-01-01', -10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-203, test_get_account_id('-11112'), '1000-01-01', 10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, test_get_account_id('-11111'), '1000-01-01', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-204, test_get_account_id('-11112'), '1000-01-01', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, test_get_account_id('-11111'), '1000-01-03', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-205, test_get_account_id('-11112'), '1000-01-03', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, test_get_account_id('-11111'), '1000-01-01', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-206, test_get_account_id('-11112'), '1000-01-01', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, test_get_account_id('-11111'), '1000-01-03', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-207, test_get_account_id('-11112'), '1000-01-03', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, test_get_account_id('-11111'), '1000-01-01', -10, '2');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-208, test_get_account_id('-11112'), '1000-01-01', 10, '2');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, test_get_account_id('-11111'), '1000-01-03', -10, '2');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-209, test_get_account_id('-11112'), '1000-01-03', 10, '2');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, test_get_account_id('-11111'), '1000-01-03', -10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-210, test_get_account_id('-11112'), '1000-01-03', 10, '1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, test_get_account_id('-11111'), '1000-01-03', -10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source) values (-211, test_get_account_id('-11112'), '1000-01-03', 10, 't gl 1');
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, test_get_account_id('-11111'), '1000-01-03', -10, '1', true);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-212, test_get_account_id('-11112'), '1000-01-03', 10, '1', true);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, test_get_account_id('-11111'), '1000-01-03', -10, '1', false);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, cleared) values (-213, test_get_account_id('-11112'), '1000-01-03', 10, '1', false);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, test_get_account_id('-11111'), '1000-01-03', -10, '1', false);
INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, approved) values (-214, test_get_account_id('-11112'), '1000-01-03', 10, '1', false);