[open-ils-commits] r8747 - in branches/acq-experiment/Open-ILS:
examples src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Feb 13 17:32:37 EST 2008
Author: miker
Date: 2008-02-13 17:03:08 -0500 (Wed, 13 Feb 2008)
New Revision: 8747
Modified:
branches/acq-experiment/Open-ILS/examples/fm_IDL.xml
branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql
Log:
adding first cut of purchase order stuff
Modified: branches/acq-experiment/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/acq-experiment/Open-ILS/examples/fm_IDL.xml 2008-02-13 18:15:23 UTC (rev 8746)
+++ branches/acq-experiment/Open-ILS/examples/fm_IDL.xml 2008-02-13 22:03:08 UTC (rev 8747)
@@ -2612,6 +2612,50 @@
</links>
</class>
+ <class id="acqpo" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::purchase_order" oils_persist:tablename="acq.purchase_order">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.purchase_order_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="Purchase Order ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="Owner" name="owner" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Default Fund" name="default_fund" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creation Time" name="create_time" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Edit Time" name="edit_time" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Provider" name="provider" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="State" name="state" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Expected Receive Date" name="expected_recv_time" oils_obj:array_position="10" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Actual Receive Date" name="recv_time" oils_obj:array_position="11" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Line Items" name="lineitems" oils_obj:array_position="12" oils_persist:virtual="true" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="owner" reltype="has_a" key="id" map="" class="au"/>
+ <link field="default_fund" reltype="has_a" key="id" map="" class="acqf"/>
+ <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
+ <link field="lineitems" reltype="has_many" key="purchase_order" map="" class="acqpoli"/>
+ </links>
+ </class>
+
+ <class id="acqpon" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::po_note" oils_persist:tablename="acq.po_note">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.po_note_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="PO Note ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="Purchase Order" name="purchase_order" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creator" name="creator" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creation Time" name="create_time" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Edit Time" name="edit_time" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Editor" name="editor" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Vote Value" name="value" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="creator" reltype="has_a" key="id" map="" class="au"/>
+ <link field="editor" reltype="has_a" key="id" map="" class="au"/>
+ <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
+ </links>
+ </class>
+
<class id="acqple" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::picklist_entry" oils_persist:tablename="acq.picklist_entry">
<fields oils_persist:primary="id" oils_persist:sequence="acq.picklist_entry_id_seq">
<field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
@@ -2635,6 +2679,52 @@
</links>
</class>
+ <class id="acqpoli" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::po_lineitem" oils_persist:tablename="acq.po_lineitem">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.po_lineitem_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="PO Line Item ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="Purchase Order" name="purchase_order" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Fund" name="fund" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creation Time" name="create_time" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Edit Time" name="edit_time" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="MARC" name="marc" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Evergreen Bib ID" name="eg_bib_id" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="List Price" name="list_price" oils_obj:array_position="10" oils_persist:virtual="false" reporter:datatype="money" />
+ <field reporter:label="Item Count" name="item_count" oils_obj:array_position="11" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Descriptive Attributes" name="attributes" oils_obj:array_position="12" oils_persist:virtual="true" reporter:datatype="link" />
+ <field reporter:label="Line Item Details" name="lineitem_details" oils_obj:array_position="13" oils_persist:virtual="true" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
+ <link field="fund" reltype="has_a" key="id" map="" class="acqf"/>
+ <link field="eg_bib_id" reltype="has_a" key="id" map="" class="bre"/>
+ <link field="attributes" reltype="has_many" key="po_lineitem" map="" class="acqpolia"/>
+ <link field="lineitem_details" reltype="has_many" key="po_lineitem" map="" class="acqpolid"/>
+ </links>
+ </class>
+
+ <class id="acqpolin" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::po_li_note" oils_persist:tablename="acq.po_li_note">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.po_li_note_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="PO Line Item Note ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="Line Item" name="po_lineitem" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creator" name="creator" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Creation Time" name="create_time" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Edit Time" name="edit_time" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="timestamp" />
+ <field reporter:label="Editor" name="editor" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Vote Value" name="value" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="creator" reltype="has_a" key="id" map="" class="au"/>
+ <link field="editor" reltype="has_a" key="id" map="" class="au"/>
+ <link field="po_lineitem" reltype="has_a" key="id" map="" class="acqpoli"/>
+ </links>
+ </class>
+
<class id="acqplea" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::picklist_entry_attr" oils_persist:tablename="acq.picklist_entry_attr">
<fields oils_persist:primary="id" oils_persist:sequence="acq.picklist_entry_attr_id_seq">
<field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
@@ -2651,6 +2741,39 @@
</links>
</class>
+ <class id="acqpolia" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::po_li_attr" oils_persist:tablename="acq.po_li_attr">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.po_li_attr_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="Attribute Value ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="PO Line Item" name="po_lineitem" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Type" name="attr_type" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Name" name="attr_name" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Value" name="attr_value" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="po_lineitem" reltype="has_a" key="id" map="" class="acqpoli"/>
+ </links>
+ </class>
+
+ <class id="acqpolid" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::po_li_detail" oils_persist:tablename="acq.po_li_detail">
+ <fields oils_persist:primary="id" oils_persist:sequence="acq.po_li_detail_id_seq">
+ <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+ <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+ <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+ <field reporter:label="Item Detail ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+ <field reporter:label="PO Line Item" name="po_lineitem" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Evergreen Copy ID" name="eg_copy_id" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Barcode" name="barcode" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Call Number Label" name="cn_label" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="po_lineitem" reltype="has_a" key="id" map="" class="acqpoli"/>
+ <link field="eg_copy_id" reltype="has_a" key="id" map="" class="acp"/>
+ </links>
+ </class>
+
<class id="acqplead" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::picklist_attr_definition" oils_persist:tablename="acq.picklist_attr_definition">
<fields oils_persist:primary="id" oils_persist:sequence="acq.picklist_attr_definition_id_seq">
<field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
Modified: branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql 2008-02-13 18:15:23 UTC (rev 8746)
+++ branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql 2008-02-13 22:03:08 UTC (rev 8747)
@@ -4,6 +4,10 @@
CREATE SCHEMA acq;
+
+-- Tables
+
+
CREATE TABLE acq.currency_type (
code TEXT PRIMARY KEY,
label TEXT
@@ -48,6 +52,38 @@
note TEXT
);
+CREATE TABLE acq.fund (
+ id SERIAL PRIMARY KEY,
+ org INT NOT NULL REFERENCES actor.org_unit (id) ON UPDATE CASCADE ON DELETE CASCADE,
+ name TEXT NOT NULL,
+ year INT NOT NULL DEFAULT EXTRACT( YEAR FROM NOW() ),
+ currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
+ CONSTRAINT name_once_per_org_year UNIQUE (org,name,year)
+);
+
+CREATE TABLE acq.fund_debit (
+ id SERIAL PRIMARY KEY,
+ fund INT NOT NULL REFERENCES acq.fund (id),
+ origin_amount NUMERIC NOT NULL, -- pre-exchange-rate amount
+ origin_currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
+ amount NUMERIC NOT NULL,
+ encumberance BOOL NOT NULL DEFAULT TRUE,
+ debit_type TEXT NOT NULL,
+ xfer_destination INT REFERENCES acq.fund (id)
+);
+
+CREATE TABLE acq.fund_allocation (
+ id SERIAL PRIMARY KEY,
+ funding_source INT NOT NULL REFERENCES acq.funding_source (id) ON UPDATE CASCADE ON DELETE CASCADE,
+ fund INT NOT NULL REFERENCES acq.fund (id) ON UPDATE CASCADE ON DELETE CASCADE,
+ amount NUMERIC,
+ percent NUMERIC CHECK (percent IS NULL OR percent BETWEEN 0.0 AND 100.0),
+ allocator INT NOT NULL REFERENCES actor.usr (id),
+ note TEXT,
+ CONSTRAINT allocation_amount_or_percent CHECK ((percent IS NULL AND amount IS NOT NULL) OR (percent IS NOT NULL AND amount IS NULL))
+);
+
+
CREATE TABLE acq.picklist (
id SERIAL PRIMARY KEY,
owner INT NOT NULL REFERENCES actor.usr (id),
@@ -57,6 +93,32 @@
CONSTRAINT name_once_per_owner UNIQUE (name,owner)
);
+CREATE TABLE acq.purchase_order (
+ id SERIAL PRIMARY KEY,
+ owner INT NOT NULL REFERENCES actor.usr (id),
+ default_fund INT REFERENCES acq.fund (id),
+ create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ edit_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ provider INT NOT NULL REFERENCES acq.provider (id),
+ state TEXT NOT NULL DEFAULT 'new',
+ expected_recv_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() + '30 days',
+ recv_time TIMESTAMP WITH TIME ZONE
+);
+CREATE INDEX po_owner_idx ON acq.purchase_order (owner);
+CREATE INDEX po_provider_idx ON acq.purchase_order (provider);
+CREATE INDEX po_state_idx ON acq.purchase_order (state);
+
+CREATE TABLE acq.po_note (
+ id SERIAL PRIMARY KEY,
+ purchase_order INT NOT NULL REFERENCES acq.purchase_order (id),
+ creator INT NOT NULL REFERENCES actor.usr (id),
+ editor INT NOT NULL REFERENCES actor.usr (id),
+ create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ edit_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ value TEXT NOT NULL
+);
+CREATE INDEX po_note_po_idx ON acq.po_note (purchase_order);
+
CREATE TABLE acq.picklist_entry (
id BIGSERIAL PRIMARY KEY,
picklist INT NOT NULL REFERENCES acq.picklist (id) ON DELETE CASCADE,
@@ -64,10 +126,46 @@
create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
edit_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
marc TEXT NOT NULL,
- eg_bib_id INT,
+ eg_bib_id INT REFERENCES biblio.record_entry (id),
source_label TEXT
);
+CREATE TABLE acq.po_lineitem (
+ id BIGSERIAL PRIMARY KEY,
+ purchase_order INT NOT NULL REFERENCES acq.purchase_order (id),
+ fund INT REFERENCES acq.fund (id),
+ fund_debit INT REFERENCES acq.fund_debit (id),
+ create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ edit_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ marc TEXT NOT NULL,
+ eg_bib_id INT REFERENCES biblio.record_entry (id),
+ fund_debit INT REFERENCES acq.fund_debit (id),
+ list_price NUMERIC,
+ item_count INT NOT NULL DEFAULT 0
+);
+CREATE INDEX po_li_po_idx ON acq.po_lineitem (purchase_order);
+
+CREATE TABLE acq.po_li_note (
+ id SERIAL PRIMARY KEY,
+ po_lineitem INT NOT NULL REFERENCES acq.po_lineitem (id),
+ creator INT NOT NULL REFERENCES actor.usr (id),
+ editor INT NOT NULL REFERENCES actor.usr (id),
+ create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ edit_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ value TEXT NOT NULL
+);
+CREATE INDEX po_li_note_li_idx ON acq.po_li_note (po_lineitem);
+
+CREATE TABLE acq.po_li_detail (
+ id BIGSERIAL PRIMARY KEY,
+ po_lineitem INT NOT NULL REFERENCES acq.po_lineitem (id),
+ eg_copy_id BIGINT REFERENCES asset.copy (id),
+ barcode TEXT,
+ cn_label TEXT
+);
+
+CREATE INDEX po_li_detail_li_idx ON acq.po_li_detail (po_lineitem);
+
CREATE TABLE acq.picklist_entry_attr (
id BIGSERIAL PRIMARY KEY,
picklist_entry BIGINT NOT NULL REFERENCES acq.picklist_entry (id) ON DELETE CASCADE,
@@ -76,22 +174,16 @@
attr_value TEXT NOT NULL
);
-CREATE OR REPLACE FUNCTION public.extract_marc_field ( TEXT, BIGINT, TEXT ) RETURNS TEXT AS $$
- SELECT array_to_string( array_accum( output ),' ' ) FROM xpath_table('id', 'marc', $1, $3, 'id='||$2)x(id INT, output TEXT);
-$$ LANGUAGE SQL;
+CREATE TABLE acq.po_li_attr (
+ id BIGSERIAL PRIMARY KEY,
+ po_lineitem BIGINT NOT NULL REFERENCES acq.po_lineitem (id),
+ attr_type TEXT NOT NULL,
+ attr_name TEXT NOT NULL,
+ attr_value TEXT NOT NULL
+);
-CREATE OR REPLACE FUNCTION public.extract_acq_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
- SELECT public.extract_marc_field('acq.picklist_entry', $1, $2);
-$$ LANGUAGE SQL;
+CREATE INDEX po_li_attr_li_idx ON acq.po_li_attr (po_lineitem);
-CREATE OR REPLACE FUNCTION public.extract_bib_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
- SELECT public.extract_marc_field('biblio.record_entry', $1, $2);
-$$ LANGUAGE SQL;
-
-CREATE OR REPLACE FUNCTION public.extract_authority_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
- SELECT public.extract_marc_field('authority.record_entry', $1, $2);
-$$ LANGUAGE SQL;
-
CREATE TABLE acq.picklist_attr_definition (
id BIGSERIAL PRIMARY KEY,
code TEXT NOT NULL,
@@ -117,6 +209,10 @@
usr INT NOT NULL REFERENCES actor.usr (id)
) INHERITS (acq.picklist_attr_definition);
+
+-- Seed data
+
+
INSERT INTO acq.picklist_marc_attr_definition ( code, description, xpath ) VALUES ('title','Title of work','//*[@tag="245"]/*[contains("abcmnopr", at code)]');
INSERT INTO acq.picklist_marc_attr_definition ( code, description, xpath ) VALUES ('author','Author of work','//*[@tag="100" or @tag="110" or @tag="113"]/*[contains("ad", at code)]');
INSERT INTO acq.picklist_marc_attr_definition ( code, description, xpath ) VALUES ('language','Lanuage of work','//*[@tag="240"]/*[@code="l"][1]');
@@ -129,6 +225,26 @@
INSERT INTO acq.picklist_marc_attr_definition ( code, description, xpath ) VALUES ('pubdate','Publication Date','//*[@tag="260"]/*[@code="c"][1]');
INSERT INTO acq.picklist_marc_attr_definition ( code, description, xpath ) VALUES ('edition','Edition','//*[@tag="250"]/*[@code="a"][1]');
+
+-- Functions
+
+
+CREATE OR REPLACE FUNCTION public.extract_marc_field ( TEXT, BIGINT, TEXT ) RETURNS TEXT AS $$
+ SELECT array_to_string( array_accum( output ),' ' ) FROM xpath_table('id', 'marc', $1, $3, 'id='||$2)x(id INT, output TEXT);
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION public.extract_acq_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
+ SELECT public.extract_marc_field('acq.picklist_entry', $1, $2);
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION public.extract_bib_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
+ SELECT public.extract_marc_field('biblio.record_entry', $1, $2);
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION public.extract_authority_marc_field ( BIGINT, TEXT ) RETURNS TEXT AS $$
+ SELECT public.extract_marc_field('authority.record_entry', $1, $2);
+$$ LANGUAGE SQL;
+
-- For example:
-- INSERT INTO acq.picklist_provider_attr_definition ( provider, code, description, xpath ) VALUES (1,'price','Price','//*[@tag="020" or @tag="022"]/*[@code="a"][1]');
@@ -185,35 +301,6 @@
AFTER INSERT OR UPDATE ON acq.picklist_entry
FOR EACH ROW EXECUTE PROCEDURE public.ingest_acq_marc();
-CREATE TABLE acq.fund (
- id SERIAL PRIMARY KEY,
- org INT NOT NULL REFERENCES actor.org_unit (id) ON UPDATE CASCADE ON DELETE CASCADE,
- name TEXT NOT NULL,
- year INT NOT NULL DEFAULT EXTRACT( YEAR FROM NOW() ),
- currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
- CONSTRAINT name_once_per_org_year UNIQUE (org,name,year)
-);
-
-CREATE TABLE acq.fund_debit (
- id SERIAL PRIMARY KEY,
- fund INT NOT NULL REFERENCES acq.fund (id),
- origin_amount NUMERIC NOT NULL, -- pre-exchange-rate amount
- origin_currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
- amount NUMERIC NOT NULL,
- encumberance BOOL NOT NULL DEFAULT TRUE
-);
-
-CREATE TABLE acq.fund_allocation (
- id SERIAL PRIMARY KEY,
- funding_source INT NOT NULL REFERENCES acq.funding_source (id) ON UPDATE CASCADE ON DELETE CASCADE,
- fund INT NOT NULL REFERENCES acq.fund (id) ON UPDATE CASCADE ON DELETE CASCADE,
- amount NUMERIC,
- percent NUMERIC CHECK (percent IS NULL OR percent BETWEEN 0.0 AND 100.0),
- allocator INT NOT NULL REFERENCES actor.usr (id),
- note TEXT,
- CONSTRAINT allocation_amount_or_percent CHECK ((percent IS NULL AND amount IS NOT NULL) OR (percent IS NOT NULL AND amount IS NULL))
-);
-
CREATE OR REPLACE FUNCTION acq.exchange_ratio ( from_ex TEXT, to_ex TEXT ) RETURNS NUMERIC AS $$
DECLARE
rat NUMERIC;
More information about the open-ils-commits
mailing list