Added tagging, validation of doc upload
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Swarmops.Database
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFinancialTransactionTags (int financialTransactionId)
|
||||
public void DeleteFinancialTransactionTags(int financialTransactionId)
|
||||
{
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
@@ -83,6 +83,21 @@ namespace Swarmops.Database
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteFinancialTransactionTag(int financialTransactionTagId)
|
||||
{
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
DbCommand command = GetDbCommand("DeleteFinancialTransactionTag", connection);
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
AddParameterWithName(command, "financialTransactionTagId", financialTransactionTagId);
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
public static ExpenseClaim Create(Person claimer, Organization organization, FinancialAccount budget,
|
||||
FinancialAccount costType, DateTime expenseDate, string description, Int64 amountCents)
|
||||
DateTime expenseDate, string description, Int64 amountCents)
|
||||
{
|
||||
ExpenseClaim newClaim = FromIdentityAggressive (SwarmDb.GetDatabaseForWriting().CreateExpenseClaim (claimer.Identity, organization.Identity,
|
||||
budget.Identity, expenseDate, description, amountCents));
|
||||
|
||||
@@ -272,6 +272,16 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
|
||||
|
||||
public void CreateTag (FinancialTransactionTagType tagType, Person creatingPerson)
|
||||
{
|
||||
// TODO: Verify that there isn't already a tag in this set in the transaction, and if so, delete it first
|
||||
|
||||
SwarmDb.GetDatabaseForWriting().CreateFinancialTransactionTag(this.Identity, tagType.Identity);
|
||||
|
||||
// TODO: Log that the tag was added (and by whom?)
|
||||
}
|
||||
|
||||
|
||||
public bool RecalculateTransaction (Dictionary<int, Int64> nominalTransaction, Person loggingPerson)
|
||||
{
|
||||
// TODO: Update dimension 2 with dimension 1 P&L accounts as template
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Swarmops.Basic.Types.Financial;
|
||||
using Swarmops.Database;
|
||||
|
||||
namespace Swarmops.Logic.Financial
|
||||
{
|
||||
@@ -18,6 +19,11 @@ namespace Swarmops.Logic.Financial
|
||||
return new FinancialTransactionTagType(basic);
|
||||
}
|
||||
|
||||
public static FinancialTransactionTagType FromIdentity (int identity)
|
||||
{
|
||||
return FromBasic(SwarmDb.GetDatabaseForReading().GetFinancialTransactionTagType(identity));
|
||||
}
|
||||
|
||||
public int ParentIdentity
|
||||
{
|
||||
get { return base.ParentFinancialTransactionTagTypeId; }
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Swarmops.Logic.Support
|
||||
case "Swarmops.Basic.Types.Financial.BasicFinancialAccount":
|
||||
return FinancialAccount.FromBasic((BasicFinancialAccount)basic);
|
||||
|
||||
case "Swarmops.Basic.Types.BasicFinancialTransaction":
|
||||
case "Swarmops.Basic.Types.Financial.BasicFinancialTransaction":
|
||||
return FinancialTransaction.FromBasic((BasicFinancialTransaction)basic);
|
||||
|
||||
case "Swarmops.Basic.Types.BasicFinancialValidation":
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for FieldValidation
|
||||
@@ -74,4 +75,17 @@ public class FieldValidation : System.Web.Services.WebService {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public bool AreDocumentsUploaded (string guidString)
|
||||
{
|
||||
Documents documents = Documents.RecentFromDescription(guidString);
|
||||
|
||||
if (documents.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,16 +238,19 @@
|
||||
<data name="FileExpenseClaim_UploadRecieptImages" xml:space="preserve">
|
||||
<value>Upload Receipt Images:</value>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_ValidationErron_Purpose" xml:space="preserve">
|
||||
<value>Please describe what this purchase was.</value>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_ValidationError_Amount" xml:space="preserve">
|
||||
<value>Please enter the amount of money (in {0}) that you are claiming.</value>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_ValidationError_Documents" xml:space="preserve">
|
||||
<value>Please upload one or more receipt images supporting the expense claim.</value>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_ValidationError_MissingTag" xml:space="preserve">
|
||||
<value>Please select an option as indicated.</value>
|
||||
<comment>Very general as tags may be many things.</comment>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_ValidationError_Purpose" xml:space="preserve">
|
||||
<value>Please describe what this purchase was.</value>
|
||||
</data>
|
||||
<data name="PayOutMoney_GridHeader_Amount" xml:space="preserve">
|
||||
<value>Amount</value>
|
||||
<comment>Amount to be paid out</comment>
|
||||
|
||||
@@ -73,6 +73,22 @@
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Automation/FieldValidation.asmx/AreDocumentsUploaded",
|
||||
data: "{'guidString': '<%=this.FileUpload.GuidString %>'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d != true) {
|
||||
isValid = false;
|
||||
$('#TextAmount').addClass("entryError");
|
||||
alertify.error("<asp:Literal runat="server" ID="LiteralErrorDocuments" />");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,12 +117,13 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
this.LabelImageFiles.Text = Resources.Pages.Financial.FileExpenseClaim_UploadRecieptImages;
|
||||
|
||||
this.LiteralErrorAmount.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationError_Amount;
|
||||
this.LiteralErrorPurpose.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationErron_Purpose;
|
||||
this.LiteralErrorPurpose.Text = Resources.Pages.Financial.FileExpenseClaim_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;
|
||||
|
||||
this.LiteralErrorDocuments.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationError_Documents;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -138,8 +139,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
string description = this.TextPurpose.Text;
|
||||
|
||||
FinancialAccount budget = FinancialAccount.FromIdentity(Int32.Parse(this.Request.Form["DropBudgets"]));
|
||||
FinancialAccount costType =
|
||||
FinancialAccount.FromIdentity (Int32.Parse ((this.Request.Form["DropCostTypes"])));
|
||||
|
||||
// sanity check
|
||||
|
||||
@@ -148,11 +147,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
throw new InvalidOperationException("Budget-organization mismatch; won't file expense claim");
|
||||
}
|
||||
|
||||
if (costType.Organization.Identity != CurrentOrganization.Identity)
|
||||
{
|
||||
throw new InvalidOperationException("CostType-organization mismatch; won't file expense claim");
|
||||
}
|
||||
|
||||
// Store bank details for current user
|
||||
|
||||
CurrentUser.BankName = this.TextBank.Text;
|
||||
@@ -168,15 +162,26 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
throw new InvalidOperationException("No documents uploaded");
|
||||
}
|
||||
|
||||
ExpenseClaim claim = ExpenseClaim.Create (this.CurrentUser, this.CurrentOrganization, budget, costType,
|
||||
DateTime.UtcNow, description, amountCents);
|
||||
ExpenseClaim claim = ExpenseClaim.Create (this.CurrentUser, this.CurrentOrganization, budget, DateTime.UtcNow, description, amountCents);
|
||||
|
||||
foreach (int tagSetId in _tagSetIds)
|
||||
{
|
||||
string selectedTagString =
|
||||
this.Request.Form["DropTags" + tagSetId.ToString(CultureInfo.InvariantCulture)];
|
||||
|
||||
if (!String.IsNullOrEmpty(selectedTagString))
|
||||
{
|
||||
int selectedTagType = Int32.Parse(selectedTagString);
|
||||
claim.FinancialTransaction.CreateTag(FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser);
|
||||
}
|
||||
}
|
||||
|
||||
documents.SetForeignObjectForAll(claim);
|
||||
|
||||
string successMessage = string.Format(Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartOne,
|
||||
HttpUtility.HtmlEncode(CurrentUser.Name),
|
||||
HttpUtility.HtmlEncode(description), CurrentOrganization.Currency.Code,
|
||||
(double) (amountCents/100.0));
|
||||
CurrentOrganization.Currency.Code,
|
||||
(double) (amountCents/100.0),
|
||||
budget.Name);
|
||||
|
||||
if (budget.OwnerPersonId != CurrentUser.Identity)
|
||||
{
|
||||
@@ -189,7 +194,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartTwoOwnBudget +
|
||||
"<br/>";
|
||||
claim.Attest (CurrentUser);
|
||||
// TODO: Auto-attest
|
||||
}
|
||||
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(successMessage)));
|
||||
|
||||
Reference in New Issue
Block a user