From e5ea9542aa948c622177e961066dd78a172cd7a1 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 29 Mar 2010 19:31:59 +0000 Subject: [PATCH] Acq: In fund transfer, add destination amount field when warranted When warranted means when source and dest fund have differing currencies. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16039 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Financials.pm | 2 + Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 3 +- .../0221.perm.perm_list.acq_imbalanced_xfer.sql | 9 +++ Open-ILS/web/css/skin/default/acq.css | 5 +- .../web/js/ui/default/acq/financial/view_fund.js | 64 +++++++++++++++------- .../templates/default/acq/financial/view_fund.tt2 | 30 +++++++++- 7 files changed, 88 insertions(+), 27 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0221.perm.perm_list.acq_imbalanced_xfer.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm index caa14d4507..e669e11c0d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm @@ -429,6 +429,8 @@ sub transfer_money_between_funds { $ratio = @{$exchange_rate}[0]->{ratio}; } $dfund_amount = $ofund_amount * $ratio; + } else { + return $e->die_event unless $e->allowed("ACQ_XFER_MANUAL_DFUND_AMOUNT"); } $e->json_query({ diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index e2f7eb5e13..00d9cb18fb 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -60,7 +60,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0220); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0221'); -- senator CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, 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 ef48b0c2f4..327c8cdf22 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1332,7 +1332,8 @@ INSERT INTO permission.perm_list VALUES (385, 'CREATE_TRIGGER_VALIDATOR', oils_i18n_gettext(385, 'Allow a user to create trigger validators', 'ppl', 'description')), (386, 'DELETE_TRIGGER_VALIDATOR', oils_i18n_gettext(386, 'Allow a user to delete trigger validators', 'ppl', 'description')), (387, 'UPDATE_TRIGGER_VALIDATOR', oils_i18n_gettext(387, 'Allow a user to update trigger validators', 'ppl', 'description')), - (388, 'UPDATE_ORG_UNIT_SETTING.circ.block_renews_for_holds', oils_i18n_gettext(388, 'Allow a user to enable blocking of renews on items that could fulfill holds', 'ppl', 'description')) + (388, 'UPDATE_ORG_UNIT_SETTING.circ.block_renews_for_holds', oils_i18n_gettext(388, 'Allow a user to enable blocking of renews on items that could fulfill holds', 'ppl', 'description')), + (389, 'ACQ_XFER_MANUAL_DFUND_AMOUNT', oils_i18n_gettext(389, 'Allow a user to transfer different amounts of money out of one fund and into another', 'ppl', 'description')) ; SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000); diff --git a/Open-ILS/src/sql/Pg/upgrade/0221.perm.perm_list.acq_imbalanced_xfer.sql b/Open-ILS/src/sql/Pg/upgrade/0221.perm.perm_list.acq_imbalanced_xfer.sql new file mode 100644 index 0000000000..ba948607d3 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0221.perm.perm_list.acq_imbalanced_xfer.sql @@ -0,0 +1,9 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0221'); -- senator + +INSERT INTO permission.perm_list (id, code, description) + VALUES (389, 'ACQ_XFER_MANUAL_DFUND_AMOUNT', + oils_i18n_gettext( 389, 'Allow a user to transfer different amounts of money out of one fund and into another', 'ppl', 'description' )); + +COMMIT; diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 78e2bd1d31..be0c83b45f 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -117,9 +117,8 @@ padding: 4px; } .oils-acq-fund-tag A { margin-left: 10px; } -#oils-acq-fund-xfer-table th { vertical-align: top; border-right: 1px solid #999; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 4px; } -#oils-acq-fund-xfer-table td { padding-left: 24px; } -#oils-acq-fund-xfer-name-fund { font-style: italic; } +#oils-acq-fund-xfer-table th { border-right: 1px solid #999; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 4px; } +#oils-acq-fund-xfer-table td { padding: 4px 4px 4px 24px; } #oils-acq-fund-xfer-submit-row { text-align: center; } /* li search page */ diff --git a/Open-ILS/web/js/ui/default/acq/financial/view_fund.js b/Open-ILS/web/js/ui/default/acq/financial/view_fund.js index 5a0a779ef2..aedddf1e8f 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/view_fund.js +++ b/Open-ILS/web/js/ui/default/acq/financial/view_fund.js @@ -4,6 +4,7 @@ dojo.require('dijit.layout.TabContainer'); dojo.require('dijit.layout.ContentPane'); dojo.require('dojox.grid.DataGrid'); dojo.require('dijit.form.CurrencyTextBox'); +dojo.require("dijit.form.CheckBox"); dojo.require('dojo.data.ItemFileReadStore'); dojo.require("fieldmapper.OrgUtils"); dojo.require('openils.acq.Fund'); @@ -85,23 +86,43 @@ function fetchFund() { function TransferManager() { var self = this; - new openils.widget.AutoFieldWidget({ - "fmField": "fund", - /* We're not really using LIDs here, we just need some class that has - * a fund field to take advantage of AutoFieldWidget's magic. - */ - "fmClass": "acqlid", - "labelFormat": ["${0} (${1})", "code", "year"], - "searchFormat": ["${0} (${1})", "code", "year"], - "searchFilter": {"active": "t"}, /* consider making it possible to select inactive? */ - "parentNode": dojo.byId("oils-acq-fund-xfer-d-selector"), - "orgLimitPerms": ["ADMIN_ACQ_FUND"], /* XXX is there a more appropriate permission for this? */ - "dijitArgs": {"name": "d_fund"}, - "forceSync": true - }).build(function(w, ww) { self.fundSelector = w; }); + this._init = function() { + new openils.widget.AutoFieldWidget({ + "fmField": "fund", + /* We're not really using LIDs here, we just need some class + * that has a fund field to take advantage of AutoFieldWidget's + * magic. */ + "fmClass": "acqlid", + "labelFormat": ["${0} (${1})", "code", "year"], + "searchFormat": ["${0} (${1})", "code", "year"], + "searchFilter": {"active": "t"}, /* consider making it possible + to select inactive? */ + "parentNode": dojo.byId("oils-acq-fund-xfer-d-selector"), + "orgLimitPerms": ["ADMIN_ACQ_FUND"], /* XXX is there a more + appropriate permission + for this? */ + "dijitArgs": { + "onChange": function() { + openils.Util[ + this.item.currency_type == fund.currency_type() ? + "hide" : "show" + ]("oils-acq-fund-xfer-dest-amount", "table-row"); + } + }, + "forceSync": true + }).build(function(w, ww) { self.fundSelector = w; }); + + dijit.byId("oils-acq-fund-xfer-same-o-d").onChange = function() { + dijit.byId("oils-acq-fund-xfer-d-amount").attr( + "disabled", this.attr("checked") + ); + } + }; + + this._init(); this.clearFundSelector = function() { - if (!this.fundSelector.attr("value")) + if (this.fundSelector.attr("value")) this.fundSelector.attr("value", ""); }; @@ -112,7 +133,10 @@ function TransferManager() { this.submit = function() { var values = xferDialog.getValues(); - if (values.d_fund == fund.id()) { + var dfund = this.fundSelector.item; + var dfund_id = typeof(dfund.id) == "object" ? dfund.id[0] : dfund.id; + + if (dfund_id == fund.id()) { alert(localeStrings.FUND_XFER_SAME_SOURCE_AND_DEST); return false; } @@ -121,8 +145,11 @@ function TransferManager() { ["open-ils.acq", "open-ils.acq.funds.transfer_money"], { "params": [ openils.User.authtoken, - fund.id(), values.o_amount, - values.d_fund, null, + fund.id(), + values.o_amount, + dfund_id, + (dfund.currency_type != fund.currency_type() && + values.same_o_d.length) ? null : values.d_amount, values.note ], "async": true, @@ -134,7 +161,6 @@ function TransferManager() { } ); } - return true; }; } diff --git a/Open-ILS/web/templates/default/acq/financial/view_fund.tt2 b/Open-ILS/web/templates/default/acq/financial/view_fund.tt2 index f98c38527f..4d183d19ad 100644 --- a/Open-ILS/web/templates/default/acq/financial/view_fund.tt2 +++ b/Open-ILS/web/templates/default/acq/financial/view_fund.tt2 @@ -76,7 +76,7 @@ Transfer Money