diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs
index 272a1021..9d0f3f03 100644
--- a/Logic/Communications/OutboundComm.cs
+++ b/Logic/Communications/OutboundComm.cs
@@ -159,6 +159,9 @@ namespace Swarmops.Logic.Communications
}
+
+
+
public static OutboundComm CreateNotificationAttestationNeeded (FinancialAccount budget, Person concernedPerson,
string supplier, double amountRequested, string purpose, NotificationResource notification)
{
@@ -166,7 +169,7 @@ namespace Swarmops.Logic.Communications
payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.DisplayCode;
payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name;
payload.Strings[NotificationString.BudgetAmountFloat] =
- amountRequested.ToString (CultureInfo.InvariantCulture);
+ amountRequested.ToString ("N2");
payload.Strings[NotificationString.RequestPurpose] = purpose;
payload.Strings[NotificationString.Description] = purpose;
payload.Strings[NotificationString.Supplier] = supplier;
@@ -201,7 +204,7 @@ namespace Swarmops.Logic.Communications
payload.Strings[NotificationString.CurrencyCode] = organization.Currency.DisplayCode;
payload.Strings[NotificationString.OrganizationName] = organization.Name;
payload.Strings[NotificationString.BudgetAmountFloat] =
- amountRequested.ToString (CultureInfo.InvariantCulture);
+ amountRequested.ToString("N2");
OutboundComm comm = OutboundComm.Create (null, null, organization, CommResolverClass.Unknown, null,
CommTransmitterClass.CommsTransmitterMail,
@@ -222,16 +225,17 @@ namespace Swarmops.Logic.Communications
public static OutboundComm CreateNotificationOfFinancialValidation (FinancialAccount budget,
- Person concernedPerson, double amountRequested, string purpose, NotificationResource notification)
+ Person concernedPerson, double amountRequested, string purpose, NotificationResource notification, string reasonGiven="")
{
NotificationPayload payload = new NotificationPayload (notification.ToString());
payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.DisplayCode;
payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name;
payload.Strings[NotificationString.BudgetAmountFloat] =
- amountRequested.ToString (CultureInfo.InvariantCulture);
+ amountRequested.ToString("N2");
payload.Strings[NotificationString.RequestPurpose] = purpose;
payload.Strings[NotificationString.BudgetName] = budget.Name;
payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical;
+ payload.Strings[NotificationString.EmbeddedPreformattedText] = reasonGiven;
OutboundComm comm = OutboundComm.Create (null, null, budget.Organization, CommResolverClass.Unknown, null,
CommTransmitterClass.CommsTransmitterMail,
diff --git a/Logic/Financial/CashAdvance.cs b/Logic/Financial/CashAdvance.cs
index 502957e0..5ae409fb 100644
--- a/Logic/Financial/CashAdvance.cs
+++ b/Logic/Financial/CashAdvance.cs
@@ -62,7 +62,7 @@ namespace Swarmops.Logic.Financial
public void Attest (Person attester)
{
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Attestation,
- FinancialDependencyType.CashAdvance, Identity, DateTime.Now, attester.Identity, AmountCents/100.0);
+ FinancialDependencyType.CashAdvance, Identity, DateTime.UtcNow, attester.Identity, AmountCents/100.0);
SwarmDb.GetDatabaseForWriting().SetCashAdvanceAttested (Identity, true, attester.Identity);
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Person, AmountCents/100.0, Description,
@@ -72,13 +72,25 @@ namespace Swarmops.Logic.Financial
public void Deattest (Person deattester)
{
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Deattestation,
- FinancialDependencyType.CashAdvance, Identity, DateTime.Now, deattester.Identity, AmountCents/100.0);
+ FinancialDependencyType.CashAdvance, Identity, DateTime.UtcNow, deattester.Identity, AmountCents/100.0);
SwarmDb.GetDatabaseForWriting().SetCashAdvanceAttested (Identity, false, Person.NobodyId);
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Person, AmountCents/100.0, Description,
NotificationResource.CashAdvance_Deattested);
}
+ public void DenyAttestation (Person denyingPerson, string reason)
+ {
+ SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Kill,
+ FinancialDependencyType.CashAdvance, Identity, DateTime.UtcNow, denyingPerson.Identity, AmountCents / 100.0);
+
+ OutboundComm.CreateNotificationOfFinancialValidation(Budget, Person, AmountCents / 100.0, Description,
+ NotificationResource.CashAdvance_Denied, reason);
+ Attested = false;
+ Open = false;
+ }
+
+
#endregion
public Person Person
@@ -198,6 +210,7 @@ namespace Swarmops.Logic.Financial
public void SetAmountCents(Int64 newAmount, Person settingPerson)
{
SwarmDb.GetDatabaseForWriting().SetCashAdvanceAmountCents (this.Identity, newAmount);
+ base.AmountCents = newAmount;
}
}
}
\ No newline at end of file
diff --git a/Logic/Financial/ExpenseClaim.cs b/Logic/Financial/ExpenseClaim.cs
index 23601be6..4ba0edb7 100644
--- a/Logic/Financial/ExpenseClaim.cs
+++ b/Logic/Financial/ExpenseClaim.cs
@@ -292,7 +292,7 @@ namespace Swarmops.Logic.Financial
SwarmDb.GetDatabaseForWriting().SetExpenseClaimValidated (Identity, true);
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Validation,
FinancialDependencyType.ExpenseClaim, Identity,
- DateTime.Now, validator.Identity, (double) Amount);
+ DateTime.UtcNow, validator.Identity, (double) Amount);
base.Validated = true;
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Claimer, AmountCents/100.0, Description,
@@ -304,7 +304,7 @@ namespace Swarmops.Logic.Financial
SwarmDb.GetDatabaseForWriting().SetExpenseClaimValidated (Identity, false);
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Devalidation,
FinancialDependencyType.ExpenseClaim, Identity,
- DateTime.Now, devalidator.Identity, (double) Amount);
+ DateTime.UtcNow, devalidator.Identity, (double) Amount);
base.Validated = false;
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Claimer, AmountCents/100.0, Description,
@@ -317,11 +317,10 @@ namespace Swarmops.Logic.Financial
public void Attest (Person attester)
{
- SwarmDb.GetDatabaseForWriting().SetExpenseClaimAttested (Identity, true);
- SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Attestation,
+ Attested = true;
+ SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.ExpenseClaim, Identity,
- DateTime.Now, attester.Identity, (double) Amount);
- base.Attested = true;
+ DateTime.UtcNow, attester.Identity, (double) Amount);
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Claimer, AmountCents/100.0, Description,
NotificationResource.ExpenseClaim_Attested);
@@ -329,16 +328,27 @@ namespace Swarmops.Logic.Financial
public void Deattest (Person deattester)
{
- SwarmDb.GetDatabaseForWriting().SetExpenseClaimAttested (Identity, false);
- SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Deattestation,
+ Attested = false;
+ SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation,
FinancialDependencyType.ExpenseClaim, Identity,
- DateTime.Now, deattester.Identity, (double) Amount);
- base.Attested = false;
+ DateTime.UtcNow, deattester.Identity, (double) Amount);
OutboundComm.CreateNotificationOfFinancialValidation (Budget, Claimer, AmountCents/100.0, Description,
NotificationResource.ExpenseClaim_Deattested);
}
+ public void DenyAttestation (Person denyingPerson, string reason)
+ {
+ Attested = false;
+ Open = false;
+ SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Kill,
+ FinancialDependencyType.ExpenseClaim, Identity,
+ DateTime.UtcNow, denyingPerson.Identity, (double)Amount);
+
+ OutboundComm.CreateNotificationOfFinancialValidation(Budget, Claimer, AmountCents / 100.0, Description,
+ NotificationResource.ExpenseClaim_Denied, reason);
+ }
+
#endregion
public FinancialAccount Budget
@@ -378,6 +388,12 @@ namespace Swarmops.Logic.Financial
base.AmountCents = amountCents;
SwarmDb.GetDatabaseForWriting().SetExpenseClaimAmount (Identity, amountCents);
UpdateFinancialTransaction (settingPerson);
+
+ if (Validated)
+ {
+ // Reset validation, since amount was changed
+ Devalidate (settingPerson);
+ }
}
@@ -402,7 +418,7 @@ namespace Swarmops.Logic.Financial
// Mark transaction as invalid in description
- FinancialTransaction.Description = "Expense Claim #" + Identity + " (killed/zeroed)";
+ FinancialTransaction.Description = "[strikeout]Expense Claim #" + Identity;
}
diff --git a/Logic/Financial/IAttestable.cs b/Logic/Financial/IAttestable.cs
index b37a3c35..56e33bc3 100644
--- a/Logic/Financial/IAttestable.cs
+++ b/Logic/Financial/IAttestable.cs
@@ -7,5 +7,7 @@ namespace Swarmops.Logic.Financial
FinancialAccount Budget { get; }
void Attest (Person attester);
void Deattest (Person deattester);
+
+ void DenyAttestation(Person denyingPerson, string reason);
}
}
\ No newline at end of file
diff --git a/Logic/Financial/InboundInvoice.cs b/Logic/Financial/InboundInvoice.cs
index 5e16d44a..3dcf53e7 100644
--- a/Logic/Financial/InboundInvoice.cs
+++ b/Logic/Financial/InboundInvoice.cs
@@ -115,7 +115,7 @@ namespace Swarmops.Logic.Financial
SwarmDb.GetDatabaseForWriting().SetInboundInvoiceAttested (Identity, true);
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Attestation,
FinancialDependencyType.InboundInvoice, Identity,
- DateTime.Now, attester.Identity, (double) Amount);
+ DateTime.UtcNow, attester.Identity, (double) Amount);
base.Attested = true;
}
@@ -124,10 +124,19 @@ namespace Swarmops.Logic.Financial
SwarmDb.GetDatabaseForWriting().SetInboundInvoiceAttested (Identity, false);
SwarmDb.GetDatabaseForWriting().CreateFinancialValidation (FinancialValidationType.Deattestation,
FinancialDependencyType.InboundInvoice, Identity,
- DateTime.Now, deattester.Identity, (double) Amount);
+ DateTime.UtcNow, deattester.Identity, (double) Amount);
base.Attested = false;
}
+ public void DenyAttestation (Person denyingPerson, string reason)
+ {
+ SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Kill,
+ FinancialDependencyType.InboundInvoice, Identity,
+ DateTime.UtcNow, denyingPerson.Identity, (double)Amount);
+ Attested = false;
+ Open = false;
+ }
+
#endregion
public FinancialAccount Budget
diff --git a/Logic/Financial/Salary.cs b/Logic/Financial/Salary.cs
index a45ee2ee..5401e0a5 100644
--- a/Logic/Financial/Salary.cs
+++ b/Logic/Financial/Salary.cs
@@ -138,6 +138,14 @@ namespace Swarmops.Logic.Financial
SwarmDb.GetDatabaseForWriting().SetSalaryAttested (Identity, false);
}
+ public void DenyAttestation (Person denyingPerson, string reason)
+ {
+ // Denying a salary payout is not to be taken lightly. This needs to be a larger feature. Until
+ // then, it's not implemented at all.
+
+ throw new NotImplementedException();
+ }
+
#endregion
public FinancialAccount Budget // needed for IAttestable
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
index e0a38a58..4938065f 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs
@@ -98,6 +98,27 @@ namespace Swarmops.Logic.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. The text below was given as reason for denying it:
+ ///
+ ///[EmbeddedPreformattedText]
+ ///.
+ ///
+ internal static string CashAdvance_Denied_Body {
+ get {
+ return ResourceManager.GetString("CashAdvance_Denied_Body", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to [[OrganizationName]] Cash Advance DENIED: [CurrencyCode] [BudgetAmountFloat].
+ ///
+ internal static string CashAdvance_Denied_Subject {
+ get {
+ return ResourceManager.GetString("CashAdvance_Denied_Subject", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Your request for a cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants.
///
@@ -197,7 +218,10 @@ namespace Swarmops.Logic.Resources {
}
///
- /// Looks up a localized string similar to Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. Expect more communications to follow on what you need to do to file a proper expense claim..
+ /// Looks up a localized string similar to Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. The text below was given as reason for denying it:
+ ///
+ ///[EmbeddedPreformattedText]
+ ///.
///
internal static string ExpenseClaim_Denied_Body {
get {
diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
index c7e67370..6c470419 100644
--- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
+++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx
@@ -131,6 +131,15 @@ Expect more communication from the budget owner to follow on the matter.
[OrganizationName] Cash Advance DE-attested: [CurrencyCode] [BudgetAmountFloat]
+
+ Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. The text below was given as reason for denying it:
+
+[EmbeddedPreformattedText]
+
+
+
+ [[OrganizationName]] Cash Advance DENIED: [CurrencyCode] [BudgetAmountFloat]
+
Your request for a cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants.
@@ -176,7 +185,10 @@ Expect more communication from the budget owner to follow on the matter.
[[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]
- Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. Expect more communications to follow on what you need to do to file a proper expense claim.
+ Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. The text below was given as reason for denying it:
+
+[EmbeddedPreformattedText]
+
This is sent to the claimer.
diff --git a/Logic/Swarm/Parley.cs b/Logic/Swarm/Parley.cs
index d374c74c..2f249d6b 100644
--- a/Logic/Swarm/Parley.cs
+++ b/Logic/Swarm/Parley.cs
@@ -193,6 +193,13 @@ namespace Swarmops.Logic.Swarm
// this.BudgetId = this.Budget.ParentIdentity;
}
+ public void DenyAttestation (Person denyingPerson, string denyReason)
+ {
+ // Re-implement if and when parleys are resurrected
+
+ throw new NotImplementedException();
+ }
+
#endregion
public FinancialAccount Budget
diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx
index 52ede672..17dd08d9 100644
--- a/Site5/App_GlobalResources/Global.resx
+++ b/Site5/App_GlobalResources/Global.resx
@@ -667,4 +667,8 @@
Swarmops does not understand your currency amount. (One thousand money and zero cents are written like "{0:N2}".) Try again?
The {0:N2} is just fed with the number 1000.00 in culture-specific format.
+
+ No reason was specified.
+ As inter-activist communication when denying resources, et cetera
+
\ No newline at end of file
diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx b/Site5/Pages/v5/Financial/AttestCosts.aspx
index 77b435e1..29a549f9 100644
--- a/Site5/Pages/v5/Financial/AttestCosts.aspx
+++ b/Site5/Pages/v5/Financial/AttestCosts.aspx
@@ -294,6 +294,35 @@
budgetRemainingLookup.attestabilityInitialized = true;
}
+
+ function onDenyRecord() {
+ var reason = $('#<%=this.TextDenyReason.ClientID%>').val();
+
+ // hide yes/no icons, show denied icon, but set it to "loading" icon until completed
+
+ $('#IconApproval' + recordId).hide();
+ $('#IconDenial' + recordId).hide();
+ $('#IconDenied' + recordId).attr('src', '/Images/Abstract/ajaxloader-48x36px.gif');
+ <%= this.DialogDeny.ClientID %>_close();
+
+ SwarmopsJS.ajaxCall(
+ "/Pages/v5/Financial/AttestCosts.aspx/DenyItem",
+ { recordId: recordId, reason: reason },
+ $.proxy(function(result) {
+ if (result.Success) {
+ $(this).attr("src", "/Images/Icons/iconshock-red-cross-circled-128x96px.png");
+ $(this).fadeIn(); // was visible already, but this will create an effect as it changes image
+ } else {
+ // Failure can happen for many reasons, all bad, so we're just reloading the
+ // entire grid to cover our bases
+ alertify.error(result.DisplayMessage);
+ recheckBudgets();
+ $('#TableAttestableCosts').datagrid('reload');
+ }
+ }, $('#IconDenied' + recordId)));
+ }
+
+
function onRebudgetRecord() {
var newAccountId = <%=this.DropBudgetsRebudget.ClientID%>_val();
if (newAccountId == 0) {
@@ -333,7 +362,8 @@
if (!result.Success) {
alertify.error(result.DisplayMessage);
} else {
- // Succeeded, attested for new amount. Since amount was changed, reload grid
+ // Succeeded, attested for new amount. Since amount was changed, reload grid and budgets
+ recheckBudgets();
$('#TableAttestableCosts').datagrid('reload');
<%= this.DialogDeny.ClientID %>_close();
}
diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
index e512c05d..a6d93859 100644
--- a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
+++ b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
@@ -130,7 +130,24 @@ namespace Swarmops.Frontend.Pages.v5.Financial
throw new NotImplementedException("Unknown record type");
}
}
-
+
+
+ [WebMethod]
+ public static void DenyItem (string recordId, string reason)
+ {
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+ IPayable payable = PayableFromRecordId (recordId);
+ FinancialAccount budget = payable.Budget;
+
+ if (budget.OrganizationId != authData.CurrentOrganization.Identity ||
+ budget.OwnerPersonId != authData.CurrentUser.Identity)
+ {
+ throw new UnauthorizedAccessException();
+ }
+
+ payable.DenyAttestation (authData.CurrentUser, reason);
+ }
+
[WebMethod]
public static void RebudgetItem (string recordId, int newAccountId)
@@ -233,28 +250,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
};
}
- [WebMethod]
- public static string GetOverdraftMessage (int accountId)
- {
- AuthenticationData authData = GetAuthenticationDataAndCulture();
- FinancialAccount account = FinancialAccount.FromIdentity (accountId);
- if (account.OrganizationId != authData.CurrentOrganization.Identity)
- {
- throw new UnauthorizedAccessException();
- }
-
- if (authData.CurrentUser.Identity != account.OwnerPersonId)
- {
- throw new UnauthorizedAccessException();
- }
-
- int year = DateTime.UtcNow.Year;
- Int64 budgetRemainingCents = GetBudgetRemaining (account, year);
-
- return String.Format (Resources.Pages.Financial.AttestCosts_OutOfBudgetPrecise,
- authData.CurrentOrganization.Currency.DisplayCode, budgetRemainingCents/100.0, year);
- }
[WebMethod]
public static BudgetRemainder[] GetRemainingBudgets()
@@ -371,7 +367,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial
Int64 deltaCentsYear = account.GetDeltaCents(new DateTime(year, 1, 1),
new DateTime(year + 1, 1, 1));
Int64 budgetYear = account.GetBudgetCents(year);
- return -(budgetYear - deltaCentsYear);
+
+ Dictionary adjustments = GetAccountingAdjustments (account.Organization);
+
+ return -(budgetYear - deltaCentsYear) + (adjustments.ContainsKey(account.Identity)? adjustments[account.Identity]: 0);
}
public class BudgetRemainder
@@ -403,15 +402,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
- IAttestable attestableItem = null;
- string attestedTemplate = string.Empty;
- string deattestedTemplate = string.Empty;
+ IAttestable attestableItem;
+ string attestedTemplate;
+ string deattestedTemplate;
char costType = identifier[0];
int itemId = Int32.Parse (identifier.Substring (1));
Int64 amountCents;
- string beneficiary = string.Empty;
- string result = string.Empty;
+ string beneficiary;
+ string result;
// Find the item we are attesting or deattesting