From 3fa7e933f361b1a81999e88f260f058b949610d7 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 29 Jan 2019 19:30:16 +0100 Subject: [PATCH] Work on Payment History --- Site/App_GlobalResources/Global.designer.cs | 72 +++++++++++++++++++ Site/App_GlobalResources/Global.resx | 31 ++++++++ ...son-MasterPersonEditPaymentHistory.aspx.cs | 56 +++++++++++++-- Site/Style/style-v5.css | 18 +++++ 4 files changed, 171 insertions(+), 6 deletions(-) diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index 3ba5f490..047e20b4 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -186,6 +186,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to All Balances Are Settled. + /// + internal static string Financial_AllBalancesSettled { + get { + return ResourceManager.GetString("Financial_AllBalancesSettled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Amount. /// @@ -393,6 +402,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Current Balance. + /// + internal static string Financial_CurrentBalance { + get { + return ResourceManager.GetString("Financial_CurrentBalance", resourceCulture); + } + } + /// /// Looks up a localized string similar to Liabilities. /// @@ -663,6 +681,24 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Person Is Owed. + /// + internal static string Financial_PersonIsOwed { + get { + return ResourceManager.GetString("Financial_PersonIsOwed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Person Owes Amount. + /// + internal static string Financial_PersonOwes { + get { + return ResourceManager.GetString("Financial_PersonOwes", resourceCulture); + } + } + /// /// Looks up a localized string similar to Annual Profit/Loss To Date ({0}). /// @@ -816,6 +852,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Unconfirmed Payout. + /// + internal static string Financial_UnconfirmedPayout { + get { + return ResourceManager.GetString("Financial_UnconfirmedPayout", resourceCulture); + } + } + /// /// Looks up a localized string similar to Yearly result. /// @@ -825,6 +870,24 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to {0} Owes You. + /// + internal static string Financial_YouAreOwed { + get { + return ResourceManager.GetString("Financial_YouAreOwed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You Owe This Amount. + /// + internal static string Financial_YouOwe { + get { + return ResourceManager.GetString("Financial_YouOwe", resourceCulture); + } + } + /// /// Looks up a localized string similar to YTD. /// @@ -834,6 +897,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Zero. + /// + internal static string Financial_Zero { + get { + return ResourceManager.GetString("Financial_Zero", resourceCulture); + } + } + /// /// Looks up a localized string similar to Two-factor authentication. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index 944a3fb9..14b166b3 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -1011,6 +1011,13 @@ EBITDA Earnings before Interest, Taxes, Depreciation, and Amortization - a financial term + + All Balances Are Settled + Nobody owes anybody anything + + + Current Balance + Payment #{0:N0} A Payment (as opposed to payout) is money entering the organization @@ -1019,4 +1026,28 @@ Payout #{0:N0} A Pay-OUT is always money leaving the organization + + Person Is Owed + This is the amount the organization owes to a person, like after filing expense claims. + + + Person Owes Amount + This is the amount a person owes to the organization, like after a cash advance. + + + Unconfirmed Payout + This is a payout that's not yet been seen in a Connected Account, like a bank account + + + {0} Owes You + The {0} is the organization name + + + You Owe This Amount + Like Person Owes, but directed at the user at the screen + + + Zero + This is used when a debt is zero; there is no debt to settle + \ No newline at end of file diff --git a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs index 2932112d..c9d68f2c 100644 --- a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs +++ b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Resources; using System.Text; using System.Web; using System.Web.UI; @@ -48,8 +49,8 @@ namespace Swarmops.Frontend.Automation list.Sort(LineItemSorterByDate); Response.ContentType = "application/json"; - Response.Output.WriteLine("{\"rows\": " + JsonWriteItems(list) + ", \"footer\": [" + - JsonWriteFooter(list) + "]}"); + Response.Output.WriteLine("{\"rows\": " + JsonWriteItems(list) + ", \"footer\": [{" + + JsonWriteFooter(list) + "}]}"); Response.End(); @@ -148,7 +149,7 @@ namespace Swarmops.Frontend.Automation { if (payout.Open) { - continue; // do not list unconfirmed payouts + _payoutDescriptionOverride[payout.Identity] = Resources.Global.Financial_UnconfirmedPayout; } PaymentHistoryLineItem newItem = new PaymentHistoryLineItem(); @@ -166,7 +167,7 @@ namespace Swarmops.Frontend.Automation newItem.OpenedDate = payout.CreatedDateTime; FinancialTransaction closeTx = payout.FinancialTransaction; - if (closeTx != null) // it damn well should not be null since Open is false + if (closeTx != null) { newItem.ClosedDate = closeTx.DateTime; } @@ -186,7 +187,7 @@ namespace Swarmops.Frontend.Automation { result.Append("{"); result.AppendFormat( - "\"id\":\"{0}\",\"name\":\"{1}\",\"description\":\"{2}\",\"opened\":\"{3}\",\"owedToPerson\":\"{4}\",\"paidToPerson\":\"{5}\",\"closed\":\"{6}\"", + "\"id\":\"{0}\",\"name\":\"{1}\",\"description\":\"{2}\",\"opened\":\"{3}\",\"owedToPerson\":\"{4}\",\"paidToPerson\":\"{5}\",\"closed\":\"{6}\"", JsonSanitize(item.Id), JsonSanitize(item.Name), JsonSanitize(item.Description), @@ -208,7 +209,50 @@ namespace Swarmops.Frontend.Automation public string JsonWriteFooter(List items) { - return string.Empty; + Int64 currentBalance = 0; + + foreach (PaymentHistoryLineItem item in items) + { + currentBalance += item.OwedToPerson; + currentBalance -= item.PaidToPerson; + } + + string summary = string.Empty; + if (_person.Identity == _authenticationData.CurrentUser.Identity) + { + if (currentBalance > 0) + { + summary = Resources.Global.Financial_YouAreOwed; + } + else + { + summary = Resources.Global.Financial_YouOwe; + } + } + else + { + if (currentBalance > 0) + { + summary = Resources.Global.Financial_PersonIsOwed; + } + else + { + summary = Resources.Global.Financial_PersonOwes; + } + } + + if (currentBalance == 0) + { + summary = Resources.Global.Financial_AllBalancesSettled; + } + + return String.Format( + "\"id\":\"Footer\",\"name\":\"{0}\",\"description\":\"{1}\",\"owedToPerson\":\"{2}\",\"paidToPerson\":\"{3}\"", + JsonSanitize(Resources.Global.Financial_CurrentBalance), + JsonSanitize(summary), + currentBalance == 0 ? Resources.Global.Financial_Zero : currentBalance > 0 ? (currentBalance / 100.0).ToString("N2") : string.Empty, + currentBalance == 0 ? Resources.Global.Financial_Zero : currentBalance < 0 ? (currentBalance / -100.0).ToString("N2") : string.Empty + ); } public static int LineItemSorterByDate(PaymentHistoryLineItem a, PaymentHistoryLineItem b) diff --git a/Site/Style/style-v5.css b/Site/Style/style-v5.css index fcc6c6dd..0a6f2e05 100644 --- a/Site/Style/style-v5.css +++ b/Site/Style/style-v5.css @@ -1439,7 +1439,25 @@ span.spanGrayedOut { opacity: .5; } +span.light { + font-weight: 300; +} +span.regular-weight { + font-weight: 400; +} + +span.medium { + font-weight: 500; +} + +span.strong { + font-weight: 700; +} + +span.uppercase { + text-transform: uppercase; +} /* COLOR SCHEME