// Timestamp,Merchant,Amount,MCC,Category,Tag,Comment,Reimbursable,"Original Currency","Original Amount",Receipt protected void ButtonRequest_Click(object sender, EventArgs e) { // The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here. // People who choose to disable JavaScript and then submit bad input almost deserve to be hurt. Int64 amountCents = this.CurrencyAmount.Cents; Int64 vatCents = this.CurrencyVat.Cents; string description = this.TextPurpose.Text; FinancialAccount budget = this.ComboBudgets.SelectedAccount; // sanity check if (budget.Organization.Identity != CurrentOrganization.Identity) { throw new InvalidOperationException("Budget-organization mismatch; won't file expense claim"); } // Store bank details for current user CurrentUser.BankName = this.TextBank.Text; CurrentUser.BankClearing = this.TextClearing.Text; CurrentUser.BankAccount = this.TextAccount.Text; // Get documents; check that documents have been uploaded Documents documents = Documents.RecentFromDescription(this.FileUpload.GuidString); if (documents.Count == 0) { throw new InvalidOperationException("No documents uploaded"); } ExpenseClaim claim = ExpenseClaim.Create(CurrentUser, CurrentOrganization, budget, DateTime.UtcNow, description, amountCents, vatCents); foreach (int tagSetId in this._tagSetIds) { string selectedTagString = Request.Form["DropTags" + tagSetId.ToString(CultureInfo.InvariantCulture)]; if (!String.IsNullOrEmpty(selectedTagString)) { int selectedTagType = Int32.Parse(selectedTagString); if (selectedTagType != 0) { claim.FinancialTransaction.CreateTag( FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser); } } } documents.SetForeignObjectForAll(claim); string successMessage = string.Format(Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartOne, CurrentOrganization.Currency.Code, amountCents / 100.0, budget.Name); if (budget.OwnerPersonId != CurrentUser.Identity) { successMessage += "<br/><br/>" + Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartTwo + "<br/>"; } else { successMessage += "<br/><br/>" + Resources.Pages.Financial.FileExpenseClaim_SuccessMessagePartTwoOwnBudget + "<br/>"; claim.Approve(CurrentUser); } DashboardMessage.Set(successMessage); // Redirect to dashboard Response.Redirect("/", true); }