From 3d894cb416879746a103bd842d75a02d2ccc9dd2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 25 Mar 2015 15:57:28 +0100 Subject: [PATCH] Added localized payout specs --- Logic/Financial/Payout.cs | 94 ++++++ Logic/Logic.csproj | 9 + .../Logic.Financial.Payout.Designer.cs | 288 ++++++++++++++++++ Logic/Resources/Logic.Financial.Payout.resx | 197 ++++++++++++ Logic/Resources/SourceResourceFiles.txt | 1 + Site5/App_GlobalResources/Pages.Ledgers.resx | 6 +- .../v5/Ledgers/BalanceTransactions.aspx.cs | 5 +- 7 files changed, 595 insertions(+), 5 deletions(-) create mode 100644 Logic/Resources/Logic.Financial.Payout.Designer.cs create mode 100644 Logic/Resources/Logic.Financial.Payout.resx diff --git a/Logic/Financial/Payout.cs b/Logic/Financial/Payout.cs index 2c303edd..8cff08f8 100644 --- a/Logic/Financial/Payout.cs +++ b/Logic/Financial/Payout.cs @@ -668,6 +668,100 @@ namespace Swarmops.Logic.Financial Open = false; } + + /// + /// Gets a (localized) specification of what this payout is for. Will return a type and identity or identities. Does not include the recipient name. + /// + public string Specification + { + get + { + if (this.DependentCashAdvancesPayout.Count > 0) + { + if (this.DependentCashAdvancesPayout.Count > 1) + { + return String.Format (Resources.Logic_Financial_Payout.Payout_CashAdvanceIdentities, + Formatting.GenerateRangeString (this.DependentCashAdvancesPayout.Identities)); + } + + return String.Format(Resources.Logic_Financial_Payout.Payout_CashAdvanceIdentity, + this.DependentCashAdvancesPayout [0].Identity); + } + + if (this.DependentExpenseClaims.Count > 0) + { + if (this.DependentExpenseClaims.Count > 1) + { + if (this.DependentCashAdvancesPayback.Count > 0) + { + if (this.DependentCashAdvancesPayback.Count > 1) + { + // multiple expenses, multiple paybacks + + return String.Format(Resources.Logic_Financial_Payout.Payout_ExpenseClaimIdentitiesLessAdvanceIdentities, + Formatting.GenerateRangeString(this.DependentExpenseClaims.Identities), + Formatting.GenerateRangeString(this.DependentCashAdvancesPayback.Identities)); + } + + // multiple expenses, single payback + + return String.Format(Resources.Logic_Financial_Payout.Payout_ExpenseClaimIdentitiesLessAdvanceIdentities, + Formatting.GenerateRangeString(this.DependentExpenseClaims.Identities), + this.DependentCashAdvancesPayback[0].Identity); + } + + // multiple expenses, no payback + + return String.Format (Resources.Logic_Financial_Payout.Payout_ExpenseClaimIdentities, + Formatting.GenerateRangeString (this.DependentExpenseClaims.Identities)); + } + + // single expense, no payback + + return String.Format (Resources.Logic_Financial_Payout.Payout_ExpenseClaimIdentity, + this.DependentExpenseClaims[0].Identity); + } + + if (this.DependentInvoices.Count > 0) + { + if (this.DependentInvoices.Count > 1) + { + return @"NO SUPPORT FOR MULTIPLE INVOICES - FIX IN PAYOUT.SPECIFICATION"; + } + + return String.Format (Resources.Logic_Financial_Payout.Payout_InboundInvoiceIdentity, + this.DependentInvoices[0].Identity); + } + + if (this.DependentSalariesNet.Count > 0) + { + if (this.DependentSalariesNet.Count > 1) + { + return @"NO SUPPORT FOR MULTIPLE NET SALARIES - FIX IN PAYOUT.SPECIFICATION"; + } + + return String.Format (Resources.Logic_Financial_Payout.Payout_SalaryIdentityMonth, + this.DependentSalariesNet[0].Identity, + this.DependentSalariesNet[0].PayoutDate); + } + + if (this.DependentSalariesTax.Count > 0) + { + if (this.DependentSalariesTax.Count > 1) + { + // tax for multiple salaries + + return String.Format (Resources.Logic_Financial_Payout.Payout_SalaryTaxIdentitiesMonth, + Formatting.GenerateRangeString (this.DependentSalariesTax.Identities), + this.DependentSalariesTax[0].PayoutDate); // assumes all salaries on same date + } + } + + return @"UNSUPPORTED CASE - FIX IN PAYOUT.SPECIFICATION"; + + } + } + #region Implementation of ISummable public long SumCents diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index f035f7e1..cd92920f 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -87,6 +87,11 @@ True Logic.Financial.FinancialTransactionTagSetTypesStock.resx + + True + True + Logic.Financial.Payout.resx + True True @@ -487,6 +492,10 @@ + + ResXFileCodeGenerator + Logic.Financial.Payout.Designer.cs + diff --git a/Logic/Resources/Logic.Financial.Payout.Designer.cs b/Logic/Resources/Logic.Financial.Payout.Designer.cs new file mode 100644 index 00000000..75917f40 --- /dev/null +++ b/Logic/Resources/Logic.Financial.Payout.Designer.cs @@ -0,0 +1,288 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Logic_Financial_Payout { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Logic_Financial_Payout() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Financial.Payout", typeof(Logic_Financial_Payout).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Cash Advances {0}. + /// + internal static string Payout_CashAdvanceIdentities { + get { + return ResourceManager.GetString("Payout_CashAdvanceIdentities", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cash Advances {0} for {1}. + /// + internal static string Payout_CashAdvanceIdentitiesRecipient { + get { + return ResourceManager.GetString("Payout_CashAdvanceIdentitiesRecipient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cash Advance #{0}. + /// + internal static string Payout_CashAdvanceIdentity { + get { + return ResourceManager.GetString("Payout_CashAdvanceIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cash Advance #{0:N0} for {1}. + /// + internal static string Payout_CashAdvanceIdentityRecipient { + get { + return ResourceManager.GetString("Payout_CashAdvanceIdentityRecipient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cash Advances {0} Payback. + /// + internal static string Payout_CashAdvancePaybackIdentities { + get { + return ResourceManager.GetString("Payout_CashAdvancePaybackIdentities", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cash Advance #{0:N0} Payback. + /// + internal static string Payout_CashAdvancePaybackIdentity { + get { + return ResourceManager.GetString("Payout_CashAdvancePaybackIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expenses {0}. + /// + internal static string Payout_ExpenseClaimIdentities { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentities", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expenses {0} (minus advances {1}). + /// + internal static string Payout_ExpenseClaimIdentitiesLessAdvanceIdentities { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentitiesLessAdvanceIdentities", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expenses {0} (minus advance #{1:N0}). + /// + internal static string Payout_ExpenseClaimIdentitiesLessAdvanceIdentity { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentitiesLessAdvanceIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense Claims {0} by {1}. + /// + internal static string Payout_ExpenseClaimIdentitiesRecipient { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentitiesRecipient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense #{0:N0}. + /// + internal static string Payout_ExpenseClaimIdentity { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense #{0:N0} (minus advances {1}). + /// + internal static string Payout_ExpenseClaimIdentityLessAdvanceIdentities { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentityLessAdvanceIdentities", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense #{0:N0} (minus advance #{1:N0}). + /// + internal static string Payout_ExpenseClaimIdentityLessAdvanceIdentity { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentityLessAdvanceIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense Claim #{0:N0} by {1}. + /// + internal static string Payout_ExpenseClaimIdentityRecipient { + get { + return ResourceManager.GetString("Payout_ExpenseClaimIdentityRecipient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expense Claim #{0:N0}. + /// + internal static string Payout_ExpenseClaimLongIdentity { + get { + return ResourceManager.GetString("Payout_ExpenseClaimLongIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Inbound Invoice #{0:N0}. + /// + internal static string Payout_InboundInvoiceIdentity { + get { + return ResourceManager.GetString("Payout_InboundInvoiceIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Inbound Invoice #{0:N0} from {1}. + /// + internal static string Payout_InboundInvoiceIdentitySender { + get { + return ResourceManager.GetString("Payout_InboundInvoiceIdentitySender", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salary Taxes for {0:yyyy-MMM}. + /// + internal static string Payout_SalariesTaxMonth { + get { + return ResourceManager.GetString("Payout_SalariesTaxMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salaries {0} for {1:yyyy-MMM}. + /// + internal static string Payout_SalaryIdentitiesMonth { + get { + return ResourceManager.GetString("Payout_SalaryIdentitiesMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salary #{0:N0}. + /// + internal static string Payout_SalaryIdentity { + get { + return ResourceManager.GetString("Payout_SalaryIdentity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salary #{0:N0} for {1:yyyy-MMM}. + /// + internal static string Payout_SalaryIdentityMonth { + get { + return ResourceManager.GetString("Payout_SalaryIdentityMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salary #{0:N0} for {1:yyyy-MMM} for {2}. + /// + internal static string Payout_SalaryIdentityMonthRecipient { + get { + return ResourceManager.GetString("Payout_SalaryIdentityMonthRecipient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Salary for {0:yyyy-MMM}. + /// + internal static string Payout_SalaryMonth { + get { + return ResourceManager.GetString("Payout_SalaryMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Taxes for Salaries {0} for {1:yyyy-MMM}. + /// + internal static string Payout_SalaryTaxIdentitiesMonth { + get { + return ResourceManager.GetString("Payout_SalaryTaxIdentitiesMonth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Taxes for Salary #{0:N0} for {1:yyyy-MMM}. + /// + internal static string Payout_SalaryTaxIdentityMonth { + get { + return ResourceManager.GetString("Payout_SalaryTaxIdentityMonth", resourceCulture); + } + } + } +} diff --git a/Logic/Resources/Logic.Financial.Payout.resx b/Logic/Resources/Logic.Financial.Payout.resx new file mode 100644 index 00000000..60526ff4 --- /dev/null +++ b/Logic/Resources/Logic.Financial.Payout.resx @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cash Advances {0} + + + Cash Advances {0} for {1} + + + Cash Advance #{0} + + + Cash Advance #{0:N0} for {1} + + + Cash Advances {0} Payback + + + Cash Advance #{0:N0} Payback + + + Expenses {0} + + + Expenses {0} (minus advances {1}) + + + Expenses {0} (minus advance #{1:N0}) + + + Expense Claims {0} by {1} + + + Expense #{0:N0} + + + Expense #{0:N0} (minus advances {1}) + + + Expense #{0:N0} (minus advance #{1:N0}) + + + Expense Claim #{0:N0} by {1} + + + Expense Claim #{0:N0} + + + Inbound Invoice #{0:N0} + + + Inbound Invoice #{0:N0} from {1} + + + Salary Taxes for {0:yyyy-MMM} + + + Salaries {0} for {1:yyyy-MMM} + + + Salary #{0:N0} + + + Salary #{0:N0} for {1:yyyy-MMM} + + + Salary #{0:N0} for {1:yyyy-MMM} for {2} + 0 is identity, 1 is month, 2 is name + + + Salary for {0:yyyy-MMM} + The payout date is inserted for date, like "Salary for 2012-Aug". + + + Taxes for Salaries {0} for {1:yyyy-MMM} + + + Taxes for Salary #{0:N0} for {1:yyyy-MMM} + + \ No newline at end of file diff --git a/Logic/Resources/SourceResourceFiles.txt b/Logic/Resources/SourceResourceFiles.txt index 9ecd7b06..858ac117 100644 --- a/Logic/Resources/SourceResourceFiles.txt +++ b/Logic/Resources/SourceResourceFiles.txt @@ -3,6 +3,7 @@ Logic.Communications.Transmission.MailPayload.resx Logic.Communications.Transmission.NotificationPayload.resx Logic.Financial.FinancialAccount.resx Logic.Financial.FinancialTransactionTagSetTypesStock.resx +Logic.Financial.Payout.resx Logic.Swarm.DashboardTodos.resx Logic.Swarm.ParticipantTitle.resx Logic.Swarm.Position.resx diff --git a/Site5/App_GlobalResources/Pages.Ledgers.resx b/Site5/App_GlobalResources/Pages.Ledgers.resx index c923f8ba..9e1def59 100644 --- a/Site5/App_GlobalResources/Pages.Ledgers.resx +++ b/Site5/App_GlobalResources/Pages.Ledgers.resx @@ -728,8 +728,8 @@ Amount Within 10% Tolerance Header in selection list. Capitalize as customary for culture. - - Payout #{0:N0}, expected {1:yyyy-MMM-dd}, for {2}: {3} {4:N2} - 0 is the payout Id, 1 is the date (do culturally edit format if called for), 2 is the recipient name, and 3 4 is the currency and amount + + Payout #{0:N0}, {5} (expected {1:yyyy-MMM-dd}) for {2}: {3} {4:N2} + 0 is the payout Id, 1 is the date (do edit format if called for in culture), 2 is the recipient name, and 3 4 is the currency and amount, 5 is the specification (like "Expense Claim #4711") \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs index dcc943a3..fc1b7470 100644 --- a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs +++ b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs @@ -112,8 +112,9 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { if (payout.AmountCents == -matchAmount) { - string description = String.Format (Resources.Pages.Ledgers.BalanceTransaction_PayoutMatch, payout.Identity, - payout.ExpectedTransactionDate, payout.Recipient, payout.Organization.Currency.DisplayCode, payout.AmountCents / 100.0); + string description = String.Format (Resources.Pages.Ledgers.BalanceTransactions_PayoutMatch, payout.Identity, + payout.ExpectedTransactionDate, payout.Recipient, payout.Organization.Currency.DisplayCode, payout.AmountCents / 100.0, + payout.Specification); result.Add(new DropdownOption {