From ed2cdd9b633999f738bedfa80367706e849cf0d2 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 27 Jul 2012 13:32:12 -0400 Subject: [PATCH] Finishing off rollover-without-money feature - Minor correction to make stock schema match upgrade script match. - OU setting determining whether to offer rollover-without-money in UI and allow it in DB. Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Bill Erickson --- Open-ILS/src/sql/Pg/200.schema.acq.sql | 13 ++++++-- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 21 ++++++++++++- .../Pg/upgrade/XXXX.schema.acq-function-dedup.sql | 35 +++++++++++++++++++++- Open-ILS/src/templates/acq/fund/list.tt2 | 4 +-- .../web/js/ui/default/acq/financial/list_funds.js | 15 ++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index f0a1bf37b8..c84279b3e6 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -1974,7 +1974,7 @@ BEGIN year = old_year AND propagate AND ( ( include_desc AND org IN ( SELECT id FROM actor.org_unit_descendants( org_unit_id ) ) ) - OR (NOT include_desc AND oldf.org = org_unit_id ) ) + OR (NOT include_desc AND org = org_unit_id ) ) LOOP BEGIN @@ -2028,7 +2028,8 @@ DECLARE new_fund INT; new_year INT := old_year + 1; org_found BOOL; -xfer_amount NUMERIC; +perm_ous BOOL; +xfer_amount NUMERIC := 0; roll_fund RECORD; deb RECORD; detail RECORD; @@ -2060,6 +2061,14 @@ BEGIN -- IF org_found IS NULL THEN RAISE EXCEPTION 'Org unit id % is invalid', org_unit_id; + ELSIF encumb_only THEN + SELECT INTO perm_ous value::BOOL FROM + actor.org_unit_ancestor_setting( + 'acq.fund.allow_rollover_without_money', org_unit_id + ); + IF NOT FOUND OR NOT perm_ous THEN + RAISE EXCEPTION 'Encumbrance-only rollover not permitted at org %', org_unit_id; + END IF; END IF; END IF; -- diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index ed53b9baef..d4b88260f5 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11748,7 +11748,6 @@ INSERT INTO config.org_unit_setting_type ( 'interval' ); - -- kid's opac main search filter INSERT INTO actor.search_filter_group (owner, code, label) @@ -11779,3 +11778,23 @@ INSERT INTO actor.search_filter_group_entry (grp, query, pos) (SELECT id FROM actor.search_query WHERE label = 'General/Adult Materials'), 2 ); +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'acq.fund.allow_rollover_without_money', + 'acq', + oils_i18n_gettext( + 'acq.fund.allow_rollover_without_money', + 'Allow funds to be rolled over without bringing the money along', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'acq.fund.allow_rollover_without_money', + 'Allow funds to be rolled over without bringing the money along. This makes money left in the old fund disappear, modeling its return to some outside entity.', + 'coust', + 'description' + ), + 'bool' + ); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-function-dedup.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-function-dedup.sql index a7167ce6e1..149c1ce23e 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-function-dedup.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-function-dedup.sql @@ -1,3 +1,6 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('XXXX', :eg_version); -- miker DROP FUNCTION acq.propagate_funds_by_org_tree (INT, INT, INT); DROP FUNCTION acq.propagate_funds_by_org_unit (INT, INT, INT); @@ -47,7 +50,7 @@ BEGIN year = old_year AND propagate AND ( ( include_desc AND org IN ( SELECT id FROM actor.org_unit_descendants( org_unit_id ) ) ) - OR (NOT include_desc AND oldf.org = org_unit_id ) ) + OR (NOT include_desc AND org = org_unit_id ) ) LOOP BEGIN @@ -92,6 +95,7 @@ $$ LANGUAGE SQL; DROP FUNCTION acq.rollover_funds_by_org_tree (INT, INT, INT); DROP FUNCTION acq.rollover_funds_by_org_unit (INT, INT, INT); + CREATE OR REPLACE FUNCTION acq.rollover_funds_by_org_tree( old_year INTEGER, user_id INTEGER, @@ -104,6 +108,7 @@ DECLARE new_fund INT; new_year INT := old_year + 1; org_found BOOL; +perm_ous BOOL; xfer_amount NUMERIC := 0; roll_fund RECORD; deb RECORD; @@ -136,6 +141,14 @@ BEGIN -- IF org_found IS NULL THEN RAISE EXCEPTION 'Org unit id % is invalid', org_unit_id; + ELSIF encumb_only THEN + SELECT INTO perm_ous value::BOOL FROM + actor.org_unit_ancestor_setting( + 'acq.fund.allow_rollover_without_money', org_unit_id + ); + IF NOT FOUND OR NOT perm_ous THEN + RAISE EXCEPTION 'Encumbrance-only rollover not permitted at org %', org_unit_id; + END IF; END IF; END IF; -- @@ -276,4 +289,24 @@ CREATE OR REPLACE FUNCTION acq.rollover_funds_by_org_unit( old_year INTEGER, use SELECT acq.rollover_funds_by_org_tree( $1, $2, $3, $4, FALSE ); $$ LANGUAGE SQL; +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'acq.fund.allow_rollover_without_money', + 'acq', + oils_i18n_gettext( + 'acq.fund.allow_rollover_without_money', + 'Allow funds to be rolled over without bringing the money along', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'acq.fund.allow_rollover_without_money', + 'Allow funds to be rolled over without bringing the money along. This makes money left in the old fund disappear, modeling its return to some outside entity.', + 'coust', + 'description' + ), + 'bool' + ); +COMMIT; diff --git a/Open-ILS/src/templates/acq/fund/list.tt2 b/Open-ILS/src/templates/acq/fund/list.tt2 index 0173e739c5..6fa4b0de01 100644 --- a/Open-ILS/src/templates/acq/fund/list.tt2 +++ b/Open-ILS/src/templates/acq/fund/list.tt2 @@ -72,13 +72,13 @@ - + - +
This modifies the above described Close-out Operation, causing funds to be diff --git a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js index 4586333a4e..abad41d987 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js +++ b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js @@ -37,6 +37,21 @@ var cachedFunds = []; function initPage() { contextOrg = openils.User.user.ws_ou(); + /* Reveal controls for rollover without money if org units say ok. + * Actual ability to do the operation is controlled in the database, of + * course. */ + var ouSettings = fieldmapper.aou.fetchOrgSettingBatch( + openils.User.user.ws_ou(), ["acq.fund.allow_rollover_without_money"] + ); + if ( + ouSettings["acq.fund.allow_rollover_without_money"] && + ouSettings["acq.fund.allow_rollover_without_money"].value + ) { + dojo.query(".encumb_only").forEach( + function(o) { openils.Util.show(o, "table-row"); } + ); + } + var connect = function() { dojo.connect(contextOrgSelector, 'onChange', function() { -- 2.11.0