SMall work on attestation loc

This commit is contained in:
Rick Falkvinge
2013-02-10 11:18:34 +00:00
parent e71a25bed1
commit 4ff1eaa7c9
10 changed files with 117 additions and 68 deletions
+5 -1
View File
@@ -37,6 +37,10 @@ namespace Swarmops.Basic.Enums
/// <summary>
/// A conference or similar event (called 'parley' in lingo)
/// </summary>
Parley
Parley,
/// <summary>
/// A cash advance (prior payment, rather than doing an expense claim post purchase)
/// </summary>
CashAdvance
}
}
+19 -3
View File
@@ -134,9 +134,6 @@ namespace Swarmops.Database
}
// TODO: SetCashAdvanceAttested
public void SetCashAdvanceOpen(int cashAdvanceId, bool open)
{
using (DbConnection connection = GetMySqlDbConnection())
@@ -154,6 +151,25 @@ namespace Swarmops.Database
}
public void SetCashAdvanceAttested(int cashAdvanceId, bool attested, int attestedByPersonId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("SetCashAdvanceAttested", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "cashAdvanceId", cashAdvanceId);
AddParameterWithName(command, "attested", attested);
AddParameterWithName(command, "attestedByPersonId", attestedByPersonId);
AddParameterWithName(command, "attestedDateTime", DateTime.Now);
command.ExecuteNonQuery();
}
}
public void SetCashAdvancePaidOut(int cashAdvanceId, bool paidOut)
{
using (DbConnection connection = GetMySqlDbConnection())
+7 -2
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Swarm;
@@ -52,12 +53,16 @@ namespace Swarmops.Logic.Financial
public void Attest(Person attester)
{
throw new NotImplementedException();
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.CashAdvance, this.Identity, DateTime.Now, attester.Identity, this.AmountCents / 100.0);
SwarmDb.GetDatabaseForWriting().SetCashAdvanceAttested(this.Identity, true, attester.Identity);
}
public void Deattest(Person deattester)
{
throw new NotImplementedException();
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation,
FinancialDependencyType.CashAdvance, this.Identity, DateTime.Now, deattester.Identity, this.AmountCents / 100.0);
SwarmDb.GetDatabaseForWriting().SetCashAdvanceAttested(this.Identity, false, Person.NobodyId);
}
#endregion
+5
View File
@@ -1028,6 +1028,11 @@ namespace Swarmops.Logic.Swarm
return GetAvatarLink(pixelSize).Replace("http://www", "https://secure");
}
public static int NobodyId
{
get { return 0; }
}
public bool HasAccess (Access access)
{
if (access == null)
@@ -19,9 +19,9 @@ namespace Swarmops.Frontend.Pages.v5.Finance
return;
}
this.PageTitle = Resources.Pages.Finance.RequestCashAdvance_PageTitle;
this.PageTitle = Resources.Pages.Financial.RequestCashAdvance_PageTitle;
this.PageIcon = "iconshock-walletmoney";
this.InfoBoxLiteral = Resources.Pages.Finance.RequestCashAdvance_Info;
this.InfoBoxLiteral = Resources.Pages.Financial.RequestCashAdvance_Info;
if (!Page.IsPostBack)
{
@@ -40,21 +40,21 @@ namespace Swarmops.Frontend.Pages.v5.Finance
private void Localize()
{
this.LabelAmount.Text = string.Format(Resources.Pages.Finance.RequestCashAdvance_Amount,
this.LabelAmount.Text = string.Format(Resources.Pages.Financial.RequestCashAdvance_Amount,
CurrentOrganization.Currency.Code);
this.LabelPurpose.Text = Resources.Pages.Finance.RequestCashAdvance_Purpose;
this.LabelBudget.Text = Resources.Pages.Finance.RequestCashAdvance_Budget;
this.LabelHeaderBankDetails.Text = Resources.Pages.Finance.RequestCashAdvance_HeaderBankDetails;
this.LabelBankName.Text = Resources.Pages.Finance.RequestCashAdvance_BankName;
this.LabelBankClearing.Text = Resources.Pages.Finance.RequestCashAdvance_BankClearing;
this.LabelBankAccount.Text = Resources.Pages.Finance.RequestCashAdvance_BankAccount;
this.LabelPurpose.Text = Resources.Pages.Financial.RequestCashAdvance_Purpose;
this.LabelBudget.Text = Resources.Pages.Financial.RequestCashAdvance_Budget;
this.LabelHeaderBankDetails.Text = Resources.Pages.Financial.RequestCashAdvance_HeaderBankDetails;
this.LabelBankName.Text = Resources.Pages.Financial.RequestCashAdvance_BankName;
this.LabelBankClearing.Text = Resources.Pages.Financial.RequestCashAdvance_BankClearing;
this.LabelBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_BankAccount;
this.LiteralErrorAmount.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Amount;
this.LiteralErrorPurpose.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Purpose;
this.LiteralErrorBudget.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Budget;
this.LiteralErrorBankName.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankName;
this.LiteralErrorBankClearing.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankClearing;
this.LiteralErrorBankAccount.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankAccount;
this.LiteralErrorAmount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Amount;
this.LiteralErrorPurpose.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Purpose;
this.LiteralErrorBudget.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Budget;
this.LiteralErrorBankName.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankName;
this.LiteralErrorBankClearing.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankClearing;
this.LiteralErrorBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankAccount;
}
@@ -91,20 +91,20 @@ namespace Swarmops.Frontend.Pages.v5.Finance
// Create success message
string successMessage = string.Format(Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartOne,
string successMessage = string.Format(Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartOne,
HttpUtility.HtmlEncode(CurrentUser.Name),
HttpUtility.HtmlEncode(description), CurrentOrganization.Currency.Code,
(double) (amountCents/100.0));
if (budget.OwnerPersonId != CurrentUser.Identity)
{
successMessage += "<br/><br/>" + Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartTwo +
successMessage += "<br/><br/>" + Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartTwo +
"<br/>";
}
else
{
successMessage += "<br/><br/>" +
Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartTwoOwnBudget +
Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartTwoOwnBudget +
"<br/>";
// TODO: Auto-attest
}
+34 -19
View File
@@ -14,11 +14,11 @@
preload([
'/Images/Abstract/ajaxloader-medium.gif',
'/Images/Icons/iconshock-redcross-16px.png',
'/Images/Icons/iconshock-redcross-16px-desat.png',
'/Images/Icons/iconshock-balloon-yes-16px-hot.png',
'/Images/Icons/iconshock-balloon-no-16px-hot.png',
'/Images/Icons/iconshock-greentick-16px.png',
'/Images/Icons/iconshock-greentick-16px-desat.png',
'/Images/Icons/iconshock-glass-16px-hot.png'
'/Images/Icons/iconshock-redcross-16px.png',
'/Images/Icons/undo-16px.png'
]);
$(document).ready(function () {
@@ -60,14 +60,21 @@
$(this).attr("rel", "loading");
$(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif");
$("#IconDenial" + $(this).attr("baseid")).fadeTo(1000, 0.01).css("cursor", "default");
$(this).fadeOut(2000, function () {
$(this).css("display", "none");
$(this).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png");
$(this).attr("rel", "active");
$("#IconApproved" + $(this).attr("baseid")).fadeIn(100);
alertify.success("Foo approved.");
var thisIcon = this;
$.ajax({
type: "POST",
url: "AttestCosts.aspx/Attest",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$(thisIcon).css("display", "none");
$(thisIcon).attr("src", "/Images/Icons/iconshock-balloon-yes-16px.png");
$(thisIcon).attr("rel", "active");
$("#IconApproved" + $(thisIcon).attr("baseid")).fadeIn(100);
alertify.success(unescape(msg.d));
}
});
}
});
@@ -75,14 +82,22 @@
if ($(this).attr("rel") != "loading") {
$(this).attr("rel", "loading");
$(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif");
$(this).fadeOut(2000, function () {
$(this).css("display", "none");
$(this).attr("src", "/Images/Icons/iconshock-greentick-16px.png");
$(this).attr("rel", "");
$("#IconApproval" + $(this).attr("baseid")).fadeIn(100);
$("#" + $(this).attr("rel"), "");
alertify.log("Foo de-attested.");
$("#IconDenial" + $(this).attr("baseid")).fadeTo(100, 1).css("cursor", "pointer");
var thisIcon = this;
$.ajax({
type: "POST",
url: "AttestCosts.aspx/Deattest",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$(thisIcon).css("display", "none");
$(thisIcon).attr("src", "/Images/Icons/iconshock-greentick-16px.png");
$(thisIcon).attr("rel", "");
$("#IconApproval" + $(thisIcon).attr("baseid")).fadeIn(100);
$("#" + $(thisIcon).attr("rel"), "");
alertify.log(unescape(msg.d).replace('+', ' '));
$("#IconDenial" + $(thisIcon).attr("baseid")).fadeTo(100, 1).css("cursor", "pointer");
}
});
}
+11 -7
View File
@@ -34,13 +34,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial
private void Localize()
{
this.PageTitle = Resources.Pages.Finance.AttestCosts_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Finance.AttestCosts_Info;
this.PageTitle = Resources.Pages.Financial.AttestCosts_PageTitle;
this.InfoBoxLiteral = Resources.Pages.Financial.AttestCosts_Info;
}
[WebMethod]
public static string Attest (string identifier)
{
identifier = HttpUtility.UrlDecode(identifier);
string identity = HttpContext.Current.User.Identity.Name;
string[] identityTokens = identity.Split(',');
@@ -66,7 +68,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
throw new InvalidOperationException("Called to attest out-of-org line item");
}
if (advance.FinancialAccount.OwnerPersonId != currentUserId)
if (advance.FinancialAccount.OwnerPersonId != currentUserId && advance.FinancialAccount.OwnerPersonId != Person.NobodyId)
{
throw new SecurityAccessDeniedException("Called without attestation privileges");
}
@@ -76,12 +78,14 @@ namespace Swarmops.Frontend.Pages.v5.Financial
break;
}
return result;
return HttpUtility.UrlEncode(result);
}
[WebMethod]
public static string Deattest(string identifier)
{
identifier = HttpUtility.UrlDecode(identifier);
string identity = HttpContext.Current.User.Identity.Name;
string[] identityTokens = identity.Split(',');
@@ -107,17 +111,17 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
throw new InvalidOperationException("Called to attest out-of-org line item");
}
if (advance.FinancialAccount.OwnerPersonId != currentUserId)
if (advance.FinancialAccount.OwnerPersonId != currentUserId && advance.FinancialAccount.OwnerPersonId != Person.NobodyId)
{
throw new SecurityAccessDeniedException("Called without attestation privileges");
}
result = "XYZ Cash Advance";
result = "XYZ Cash Advance for " + beneficiary;
advance.Deattest(currentUser);
break;
}
return result;
return HttpUtility.UrlEncode(result).Replace("+", "%20");
}
}
}
@@ -19,9 +19,9 @@ namespace Swarmops.Frontend.Pages.v5.Financial
return;
}
this.PageTitle = Resources.Pages.Finance.RequestCashAdvance_PageTitle;
this.PageTitle = Resources.Pages.Financial.RequestCashAdvance_PageTitle;
this.PageIcon = "iconshock-walletmoney";
this.InfoBoxLiteral = Resources.Pages.Finance.RequestCashAdvance_Info;
this.InfoBoxLiteral = Resources.Pages.Financial.RequestCashAdvance_Info;
if (!Page.IsPostBack)
{
@@ -40,21 +40,21 @@ namespace Swarmops.Frontend.Pages.v5.Financial
private void Localize()
{
this.LabelAmount.Text = string.Format(Resources.Pages.Finance.RequestCashAdvance_Amount,
this.LabelAmount.Text = string.Format(Resources.Pages.Financial.RequestCashAdvance_Amount,
CurrentOrganization.Currency.Code);
this.LabelPurpose.Text = Resources.Pages.Finance.RequestCashAdvance_Purpose;
this.LabelBudget.Text = Resources.Pages.Finance.RequestCashAdvance_Budget;
this.LabelHeaderBankDetails.Text = Resources.Pages.Finance.RequestCashAdvance_HeaderBankDetails;
this.LabelBankName.Text = Resources.Pages.Finance.RequestCashAdvance_BankName;
this.LabelBankClearing.Text = Resources.Pages.Finance.RequestCashAdvance_BankClearing;
this.LabelBankAccount.Text = Resources.Pages.Finance.RequestCashAdvance_BankAccount;
this.LabelPurpose.Text = Resources.Pages.Financial.RequestCashAdvance_Purpose;
this.LabelBudget.Text = Resources.Pages.Financial.RequestCashAdvance_Budget;
this.LabelHeaderBankDetails.Text = Resources.Pages.Financial.RequestCashAdvance_HeaderBankDetails;
this.LabelBankName.Text = Resources.Pages.Financial.RequestCashAdvance_BankName;
this.LabelBankClearing.Text = Resources.Pages.Financial.RequestCashAdvance_BankClearing;
this.LabelBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_BankAccount;
this.LiteralErrorAmount.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Amount;
this.LiteralErrorPurpose.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Purpose;
this.LiteralErrorBudget.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_Budget;
this.LiteralErrorBankName.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankName;
this.LiteralErrorBankClearing.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankClearing;
this.LiteralErrorBankAccount.Text = Resources.Pages.Finance.RequestCashAdvance_ValidationError_BankAccount;
this.LiteralErrorAmount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Amount;
this.LiteralErrorPurpose.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Purpose;
this.LiteralErrorBudget.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Budget;
this.LiteralErrorBankName.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankName;
this.LiteralErrorBankClearing.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankClearing;
this.LiteralErrorBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankAccount;
}
@@ -91,20 +91,20 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// Create success message
string successMessage = string.Format(Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartOne,
string successMessage = string.Format(Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartOne,
HttpUtility.HtmlEncode(CurrentUser.Name),
HttpUtility.HtmlEncode(description), CurrentOrganization.Currency.Code,
(double) (amountCents/100.0));
if (budget.OwnerPersonId != CurrentUser.Identity)
{
successMessage += "<br/><br/>" + Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartTwo +
successMessage += "<br/><br/>" + Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartTwo +
"<br/>";
}
else
{
successMessage += "<br/><br/>" +
Resources.Pages.Finance.RequestCashAdvance_SuccessMessagePartTwoOwnBudget +
Resources.Pages.Financial.RequestCashAdvance_SuccessMessagePartTwoOwnBudget +
"<br/>";
// TODO: Auto-attest
}