[open-ils-commits] r15552 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 16 11:33:33 EST 2010
Author: miker
Date: 2010-02-16 11:33:30 -0500 (Tue, 16 Feb 2010)
New Revision: 15552
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0162.schema.acq-invoicing.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
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
initial invoicing schema
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2010-02-16 15:43:02 UTC (rev 15551)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2010-02-16 16:33:30 UTC (rev 15552)
@@ -847,6 +847,38 @@
</permacrud>
</class>
+ <class id="aiit" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::invoice_item_type" oils_persist:tablename="acq.invoice_item_type" reporter:label="Non-bibliographic Invoice Item Type" oils_persist:field_safe="true">
+ <fields oils_persist:primary="code">
+ <field reporter:label="Code" name="code" reporter:selector="name" reporter:datatype="id"/>
+ <field reporter:label="Label" name="label" reporter:datatype="text" oils_persist:i18n="true"/>
+ </fields>
+ <links/>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="CREATE_INVOICE_ITEM_TYPE" global_required="true"/>
+ <retrieve/>
+ <update permission="UPDATE_INVOICE_ITEM_TYPE" global_required="true"/>
+ <delete permission="DELETE_INVOICE_ITEM_TYPE" global_required="true"/>
+ </actions>
+ </permacrud>
+ </class>
+
+ <class id="acqim" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::invoice_method" oils_persist:tablename="acq.invoice_method" reporter:label="Invoice Method used by Vendor" oils_persist:field_safe="true">
+ <fields oils_persist:primary="code">
+ <field reporter:label="Code" name="code" reporter:selector="name" reporter:datatype="id"/>
+ <field reporter:label="Label" name="label" reporter:datatype="text" oils_persist:i18n="true"/>
+ </fields>
+ <links/>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="CREATE_INVOICE_METHOD" global_required="true"/>
+ <retrieve/>
+ <update permission="UPDATE_INVOICE_METHOD" global_required="true"/>
+ <delete permission="DELETE_INVOICE_METHOD" global_required="true"/>
+ </actions>
+ </permacrud>
+ </class>
+
<class id="ccpbt" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="container::copy_bucket_type" oils_persist:tablename="container.copy_bucket_type" reporter:label="Copy Bucket Type" oils_persist:field_safe="true">
<fields oils_persist:primary="code">
<field reporter:label="Code" name="code" reporter:selector="name" reporter:datatype="id"/>
@@ -4444,6 +4476,105 @@
</permacrud>
</class>
+ <class id="acqinv" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::invoice" oils_persist:tablename="acq.invoice" reporter:label="Invoice">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.invoice_id_seq">
+ <field reporter:label="Internal Invoice 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/Time" name="recv_date" reporter:datatype="timestamp" />
+ <field reporter:label="Receive Method" name="receive_method" reporter:datatype="link" />
+ <field reporter:label="Invoice Type" name="invoice_type" reporter:datatype="text" />
+ <field reporter:label="Vendor Invoice ID" name="inv_ident" reporter:datatype="text" />
+ </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="receive_method" reltype="has_a" key="id" map="" class="acqim"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_INVOICE" context_field="receiver"/>
+ <retrieve permission="ADMIN_INVOICE" context_field="receiver"/>
+ <update permission="ADMIN_INVOICE" context_field="receiver"/>
+ <delete permission="ADMIN_INVOICE" context_field="receiver"/>
+ </actions>
+ </permacrud>
+ </class>
+
+ <class id="acqie" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::invoice_entry" oils_persist:tablename="acq.invoice_entry" reporter:label="Invoice Entry">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.invoice_entry_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Invoice" name="invoice" reporter:datatype="link" />
+ <field reporter:label="Purchase Order" name="purchase_order" reporter:datatype="link"/>
+ <field reporter:label="PO Line Item" name="lineitem" reporter:datatype="link"/>
+ <field reporter:label="Invoice Item Count" name="inv_item_count" reporter:datatype="int" />
+ <field reporter:label="Physical Item Count" name="phys_item_count" reporter:datatype="int" />
+ <field reporter:label="Note" name="note" reporter:datatype="text" />
+ <field reporter:label="Billed Cost per Item" name="billed_per_item" reporter:datatype="bool" />
+ <field reporter:label="Cost Billed" name="cost_billed" reporter:datatype="money" />
+ <field reporter:label="Actual Cost" name="actual_cost" reporter:datatype="money" />
+ </fields>
+ <links>
+ <link field="invoice" reltype="has_a" key="id" map="" class="acqinv"/>
+ <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
+ <link field="lineitem" reltype="has_a" key="id" map="" class="acqli"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </create>
+ <retrieve permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </retrieve>
+ <update permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </update>
+ <delete permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </delete>
+ </actions>
+ </permacrud>
+ </class>
+
+ <class id="acqii" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::invoice_item" oils_persist:tablename="acq.invoice_item" reporter:label="Non-bibliographic Invoice Item">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.invoice_item_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Invoice" name="invoice" reporter:datatype="link" />
+ <field reporter:label="Purchase Order" name="purchase_order" reporter:datatype="link"/>
+ <field reporter:label="Fund Debit" name="fund_debit" reporter:datatype="link"/>
+ <field reporter:label="Invoice Item Type" name="inv_item_type" reporter:datatype="link" />
+ <field reporter:label="Title or Item Name" name="title" reporter:datatype="text" />
+ <field reporter:label="Author" name="author" reporter:datatype="text" />
+ <field reporter:label="Note" name="note" reporter:datatype="text" />
+ <field reporter:label="Cost Billed" name="cost_billed" reporter:datatype="money" />
+ <field reporter:label="Actual Cost" name="actual_cost" reporter:datatype="money" />
+ </fields>
+ <links>
+ <link field="invoice" reltype="has_a" key="id" map="" class="acqinv"/>
+ <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
+ <link field="fund_debit" reltype="has_a" key="id" map="" class="acqfdeb"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </create>
+ <retrieve permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </retrieve>
+ <update permission="ADMIN_INVOICE">
+ <context link="invoice" field="receiver"/>
+ </update>
+ <delete permission="ADMIN_INVOICE">
+ <context link="invoice" 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"/>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-16 15:43:02 UTC (rev 15551)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-16 16:33:30 UTC (rev 15552)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0161'); --Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0162'); --miker
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-02-16 15:43:02 UTC (rev 15551)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2010-02-16 16:33:30 UTC (rev 15552)
@@ -700,7 +700,63 @@
CREATE INDEX acq_attribution_credit_idx
ON acq.debit_attribution( funding_source_credit );
+-- Invoicing
+CREATE TABLE acq.invoice_method (
+ code TEXT PRIMARY KEY,
+ name TEXT NOT NULL -- i18n-ize
+);
+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'));
+
+
+CREATE TABLE acq.invoice (
+ 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(),
+ recv_method TEXT NOT NULL REFERENCES acq.invoice_method (code) DEFAULT 'EDI',
+ inv_type TEXT, -- A "type" field is desired, but no idea what goes here
+ inv_ident TEXT NOT NULL -- vendor-supplied invoice id/number
+);
+
+CREATE TABLE acq.invoice_entry (
+ id SERIAL PRIMARY KEY,
+ invoice INT NOT NULL REFERENCES acq.invoice (id) ON DELETE CASCADE,
+ purchase_order INT REFERENCES acq.purchase_order (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ lineitem INT REFERENCES acq.lineitem (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ inv_item_count INT NOT NULL, -- How many acqlids did they say they sent
+ phys_item_count INT, -- and how many did staff count
+ note TEXT,
+ billed_per_item BOOL,
+ cost_billed NUMERIC(8,2),
+ actual_cost NUMERIC(8,2)
+);
+
+CREATE TABLE acq.invoice_item_type (
+ code TEXT PRIMARY KEY,
+ name TEXT NOT NULL -- i18n-ize
+);
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('TAX',oils_i18n_gettext('TAX', 'Tax', 'aiit', 'name'));
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('PRO',oils_i18n_gettext('PRO', 'Processing Fee', 'aiit', 'name'));
+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'));
+
+CREATE TABLE acq.invoice_item ( -- for invoice-only debits: taxes/fees/non-bib items/etc
+ id SERIAL PRIMARY KEY,
+ invoice INT NOT NULL REFERENCES acq.invoice (id) ON UPDATE CASCADE ON DELETE CASCADE,
+ purchase_order INT REFERENCES acq.purchase_order (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ fund_debit INT REFERENCES acq.fund_debit (id),
+ inv_item_type TEXT NOT NULL REFERENCES acq.invoice_item_type (code),
+ title TEXT,
+ author TEXT,
+ note TEXT,
+ cost_billed NUMERIC(8,2),
+ actual_cost NUMERIC(8,2)
+);
+
-- Patron requests
CREATE TABLE acq.user_request_type (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-02-16 15:43:02 UTC (rev 15551)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-02-16 16:33:30 UTC (rev 15552)
@@ -3921,3 +3921,13 @@
oils_i18n_gettext('acq.fund.balance_limit.block', 'When the amount remaining in the fund, including spent money and encumbrances, goes below this percentage, attempts to spend from the fund will be blocked.', 'coust', 'description'),
'integer'
);
+
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('TAX',oils_i18n_gettext('TAX', 'Tax', 'aiit', 'name'));
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('PRO',oils_i18n_gettext('PRO', 'Processing Fee', 'aiit', 'name'));
+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_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'));
+
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0162.schema.acq-invoicing.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0162.schema.acq-invoicing.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0162.schema.acq-invoicing.sql 2010-02-16 16:33:30 UTC (rev 15552)
@@ -0,0 +1,61 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0162'); -- miker
+
+CREATE TABLE acq.invoice_method (
+ code TEXT PRIMARY KEY,
+ name TEXT NOT NULL -- i18n-ize
+);
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('EDI',oils_i18n_gettext('EDI', 'EDI', 'acqim', 'name'));
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('PPR',oils_i18n_gettext('PPR', 'Paper', 'acqit', 'name'));
+
+
+CREATE TABLE acq.invoice (
+ 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(),
+ recv_method TEXT NOT NULL REFERENCES acq.invoice_method (code) DEFAULT 'EDI',
+ inv_type TEXT, -- A "type" field is desired, but no idea what goes here
+ inv_ident TEXT NOT NULL -- vendor-supplied invoice id/number
+);
+
+CREATE TABLE acq.invoice_entry (
+ id SERIAL PRIMARY KEY,
+ invoice INT NOT NULL REFERENCES acq.invoice (id) ON DELETE CASCADE,
+ purchase_order INT REFERENCES acq.purchase_order (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ lineitem INT REFERENCES acq.lineitem (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ inv_item_count INT NOT NULL, -- How many acqlids did they say they sent
+ phys_item_count INT, -- and how many did staff count
+ note TEXT,
+ billed_per_item BOOL,
+ cost_billed NUMERIC(8,2),
+ actual_cost NUMERIC(8,2)
+);
+
+CREATE TABLE acq.invoice_item_type (
+ code TEXT PRIMARY KEY,
+ name TEXT NOT NULL -- i18n-ize
+);
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('TAX',oils_i18n_gettext('TAX', 'Tax', 'aiit', 'name'));
+INSERT INTO acq.invoice_item_type (code,name) VALUES ('PRO',oils_i18n_gettext('PRO', 'Processing Fee', 'aiit', 'name'));
+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'));
+
+CREATE TABLE acq.invoice_item ( -- for invoice-only debits: taxes/fees/non-bib items/etc
+ id SERIAL PRIMARY KEY,
+ invoice INT NOT NULL REFERENCES acq.invoice (id) ON UPDATE CASCADE ON DELETE CASCADE,
+ purchase_order INT REFERENCES acq.purchase_order (id) ON UPDATE CASCADE ON DELETE SET NULL,
+ fund_debit INT REFERENCES acq.fund_debit (id),
+ inv_item_type TEXT NOT NULL REFERENCES acq.invoice_item_type (code),
+ title TEXT,
+ author TEXT,
+ note TEXT,
+ cost_billed NUMERIC(8,2),
+ actual_cost NUMERIC(8,2)
+);
+
+COMMIT;
+
More information about the open-ils-commits
mailing list