From 146eeee910bb4efaeb8ddbb5a133d3ea0b2f7b36 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 7 May 2016 06:00:03 +0200 Subject: [PATCH] Added basic OCR readability to pending payouts --- Logic/Financial/Payouts.cs | 19 +- Logic/Support/Formatting.cs | 27 +- Site5/Master-v5.master | 4 + Site5/Pages/v5/Admin/OrgSettings.aspx | 4 +- Site5/Pages/v5/Admin/OrgSettings.aspx.cs | 12 + .../v5/Financial/Json-PayableCosts.aspx.cs | 20 +- .../v5/Financial/Json-PayableCostsOcr.aspx | 1 + .../v5/Financial/Json-PayableCostsOcr.aspx.cs | 126 ++++++++ Site5/Pages/v5/Financial/PayOutMoney.aspx | 284 +++++++++++------- 9 files changed, 351 insertions(+), 146 deletions(-) create mode 100644 Site5/Pages/v5/Financial/Json-PayableCostsOcr.aspx create mode 100644 Site5/Pages/v5/Financial/Json-PayableCostsOcr.aspx.cs diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs index ec1ab3f7..3416afdc 100644 --- a/Logic/Financial/Payouts.cs +++ b/Logic/Financial/Payouts.cs @@ -332,23 +332,8 @@ namespace Swarmops.Logic.Financial { // Add the summarized tax line, too - string referenceString = string.Empty; - - if (identityList.Count == 1) - { - referenceString = "[Loc]Financial_TaxSpecification|" + identityList[0]; - } - else - { - identityList.Sort(); - referenceString = "[Loc]Financial_TaxesSpecification|" + - Formatting.GenerateRangeString (identityList); - } - - - BasicPayout basicPayout = new BasicPayout (0, organization.Identity, "[Loc]Financial_TheTaxMan", - string.Empty, referenceString, - taxTotalCents, payDay, false, DateTime.Now, 0); + BasicPayout basicPayout = new BasicPayout (0, organization.Identity, "[Loc]Financial_TheTaxMan", "SEBG 5050-1055", // HACK: Get tax account from something + organization.TaxPaymentOcr, taxTotalCents, payDay, false, DateTime.Now, 0); Payout payout = Payout.FromBasic (basicPayout); foreach (int salaryId in identityList) diff --git a/Logic/Support/Formatting.cs b/Logic/Support/Formatting.cs index 8872993d..c41c7fbc 100644 --- a/Logic/Support/Formatting.cs +++ b/Logic/Support/Formatting.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Text; using System.Text.RegularExpressions; @@ -167,16 +168,38 @@ namespace Swarmops.Logic.Support } public static string AddLuhnChecksum (string number) + { + return number + GetLuhnChecksum (number); + } + + public static string GetLuhnChecksum (string number) { int sum = 0; for (int i = 0; i < number.Length; i++) { - int temp = (number[i] - '0')*(((number.Length - i)%2) == 1 ? 2 : 1); + int temp = (number[i] - '0') * (((number.Length - i) % 2) == 1 ? 2 : 1); if (temp > 9) temp -= 9; sum += temp; } - return number + ((10 - (sum%10))%10); + return ((10 - (sum % 10)) % 10).ToString(CultureInfo.InvariantCulture); + } + + public static bool CheckLuhnChecksum (string number) + { + number = CleanNumber (number); + + if (number.Length < 2) + { + return false; // requires at least data and checksum + } + + if (!number.EndsWith (GetLuhnChecksum (number.Substring (0, number.Length - 1)))) + { + return false; + } + + return true; } diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index d0802183..039e52fa 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -214,6 +214,10 @@ + + + + diff --git a/Site5/Pages/v5/Admin/OrgSettings.aspx b/Site5/Pages/v5/Admin/OrgSettings.aspx index a759a8e8..e6567690 100644 --- a/Site5/Pages/v5/Admin/OrgSettings.aspx +++ b/Site5/Pages/v5/Admin/OrgSettings.aspx @@ -235,9 +235,9 @@

Regulatory stuff (optional)

- ​
+ ​
​
- ​
+ ​