money.grocery

Trigger Side Effects: Writing to this table automatically triggers writes to other tables:

Columns

Column Type Nullable Default Notes

id PK

bigint

No

nextval('money.billable_xact_id_seq'::regclass)

usr

integer

No

xact_start

timestamp with time zone

No

now()

xact_finish

timestamp with time zone

Yes

unrecovered

boolean

Yes

billing_location

integer

No

note

text

Yes

Primary Key

(id)

Indexes

Index Method Definition

grocery_pkey PK

btree

CREATE UNIQUE INDEX grocery_pkey ON money.grocery USING btree (id)

circ_open_date_idx

btree

CREATE INDEX circ_open_date_idx ON money.grocery USING btree (xact_start) WHERE (xact_finish IS NULL)

m_g_usr_idx

btree

CREATE INDEX m_g_usr_idx ON money.grocery USING btree (usr)

Triggers

Trigger Timing Event Level Function

mat_summary_change_tgr

AFTER

UPDATE

ROW

money.mat_summary_update()

mat_summary_create_tgr

AFTER

INSERT

ROW

money.mat_summary_create()

mat_summary_remove_tgr

AFTER

DELETE

ROW

money.mat_summary_delete()

Trigger Bodies

mat_summary_change_tgr

Function: money.mat_summary_update()
Timing: AFTER UPDATE ROW

BEGIN
	UPDATE	money.materialized_billable_xact_summary
	  SET	usr = NEW.usr,
		xact_start = NEW.xact_start,
		xact_finish = NEW.xact_finish
	  WHERE	id = NEW.id;
	RETURN NEW;
END;

mat_summary_create_tgr

Function: money.mat_summary_create()
Timing: AFTER INSERT ROW

BEGIN
	INSERT INTO money.materialized_billable_xact_summary (id, usr, xact_start, xact_finish, total_paid, total_owed, balance_owed, xact_type)
		VALUES ( NEW.id, NEW.usr, NEW.xact_start, NEW.xact_finish, 0.0, 0.0, 0.0, TG_ARGV[0]);
	RETURN NEW;
END;

mat_summary_remove_tgr

Function: money.mat_summary_delete()
Timing: AFTER DELETE ROW

BEGIN
	DELETE FROM money.materialized_billable_xact_summary WHERE id = OLD.id;
	RETURN OLD;
END;