[open-ils-commits] r15237 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Dec 28 16:47:41 EST 2009
Author: scottmk
Date: 2009-12-28 16:47:36 -0500 (Mon, 28 Dec 2009)
New Revision: 15237
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.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
Log:
Add new view acq.ordered_funding_source_credit, to define priorities
for spending from funding source credits. See COMMENT in
Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.sql.
M Open-ILS/src/sql/Pg/200.schema.acq.sql
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-12-28 21:40:02 UTC (rev 15236)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-12-28 21:47:36 UTC (rev 15237)
@@ -4514,6 +4514,22 @@
</links>
</class>
+ <class id="acqofscred" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::ordered_funding_source_credit" oils_persist:tablename="acq.ordered_funding_source_credit" reporter:label="Ordered Funding Source Credit">
+ <fields oils_persist:primary="id">
+ <field reporter:label="Ordered Fund Src ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Sort Priority" name="sort_priority" reporter:datatype="int"/>
+ <field reporter:label="Sort Date" name="sort_date" reporter:datatype="timestamp"/>
+ <field reporter:label="Funding Source ID" name="funding_source" reporter:datatype="link"/>
+ <field reporter:label="Amount" name="amount" reporter:datatype="money"/>
+ <field reporter:label="Note" name="note" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="funding_source" reltype="has_a" key="id" map="" class="acqfs"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
<class id="acqfdeb" controller="open-ils.cstore open-ils.reporter-store" oils_obj:fieldmapper="acq::fund_debit" oils_persist:tablename="acq.fund_debit" reporter:label="Debit From Fund">
<fields oils_persist:primary="id" oils_persist:sequence="acq.fund_debit_id_seq">
<field reporter:label="Debit ID" name="id" reporter:datatype="id" />
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-12-28 21:40:02 UTC (rev 15236)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-12-28 21:47:36 UTC (rev 15237)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0124'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0125'); -- Scott McKellar
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 2009-12-28 21:40:02 UTC (rev 15236)
+++ trunk/Open-ILS/src/sql/Pg/200.schema.acq.sql 2009-12-28 21:47:36 UTC (rev 15237)
@@ -105,6 +105,62 @@
effective_date TIMESTAMPTZ NOT NULL default now()
);
+CREATE VIEW acq.ordered_funding_source_credit AS
+ SELECT
+ CASE WHEN deadline_date IS NULL THEN
+ 2
+ ELSE
+ 1
+ END AS sort_priority,
+ CASE WHEN deadline_date IS NULL THEN
+ effective_date
+ ELSE
+ deadline_date
+ END AS sort_date,
+ id,
+ funding_source,
+ amount,
+ note
+ FROM
+ acq.funding_source_credit;
+
+COMMENT ON VIEW acq.ordered_funding_source_credit IS $$
+/*
+ * Copyright (C) 2009 Georgia Public Library Service
+ * Scott McKellar <scott at gmail.com>
+ *
+ * The acq.ordered_funding_source_credit view is a prioritized
+ * ordering of funding source credits. When ordered by the first
+ * three columns, this view defines the order in which the various
+ * credits are to be tapped for spending, subject to the allocations
+ * in the acq.fund_allocation table.
+ *
+ * The first column reflects the principle that we should spend
+ * money with deadlines before spending money without deadlines.
+ *
+ * The second column reflects the principle that we should spend the
+ * oldest money first. For money with deadlines, that means that we
+ * spend first from the credit with the earliest deadline. For
+ * money without deadlines, we spend first from the credit with the
+ * earliest effective date.
+ *
+ * The third column is a tie breaker to ensure a consistent
+ * ordering.
+ *
+ * ****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+$$;
+
CREATE TABLE acq.fund (
id SERIAL PRIMARY KEY,
org INT NOT NULL REFERENCES actor.org_unit (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0125.schema.acq-ord-fund-src-credit.sql 2009-12-28 21:47:36 UTC (rev 15237)
@@ -0,0 +1,61 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0125'); -- Scott McKellar
+
+CREATE VIEW acq.ordered_funding_source_credit AS
+ SELECT
+ CASE WHEN deadline_date IS NULL THEN
+ 2
+ ELSE
+ 1
+ END AS sort_priority,
+ CASE WHEN deadline_date IS NULL THEN
+ effective_date
+ ELSE
+ deadline_date
+ END AS sort_date,
+ id,
+ funding_source,
+ amount,
+ note
+ FROM
+ acq.funding_source_credit;
+
+COMMENT ON VIEW acq.ordered_funding_source_credit IS $$
+/*
+ * Copyright (C) 2009 Georgia Public Library Service
+ * Scott McKellar <scott at gmail.com>
+ *
+ * The acq.ordered_funding_source_credit view is a prioritized
+ * ordering of funding source credits. When ordered by the first
+ * three columns, this view defines the order in which the various
+ * credits are to be tapped for spending, subject to the allocations
+ * in the acq.fund_allocation table.
+ *
+ * The first column reflects the principle that we should spend
+ * money with deadlines before spending money without deadlines.
+ *
+ * The second column reflects the principle that we should spend the
+ * oldest money first. For money with deadlines, that means that we
+ * spend first from the credit with the earliest deadline. For
+ * money without deadlines, we spend first from the credit with the
+ * earliest effective date.
+ *
+ * The third column is a tie breaker to ensure a consistent
+ * ordering.
+ *
+ * ****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+$$;
+
+COMMIT;
More information about the open-ils-commits
mailing list