From 680b749bfb716c8a286e8d5ff237b4e978f4dce2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 15 Sep 2017 18:49:40 +0200 Subject: [PATCH] Work on outbound invoices; inbound invoice list --- Logic/Financial/OutboundInvoice.cs | 8 +- Logic/Swarm/ParleyAttendee.cs | 4 +- Site/App_GlobalResources/Global.designer.cs | 9 + Site/App_GlobalResources/Global.resx | 3 + Site/App_GlobalResources/Menu5.designer.cs | 2 +- Site/App_GlobalResources/Menu5.resx | 2 +- .../Icons/iconshock-empty-tick-128x96px.png | Bin 0 -> 9766 bytes Site/MainMenu-v5.xml | 29 +- .../v5/Admin/Hacks/TemporaryHack.aspx.cs | 4 +- .../v5/Financial/CreateOutboundInvoice.aspx | 10 +- .../Financial/CreateOutboundInvoice.aspx.cs | 32 +- .../CreateOutboundInvoice.aspx.designer.cs | 26 +- .../v5/Financial/ListInvoicesInbound.aspx | 212 +++++++ .../v5/Financial/ListInvoicesInbound.aspx.cs | 600 ++++++++++++++++++ .../ListInvoicesInbound.aspx.designer.cs | 150 +++++ Site/Site.csproj | 9 + 16 files changed, 1035 insertions(+), 65 deletions(-) create mode 100644 Site/Images/Icons/iconshock-empty-tick-128x96px.png create mode 100644 Site/Pages/v5/Financial/ListInvoicesInbound.aspx create mode 100644 Site/Pages/v5/Financial/ListInvoicesInbound.aspx.cs create mode 100644 Site/Pages/v5/Financial/ListInvoicesInbound.aspx.designer.cs diff --git a/Logic/Financial/OutboundInvoice.cs b/Logic/Financial/OutboundInvoice.cs index ee39b092..c3daaaf2 100644 --- a/Logic/Financial/OutboundInvoice.cs +++ b/Logic/Financial/OutboundInvoice.cs @@ -228,9 +228,7 @@ namespace Swarmops.Logic.Financial return result; } - public static OutboundInvoice Create (Organization organization, Person createdByPerson, DateTime dueDate, - FinancialAccount budget, string customerName, string invoiceAddressMail, string invoiceAddressPaper, - Currency currency, bool domestic, string theirReference) + public static OutboundInvoice Create (Organization organization, DateTime dueDate, FinancialAccount budget, string customerName, string invoiceAddressMail, string invoiceAddressPaper, Currency currency, bool domestic, string theirReference, Person createdByPerson) { OutboundInvoice invoice = FromIdentity (SwarmDb.GetDatabaseForWriting() @@ -272,11 +270,11 @@ namespace Swarmops.Logic.Financial public OutboundInvoice Credit (Person creditingPerson) { - OutboundInvoice credit = Create (Organization, creditingPerson, DateTime.Now, + OutboundInvoice credit = Create (Organization, DateTime.Now, Budget, CustomerName, InvoiceAddressMail, InvoiceAddressPaper, Currency, - Domestic, TheirReference); + Domestic, TheirReference, creditingPerson); if (Domestic) // TODO: LANGUAGE { credit.AddItem ("Kredit för faktura " + Reference, -AmountCents); diff --git a/Logic/Swarm/ParleyAttendee.cs b/Logic/Swarm/ParleyAttendee.cs index babcfea9..de0aac51 100644 --- a/Logic/Swarm/ParleyAttendee.cs +++ b/Logic/Swarm/ParleyAttendee.cs @@ -79,11 +79,11 @@ namespace Swarmops.Logic.Swarm invoiceDue = maxInvoiceDue; } - OutboundInvoice invoice = OutboundInvoice.Create (Parley.Organization, Parley.Person, invoiceDue, + OutboundInvoice invoice = OutboundInvoice.Create (Parley.Organization, invoiceDue, Parley.Budget, Person.Name, Person.Mail, string.Empty, Parley.Organization.DefaultCountry.Currency, true, - string.Empty); + string.Empty, Parley.Person); invoice.AddItem ("Deltagarkostnad " + Parley.Name, Parley.AttendanceFeeCents); // TODO: Localize diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index 253c4e09..8b17e99d 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -312,6 +312,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Client / Customer. + /// + internal static string Financial_Client { + get { + return ResourceManager.GetString("Financial_Client", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expenses. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index 512aa333..1f4e80fa 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -909,4 +909,7 @@ Annual Profit/Loss To Date ({0}) {0} is the currency code + + Client / Customer + \ No newline at end of file diff --git a/Site/App_GlobalResources/Menu5.designer.cs b/Site/App_GlobalResources/Menu5.designer.cs index 27a9dae9..cd5a1e94 100644 --- a/Site/App_GlobalResources/Menu5.designer.cs +++ b/Site/App_GlobalResources/Menu5.designer.cs @@ -349,7 +349,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to List. + /// Looks up a localized string similar to List.... /// internal static string Menu5_Financial_List { get { diff --git a/Site/App_GlobalResources/Menu5.resx b/Site/App_GlobalResources/Menu5.resx index b5bacf21..3aeb93d4 100644 --- a/Site/App_GlobalResources/Menu5.resx +++ b/Site/App_GlobalResources/Menu5.resx @@ -193,7 +193,7 @@ Gigs Assistant - List + List... Cash Requests diff --git a/Site/Images/Icons/iconshock-empty-tick-128x96px.png b/Site/Images/Icons/iconshock-empty-tick-128x96px.png new file mode 100644 index 0000000000000000000000000000000000000000..ff6911e7917308d3c487163fab3cd8ffc91e4e5e GIT binary patch literal 9766 zcmWk!2RM~q82@myvbW4`LfK`nj4SJp$hBwJ-r0Na8M0Rta_y{a5|WUFP$=WlwfFWv zeeQUk@A2GozH{F9{f+m;J<(JqCB8)rK@h2`3PJ~bhk~~SAwKw=^!HZ}xKk(-L42L#=u{`ba#a`PF$O#)9<4JCr#L}V~#BCBG_MF?VtR1xyJzO$P_ zelMBzgSL*_n+{~v$G*Kb6i%3`r*rIooKRoK%Si;MF*tn`y9eV-TkQj z>6wCxZ#H#LBp-#-V0~2TmuH6TsG(-M;WXQcs$Vj{CS*E&ro9)~&<+l2zaHN4Yn*wC z`M#c$i!MZ;2X$ZixKh%!U|rge=L3kKbPm-gNMt9rrhV4aG~_0wmui|Y@_q&xtEA@| zGlVZkU;*`9U7nwoUI`d6Z(*qewQ2gbLe3^iZ43QuP|~c|zWiAM?UoEXzS4FM4wBmU zGqwW$R+M+S-oYX05y*fgz}|O-5H#B7f>MYeLxXn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WySv$byS;zrFfE;_!I^$cN=6pEK(bq-3VyT@@`#FsKwF~_EQn?8^!a1B z`%G<93GkUCYiju4|JvFkUeX)R%&=_CjFRx#V*c>ktzVQs9X8`B8Fan4xY)BB0PJ)hS|RU^r>>J9WejT)f{c{MTI!b2A6$J>(nvsZV0Mt-XDLmIQzM zZix*hUshw{>({TLhuG=Y2E5PQ+$f;0Gc$1@64JS}KylE2893pS4LZ-qDWJ4J>*61n zZ?4Aqdc3{hx`_YFCAKAIY?YcK6|`{+y<1I|__G|-*$HvlX^d}Mg3}ghch$d6OhhCn zlevvP-&ef;9z1lwQ0H8X9%F4<`f(y5v71e2*`5*ZoAGrFGE`Ej4J--V*fLbc9 zDgf-*Dk}Dwzc;Cwq~%})4lihJL7@h`dWDU@rD>rIwbBM~PGth%mfm%t$ED2Dq$b|q{trRUy%|a0zpV`1GBZ$o) zI|^RgZ<7PDbY~-S2%f|v;9TIk2Bbu`ve>Gbj6EQC`U|b}BU#zth2`aCi7)xp4^a|y z9gjtSKkitU*n@!@ghHbW56&<1VDfg^)r3|>gZjL5S_O|nuI^OmqQ_DfwVfDcf5y&V zIevzHp<+=H^2J)Kt&E8Tw|Ya`gt%+jXaU+2!4t zq20wIp{CT?LD8cX>k#|>c&ew!!Xp01n2_jwX&K2dMUYGu4sG?k87sm z>D09`M^BP9)kh$%_-Kd)d^_j)wP~_uH#@<<+ccyUNO-KG-q(F?OinmIc8M(+#pXhs zM7|jVRNC4vb-|gT(WTu+!2!MO&WKM|56BOXkFRAg(qReu%kN#2l4Mvo|+GkdQh6PIN)4N}7lo1&i?i E0cDHn^8f$< literal 0 HcmV?d00001 diff --git a/Site/MainMenu-v5.xml b/Site/MainMenu-v5.xml index d5b4720f..7c92713b 100644 --- a/Site/MainMenu-v5.xml +++ b/Site/MainMenu-v5.xml @@ -245,8 +245,35 @@ Separator - + + + Financial_List + 3 + + Disabled + + Financial_List_InboundInvoices + 3 + + + /Pages/v5/Financial/ListInvoicesInbound.aspx + Link + + + + Financial_List_OutboundInvoices + 3 + + + /Pages/v5/Financial/ListInvoicesInbound.aspx + Link + + + + + + Financial_Payroll 3 diff --git a/Site/Pages/v5/Admin/Hacks/TemporaryHack.aspx.cs b/Site/Pages/v5/Admin/Hacks/TemporaryHack.aspx.cs index 8043f192..d949b476 100644 --- a/Site/Pages/v5/Admin/Hacks/TemporaryHack.aspx.cs +++ b/Site/Pages/v5/Admin/Hacks/TemporaryHack.aspx.cs @@ -22,9 +22,9 @@ public partial class Pages_v5_Admin_Hacks_TemporaryHack : Page { // outbound intl invoice. Add an untracked intl invoice 10 days prior, map it to this - OutboundInvoice newInvoice = OutboundInvoice.Create (euroPirates, Person.FromIdentity (1), + OutboundInvoice newInvoice = OutboundInvoice.Create (euroPirates, transaction.DateTime, euroPirates.FinancialAccounts.IncomeSales, "Untracked", - "untracked@example.com", string.Empty, euroPirates.Currency, false, string.Empty); + "untracked@example.com", string.Empty, euroPirates.Currency, false, string.Empty, Person.FromIdentity (1)); newInvoice.AddItem ("Untracked item", transaction.Rows.BalanceCentsDelta); // Doesn't close diff --git a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx index 024c24cc..4aa756f9 100644 --- a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx +++ b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx @@ -39,8 +39,6 @@ function validateFields() { var isValid = true; - isValid = validateTextField('#<%=this.TextAccount.ClientID %>', SwarmopsJS.unescape('<%= this.Localized_ValidationError_Account %>')) && isValid; - if ($('#<%=this.ComboBudgets.ClientID %>_DropBudgets').combotree('tree').tree('getSelected') == null) { isValid = false; $('#<%=this.ComboBudgets.ClientID %>_SpanBudgets').addClass("entryError"); @@ -145,12 +143,12 @@

-
+
- + "> 
@@ -162,12 +160,11 @@
-
diff --git a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.cs b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.cs index ff1d6dce..1a56fd3c 100644 --- a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.cs +++ b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.cs @@ -101,7 +101,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial this.CurrencyAmount.Cents = 0; this.CurrencyVat.Cents = 0; - this.TextSupplier.Focus(); + this.TextClient.Focus(); this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture Localize(); @@ -111,7 +111,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial private void Localize() { - this.LabelSupplier.Text = Global.Financial_Supplier; + this.LabelClient.Text = Global.Financial_Client; this.LabelDueDate.Text = Global.Financial_DueDate; this.LabelAmount.Text = string.Format (Resources.Pages.Financial.CreateInboundInvoice_Amount, CurrentOrganization.Currency.Code); @@ -123,7 +123,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial 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.ButtonCreate.Text = Resources.Pages.Financial.CreateInboundInvoice_ButtonCreate; } @@ -148,7 +147,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial if (budget.Organization.Identity != CurrentOrganization.Identity) { - throw new InvalidOperationException ("Budget-organization mismatch; won't file expense claim"); + throw new InvalidOperationException ("Budget-organization mismatch; won't file invoice"); } @@ -161,25 +160,11 @@ namespace Swarmops.Frontend.Pages.v5.Financial throw new InvalidOperationException ("No documents uploaded"); } - InboundInvoice invoice = InboundInvoice.Create (CurrentOrganization, dueDate, amountCents, amountVatCents, budget, - this.TextSupplier.Text, this.TextPurpose.Text, this.TextAccount.Text, string.Empty, - this.TextReference.Text, CurrentUser); + OutboundInvoice invoice = OutboundInvoice.Create (CurrentOrganization, dueDate, budget, this.TextClient.Text, string.Empty, string.Empty, CurrentOrganization.Currency, false, this.TextReference.Text, CurrentUser); - foreach (int tagSetId in this._tagSetIds) - { - string selectedTagString = - Request.Form["DropTags" + tagSetId.ToString (CultureInfo.InvariantCulture)]; + invoice.AddItem(this.TextPurpose.Text, amountCents); - if (!String.IsNullOrEmpty (selectedTagString)) - { - int selectedTagType = Int32.Parse (selectedTagString); - if (selectedTagType != 0) - { - invoice.FinancialTransaction.CreateTag ( - FinancialTransactionTagType.FromIdentity (selectedTagType), CurrentUser); - } - } - } + // TODO: VAT documents.SetForeignObjectForAll (invoice); @@ -190,8 +175,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial // Reset all fields for next invoice this.FileUpload.Reset(); - this.TextSupplier.Text = String.Empty; - this.TextAccount.Text = String.Empty; + this.TextClient.Text = String.Empty; this.TextPurpose.Text = String.Empty; this.TextReference.Text = String.Empty; this.CurrencyAmount.Cents = 0; @@ -200,7 +184,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial // the easyUI combo fields should reset automatically on form submission unless we explicitly reconstruct - this.TextSupplier.Focus(); + this.TextClient.Focus(); } diff --git a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.designer.cs b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.designer.cs index 897d1842..791334d9 100644 --- a/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.designer.cs +++ b/Site/Pages/v5/Financial/CreateOutboundInvoice.aspx.designer.cs @@ -49,13 +49,13 @@ namespace Swarmops.Frontend.Pages.v5.Financial { protected global::System.Web.UI.WebControls.HiddenField HiddenTagSetIdentifiers; /// - /// TextSupplier control. + /// TextClient control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.TextBox TextSupplier; + protected global::System.Web.UI.WebControls.TextBox TextClient; /// /// CurrencyAmount control. @@ -120,15 +120,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial { /// protected global::Swarmops.Controls.Base.FileUpload FileUpload; - /// - /// TextAccount control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox TextAccount; - /// /// TextReference control. /// @@ -148,13 +139,13 @@ namespace Swarmops.Frontend.Pages.v5.Financial { protected global::System.Web.UI.WebControls.Button ButtonCreate; /// - /// LabelSupplier control. + /// LabelClient control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Label LabelSupplier; + protected global::System.Web.UI.WebControls.Label LabelClient; /// /// LabelAmount control. @@ -237,15 +228,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial { /// protected global::System.Web.UI.WebControls.Label LabelHeaderBankDetails; - /// - /// LabelAccount control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label LabelAccount; - /// /// LabelReference control. /// diff --git a/Site/Pages/v5/Financial/ListInvoicesInbound.aspx b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx new file mode 100644 index 00000000..ee49ab2e --- /dev/null +++ b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx @@ -0,0 +1,212 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.v5.Financial.ListInvoicesInbound" Codebehind="ListInvoicesInbound.aspx.cs" %> +<%@ Register src="~/Controls/v5/Base/ModalDialog.ascx" tagname="ModalDialog" tagprefix="Swarmops5" %> +<%@ Register src="~/Controls/v5/Financial/ComboBudgets.ascx" tagname="ComboBudgets" tagprefix="Swarmops5" %> +<%@ Register src="~/Controls/v5/Financial/CurrencyTextBox.ascx" tagname="CurrencyTextBox" tagprefix="Swarmops5" %> + + + + + + + + + + + + +

+ + + + + + + + + + + + + + +
+ + +
+ + + diff --git a/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.cs b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.cs new file mode 100644 index 00000000..f9e02c0f --- /dev/null +++ b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.cs @@ -0,0 +1,600 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Security; +using System.Threading; +using System.Web; +using System.Web.Services; +using System.Web.UI; +using Resources; +using Swarmops.Common.Enums; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Support; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Frontend.Pages.v5.Financial +{ + public partial class ListInvoicesInbound : PageV5Base + { + private Dictionary _attestationRights; + private List _documentList; + + protected void Page_Load (object sender, EventArgs e) + { + if (!CurrentOrganization.IsEconomyEnabled) + { + Response.Redirect ("/Pages/v5/Financial/EconomyNotEnabled.aspx", true); + return; + } + + PageIcon = "iconshock-stamped-paper"; + + PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Participant, AccessType.Read); // No specific access aspect for owning a budget (yet?) + + if (!Page.IsPostBack) + { + Localize(); + } + + // this.TextDenyReason.Style [HtmlTextWriterStyle.FontSize] = "60% !important"; + + this._attestationRights = GetAttestationRights(); + this._documentList = new List(); + this.LiteralCanOverdraftBudgets.Text = + CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.Administration)).ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); + + PopulateInboundInvoices(); + PopulateExpenses(); + // PopulateSalaries(); + + RegisterControl(EasyUIControl.DataGrid); + + this.RepeaterLightboxItems.DataSource = this._documentList; + this.RepeaterLightboxItems.DataBind(); + } + + + static private Dictionary GetAttestationRights() + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + // Right now, this function is quite primitive. At some point in the future, it needs to take into + // account that a budget may have several attesters. Right now, it just loops over all accounts and + // checks the owner. + + Dictionary result = new Dictionary(); + FinancialAccounts accounts = FinancialAccounts.ForOrganization(authData.CurrentOrganization); + + foreach (FinancialAccount account in accounts) + { + if (account.OwnerPersonId == authData.CurrentUser.Identity || + (account.OwnerPersonId == 0 && authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Administration)))) + { + if (account.AccountType == FinancialAccountType.Cost) + { + result[account.Identity] = true; + } + } + } + + return result; + } + + [WebMethod] + public static int[] GetUninitializedBudgets() + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + // This function finds the exceptional accounts that aren't initialized, to let a sysadmin approve expenses to them. + + List result = new List(); + FinancialAccounts accounts = FinancialAccounts.ForOrganization(authData.CurrentOrganization); + + foreach (FinancialAccount account in accounts) + { + if (account.AccountType == FinancialAccountType.Cost) + { + if (account.OwnerPersonId == 0 && + authData.Authority.HasAccess (new Access (authData.CurrentOrganization, + AccessAspect.Administration))) + { + result.Add (account.Identity); + } + } + } + + return result.ToArray(); + } + + private void Localize() + { + PageTitle = Resources.Pages.Financial.AttestCosts_PageTitle; + InfoBoxLiteral = Resources.Pages.Financial.AttestCosts_Info; + this.LabelAttestCostsHeader.Text = Resources.Pages.Financial.AttestCosts_Header_CostsAwaitingAttestation; + //this.LabelGridHeaderAction.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Action; + this.LabelGridHeaderBeneficiary.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Beneficiary; + this.LabelGridHeaderBudget.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Budget; + this.LabelGridHeaderDescription.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Description; + this.LabelGridHeaderDocs.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Docs; + this.LabelGridHeaderItem.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Item; + this.LabelGridHeaderRequested.Text = Resources.Pages.Financial.AttestCosts_GridHeader_Requested; + + /* this.LiteralErrorInsufficientBudget.Text = JavascriptEscape (Resources.Pages.Financial.AttestCosts_OutOfBudget); + this.LiteralWarnUnintializedBudget.Text = + JavascriptEscape (Resources.Pages.Financial.AttestCosts_Warn_UninitializedBudget);*/ +/* + this.LabelDescribeDeny.Text = Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionDeny; + this.LabelDescribeCorrect.Text = String.Format (Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionAmount, CurrentOrganization.Currency.DisplayCode); + this.LabelDescribeRebudget.Text = Resources.Pages.Financial.AttestCosts_Modal_DescribeOptionRebudget; + + this.LabelRadioCorrect.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionAmount; + this.LabelRadioDeny.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionDeny; + this.LabelRadioRebudget.Text = Resources.Pages.Financial.AttestCosts_Modal_RadioOptionRebudget;*/ + + this.LiteralButtonCorrect.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_Modal_ButtonAmount); + this.LiteralButtonDeny.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_Modal_ButtonDeny); + this.LiteralButtonRebudget.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_Modal_ButtonRebudget); + + /* this.LabelModalDenyHeader.Text = Resources.Pages.Financial.AttestCosts_Modal_Header; + this.LabelWhatProblem.Text = Resources.Pages.Financial.AttestCosts_Modal_WhatIsProblem; + + this.LiteralPleaseSelectBudget.Text = JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_PleaseSelectBudget); + this.LiteralCannotRebudgetSalary.Text = + JavascriptEscape (Resources.Pages.Financial.AttestCosts_Error_CantRebudgetSalary); + + this.LiteralConfirmOverdraftNo.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmNo); + this.LiteralConfirmOverdraftYes.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirmYes); + this.LiteralConfirmOverdraft.Text = JavascriptEscape(Resources.Pages.Financial.AttestCosts_OverdraftConfirm);*/ + } + + static protected IPayable PayableFromRecordId (string recordId) + { + char recordType = recordId[0]; + int itemId = Int32.Parse(recordId.Substring(1)); + + switch (recordType) + { + case 'E': // Expense claim + return ExpenseClaim.FromIdentity (itemId); + case 'A': // Cash advance + return CashAdvance.FromIdentity(itemId); + case 'I': // Inbound invoice + return InboundInvoice.FromIdentity (itemId); + default: + throw new NotImplementedException("Unknown record type"); + } + } + + + [WebMethod] + public static AjaxCallResult 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 && + budget.OwnerPersonId != Person.NobodyId)) + { + throw new UnauthorizedAccessException(); + } + + if (String.IsNullOrEmpty (reason.Trim())) + { + reason = Resources.Global.Global_NoReasonGiven; + } + + payable.DenyAttestation (authData.CurrentUser, reason); + + return new AjaxCallResult { Success = true }; + } + + + [WebMethod] + public static void RebudgetItem (string recordId, int newAccountId) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + IPayable payable = PayableFromRecordId (recordId); + FinancialAccount newAccount = FinancialAccount.FromIdentity(newAccountId); + + if (payable.Budget.OrganizationId != authData.CurrentOrganization.Identity || + payable.Budget.OwnerPersonId != authData.CurrentUser.Identity || + newAccount.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new UnauthorizedAccessException(); + } + + payable.SetBudget (newAccount, authData.CurrentUser); + } + + [WebMethod] + public static AjaxCallResult AttestCorrectedItem(string recordId, string amountString) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + double amount = 0.0; + + try + { + amount = Double.Parse (amountString, NumberStyles.Currency, Thread.CurrentThread.CurrentCulture); + } + catch (Exception) + { + return new AjaxCallResult + { + Success = false, + DisplayMessage = String.Format(Resources.Global.Error_CurrencyParsing, 1000.00) + }; + } + + Int64 amountCents = (Int64) (amount*100); + + if (amountCents < 0) + { + return new AjaxCallResult + { + Success = false, + DisplayMessage = Resources.Pages.Financial.AttestCosts_CannotAttestNegative + }; + } + + if (amountCents == 0) + { + return new AjaxCallResult + { + Success = false, + DisplayMessage = Resources.Pages.Financial.AttestCosts_CannotAttestZero + }; + } + + IPayable payable = PayableFromRecordId (recordId); + FinancialAccount budget = payable.Budget; + + if (budget.OrganizationId != authData.CurrentOrganization.Identity || + budget.OwnerPersonId != authData.CurrentUser.Identity) + { + throw new UnauthorizedAccessException(); + } + + Int64 centsRemaining = budget.GetBudgetCentsRemaining(); + + if (centsRemaining/100.0 < amount) + { + // TODO: Handle the special case where the IPayable is not on current year, so against another (last) year's budget + + string notEnoughFunds; + + if (centsRemaining > 0) + { + notEnoughFunds = String.Format (Resources.Pages.Financial.AttestCosts_OutOfBudgetPrecise, + authData.CurrentOrganization.Currency.DisplayCode, centsRemaining/100.0, DateTime.UtcNow.Year); + } + else + { + notEnoughFunds = String.Format (Resources.Pages.Financial.AttestCosts_BudgetIsEmpty, + DateTime.UtcNow.Year); + } + + return new AjaxCallResult + { + Success = false, + DisplayMessage = notEnoughFunds + }; + } + + payable.SetAmountCents (amountCents, authData.CurrentUser); + payable.Attest (authData.CurrentUser); + + return new AjaxCallResult + { + Success = true + }; + } + + + + [WebMethod] + public static BudgetRemainder[] GetRemainingBudgets() + { + Dictionary accountLookup = GetAttestationRights(); + + if (accountLookup.Count == 0) + { + return new BudgetRemainder[0]; + } + + Organization organization = FinancialAccount.FromIdentity (accountLookup.Keys.First()).Organization; + + List result = new List(); + int currentYear = DateTime.UtcNow.Year; + + foreach (int accountId in accountLookup.Keys) + { + FinancialAccount account = FinancialAccount.FromIdentity (accountId); + Int64 remaining = account.GetBudgetCentsRemaining (currentYear); + + result.Add (new BudgetRemainder { AccountId = accountId, Remaining = remaining/100.0 }); + } + + return result.ToArray(); + } + + + public class BudgetRemainder + { + public int AccountId { get; set; } + public double Remaining { get; set; } + } + + + + [WebMethod] + public static AjaxCallResult Attest (string identifier) + { + identifier = HttpUtility.UrlDecode (identifier); + + return HandleAttestationDeattestation (identifier, AttestationMode.Attestation); + } + + [WebMethod] + public static AjaxCallResult Deattest (string identifier) + { + identifier = HttpUtility.UrlDecode (identifier); + + return HandleAttestationDeattestation (identifier, AttestationMode.Deattestation); + } + + + private static AjaxCallResult HandleAttestationDeattestation (string identifier, AttestationMode mode) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + IAttestable attestableItem; + string attestedTemplate; + string deattestedTemplate; + + char costType = identifier[0]; + int itemId = Int32.Parse (identifier.Substring (1)); + Int64 amountCents; + string beneficiary; + string result; + + // Find the item we are attesting or deattesting + + switch (costType) + { + case 'A': // Case advance + CashAdvance advance = CashAdvance.FromIdentity (itemId); + if (advance.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new InvalidOperationException ("Called to attest out-of-org line item"); + } + if (advance.Budget.OwnerPersonId != authData.CurrentUser.Identity && + advance.Budget.OwnerPersonId != Person.NobodyId) + { + throw new SecurityException ("Called without attestation privileges"); + } + + attestableItem = advance; + attestedTemplate = Resources.Pages.Financial.AttestCosts_AdvanceAttested; + deattestedTemplate = Resources.Pages.Financial.AttestCosts_AdvanceDeattested; + beneficiary = advance.Person.Name; + amountCents = advance.AmountCents; + + break; + case 'E': // Expense claim + ExpenseClaim expense = ExpenseClaim.FromIdentity (itemId); + if (expense.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new InvalidOperationException ("Called to attest out-of-org line item"); + } + if (expense.Budget.OwnerPersonId != authData.CurrentUser.Identity && + expense.Budget.OwnerPersonId != Person.NobodyId) + { + throw new SecurityException ("Called without attestation privileges"); + } + + attestableItem = expense; + attestedTemplate = Resources.Pages.Financial.AttestCosts_ExpenseAttested; + deattestedTemplate = Resources.Pages.Financial.AttestCosts_ExpenseDeattested; + beneficiary = expense.Claimer.Name; + amountCents = expense.AmountCents; + + break; + case 'I': // Inbound invoice + InboundInvoice invoice = InboundInvoice.FromIdentity (itemId); + if (invoice.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new InvalidOperationException ("Called to attest out-of-org line item"); + } + if (invoice.Budget.OwnerPersonId != authData.CurrentUser.Identity && + invoice.Budget.OwnerPersonId != Person.NobodyId) + { + throw new SecurityException ("Called without attestation privileges"); + } + + attestableItem = invoice; + attestedTemplate = Resources.Pages.Financial.AttestCosts_InvoiceAttested; + deattestedTemplate = Resources.Pages.Financial.AttestCosts_InvoiceDeattested; + beneficiary = invoice.Supplier; + amountCents = invoice.AmountCents; + + break; + case 'S': // Salary payout + Salary salary = Salary.FromIdentity (itemId); + if (salary.PayrollItem.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new InvalidOperationException ("Called to attest out-of-org line item"); + } + if (salary.PayrollItem.Budget.OwnerPersonId != authData.CurrentUser.Identity && + salary.PayrollItem.Budget.OwnerPersonId != Person.NobodyId) + { + throw new SecurityException ("Called without attestation privileges"); + } + + attestableItem = salary; + attestedTemplate = Resources.Pages.Financial.AttestCosts_SalaryAttested; + deattestedTemplate = Resources.Pages.Financial.AttestCosts_SalaryDeattested; + beneficiary = salary.PayrollItem.PersonCanonical; + amountCents = salary.GrossSalaryCents + salary.AdditiveTaxCents; + + break; + case 'P': // Parley, aka Conference + Parley parley = Parley.FromIdentity (itemId); + if (parley.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new InvalidOperationException ("Called to attest out-of-org line item"); + } + if (parley.Budget.OwnerPersonId != authData.CurrentUser.Identity && + parley.Budget.OwnerPersonId != Person.NobodyId) + { + throw new SecurityException ("Called without attestation privileges"); + } + + attestableItem = parley; + attestedTemplate = Resources.Pages.Financial.AttestCosts_ParleyAttested; + deattestedTemplate = Resources.Pages.Financial.AttestCosts_ParleyDeattested; + beneficiary = parley.Person.Name; + amountCents = parley.BudgetCents; + + break; + default: + throw new InvalidOperationException ("Unknown Cost Type in HandleAttestationDeattestation: \"" + + identifier + "\""); + } + + // Finally, attest or deattest + + if (mode == AttestationMode.Attestation) + { + Int64 budgetRemaining = attestableItem.Budget.GetBudgetCentsRemaining(); + + result = string.Empty; + + if (amountCents > -budgetRemaining) + { + if ( + authData.Authority.HasAccess (new Access (authData.CurrentOrganization, + AccessAspect.Administration))) + { + // Admin rights, so allow (forced) overdraft + + // Unless budget was nonzero and allocated, set protest message + + if (attestableItem.Budget.Owner != null || attestableItem.Budget.GetBudgetCents() != 0) + + result = Resources.Pages.Financial.AttestCosts_Overdrafted + " "; + } + else + { + // Do not allow overdraft + + return new AjaxCallResult + { + DisplayMessage = Resources.Pages.Financial.AttestCosts_OutOfBudget, + Success = false + }; + } + } + + attestableItem.Attest (authData.CurrentUser); + result += string.Format (attestedTemplate, itemId, beneficiary, + authData.CurrentOrganization.Currency.Code, + amountCents/100.0); + } + else if (mode == AttestationMode.Deattestation) + { + attestableItem.Deattest (authData.CurrentUser); + result = string.Format (deattestedTemplate, itemId, beneficiary, + authData.CurrentOrganization.Currency.Code, + amountCents/100.0); + } + else + { + throw new InvalidOperationException ("Unknown Attestation Mode: " + mode); + } + + FinancialAccount.ClearAttestationAdjustmentsCache (authData.CurrentOrganization); + + return new AjaxCallResult {DisplayMessage = result, Success = true}; + } + + + private void PopulateExpenses() + { + ExpenseClaims expenses = ExpenseClaims.ForOrganization (CurrentOrganization).WhereUnattested; + + foreach (ExpenseClaim expenseClaim in expenses) + { + if (this._attestationRights.ContainsKey (expenseClaim.BudgetId) || + expenseClaim.Budget.OwnerPersonId == Person.NobodyId) + { + AddDocuments (expenseClaim.Documents, + "E" + expenseClaim.Identity.ToString (CultureInfo.InvariantCulture), + String.Format (Global.Financial_ExpenseClaimSpecificationWithClaimer + " - ", + expenseClaim.Identity, expenseClaim.ClaimerCanonical) + + Global.Financial_ReceiptSpecification); + } + } + } + + + private void PopulateInboundInvoices() + { + InboundInvoices invoices = InboundInvoices.ForOrganization (CurrentOrganization).WhereUnattested; + + foreach (InboundInvoice invoice in invoices) + { + Documents dox = invoice.Documents; + bool hasDox = (dox.Count > 0 ? true : false); + + if (this._attestationRights.ContainsKey (invoice.BudgetId) || + invoice.Budget.OwnerPersonId == Person.NobodyId) + { + AddDocuments (invoice.Documents, "I" + invoice.Identity.ToString (CultureInfo.InvariantCulture), + String.Format (Global.Financial_InboundInvoiceSpecificationWithSender + " - ", + invoice.Identity, invoice.Supplier) + Global.Global_ImageSpecification); + } + } + } + + + private void AddDocuments (Documents docs, string baseId, string titleBase) + { + int countTotal = docs.Count; + int count = 0; + + foreach (Document document in docs) + { + RepeatedDocument newDoc = new RepeatedDocument + { + DocId = document.Identity, + BaseId = baseId, + Title = String.Format (titleBase, ++count, countTotal) + }; + + this._documentList.Add (newDoc); + } + } + + private enum AttestationMode + { + Unknown = 0, + Attestation, + Deattestation + }; + + public class RepeatedDocument + { + public int DocId { get; set; } + public string BaseId { get; set; } + public string Title { get; set; } + } + + + } +} \ No newline at end of file diff --git a/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.designer.cs b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.designer.cs new file mode 100644 index 00000000..4dd838b1 --- /dev/null +++ b/Site/Pages/v5/Financial/ListInvoicesInbound.aspx.designer.cs @@ -0,0 +1,150 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Frontend.Pages.v5.Financial { + + + public partial class ListInvoicesInbound { + + /// + /// LiteralCanOverdraftBudgets control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralCanOverdraftBudgets; + + /// + /// LiteralButtonRebudget control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralButtonRebudget; + + /// + /// LiteralButtonDeny control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralButtonDeny; + + /// + /// LiteralButtonCorrect control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal LiteralButtonCorrect; + + /// + /// LabelAttestCostsHeader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelAttestCostsHeader; + + /// + /// LabelGridHeaderItem control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderItem; + + /// + /// LabelDueDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelDueDate; + + /// + /// LabelGridHeaderBeneficiary control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderBeneficiary; + + /// + /// LabelGridHeaderDescription control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderDescription; + + /// + /// LabelGridHeaderBudget control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderBudget; + + /// + /// LabelGridHeaderRequested control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderRequested; + + /// + /// LabelGridHeaderDocs control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderDocs; + + /// + /// LabelGridHeaderProgress control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelGridHeaderProgress; + + /// + /// Label1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label1; + + /// + /// RepeaterLightboxItems control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Repeater RepeaterLightboxItems; + } +} diff --git a/Site/Site.csproj b/Site/Site.csproj index c4493e6c..81b21afe 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -194,6 +194,13 @@ SendMassMessage.aspx + + ListInvoicesInbound.aspx + ASPXCodeBehind + + + ListInvoicesInbound.aspx + AttestCosts.aspx ASPXCodeBehind @@ -819,6 +826,7 @@ + @@ -1028,6 +1036,7 @@ +