acq.invoice_item

Cascading Deletes: Deleting rows from this table will cascade to: acq.invoice.

Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: invoice_item_fund_debit_fkey, invoice_item_fund_fkey, invoice_item_po_item_fkey.

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

Columns

Column Type Nullable Default Notes

id PK

integer

No

nextval('acq.invoice_item_id_seq'::regclass)

invoice FK

integer

No

acq.invoice(id)

purchase_order FK

integer

Yes

acq.purchase_order(id)

fund_debit FK

integer

Yes

acq.fund_debit(id)

inv_item_type FK

text

No

acq.invoice_item_type(code)

title

text

Yes

author

text

Yes

note

text

Yes

cost_billed

numeric(8,2)

Yes

actual_cost

numeric(8,2)

Yes

fund FK

integer

Yes

acq.fund(id)

amount_paid

numeric(8,2)

Yes

po_item FK

integer

Yes

acq.po_item(id)

target

bigint

Yes

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

fund_debit

acq.fund_debit(id)

NO ACTION

NO ACTION

DEFERRED

invoice_item_fund_debit_fkey

fund

acq.fund(id)

NO ACTION

NO ACTION

DEFERRED

invoice_item_fund_fkey

inv_item_type

acq.invoice_item_type(code)

NO ACTION

NO ACTION

No

invoice_item_inv_item_type_fkey

invoice

acq.invoice(id)

CASCADE

CASCADE

No

invoice_item_invoice_fkey

po_item

acq.po_item(id)

NO ACTION

NO ACTION

DEFERRED

invoice_item_po_item_fkey

purchase_order

acq.purchase_order(id)

SET NULL

CASCADE

No

invoice_item_purchase_order_fkey

Indexes

Index Method Definition

invoice_item_pkey PK

btree

CREATE UNIQUE INDEX invoice_item_pkey ON acq.invoice_item USING btree (id)

ii_fund_debit_idx

btree

CREATE INDEX ii_fund_debit_idx ON acq.invoice_item USING btree (fund_debit)

ii_inv_idx

btree

CREATE INDEX ii_inv_idx ON acq.invoice_item USING btree (invoice)

ii_po_idx

btree

CREATE INDEX ii_po_idx ON acq.invoice_item USING btree (purchase_order)

ii_poi_idx

btree

CREATE INDEX ii_poi_idx ON acq.invoice_item USING btree (po_item)

Triggers

Trigger Timing Event Level Function

audit_acq_invoice_item_update_trigger

AFTER

DELETE OR UPDATE

ROW

auditor.audit_acq_invoice_item_func()

Trigger Bodies

audit_acq_invoice_item_update_trigger

Function: auditor.audit_acq_invoice_item_func()
Timing: AFTER DELETE OR UPDATE ROW

        BEGIN
            INSERT INTO auditor.acq_invoice_item_history ( audit_id, audit_time, audit_action, audit_user, audit_ws, id, invoice, purchase_order, fund_debit, inv_item_type, title, author, note, cost_billed, actual_cost, fund, amount_paid, po_item, target )
                SELECT  nextval('auditor.acq_invoice_item_pkey_seq'),
                    now(),
                    SUBSTR(TG_OP,1,1),
                    eg_user,
                    eg_ws,
                    OLD.id, OLD.invoice, OLD.purchase_order, OLD.fund_debit, OLD.inv_item_type, OLD.title, OLD.author, OLD.note, OLD.cost_billed, OLD.actual_cost, OLD.fund, OLD.amount_paid, OLD.po_item, OLD.target
                FROM auditor.get_audit_info();
            RETURN NULL;
        END;