4 -- this was a mistake!!! - we should never had made gl 3 decimal places - it makes a nightmare everywhere..
6 alter table glseries alter column glseries_amount TYPE numeric(12,2);
7 --View: api.journalentry
9 DROP VIEW api.journalentry;
10 alter table gltrans alter column gltrans_amount TYPE numeric(12,2);
12 CREATE OR REPLACE VIEW api.journalentry AS
13 SELECT curr_symbol.curr_abbr AS currency, c.gltrans_amount AS amount, c.gltrans_date AS dist_date, c.gltrans_docnumber AS doc_number, formatglaccount(da.accnt_id) AS debit, formatglaccount(ca.accnt_id) AS credit, c.gltrans_notes AS notes
14 FROM gltrans d, gltrans c, accnt da, accnt ca, curr_symbol
15 WHERE d.gltrans_sequence = c.gltrans_sequence AND d.gltrans_accnt_id = da.accnt_id AND c.gltrans_accnt_id = ca.accnt_id AND d.gltrans_amount < 0::numeric AND c.gltrans_amount > 0::numeric AND d.gltrans_doctype = 'JE'::text AND c.gltrans_doctype = 'JE'::text AND curr_symbol.curr_id = basecurrid()
16 ORDER BY d.gltrans_date DESC;
18 ALTER TABLE api.journalentry
20 GRANT ALL ON TABLE api.journalentry TO admin;
21 GRANT ALL ON TABLE api.journalentry TO xtrole;
22 COMMENT ON VIEW api.journalentry
26 -- Rule: "_DELETE" ON api.journalentry
28 -- DROP RULE "_DELETE" ON api.journalentry;
30 CREATE OR REPLACE RULE "_DELETE" AS
31 ON DELETE TO api.journalentry DO INSTEAD NOTHING;
33 -- Rule: "_INSERT" ON api.journalentry
35 -- DROP RULE "_INSERT" ON api.journalentry;
37 CREATE OR REPLACE RULE "_INSERT" AS
38 ON INSERT TO api.journalentry DO INSTEAD SELECT insertgltransaction('G/L'::text, 'JE'::text, new.doc_number, new.notes, getglaccntid(new.credit), getglaccntid(new.debit), (-1), currtobase(getcurrid(new.currency::text), new.amount, new.dist_date), new.dist_date) AS insertgltransaction;
40 -- Rule: "_UPDATE" ON api.journalentry
42 -- DROP RULE "_UPDATE" ON api.journalentry;
44 CREATE OR REPLACE RULE "_UPDATE" AS
45 ON UPDATE TO api.journalentry DO INSTEAD NOTHING;