LP1952931 ASN shipment notification SQL
authorBill Erickson <berickxx@gmail.com>
Wed, 1 Dec 2021 17:55:13 +0000 (12:55 -0500)
committerJane Sandberg <sandbergja@gmail.com>
Thu, 20 Oct 2022 13:56:08 +0000 (06:56 -0700)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql [new file with mode: 0644]

index 35eaebc..d7d5241 100644 (file)
@@ -9539,6 +9539,68 @@ SELECT  usr,
         </permacrud>
        </class>
 
+       <class id="acqsn" 
+               controller="open-ils.cstore open-ils.pcrud" 
+               oils_obj:fieldmapper="acq::shipment_notification" 
+               oils_persist:tablename="acq.shipment_notification" reporter:label="Shipment Notification">
+               <fields oils_persist:primary="id" oils_persist:sequence="acq.shipment_notification_id_seq">
+                       <field reporter:label="Shipment Notification ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Receiver" name="receiver" reporter:datatype="org_unit" />
+                       <field reporter:label="Provider" name="provider" reporter:datatype="link"/>
+                       <field reporter:label="Shipper" name="shipper" reporter:datatype="link"/>
+                       <field reporter:label="Receive Date" name="recv_date" reporter:datatype="timestamp" />
+                       <field reporter:label="Container Barcode" name="container_code" reporter:datatype="text" />
+                       <field reporter:label="Lading Number" name="lading_number" reporter:datatype="text" />
+                       <field reporter:label="Note" name="note" reporter:datatype="text" />
+                       <field reporter:label="Shipment Notification Entries" name="entries" 
+                               reporter:datatype="link" oils_persist:virtual="true"/>
+               </fields>
+               <links>
+                       <link field="receiver" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
+                       <link field="shipper" reltype="has_a" key="id" map="" class="acqpro"/>
+                       <link field="entries" reltype="has_many" key="shipment_notification" map="" class="acqsne"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <retrieve permission="MANAGE_SHIPMENT_NOTIFICATION VIEW_SHIPMENT_NOTIFICATION" context_field="receiver"/>
+                               <update   permission="MANAGE_SHIPMENT_NOTIFICATION" context_field="receiver"/>
+                               <delete   permission="MANAGE_SHIPMENT_NOTIFICATION" context_field="receiver"/>
+                       </actions>
+               </permacrud>
+       </class>
+
+       <class id="acqsne" 
+               controller="open-ils.cstore open-ils.pcrud" 
+               oils_obj:fieldmapper="acq::shipment_notification_entry" 
+               oils_persist:tablename="acq.shipment_notification_entry" 
+               reporter:label="Shipment Notification Entry">
+               <fields oils_persist:primary="id" 
+                       oils_persist:sequence="acq.shipment_notification_entry_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Shipment Notification" name="shipment_notification" reporter:datatype="link" />
+                       <field reporter:label="Line Item" name="lineitem" reporter:datatype="link"/>
+                       <field reporter:label="Item Count" name="inv_item_count" reporter:datatype="int" />
+               </fields>
+               <links>
+                       <link field="shipment_notification" reltype="has_a" key="id" map="" class="acqinv"/>
+                       <link field="lineitem" reltype="has_a" key="id" map="" class="jub"/>
+               </links>
+                       <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                               <actions>
+                                       <retrieve permission="MANAGE_SHIPMENT_NOTIFICATION VIEW_SHIPMENT_NOTIFICATION">
+                                               <context link="shipment_notification" field="receiver"/>
+                                       </retrieve>
+                                       <update permission="MANAGE_SHIPMENT_NOTIFICATION">
+                                               <context link="shipment_notification" field="receiver"/>
+                                       </update>
+                                       <delete permission="MANAGE_SHIPMENT_NOTIFICATION">
+                                               <context link="shipment_notification" field="receiver"/>
+                                       </delete>
+                               </actions>
+                       </permacrud>
+       </class>
+
        <class id="acqpa" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider_address" oils_persist:tablename="acq.provider_address" reporter:label="Provider Address">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_address_id_seq">
                        <field reporter:label="Address Type" name="address_type"  reporter:datatype="text"/>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql
new file mode 100644 (file)
index 0000000..c445890
--- /dev/null
@@ -0,0 +1,33 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
+
+CREATE TABLE acq.shipment_notification (
+    id              SERIAL      PRIMARY KEY,
+    receiver        INT         NOT NULL REFERENCES actor.org_unit (id),
+    provider        INT         NOT NULL REFERENCES acq.provider (id),
+    shipper         INT         NOT NULL REFERENCES acq.provider (id),
+    recv_date       TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+    container_code  TEXT        NOT NULL, -- vendor-supplied super-barcode
+    lading_number   TEXT,       -- informational
+    note            TEXT,
+    CONSTRAINT      container_code_once_per_provider UNIQUE(provider, container_code)
+);
+
+CREATE INDEX acq_asn_container_code_idx ON acq.shipment_notification (container_code);
+
+CREATE TABLE acq.shipment_notification_entry (
+    id                      SERIAL  PRIMARY KEY,
+    shipment_notification   INT NOT NULL REFERENCES acq.invoice (id) ON DELETE CASCADE,
+    lineitem                INT REFERENCES acq.lineitem (id) ON UPDATE CASCADE ON DELETE SET NULL,
+    item_count              INT NOT NULL -- How many items the provider shipped
+);
+
+COMMIT;
+
+/* UNDO
+
+DROP TABLE acq.shipment_notification_entry;
+DROP TABLE acq.shipment_notification;
+
+*/