acq.invoice

Deferrable Constraints: The following FK constraints are deferrable — they are checked at transaction end, not statement end: invoice_closed_by_fkey, invoice_payment_method_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_id_seq'::regclass)

receiver FK

integer

No

actor.org_unit(id)

provider FK

integer

No

acq.provider(id)

shipper FK

integer

No

acq.provider(id)

recv_date

timestamp with time zone

No

now()

recv_method FK

text

No

'EDI'::text

acq.invoice_method(code)

inv_type

text

Yes

inv_ident

text

No

payment_auth

text

Yes

payment_method FK

text

Yes

acq.invoice_payment_method(code)

note

text

Yes

close_date

timestamp with time zone

Yes

closed_by FK

integer

Yes

actor.usr(id)

Primary Key

(id)

Foreign Keys

Column(s) References On Delete On Update Deferrable Constraint

closed_by

actor.usr(id)

NO ACTION

NO ACTION

DEFERRED

invoice_closed_by_fkey

payment_method

acq.invoice_payment_method(code)

NO ACTION

NO ACTION

DEFERRED

invoice_payment_method_fkey

provider

acq.provider(id)

NO ACTION

NO ACTION

No

invoice_provider_fkey

receiver

actor.org_unit(id)

NO ACTION

NO ACTION

No

invoice_receiver_fkey

recv_method

acq.invoice_method(code)

NO ACTION

NO ACTION

No

invoice_recv_method_fkey

shipper

acq.provider(id)

NO ACTION

NO ACTION

No

invoice_shipper_fkey

Unique Constraints

  • inv_ident_once_per_provider: (provider, inv_ident)

Indexes

Index Method Definition

invoice_pkey PK

btree

CREATE UNIQUE INDEX invoice_pkey ON acq.invoice USING btree (id)

inv_ident_once_per_provider UNIQUE

btree

CREATE UNIQUE INDEX inv_ident_once_per_provider ON acq.invoice USING btree (provider, inv_ident)

Triggers

Trigger Timing Event Level Function

audit_acq_invoice_update_trigger

AFTER

DELETE OR UPDATE

ROW

auditor.audit_acq_invoice_func()

Trigger Bodies

audit_acq_invoice_update_trigger

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

        BEGIN
            INSERT INTO auditor.acq_invoice_history ( audit_id, audit_time, audit_action, audit_user, audit_ws, id, receiver, provider, shipper, recv_date, recv_method, inv_type, inv_ident, payment_auth, payment_method, note, close_date, closed_by )
                SELECT  nextval('auditor.acq_invoice_pkey_seq'),
                    now(),
                    SUBSTR(TG_OP,1,1),
                    eg_user,
                    eg_ws,
                    OLD.id, OLD.receiver, OLD.provider, OLD.shipper, OLD.recv_date, OLD.recv_method, OLD.inv_type, OLD.inv_ident, OLD.payment_auth, OLD.payment_method, OLD.note, OLD.close_date, OLD.closed_by
                FROM auditor.get_audit_info();
            RETURN NULL;
        END;

Referenced By

The following tables have foreign keys pointing to acq.invoice (2 referencing table(s)):

Table Referencing Column(s) Referenced Column(s) Constraint

acq.invoice_entry

invoice

id

invoice_entry_invoice_fkey

acq.invoice_item

invoice

id

invoice_item_invoice_fkey