From 5e68152a2209ee3d2a688718b608ad60419d5e33 Mon Sep 17 00:00:00 2001 From: Liam Whalen Date: Wed, 4 Nov 2015 14:03:59 -0800 Subject: [PATCH] LP#1175400 Check for over allocation from funding source When allocating money from a funding source to a fund it is possible to allocate more money to the fund than exists in the funding source. This code adds a check with a dialog that stops the user from over allocating from a funding source unless they choose an override option. TODO: Need to add a permission check to allow the override. Signed-off-by: Liam Whalen s# Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js~ --- .../acq/funding_source/over_allocate_dialog.tt2 | 13 +++++++ Open-ILS/src/templates/acq/funding_source/view.tt2 | 1 + .../default/acq/financial/view_funding_source.js | 42 ++++++++++++++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/templates/acq/funding_source/over_allocate_dialog.tt2 diff --git a/Open-ILS/src/templates/acq/funding_source/over_allocate_dialog.tt2 b/Open-ILS/src/templates/acq/funding_source/over_allocate_dialog.tt2 new file mode 100644 index 0000000000..c644c32aa1 --- /dev/null +++ b/Open-ILS/src/templates/acq/funding_source/over_allocate_dialog.tt2 @@ -0,0 +1,13 @@ +
+

[% l('You are attempting to allocate more money than is available in the funding source.') %]

+ + + + + + + +
+ diff --git a/Open-ILS/src/templates/acq/funding_source/view.tt2 b/Open-ILS/src/templates/acq/funding_source/view.tt2 index 61e1903511..4f8c3c172b 100644 --- a/Open-ILS/src/templates/acq/funding_source/view.tt2 +++ b/Open-ILS/src/templates/acq/funding_source/view.tt2 @@ -1,3 +1,4 @@ +[%INCLUDE 'acq/funding_source/over_allocate_dialog.tt2'%] [% WRAPPER 'base.tt2' %] diff --git a/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js b/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js index 5a68df1b0e..1c1c5465b7 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js +++ b/Open-ILS/web/js/ui/default/acq/financial/view_funding_source.js @@ -39,10 +39,48 @@ function applyFSCredit(fields) { function applyFSAllocation(fields) { fields.funding_source = fundingSourceID; + //fs = openils.acq.FundingSource.retrieve(fundingSourceID, {flesh_summary:1}); + var req = ses.request( + 'open-ils.acq.funding_source.retrieve', + openils.User.authtoken, fundingSourceID, + {flesh_summary:1} + ); + + req.oncomplete = function(r) { + var msg = req.recv(); + fundingSource = msg.content(); + } + + req.send(); + + var balance = fundingSource.summary().balance; + if(isNaN(fields.amount)) fields.amount = null; - openils.acq.Fund.createAllocation( - fields, function() { resetPage(loadAllocationGrid); } + + dojo.connect(oilsFSOverAllocateContinue, 'onClick', + function() { + oilsFSOverAllocateDialog.hide(); + } ); + + dojo.connect(oilsFSOverAllocateOverride, 'onClick', + function() { + oilsFSOverAllocateDialog.hide(); + doAllocation(fields); + } + ); + + if(fields.amount > balance) { + oilsFSOverAllocateDialog.show(); + } else { + doAllocation(fields); + } + + function doAllocation(fields) { + openils.acq.Fund.createAllocation( + fields, function() { resetPage(loadAllocationGrid); } + ); + } } /** fetch the fleshed funding source ----- */ -- 2.11.0