dump of simple thoughts

This commit is contained in:
fleetside 2018-09-12 14:48:59 -04:00
parent a4b0a1f793
commit 1e26dc9401
7 changed files with 159 additions and 159 deletions

View File

@ -1,62 +1,62 @@
BEGIN TRANSACTION; BEGIN TRANSACTION;
--\conninfo --\conninfo
--drop schema evt cascade --drop schema evt cascade
--------------------------build schema---------------------------------------------- --------------------------build schema----------------------------------------------
CREATE SCHEMA evt; CREATE SCHEMA evt;
COMMENT ON SCHEMA evt IS 'event log'; COMMENT ON SCHEMA evt IS 'event log';
--------------------------event log table------------------------------------------- --------------------------event log table-------------------------------------------
CREATE TABLE evt.bpr ( CREATE TABLE evt.bpr (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
,bpr JSONB ,bpr JSONB
,bprh JSONB ,bprh JSONB
,stmp timestamptz ,stmp timestamptz
); );
COMMENT ON COLUMN evt.bpr.bpr IS 'basic pecuniary record'; COMMENT ON COLUMN evt.bpr.bpr IS 'basic pecuniary record';
COMMENT ON COLUMN evt.bpr.bprh IS 'basic pecuniary record history'; COMMENT ON COLUMN evt.bpr.bprh IS 'basic pecuniary record history';
COMMENT ON COLUMN evt.bpr.stmp IS 'insert time'; COMMENT ON COLUMN evt.bpr.stmp IS 'insert time';
--------------------------account master--------------------------------------------- --------------------------account master---------------------------------------------
--the account master should be dynamically created --the account master should be dynamically created
CREATE TABLE evt.acct ( CREATE TABLE evt.acct (
acct text PRIMARY KEY acct text PRIMARY KEY
,prop jsonb ,prop jsonb
); );
COMMENT ON COLUMN evt.acct.acct IS 'account'; COMMENT ON COLUMN evt.acct.acct IS 'account';
COMMENT ON COLUMN evt.acct.prop IS 'properties'; COMMENT ON COLUMN evt.acct.prop IS 'properties';
--------------------------relational ledger------------------------------------------ --------------------------relational ledger------------------------------------------
CREATE TABLE evt.gl ( CREATE TABLE evt.gl (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
,bpr_id INT REFERENCES evt.bpr (id) ,bpr_id INT REFERENCES evt.bpr (id)
,acct text REFERENCES evt.acct (acct) ,acct text REFERENCES evt.acct (acct)
,amount numeric (12,2) ,amount numeric (12,2)
,bpr jsonb ,bpr jsonb
); );
COMMENT ON COLUMN evt.gl.bpr_id IS 'id of initial basic pecuniary record'; COMMENT ON COLUMN evt.gl.bpr_id IS 'id of initial basic pecuniary record';
COMMENT ON COLUMN evt.gl.acct IS 'account code'; COMMENT ON COLUMN evt.gl.acct IS 'account code';
COMMENT ON COLUMN evt.gl.amount IS 'amount'; COMMENT ON COLUMN evt.gl.amount IS 'amount';
COMMENT ON COLUMN evt.gl.bpr IS 'extract from initial basic pecuniary record'; COMMENT ON COLUMN evt.gl.bpr IS 'extract from initial basic pecuniary record';
--------------------------balances---------------------------------------------------- --------------------------balances----------------------------------------------------
CREATE TABLE evt.bal ( CREATE TABLE evt.bal (
acct TEXT REFERENCES evt.acct(acct) acct TEXT REFERENCES evt.acct(acct)
,perd daterange ,perd daterange
,obal numeric(12,2) ,obal numeric(12,2)
,debits numeric(12,2) ,debits numeric(12,2)
,credits numeric(12,2) ,credits numeric(12,2)
,cbal numeric(12,2) ,cbal numeric(12,2)
); );
COMMENT ON COLUMN evt.bal.acct IS 'account'; COMMENT ON COLUMN evt.bal.acct IS 'account';
COMMENT ON COLUMN evt.bal.perd IS 'period'; COMMENT ON COLUMN evt.bal.perd IS 'period';
COMMENT ON COLUMN evt.bal.obal IS 'opening balance'; COMMENT ON COLUMN evt.bal.obal IS 'opening balance';
COMMENT ON COLUMN evt.bal.debits IS 'total debits'; COMMENT ON COLUMN evt.bal.debits IS 'total debits';
COMMENT ON COLUMN evt.bal.credits IS 'total credits'; COMMENT ON COLUMN evt.bal.credits IS 'total credits';
COMMENT ON COLUMN evt.bal.cbal IS 'closing balance'; COMMENT ON COLUMN evt.bal.cbal IS 'closing balance';
COMMIT; COMMIT;

