[open-ils-commits] r8236 - in branches/acq-experiment/Open-ILS:
examples src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 19 17:43:16 EST 2007
Author: miker
Date: 2007-12-19 17:21:37 -0500 (Wed, 19 Dec 2007)
New Revision: 8236
Added:
branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql
Modified:
branches/acq-experiment/Open-ILS/examples/fm_IDL.xml
Log:
Adding basic models for the acq experiment.
Modified: branches/acq-experiment/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/acq-experiment/Open-ILS/examples/fm_IDL.xml 2007-12-19 20:34:16 UTC (rev 8235)
+++ branches/acq-experiment/Open-ILS/examples/fm_IDL.xml 2007-12-19 22:21:37 UTC (rev 8236)
@@ -2228,6 +2228,127 @@
</fields>
<links/>
</class>
+
+ <class id="acqct" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::currency_type" oils_persist:tablename="acq.currency_type">
+ <fields oils_persist:primary="code">
+ <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="Currency Code" name="code" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="text" />
+ <field reporter:label="Currency Label" name="label" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text" oils_persist:i18n="true" />
+ </fields>
+ <links/>
+ </class>
+
+ <class id="acqexr" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::exchange_rate" oils_persist:tablename="acq.exchange_rate">
+ <fields oils_persist:primary="id">
+ <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="Exchange Rate ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="From Currency" name="from_currency" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="To Currency" name="to_currency" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Ratio" name="ratio" oils_obj:array_position="6" oils_persist:virtual="false" oils_persist:primitive="number" reporter:datatype="float" />
+ </fields>
+ <links>
+ <link field="from_currency" reltype="has_a" key="code" map="" class="acqct"/>
+ <link field="to_currency" reltype="has_a" key="code" map="" class="acqct"/>
+ </links>
+ </class>
+
+ <class id="acqpro" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::provider" oils_persist:tablename="acq.provider">
+ <fields oils_persist:primary="id">
+ <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="Provider ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Provider Name" name="name" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text" oils_persist:i18n="true" />
+ <field reporter:label="Owner" name="owner" oils_obj:array_position="5" oils_persist:virtual="false" oils_persist:primitive="number" reporter:datatype="link" />
+ <field reporter:label="Currency" name="currency_type" oils_obj:array_position="6" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="currency_type" reltype="has_a" key="code" map="" class="acqct"/>
+ <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ </class>
+
+ <class id="acqfund" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::fund" oils_persist:tablename="acq.fund">
+ <fields oils_persist:primary="id">
+ <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="Fund ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Fund Name" name="name" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text" oils_persist:i18n="true" />
+ <field reporter:label="Owner" name="owner" oils_obj:array_position="5" oils_persist:virtual="false" oils_persist:primitive="number" reporter:datatype="link" />
+ <field reporter:label="Currency" name="currency_type" oils_obj:array_position="6" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="currency_type" reltype="has_a" key="code" map="" class="acqct"/>
+ <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ </class>
+
+ <class id="acqfsm" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::fund_share_map" oils_persist:tablename="acq.fund_share_map">
+ <fields oils_persist:primary="id">
+ <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="Share ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Fund ID" name="fund" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Org" name="org" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="fund" reltype="has_a" key="id" map="" class="acqfund"/>
+ <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ </class>
+
+ <class id="acqpsm" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::provider_share_map" oils_persist:tablename="acq.provider_share_map">
+ <fields oils_persist:primary="id">
+ <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="Share ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Provider ID" name="provider" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Org" name="org" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link" />
+ </fields>
+ <links>
+ <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
+ <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ </class>
+
+ <class id="acqfcred" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::fund_credit" oils_persist:tablename="acq.fund_credit">
+ <fields oils_persist:primary="id">
+ <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="Fund ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Amount" name="amount" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="money" />
+ <field reporter:label="Note" name="note" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="fund" reltype="has_a" key="id" map="" class="acqfund"/>
+ </links>
+ </class>
+
+ <class id="acqfdeb" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::fund_debit" oils_persist:tablename="acq.fund_debit">
+ <fields oils_persist:primary="id">
+ <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="Fund ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="int" />
+ <field reporter:label="Amount" name="amount" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="money" />
+ <field reporter:label="Origin Amount" name="origin_amount" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="money" />
+ <field reporter:label="Origin Currency" name="origin_currency_type" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="link" />
+ <field reporter:label="Note" name="note" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="text" />
+ </fields>
+ <links>
+ <link field="fund" reltype="has_a" key="id" map="" class="acqfund"/>
+ <link field="origin_currency" reltype="has_a" key="code" map="" class="acqct"/>
+ </links>
+ </class>
+
<class id="rof" controller="open-ils.reporter-store" oils_obj:fieldmapper="reporter::output_folder" oils_persist:tablename="reporter.output_folder">
<fields oils_persist:primary="id" oils_persist:sequence="reporter.output_folder_id_seq">
<field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
Added: branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql
===================================================================
--- branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql (rev 0)
+++ branches/acq-experiment/Open-ILS/src/sql/Pg/200.schema.acq.sql 2007-12-19 22:21:37 UTC (rev 8236)
@@ -0,0 +1,71 @@
+DROP SCHEMA acq CASCADE;
+
+BEGIN;
+
+CREATE SCHEMA acq;
+
+CREATE TABLE acq.currency_type (
+ code TEXT PRIMARY KEY,
+ label TEXT
+);
+
+INSERT INTO acq.currency_type (code, label) VALUES ('USD','US Dollars');
+INSERT INTO acq.currency_type (code, label) VALUES ('CAN','Canadian Dollars');
+INSERT INTO acq.currency_type (code, label) VALUES ('EUR','Euros');
+
+CREATE TABLE acq.exchange_rate (
+ id SERIAL PRIMARY KEY,
+ from_currency TEXT NOT NULL REFERENCES acq.currency_type (code),
+ to_currency TEXT NOT NULL REFERENCES acq.currency_type (code),
+ ratio NUMERIC NOT NULL,
+ CONSTRAINT exchange_rate_from_to_once UNIQUE (from_currency,to_currency)
+);
+
+INSERT INTO acq.exchange_rate (from_currency,to_currency,ratio) VALUES ('USD','CAN',1.2);
+INSERT INTO acq.exchange_rate (from_currency,to_currency,ratio) VALUES ('USD','EUR',0.5);
+
+CREATE TABLE acq.provider (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ owner INT NOT NULL REFERENCES actor.org_unit (id),
+ currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
+ CONSTRAINT provider_name_once_per_owner UNIQUE (name,owner)
+);
+
+CREATE TABLE acq.provider_share_map (
+ id SERIAL PRIMARY KEY,
+ provider INT NOT NULL REFERENCES acq.provider (id),
+ org INT NOT NULL REFERENCES actor.org_unit (id),
+ CONSTRAINT provider_share_once_per_owner UNIQUE (provider,org)
+);
+
+CREATE TABLE acq.fund (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ owner INT NOT NULL REFERENCES actor.org_unit (id),
+ currency_type TEXT NOT NULL REFERENCES acq.currency_type (code),
+ CONSTRAINT fund_name_once_per_owner UNIQUE (name,owner)
+);
+
+CREATE TABLE acq.fund_share_map (
+ id SERIAL PRIMARY KEY,
+ fund INT NOT NULL REFERENCES acq.fund (id),
+ org INT NOT NULL REFERENCES actor.org_unit (id),
+ CONSTRAINT fund_share_once_per_owner UNIQUE (fund,org)
+);
+
+CREATE TABLE acq.fund_credit (
+ id SERIAL PRIMARY KEY,
+ amount NUMERIC NOT NULL,
+ note TEXT
+);
+
+CREATE TABLE acq.fund_debit (
+ id SERIAL PRIMARY KEY,
+ 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
+);
+
+COMMIT;
More information about the open-ils-commits
mailing list