<field reporter:label="Payment Auth" name="payment_auth" reporter:datatype="text" />
<field reporter:label="Payment Method" name="payment_method" reporter:datatype="link" />
<field reporter:label="Note" name="note" reporter:datatype="text" />
- <field reporter:label="Complete" name="complete" reporter:datatype="bool" />
+ <field reporter:label="Close Date" name="close_date" reporter:datatype="timestamp" />
+ <field reporter:label="Closed By" name="closed_by" reporter:datatype="link" />
<field reporter:label="Invoice Entries" name="entries" reporter:datatype="link" oils_persist:virtual="true"/>
<field reporter:label="Invoice Items" name="items" reporter:datatype="link" oils_persist:virtual="true"/>
</fields>
<link field="payment_method" reltype="has_a" key="code" map="" class="acqipm"/>
<link field="entries" reltype="has_many" key="invoice" map="" class="acqie"/>
<link field="items" reltype="has_many" key="invoice" map="" class="acqii"/>
+ <link field="closed_by" reltype="has_a" key="id" map="" class="au"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
--- /dev/null
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- TODO
+-- ADD TO PATRON PURGE SQL FUNC
+-- Back-fill closed_by? with ??
+
+DROP VIEW auditor.acq_invoice_lifecycle;
+
+ALTER TABLE acq.invoice
+ ADD COLUMN close_date TIMESTAMPTZ,
+ ADD COLUMN closed_by INTEGER
+ REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED;
+
+-- duplicate steps for auditor table
+ALTER TABLE auditor.acq_invoice_history
+ ADD COLUMN close_date TIMESTAMPTZ,
+ ADD COLUMN closed_by INTEGER;
+
+UPDATE acq.invoice SET close_date = NOW() WHERE complete;
+UPDATE auditor.acq_invoice_history SET close_date = NOW() WHERE complete;
+
+ALTER TABLE acq.invoice DROP COLUMN complete;
+ALTER TABLE auditor.acq_invoice_history DROP COLUMN complete;
+
+-- this recreates auditor.acq_invoice_lifecycle;
+SELECT auditor.update_auditors();
+
+COMMIT;
+
+
+-- UNDO
+/*
+
+BEGIN;
+DROP VIEW auditor.acq_invoice_lifecycle;
+ALTER TABLE acq.invoice ADD COLUMN complete BOOLEAN NOT NULL DEFAULT FALSE;
+ALTER TABLE auditor.acq_invoice_history
+ ADD COLUMN complete BOOLEAN NOT NULL DEFAULT FALSE;
+UPDATE acq.invoice SET complete = TRUE where close_date IS NOT NULL;
+UPDATE auditor.acq_invoice_history
+ SET complete = TRUE where close_date IS NOT NULL;
+ALTER TABLE acq.invoice DROP COLUMN close_date, DROP COLUMN closed_by;
+ALTER TABLE auditor.acq_invoice_history
+ DROP COLUMN close_date, DROP COLUMN closed_by;
+SELECT auditor.update_auditors();
+COMMIT;
+
+*/