</links>
</class>
+ <class id="acqcr" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::cancel_reason" oils_persist:tablename="acq.cancel_reason" reporter:label="Cancel Reason">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.cancel_reason_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Using Library" name="org_unit" reporter:datatype="org_unit"/>
+ <field reporter:label="Label" name="label" reporter:datatype="text"/>
+ <field reporter:label="Description" name="description" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
<class id="acqpo" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::purchase_order" oils_persist:tablename="acq.purchase_order" reporter:label="Purchase Order">
<fields oils_persist:primary="id" oils_persist:sequence="acq.purchase_order_id_seq">
<field reporter:label="Purchase Order ID" name="id" reporter:datatype="id" />
<field reporter:label="Editor" name="editor" reporter:datatype="link" />
<field reporter:label="Order Date" name="order_date" reporter:datatype="timestamp" />
<field reporter:label="Name" name="name" reporter:datatype="text" />
+ <field reporter:label="Cancel Reason" name="cancel_reason" reporter:datatype="link" />
<field reporter:label="Line Items" name="lineitems" oils_persist:virtual="true" reporter:datatype="link" />
<field reporter:label="Notes" name="notes" oils_persist:virtual="true" reporter:datatype="link" />
<field reporter:label="Line Item Count" name="lineitem_count" oils_persist:virtual="true" reporter:datatype="link" />
<link field="lineitems" reltype="has_many" key="purchase_order" map="" class="jub"/>
<link field="notes" reltype="has_many" key="purchase_order" map="" class="acqpon"/>
<link field="ordering_agency" reltype="has_a" key="id" map="" class="aou"/>
+ <link field="cancel_reason" reltype="has_a" key="id" map="" class="acqcr"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
<field reporter:label="Creator" name="creator" reporter:datatype="link" />
<field reporter:label="Editor" name="editor" reporter:datatype="link" />
<field reporter:label="Claim Interval" name="claim_interval" reporter:datatype="interval" />
+ <field reporter:label="Cancel Reason" name="cancel_reason" reporter:datatype="link" />
<field reporter:label="Item Count" name="item_count" oils_persist:virtual="true" reporter:datatype="int" />
<field reporter:label="Descriptive Attributes" name="attributes" oils_persist:virtual="true" reporter:datatype="link" />
<field reporter:label="Line Item Details" name="lineitem_details" oils_persist:virtual="true" reporter:datatype="link" />
<link field="attributes" reltype="has_many" key="lineitem" map="" class="acqlia"/>
<link field="lineitem_details" reltype="has_many" key="lineitem" map="" class="acqlid"/>
<link field="lineitem_notes" reltype="has_many" key="lineitem" map="" class="acqlin"/>
+ <link field="cancel_reason" reltype="has_a" key="id" map="" class="acqcr"/>
</links>
</class>
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0176'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0177'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
CREATE INDEX acq_picklist_creator_idx ON acq.picklist ( creator );
CREATE INDEX acq_picklist_editor_idx ON acq.picklist ( editor );
+CREATE TABLE acq.cancel_reason (
+ id SERIAL PRIMARY KEY,
+ org_unit INTEGER NOT NULL REFERENCES actor.org_unit( id )
+ DEFERRABLE INITIALLY DEFERRED,
+ label TEXT NOT NULL,
+ description TEXT NOT NULL,
+ CONSTRAINT acq_cancel_reason_one_per_org_unit UNIQUE( org_unit, label )
+);
+
+-- Reserve ids 1-999 for stock reasons
+-- Reserve ids 1000-1999 for EDI reasons
+-- 2000+ are available for staff to create
+
+SELECT SETVAL('acq.cancel_reason_id_seq'::TEXT, 2000);
+
CREATE TABLE acq.purchase_order (
id SERIAL PRIMARY KEY,
owner INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED,
provider INT NOT NULL REFERENCES acq.provider (id) DEFERRABLE INITIALLY DEFERRED,
state TEXT NOT NULL DEFAULT 'new',
order_date TIMESTAMP WITH TIME ZONE,
- name TEXT NOT NULL
+ name TEXT NOT NULL,
+ cancel_reason INT REFERENCES acq.cancel_reason( id )
+ DEFERRABLE INITIALLY DEFERRED
);
CREATE INDEX po_owner_idx ON acq.purchase_order (owner);
CREATE INDEX po_provider_idx ON acq.purchase_order (provider);
source_label TEXT,
state TEXT NOT NULL DEFAULT 'new',
claim_interval INTERVAL,
+ cancel_reason INT REFERENCES acq.cancel_reason( id )
+ DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT picklist_or_po CHECK (picklist IS NOT NULL OR purchase_order IS NOT NULL)
);
CREATE INDEX li_po_idx ON acq.lineitem (purchase_order);
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0177'); -- Scott McKellar
+
+CREATE TABLE acq.cancel_reason (
+ id SERIAL PRIMARY KEY,
+ org_unit INTEGER NOT NULL REFERENCES actor.org_unit( id )
+ DEFERRABLE INITIALLY DEFERRED,
+ label TEXT NOT NULL,
+ description TEXT NOT NULL,
+ CONSTRAINT acq_cancel_reason_one_per_org_unit UNIQUE( org_unit, label )
+);
+
+-- Reserve ids 1-999 for stock reasons
+-- Reserve ids 1000-1999 for EDI reasons
+-- 2000+ are available for staff to create
+
+SELECT SETVAL('acq.cancel_reason_id_seq'::TEXT, 2000);
+
+ALTER TABLE acq.purchase_order
+ ADD COLUMN cancel_reason INT REFERENCES acq.cancel_reason( id )
+ DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE acq.lineitem
+ ADD COLUMN cancel_reason INT REFERENCES acq.cancel_reason( id )
+ DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;