diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index 01e71c64..36a778ce 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -360,4 +360,15 @@ Image {0} of {1} + + Due Date + For invoices and similar + + + Supplier + + + English (US) + Replace with THIS language, EXPRESSED IN this language. Examples: "Español", "Français", "Svenska", etc. + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Financial.resx b/Site5/App_GlobalResources/Pages.Financial.resx index 84d20b57..4051d403 100644 --- a/Site5/App_GlobalResources/Pages.Financial.resx +++ b/Site5/App_GlobalResources/Pages.Financial.resx @@ -190,6 +190,45 @@ Salary #{0} for {1} was DE-attested. It will not be paid out unless attested again. When somebody undoes a previous attestation. + + Invoice amount (in {0}) + {0} is the organization's main currency. + + + Description + Free-text description of invoice + + + Invoice Image + + + Payment Details + Displayed as header over supplier's account details + + + This is where you file invoices received at your organization ("Accounts Payable"). Enter the supplier name, amount, due date, the invoice reference, and upload an image of the received invoice. Also, select a budget. The budget owner needs to attest, as usual. (Future roadmapped expansions to this mechanism include purchase orders and supplier lists.) + + + Received Inbound Invoice + + + Invoice reference + + + OCR / Automatic + Some invoices come with OCR numbers printed on them for automatic processing. + + + Manual + Other invoices come without automated processing and a manual + + + Account + Free text input, intended to convey everything needed to get the money right + + + Upload image file + Expense claim amount (in {0}) {0} is the currency. diff --git a/Site5/Controls/v5/Base/FileUpload.ascx.cs b/Site5/Controls/v5/Base/FileUpload.ascx.cs index 011cf332..8ec00c0d 100644 --- a/Site5/Controls/v5/Base/FileUpload.ascx.cs +++ b/Site5/Controls/v5/Base/FileUpload.ascx.cs @@ -29,7 +29,7 @@ namespace Swarmops.Controls.Base } public string GuidString; - public UploadFilter Filter; + public UploadFilter Filter { get; set; } public enum UploadFilter diff --git a/Site5/Images/PageIcons/iconshock-invoice-16px.png b/Site5/Images/PageIcons/iconshock-invoice-16px.png new file mode 100644 index 00000000..052a801e Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-invoice-16px.png differ diff --git a/Site5/Images/PageIcons/iconshock-invoice-40px.png b/Site5/Images/PageIcons/iconshock-invoice-40px.png new file mode 100644 index 00000000..51e6b5fa Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-invoice-40px.png differ diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 4cd22e12..1f12967b 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -165,7 +165,7 @@ - + diff --git a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx new file mode 100644 index 00000000..79123e35 --- /dev/null +++ b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx @@ -0,0 +1,151 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateInboundInvoice.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.CreateInboundInvoice" %> +<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> +<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> + + + + + + + + + + + + + + + +
+ ​
+ ​
+ ​
+ ​
+  
+ "> 
+ +  
+ + + + + + + +  
+  
+ ​
+ +
+ +
+
+ + + + + + diff --git a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs new file mode 100644 index 00000000..e02a4d24 --- /dev/null +++ b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Support; + +namespace Swarmops.Frontend.Pages.v5.Financial +{ + public partial class CreateInboundInvoice : PageV5Base + { + protected void Page_Init(object sender, EventArgs e) + { + string tagSetIdsString = Request["ctl00$PlaceHolderMain$HiddenTagSetIdentifiers"]; + + // Find our tag ids, either from previously hidden var or load from org + + if (String.IsNullOrEmpty(tagSetIdsString)) + { + _tagSetIds = FinancialTransactionTagSets.ForOrganization(this.CurrentOrganization).Identities; + } + else + { + string[] tagSetIdStrings = tagSetIdsString.Split(','); + _tagSetIds = new int[tagSetIdStrings.Length]; + + for (int index = 0; index < tagSetIdStrings.Length; index++) + { + _tagSetIds[index] = Int32.Parse(tagSetIdStrings[index]); + } + } + + // Construct data source + + List dataSource = new List(); + + foreach (int tagSetId in _tagSetIds) + { + TagSetDataSourceItem item = new TagSetDataSourceItem() + { + TagSetId = tagSetId, + TagSetLocalizedName = + FinancialTransactionTagSetType.GetLocalizedName( + FinancialTransactionTagSet.FromIdentity(tagSetId). + FinancialTransactionTagSetTypeId) + }; + dataSource.Add(item); + } + + // Bind data + + this.RepeaterTagLabels.DataSource = dataSource; + this.RepeaterTagDrop.DataSource = dataSource; + this.RepeaterTagDropScript.DataSource = dataSource; + this.RepeaterErrorCheckTags.DataSource = dataSource; + + this.RepeaterTagLabels.DataBind(); + this.RepeaterTagDrop.DataBind(); + this.RepeaterTagDropScript.DataBind(); + this.RepeaterErrorCheckTags.DataBind(); + + // Write set list back to hidden variable + + List tagSetIdStringList = new List(); + + foreach (int tagSetId in _tagSetIds) + { + tagSetIdStringList.Add(tagSetId.ToString(CultureInfo.InvariantCulture)); + } + + this.HiddenTagSetIdentifiers.Value = String.Join(",", tagSetIdStringList.ToArray()); + } + + private int[] _tagSetIds; + + protected void Page_Load(object sender, EventArgs e) + { + if (!this.CurrentOrganization.IsEconomyEnabled) + { + Response.Redirect("/Pages/v5/Financial/EconomyNotEnabled.aspx", true); + return; + } + + this.PageTitle = Resources.Pages.Financial.CreateInboundInvoice_PageTitle; + this.PageIcon = "iconshock-invoice"; + this.InfoBoxLiteral = Resources.Pages.Financial.CreateInboundInvoice_Info; + + if (!Page.IsPostBack) + { + // Prime bank details + + this.TextAmount.Text = 0.ToString("N2"); + this.TextSupplier.Focus(); + this.TextDueDate.Text = DateTime.Today.AddDays(30).ToShortDateString(); // Use current culture + + Localize(); + } + } + + + private void Localize() + { + this.LabelSupplier.Text = Resources.Global.Financial_Supplier; + this.LabelDueDate.Text = Resources.Global.Financial_DueDate; + this.LabelAmount.Text = string.Format(Resources.Pages.Financial.CreateInboundInvoice_Amount, + CurrentOrganization.Currency.Code); + this.LabelPurpose.Text = Resources.Pages.Financial.CreateInboundInvoice_Description; + this.LabelBudget.Text = Resources.Global.Financial_Budget; + this.LabelHeaderBankDetails.Text = Resources.Pages.Financial.CreateInboundInvoice_HeaderPaymentDetails; + this.LabelHeaderImageFiles.Text = Resources.Pages.Financial.CreateInboundInvoice_HeaderInvoiceImage; + this.LabelImageFiles.Text = Resources.Pages.Financial.CreateInboundInvoice_UploadInvoiceImage; + this.LabelReference.Text = Resources.Pages.Financial.CreateInboundInvoice_Reference; + this.LabelAccount.Text = Resources.Pages.Financial.CreateInboundInvoice_SupplierAccount; + + this.LiteralErrorAmount.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationError_Amount; // TODO: Validation errors + this.LiteralErrorPurpose.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationError_Purpose; + this.LiteralErrorBudget.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_Budget; + this.LiteralErrorBankAccount.Text = Resources.Pages.Financial.RequestCashAdvance_ValidationError_BankAccount; + this.LiteralErrorDocuments.Text = Resources.Pages.Financial.FileExpenseClaim_ValidationError_Documents; + + } + + + protected void ButtonCreate_Click(object sender, EventArgs e) // TODO + { + // 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. + + double amount = Double.Parse(this.TextAmount.Text, NumberStyles.Number); + // parses in current culture - intentional + Int64 amountCents = (Int64) amount*100; + + string description = this.TextPurpose.Text; + + DateTime dueDate = DateTime.Parse(this.TextDueDate.Text); + + + FinancialAccount budget = FinancialAccount.FromIdentity(Int32.Parse(this.Request.Form["DropBudgets"])); + + // sanity check + + if (budget.Organization.Identity != CurrentOrganization.Identity) + { + throw new InvalidOperationException("Budget-organization mismatch; won't file expense claim"); + } + + + // 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"); + } + + InboundInvoice invoice = InboundInvoice.Create(CurrentOrganization, dueDate, amountCents, budget, + this.TextSupplier.Text, this.TextAccount.Text, string.Empty, + this.TextReference.Text, CurrentUser); + + foreach (int tagSetId in _tagSetIds) + { + string selectedTagString = + this.Request.Form["DropTags" + tagSetId.ToString(CultureInfo.InvariantCulture)]; + + if (!String.IsNullOrEmpty(selectedTagString)) + { + int selectedTagType = Int32.Parse(selectedTagString); + invoice.FinancialTransaction.CreateTag(FinancialTransactionTagType.FromIdentity(selectedTagType), CurrentUser); + } + } + + documents.SetForeignObjectForAll(invoice); + + // TODO: Clear fields, show success message, return to blank fields + + } + + + protected class TagSetDataSourceItem + { + public int TagSetId { get; set; } + public string TagSetLocalizedName { get; set; } + } + } +} \ No newline at end of file