View File

@ -1,39 +1,39 @@
{ {
"gl": [ "gl": [
{ {
"jpath": [ "jpath": [
"{item,0}", "{item,0}",
"{header}" "{header}"
], ],
"amount": 2.19, "amount": 2.19,
"account": "h.food" "account": "h.food"
}, },
{ {
"jpath": [ "jpath": [
"{item,0}", "{item,0}",
"{header}" "{header}"
], ],
"amount": -2.19, "amount": -2.19,
"account": "h.dcard" "account": "h.dcard"
} }
], ],
"item": [ "item": [
{ {
"item": "green olives", "item": "green olives",
"amount": 2.19, "amount": 2.19,
"reason": "food", "reason": "food",
"account": "h.food" "account": "h.food"
} }
], ],
"header": { "header": {
"entity": "home", "entity": "home",
"module": "MHI", "module": "MHI",
"offset": "h.dcard", "offset": "h.dcard",
"vendor": "Discount Drug Mart", "vendor": "Discount Drug Mart",
"currency": "USD", "currency": "USD",
"eff_date": "1/6/2018", "eff_date": "1/6/2018",
"location": "Stow, OH", "location": "Stow, OH",
"instrument": "Discover Card", "instrument": "Discover Card",
"transaction": "purchase" "transaction": "purchase"
} }
} }

View File

@ -1,9 +1,9 @@
--------------------------account master--------------------------------------------- --------------------------account master---------------------------------------------
--the account master should be dynamically created --the account master should be dynamically created
CREATE TABLE evt.acct ( CREATE TABLE evt.acct (
acct text PRIMARY KEY acct text PRIMARY KEY
,prop jsonb ,prop jsonb
); );
COMMENT ON COLUMN evt.acct.acct IS 'account'; COMMENT ON COLUMN evt.acct.acct IS 'account';
COMMENT ON COLUMN evt.acct.prop IS 'properties'; COMMENT ON COLUMN evt.acct.prop IS 'properties';

View File

@ -1,16 +1,16 @@
--------------------------balances---------------------------------------------------- --------------------------balances----------------------------------------------------
CREATE TABLE evt.bal ( CREATE TABLE evt.bal (
acct TEXT REFERENCES evt.acct(acct) acct TEXT REFERENCES evt.acct(acct)
,perd daterange ,perd daterange
,obal numeric(12,2) ,obal numeric(12,2)
,debits numeric(12,2) ,debits numeric(12,2)
,credits numeric(12,2) ,credits numeric(12,2)
,cbal numeric(12,2) ,cbal numeric(12,2)
); );
COMMENT ON COLUMN evt.bal.acct IS 'account'; COMMENT ON COLUMN evt.bal.acct IS 'account';
COMMENT ON COLUMN evt.bal.perd IS 'period'; COMMENT ON COLUMN evt.bal.perd IS 'period';
COMMENT ON COLUMN evt.bal.obal IS 'opening balance'; COMMENT ON COLUMN evt.bal.obal IS 'opening balance';
COMMENT ON COLUMN evt.bal.debits IS 'total debits'; COMMENT ON COLUMN evt.bal.debits IS 'total debits';
COMMENT ON COLUMN evt.bal.credits IS 'total credits'; COMMENT ON COLUMN evt.bal.credits IS 'total credits';
COMMENT ON COLUMN evt.bal.cbal IS 'closing balance'; COMMENT ON COLUMN evt.bal.cbal IS 'closing balance';

