[open-ils-commits] r14789 - branches/rel_1_6/Open-ILS/src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Nov 5 13:53:21 EST 2009
Author: miker
Date: 2009-11-05 13:53:17 -0500 (Thu, 05 Nov 2009)
New Revision: 14789
Modified:
branches/rel_1_6/Open-ILS/src/sql/Pg/090.schema.action.sql
Log:
forward-porting r14786 and r14787: use a trigger to push day-granular circ due_date to the end of the calendar day
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-11-05 18:52:01 UTC (rev 14788)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-11-05 18:53:17 UTC (rev 14789)
@@ -130,7 +130,18 @@
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
+CREATE OR REPLACE FUNCTION action.push_circ_due_time () RETURNS TRIGGER AS $$
+BEGIN
+ IF (EXTRACT(EPOCH FROM NEW.circ_duration)::INT % EXTRACT(EPOCH FROM '1 day'::INTERVAL)::INT) = 0 THEN
+ NEW.due_date = (NEW.due_date::DATE + '1 day'::INTERVAL - '1 second'::INTERVAL)::TIMESTAMPTZ;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER push_due_date_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.push_circ_due_time();
+
CREATE TABLE action.aged_circulation (
usr_post_code TEXT,
usr_home_ou INT NOT NULL,
More information about the open-ils-commits
mailing list