- 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 <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
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
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;
--
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;
--
'interval'
);
-
-- kid's opac main search filter
INSERT INTO actor.search_filter_group (owner, code, label)
(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'
+ );
+
+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);
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
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,
new_fund INT;
new_year INT := old_year + 1;
org_found BOOL;
+perm_ous BOOL;
xfer_amount NUMERIC := 0;
roll_fund RECORD;
deb RECORD;
--
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;
--
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;
</div>
</td>
</tr>
- <tr>
+ <tr class="encumb_only hidden">
<td><label for="encumb_only">Limit Fiscal Year Close-out Operation to Encumbrances: </label></td>
<td>
<input dojoType="dijit.form.CheckBox" name="encumb_only"> </input>
</td>
</tr>
- <tr>
+ <tr class="encumb_only hidden">
<td colspan='2'>
<div style='width:400px;'>
This modifies the above described Close-out Operation, causing funds to be
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() {