allow ACQ-driven ordering and claiming of serial items
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Aug 2010 20:36:10 +0000 (20:36 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Aug 2010 20:36:10 +0000 (20:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17080 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0360.schema.acq-serials-integration.sql [new file with mode: 0644]

index bb4fd58..3ee30f5 100644 (file)
@@ -3238,7 +3238,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
        <class id="sunit" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="serial::unit" oils_persist:tablename="serial.unit" reporter:label="Unit">
                <fields oils_persist:primary="id" oils_persist:sequence="asset.copy_id_seq">
                        <field reporter:label="ID" name="id" reporter:datatype="id"/>
-                       <field reporter:label="Statistical Category Entries" name="stat_cat_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Age Hold Protection" name="age_protect" reporter:datatype="link"/>
                        <field reporter:label="Alert Message" name="alert_message" reporter:datatype="text"/>
                        <field reporter:label="Barcode" name="barcode" reporter:datatype="text"/>
@@ -3269,14 +3268,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Copy Status Changed Time" name="status_changed_time" reporter:datatype="timestamp"/>
                        <field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool"/>
                        <field reporter:label="Is Floating" name="floating" reporter:datatype="bool"/>
+                       <field reporter:label="Cost" name="cost" reporter:datatype="money"/>
+                       <field reporter:label="Sort Key" name="sort_key" reporter:datatype="text"/>
+                       <field reporter:label="Summary Contents" name="summary_contents" reporter:datatype="text"/>
+                       <field reporter:label="Detailed Contents" name="detailed_contents" reporter:datatype="text"/>
                        <field reporter:label="Copy Notes" name="notes" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Stat-Cat entry maps" name="stat_cat_entry_copy_maps" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Total Circulations" name="total_circ_count" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Holds" name="holds" oils_persist:virtual="true" reporter:datatype="link"/>
-                       <field reporter:label="Sort Key" name="sort_key" reporter:datatype="text"/>
-                       <field reporter:label="Summary Contents" name="summary_contents" reporter:datatype="text"/>
-                       <field reporter:label="Detailed Contents" name="detailed_contents" reporter:datatype="text"/>
+                       <field reporter:label="Statistical Category Entries" name="stat_cat_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="age_protect" reltype="has_a" key="id" map="" class="crahp"/>
@@ -4216,7 +4217,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
        </class>
        <class id="acp" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::copy" oils_persist:tablename="asset.copy" reporter:core="true" reporter:label="Item">
                <fields oils_persist:primary="id" oils_persist:sequence="asset.copy_id_seq">
-                       <field reporter:label="Statistical Category Entries" name="stat_cat_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Age Hold Protection" name="age_protect" reporter:datatype="link"/>
                        <field reporter:label="Alert Message" name="alert_message" reporter:datatype="text"/>
                        <field reporter:label="Barcode" name="barcode" reporter:datatype="text"/>
@@ -4248,11 +4248,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Copy Status Changed Time" name="status_changed_time" reporter:datatype="timestamp"/>
                        <field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool"/>
                        <field reporter:label="Is Floating" name="floating" reporter:datatype="bool"/>
+                       <field reporter:label="Cost" name="cost" reporter:datatype="money"/>
                        <field reporter:label="Copy Notes" name="notes" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Stat-Cat entry maps" name="stat_cat_entry_copy_maps" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Total Circulations" name="total_circ_count" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Holds" name="holds" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Statistical Category Entries" name="stat_cat_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="age_protect" reltype="has_a" key="id" map="" class="crahp"/>
@@ -5167,6 +5169,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Fund" name="fund" reporter:datatype="link" />
                        <field reporter:label="Amount Paid" name="amount_paid" reporter:datatype="money" />
                        <field reporter:label="Purchase Order Item" name="po_item" reporter:datatype="link" />
+                       <field reporter:label="Target" name="target" reporter:datatype="int" />
                </fields>
                <links>
                        <link field="invoice" reltype="has_a" key="id" map="" class="acqinv"/>
@@ -5879,6 +5882,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Note" name="note" reporter:datatype="text"/>
                        <field reporter:label="Estimated Cost" name="estimated_cost" reporter:datatype="money"/>
                        <field reporter:label="Fund" name="fund" reporter:datatype="link"/>
+                       <field reporter:label="Target" name="target" reporter:datatype="int" />
                </fields>
                <links>
                        <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
@@ -6728,6 +6732,38 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
+       <class id="acqscl" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::serial_claim" oils_persist:tablename="acq.serial_claim" reporter:label="Serial Claim">
+               <fields oils_persist:primary="id" oils_persist:sequence="acq.serial_claim_id_seq">
+                       <field reporter:label="Claim ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Claim Type" name="type" reporter:datatype="link"/>
+                       <field reporter:label="Serial Item" name="item" reporter:datatype="link"/>
+               </fields>
+               <links>
+                       <link field="type" reltype="has_a" key="id" map="" class="acqclt"/>
+                       <link field="item" reltype="has_a" key="id" map="" class="sitem"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+               </permacrud>
+       </class>
+
+       <class id="acqscle" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::serial_claim_event" oils_persist:tablename="acq.serial_claim_event" reporter:label="Serial Claim Event">
+               <fields oils_persist:primary="id" oils_persist:sequence="acq.serial_claim_event_id_seq">
+                       <field reporter:label="Claim Event ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Claim Event Type" name="type" reporter:datatype="link"/>
+                       <field reporter:label="Claim ID" name="claim" reporter:datatype="link"/>
+                       <field reporter:label="Event Date" name="event_date" reporter:datatype="timestamp"/>
+                       <field reporter:label="Creator" name="creator" reporter:datatype="link"/>
+                       <field reporter:label="Note" name="note" reporter:datatype="text"/>
+               </fields>
+               <links>
+                       <link field="type" reltype="has_a" key="id" map="" class="acqclet"/>
+                       <link field="claim" reltype="has_a" key="id" map="" class="acqscl"/>
+                       <link field="creator" reltype="has_a" key="id" map="" class="au"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+               </permacrud>
+       </class>
+
        <class id="acqclp" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::claim_policy" oils_persist:tablename="acq.claim_policy" reporter:label="Claim Policy">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.claim_policy_id_seq">
                        <field reporter:label="ID" name="id" reporter:datatype="id" reporter:selector="name"/>
index 92e8995..4a79a63 100644 (file)
@@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0359'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0360'); -- miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 5e34d0d..7a4d23e 100644 (file)
@@ -78,7 +78,8 @@ CREATE TABLE asset.copy (
        floating                BOOL                            NOT NULL DEFAULT FALSE,
        dummy_isbn      TEXT,
        status_changed_time TIMESTAMP WITH TIME ZONE,
-       mint_condition      BOOL        NOT NULL DEFAULT TRUE
+       mint_condition      BOOL        NOT NULL DEFAULT TRUE,
+    cost    NUMERIC(8,2)
 );
 CREATE UNIQUE INDEX copy_barcode_key ON asset.copy (barcode) WHERE deleted = FALSE OR deleted IS FALSE;
 CREATE INDEX cp_cn_idx ON asset.copy (call_number);
index 289cd79..18c0b65 100644 (file)
@@ -880,7 +880,8 @@ CREATE TABLE acq.po_item (
        note            TEXT,
        estimated_cost  NUMERIC(8,2),
        fund            INT         REFERENCES acq.fund (id)
-                                   DEFERRABLE INITIALLY DEFERRED
+                                   DEFERRABLE INITIALLY DEFERRED,
+    target          BIGINT
 );
 
 CREATE TABLE acq.invoice_item ( -- for invoice-only debits: taxes/fees/non-bib items/etc
@@ -898,7 +899,8 @@ CREATE TABLE acq.invoice_item ( -- for invoice-only debits: taxes/fees/non-bib i
                                    DEFERRABLE INITIALLY DEFERRED,
        amount_paid     NUMERIC (8,2),
        po_item         INT         REFERENCES acq.po_item (id)
-                                   DEFERRABLE INITIALLY DEFERRED
+                                   DEFERRABLE INITIALLY DEFERRED,
+    target          BIGINT
 );
 
 -- Patron requests
@@ -2622,4 +2624,29 @@ CREATE TABLE acq.claim_event (
 
 CREATE INDEX claim_event_claim_date_idx ON acq.claim_event( claim, event_date );
 
+-- And the serials version of claiming
+CREATE TABLE acq.serial_claim (
+    id     SERIAL           PRIMARY KEY,
+    type   INT              NOT NULL REFERENCES acq.claim_type
+                                     DEFERRABLE INITIALLY DEFERRED,
+    item    BIGINT          NOT NULL REFERENCES serial.item
+                                     DEFERRABLE INITIALLY DEFERRED
+);
+
+CREATE INDEX serial_claim_lid_idx ON acq.serial_claim( item );
+
+CREATE TABLE acq.serial_claim_event (
+    id             BIGSERIAL        PRIMARY KEY,
+    type           INT              NOT NULL REFERENCES acq.claim_event_type
+                                             DEFERRABLE INITIALLY DEFERRED,
+    claim          SERIAL           NOT NULL REFERENCES acq.serial_claim
+                                             DEFERRABLE INITIALLY DEFERRED,
+    event_date     TIMESTAMPTZ      NOT NULL DEFAULT now(),
+    creator        INT              NOT NULL REFERENCES actor.usr
+                                             DEFERRABLE INITIALLY DEFERRED,
+    note           TEXT
+);
+
+CREATE INDEX serial_claim_event_claim_date_idx ON acq.serial_claim_event( claim, event_date );
+
 COMMIT;
index 6b45300..11eaac2 100644 (file)
@@ -5569,6 +5569,7 @@ INSERT INTO acq.invoice_item_type (code,name) VALUES ('PRO',oils_i18n_gettext('P
 INSERT INTO acq.invoice_item_type (code,name) VALUES ('SHP',oils_i18n_gettext('SHP', 'Shipping Charge', 'aiit', 'name'));
 INSERT INTO acq.invoice_item_type (code,name) VALUES ('HND',oils_i18n_gettext('HND', 'Handling Charge', 'aiit', 'name'));
 INSERT INTO acq.invoice_item_type (code,name) VALUES ('ITM',oils_i18n_gettext('ITM', 'Non-library Item', 'aiit', 'name'));
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('SUB',oils_i18n_gettext('SUB', 'Searial Subscription', 'aiit', 'name'));
 
 INSERT INTO acq.invoice_method (code,name) VALUES ('EDI',oils_i18n_gettext('EDI', 'EDI', 'acqim', 'name'));
 INSERT INTO acq.invoice_method (code,name) VALUES ('PPR',oils_i18n_gettext('PPR', 'Paper', 'acqit', 'name'));
diff --git a/Open-ILS/src/sql/Pg/upgrade/0360.schema.acq-serials-integration.sql b/Open-ILS/src/sql/Pg/upgrade/0360.schema.acq-serials-integration.sql
new file mode 100644 (file)
index 0000000..548593c
--- /dev/null
@@ -0,0 +1,36 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0360'); -- miker
+
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('SUB',oils_i18n_gettext('SUB', 'Searial Subscription', 'aiit', 'name'));
+
+ALTER TABLE acq.po_item ADD COLUMN target BIGINT;
+ALTER TABLE acq.invoice_item ADD COLUMN target BIGINT;
+ALTER TABLE asset.copy ADD COLUMN cost NUMERIC(8,2);
+
+CREATE TABLE acq.serial_claim (
+    id     SERIAL           PRIMARY KEY,
+    type   INT              NOT NULL REFERENCES acq.claim_type
+                                     DEFERRABLE INITIALLY DEFERRED,
+    item    BIGINT          NOT NULL REFERENCES serial.item
+                                     DEFERRABLE INITIALLY DEFERRED
+);
+
+CREATE INDEX serial_claim_lid_idx ON acq.serial_claim( item );
+
+CREATE TABLE acq.serial_claim_event (
+    id             BIGSERIAL        PRIMARY KEY,
+    type           INT              NOT NULL REFERENCES acq.claim_event_type
+                                             DEFERRABLE INITIALLY DEFERRED,
+    claim          SERIAL           NOT NULL REFERENCES acq.serial_claim
+                                             DEFERRABLE INITIALLY DEFERRED,
+    event_date     TIMESTAMPTZ      NOT NULL DEFAULT now(),
+    creator        INT              NOT NULL REFERENCES actor.usr
+                                             DEFERRABLE INITIALLY DEFERRED,
+    note           TEXT
+);
+
+CREATE INDEX serial_claim_event_claim_date_idx ON acq.serial_claim_event( claim, event_date );
+
+COMMIT;
+