View File

@ -1,11 +1,11 @@
--------------------------event log table------------------------------------------- --------------------------event log table-------------------------------------------
CREATE TABLE evt.bpr ( CREATE TABLE evt.bpr (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
,bpr JSONB ,bpr JSONB
,bprh JSONB ,bprh JSONB
,stmp timestamptz ,stmp timestamptz
); );
COMMENT ON COLUMN evt.bpr.bpr IS 'basic pecuniary record'; COMMENT ON COLUMN evt.bpr.bpr IS 'basic pecuniary record';
COMMENT ON COLUMN evt.bpr.bprh IS 'basic pecuniary record history'; COMMENT ON COLUMN evt.bpr.bprh IS 'basic pecuniary record history';
COMMENT ON COLUMN evt.bpr.stmp IS 'insert time'; COMMENT ON COLUMN evt.bpr.stmp IS 'insert time';

View File

@ -1,13 +1,13 @@
--------------------------relational ledger------------------------------------------ --------------------------relational ledger------------------------------------------
CREATE TABLE evt.gl ( CREATE TABLE evt.gl (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
,bpr_id INT REFERENCES evt.bpr (id) ,bpr_id INT REFERENCES evt.bpr (id)
,acct text REFERENCES evt.acct (acct) ,acct text REFERENCES evt.acct (acct)
,amount numeric (12,2) ,amount numeric (12,2)
,bpr jsonb ,bpr jsonb
); );
COMMENT ON COLUMN evt.gl.bpr_id IS 'id of initial basic pecuniary record'; COMMENT ON COLUMN evt.gl.bpr_id IS 'id of initial basic pecuniary record';
COMMENT ON COLUMN evt.gl.acct IS 'account code'; COMMENT ON COLUMN evt.gl.acct IS 'account code';
COMMENT ON COLUMN evt.gl.amount IS 'amount'; COMMENT ON COLUMN evt.gl.amount IS 'amount';
COMMENT ON COLUMN evt.gl.bpr IS 'extract from initial basic pecuniary record'; COMMENT ON COLUMN evt.gl.bpr IS 'extract from initial basic pecuniary record';

View File

@ -1,16 +1,16 @@
--------------------------balances---------------------------------------------------- --------------------------balances----------------------------------------------------
CREATE TABLE evt.bal ( CREATE TABLE evt.bal (
acct TEXT REFERENCES evt.acct(acct) acct TEXT REFERENCES evt.acct(acct)
,perd daterange ,perd daterange
,obal numeric(12,2) ,obal numeric(12,2)
,debits numeric(12,2) ,debits numeric(12,2)
,credits numeric(12,2) ,credits numeric(12,2)
,cbal numeric(12,2) ,cbal numeric(12,2)
); );
COMMENT ON COLUMN evt.bal.acct IS 'account'; COMMENT ON COLUMN evt.bal.acct IS 'account';
COMMENT ON COLUMN evt.bal.perd IS 'period'; COMMENT ON COLUMN evt.bal.perd IS 'period';
COMMENT ON COLUMN evt.bal.obal IS 'opening balance'; COMMENT ON COLUMN evt.bal.obal IS 'opening balance';
COMMENT ON COLUMN evt.bal.debits IS 'total debits'; COMMENT ON COLUMN evt.bal.debits IS 'total debits';
COMMENT ON COLUMN evt.bal.credits IS 'total credits'; COMMENT ON COLUMN evt.bal.credits IS 'total credits';
COMMENT ON COLUMN evt.bal.cbal IS 'closing balance'; COMMENT ON COLUMN evt.bal.cbal IS 'closing balance';