[open-ils-commits] r15704 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 4 16:32:00 EST 2010
Author: scottmk
Date: 2010-03-04 16:31:55 -0500 (Thu, 04 Mar 2010)
New Revision: 15704
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0177.schema.cancel_reason.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
Log:
Create new table acq.cancel_reason.
Create new columns pointing to it in acq.purchase_order and
acq.lineitem.
See KCLS ticket #3015.
M Open-ILS/src/sql/Pg/200.schema.acq.sql
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0177.schema.cancel_reason.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2010-03-04 20:25:20 UTC (rev 15703)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2010-03-04 21:31:55 UTC (rev 15704)
@@ -5087,6 +5087,20 @@
</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" />
@@ -5100,6 +5114,7 @@
<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" />
@@ -5115,6 +5130,7 @@
<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>
@@ -5190,6 +5206,7 @@
<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" />
@@ -5206,6 +5223,7 @@
<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>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-04 20:25:20 UTC (rev 15703)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-04 21:31:55 UTC (rev 15704)
@@ -51,7 +51,7 @@
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,
Modified: trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-03-04 20:25:20 UTC (rev 15703)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-03-04 21:31:55 UTC (rev 15704)
@@ -322,6 +322,21 @@
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,
@@ -333,7 +348,9 @@
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);
@@ -435,6 +452,8 @@
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);
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0177.schema.cancel_reason.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0177.schema.cancel_reason.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0177.schema.cancel_reason.sql 2010-03-04 21:31:55 UTC (rev 15704)
@@ -0,0 +1,28 @@
+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;
More information about the open-ils-commits
mailing list