Administrative overrides for attestation work
This commit is contained in:
@@ -249,6 +249,19 @@
|
||||
<value>There are not enough funds to attest this. You can attest up to {0} {1:N2} more in this budget for the year {2}.</value>
|
||||
<comment>The {0} is the currency and the {1} is the remaining budget. The {2} is the current year.</comment>
|
||||
</data>
|
||||
<data name="AttestCosts_OverdraftConfirm" xml:space="preserve">
|
||||
<value><strong>OVERDRAFT BUDGET?</strong><br/><br/>There are not enough funds remaining in the budget to attest this expense. Normally, it would be blocked from attestation. However, you may override this limitation and attest anyway, thereby causing the account to overdraft its budget.<br/><br/>Do you want to attest the expense, thereby forcing an overdraft, or do you want to cancel attestation, staying on budget instead?<br/><br/></value>
|
||||
</data>
|
||||
<data name="AttestCosts_OverdraftConfirmNo" xml:space="preserve">
|
||||
<value>Stay on Budget</value>
|
||||
</data>
|
||||
<data name="AttestCosts_OverdraftConfirmYes" xml:space="preserve">
|
||||
<value>Force Overdraft</value>
|
||||
</data>
|
||||
<data name="AttestCosts_Overdrafted" xml:space="preserve">
|
||||
<value>BUDGET WAS OVERDRAFTED.</value>
|
||||
<comment>The UPPERCASE is intentional.</comment>
|
||||
</data>
|
||||
<data name="AttestCosts_PageTitle" xml:space="preserve">
|
||||
<value>Attest Costs</value>
|
||||
</data>
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
'/Images/Icons/iconshock-balloon-yes-128x96px-hot.png',
|
||||
'/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png',
|
||||
'/Images/Icons/iconshock-balloon-yes-128x96px-hot-disabled.png',
|
||||
'/Images/Icons/iconshock-balloon-yes-128x96px-gold.png',
|
||||
'/Images/Icons/iconshock-balloon-yes-128x96px-hot-gold.png',
|
||||
'/Images/Icons/iconshock-balloon-no-128x96px-hot.png',
|
||||
'/Images/Icons/iconshock-green-tick-128x96px.png',
|
||||
'/Images/Icons/iconshock-red-cross-128x96px.png',
|
||||
@@ -45,7 +47,7 @@
|
||||
},
|
||||
|
||||
onLoadSuccess: function () {
|
||||
$(".LocalIconApproval").attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png"); // initialize as disabled until budgets known
|
||||
$(".LocalIconApproval").attr("src", approvalOverdraftIcon); // initialize as disabled until budgets known
|
||||
$(".LocalIconApproved").attr("src", "/Images/Icons/iconshock-green-tick-128x96px.png").css("opacity", 0.5);
|
||||
$(".LocalIconDenied").attr("src", "/Images/Icons/iconshock-red-cross-circled-128x96px.png");
|
||||
$(".LocalIconUndo").attr("src", "/Images/Icons/iconshock-balloon-undo-128x96px.png");
|
||||
@@ -56,7 +58,7 @@
|
||||
$(".LocalIconApproval").mouseover(function () {
|
||||
if ($(this).attr("rel") != "loading") {
|
||||
if ($(this).hasClass("LocalFundsInsufficient")) {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-hot-disabled.png");
|
||||
$(this).attr("src", approvalOverdraftIconHover);
|
||||
} else {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-hot.png");
|
||||
}
|
||||
@@ -66,7 +68,7 @@
|
||||
$(".LocalIconApproval").mouseout(function () {
|
||||
if ($(this).attr("rel") != "loading") {
|
||||
if ($(this).hasClass("LocalFundsInsufficient")) {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png");
|
||||
$(this).attr("src", approvalOverdraftIcon);
|
||||
} else {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px.png");
|
||||
}
|
||||
@@ -110,50 +112,40 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(".LocalIconApproval").click(function () {
|
||||
if ($(this).hasClass("LocalFundsInsufficient")) {
|
||||
alertify.error (decodeURIComponent('<asp:Literal id="LiteralErrorInsufficientBudget" runat="server" />'));
|
||||
return;
|
||||
}
|
||||
|
||||
$(".LocalIconApproval").click(function() {
|
||||
if ($(this).attr("rel") != "loading" && $("#IconDenial" + $(this).attr("baseid")) != "loading") {
|
||||
$(this).attr("rel", "loading");
|
||||
$(this).attr("src", "/Images/Abstract/ajaxloader-48x36px.gif");
|
||||
$("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor", "default");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Financial/AttestCosts.aspx/Attest",
|
||||
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: $.proxy(function (msg) {
|
||||
var baseid = $(this).attr("baseid");
|
||||
if (msg.d.Success) {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px.png");
|
||||
$(this).attr("rel", "active");
|
||||
$(this).hide();
|
||||
$("#IconApproved" + baseid).fadeTo(250, 0.5);
|
||||
$("#IconDenial" + baseid).finish().css("display", "none").css("opacity", 1.0);
|
||||
$("#IconUndo" + baseid).fadeIn(100);
|
||||
$('.row' + baseid).animate({ color: "#AAA" }, 400);
|
||||
alertify.success(msg.d.DisplayMessage);
|
||||
|
||||
var accountId = $(this).attr("accountid");
|
||||
var funds = parseFloat($(this).attr("amount"));
|
||||
budgetRemainingLookup[accountId] -= funds;
|
||||
setAttestability();
|
||||
recheckBudgets(); // will double-check budgets against server
|
||||
} else {
|
||||
// failure, likely from attesting too quickly and overrunning budget
|
||||
$(this).attr("rel", "");
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png");
|
||||
$("#IconDenial" + baseid).css('opacity', 1.0).css("cursor", "pointer");
|
||||
alertify.error(msg.d.DisplayMessage);
|
||||
if ($(this).hasClass("LocalFundsInsufficient")) {
|
||||
if (!canOverdraftBudgets) {
|
||||
alertify.error(decodeURIComponent('<asp:Literal id="LiteralErrorInsufficientBudget" runat="server" />'));
|
||||
return;
|
||||
}
|
||||
|
||||
recheckBudgets();
|
||||
// Handle confirm-overdraft case
|
||||
|
||||
alertify.set({
|
||||
labels: {
|
||||
ok: decodeURIComponent('<asp:Literal ID="LiteralConfirmOverdraftNo" runat="server" />'),
|
||||
cancel: decodeURIComponent('<asp:Literal ID="LiteralConfirmOverdraftYes" runat="server" />')
|
||||
}
|
||||
}, this)
|
||||
});
|
||||
});
|
||||
|
||||
alertify.confirm(decodeURIComponent('<asp:Literal ID="LiteralConfirmOverdraft" runat="server" />'),
|
||||
$.proxy(function(response) {
|
||||
if (!response) {
|
||||
// user clicked the RED button, which is "confirm overdraft"
|
||||
|
||||
onExpenseApproval(this);
|
||||
}
|
||||
}, this));
|
||||
|
||||
return; // Do not process here - must wait for confirm dialog to return
|
||||
}
|
||||
|
||||
// Handle normal case
|
||||
|
||||
onExpenseApproval(this);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -255,9 +247,62 @@
|
||||
|
||||
budgetRemainingLookup.budgetsLoaded = true;
|
||||
});
|
||||
|
||||
// If we're running with admin privileges, allow overdraft override
|
||||
|
||||
if (canOverdraftBudgets) {
|
||||
approvalOverdraftIcon = '/Images/Icons/iconshock-balloon-yes-128x96px-gold.png';
|
||||
approvalOverdraftIconHover = '/Images/Icons/iconshock-balloon-yes-128x96px-hot-gold.png';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function onExpenseApproval(approvalIcon) {
|
||||
$(approvalIcon).attr("rel", "loading");
|
||||
$(approvalIcon).attr("src", "/Images/Abstract/ajaxloader-48x36px.gif");
|
||||
$("#IconDenial" + $(approvalIcon).attr("baseid")).fadeTo(1000, 0.01).css("cursor", "default");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Financial/AttestCosts.aspx/Attest",
|
||||
data: "{'identifier': '" + escape($(approvalIcon).attr("baseid")) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: $.proxy(function (msg) {
|
||||
var baseid = $(this).attr("baseid");
|
||||
if (msg.d.Success) {
|
||||
if ($(this).hasClass("LocalFundsInsufficient")) {
|
||||
$(this).attr("src", approvalOverdraftIcon);
|
||||
} else {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px.png");
|
||||
}
|
||||
$(this).attr("rel", "active");
|
||||
$(this).hide();
|
||||
$("#IconApproved" + baseid).fadeTo(250, 0.5);
|
||||
$("#IconDenial" + baseid).finish().css("display", "none").css("opacity", 1.0);
|
||||
$("#IconUndo" + baseid).fadeIn(100);
|
||||
$('.row' + baseid).animate({ color: "#AAA" }, 400);
|
||||
alertify.success(msg.d.DisplayMessage);
|
||||
|
||||
var accountId = $(this).attr("accountid");
|
||||
var funds = parseFloat($(this).attr("amount"));
|
||||
budgetRemainingLookup[accountId] -= funds;
|
||||
setAttestability();
|
||||
recheckBudgets(); // will double-check budgets against server
|
||||
} else {
|
||||
// failure, likely from attesting too quickly and overrunning budget
|
||||
$(this).attr("rel", "");
|
||||
$(this).attr("src", approvalOverdraftIcon);
|
||||
$("#IconDenial" + baseid).css('opacity', 1.0).css("cursor", "pointer");
|
||||
alertify.error(msg.d.DisplayMessage);
|
||||
|
||||
recheckBudgets();
|
||||
}
|
||||
}, approvalIcon)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function recheckBudgets() {
|
||||
SwarmopsJS.ajaxCall("/Pages/v5/Financial/AttestCosts.aspx/GetRemainingBudgets", {}, function(data) {
|
||||
data.forEach(function(accountData, dummy1, dummy2) {
|
||||
@@ -285,7 +330,7 @@
|
||||
else if (!$(this).hasClass("LocalFundsInsufficient")) {
|
||||
$(this).addClass("LocalFundsInsufficient");
|
||||
if ($(this).attr("rel") != "loading") {
|
||||
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png");
|
||||
$(this).attr("src", approvalOverdraftIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +422,12 @@
|
||||
var accountId = 0;
|
||||
var budgetRemainingLookup = {};
|
||||
|
||||
// The variable below is advisory for the UI - actual access control is done server-side
|
||||
var canOverdraftBudgets = <asp:Literal ID="LiteralCanOverdraftBudgets" runat="server" />;
|
||||
|
||||
var approvalOverdraftIcon = '/Images/Icons/iconshock-balloon-yes-128x96px-disabled.png';
|
||||
var approvalOverdraftIconHover = approvalOverdraftIconHover;
|
||||
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Activities.Expressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using System.ServiceModel.Security;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
@@ -43,6 +44,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
|
||||
this._attestationRights = GetAttestationRights();
|
||||
this._documentList = new List<RepeatedDocument>();
|
||||
this.LiteralCanOverdraftBudgets.Text =
|
||||
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Administration)).ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
|
||||
|
||||
PopulateInboundInvoices();
|
||||
PopulateExpenses();
|
||||
@@ -111,6 +114,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
this.LiteralPleaseSelectBudget.Text = JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_PleaseSelectBudget);
|
||||
this.LiteralCannotRebudgetSalary.Text =
|
||||
JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_CantRebudgetSalary);
|
||||
|
||||
this.LiteralConfirmOverdraftNo.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmNo);
|
||||
this.LiteralConfirmOverdraftYes.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmYes);
|
||||
this.LiteralConfirmOverdraft.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirm);
|
||||
}
|
||||
|
||||
static protected IPayable PayableFromRecordId (string recordId)
|
||||
@@ -535,17 +542,32 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
budgetRemaining += budgetAdjustments[attestableItem.Budget.Identity];
|
||||
}
|
||||
|
||||
result = string.Empty;
|
||||
|
||||
if (amountCents > budgetRemaining)
|
||||
{
|
||||
return new AjaxCallResult
|
||||
if (
|
||||
authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Administration)))
|
||||
{
|
||||
DisplayMessage = Resources.Pages.Financial.AttestCosts_OutOfBudget,
|
||||
Success = false
|
||||
};
|
||||
// Admin rights, so allow (forced) overdraft
|
||||
|
||||
result = Resources.Pages.Financial.AttestCosts_Overdrafted + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not allow overdraft
|
||||
|
||||
return new AjaxCallResult
|
||||
{
|
||||
DisplayMessage = Resources.Pages.Financial.AttestCosts_OutOfBudget,
|
||||
Success = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
attestableItem.Attest (authData.CurrentUser);
|
||||
result = string.Format (attestedTemplate, itemId, beneficiary,
|
||||
result += string.Format (attestedTemplate, itemId, beneficiary,
|
||||
authData.CurrentOrganization.Currency.Code,
|
||||
amountCents/100.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user