From b29abaf653575d206de70ce9cebf441801b7d293 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 23 Apr 2018 19:32:05 +0200 Subject: [PATCH] Resuming work on nonpres currency import --- Logic/Financial/ExternalBankData.cs | 2 +- Logic/Financial/ExternalBankDataProfile.cs | 30 +++++++-- .../FinancialAccountAutomationProfile.cs | 62 +++++++++++++++++++ Logic/Financial/StockBankDataReaders.cs | 4 +- Logic/Logic.csproj | 1 + Site/Pages/v5/Ledgers/AccountPlan.aspx | 11 ++-- Site/Pages/v5/Ledgers/AccountPlan.aspx.cs | 28 +++++++-- .../v5/Ledgers/AccountPlan.aspx.designer.cs | 9 --- 8 files changed, 121 insertions(+), 26 deletions(-) create mode 100644 Logic/Financial/FinancialAccountAutomationProfile.cs diff --git a/Logic/Financial/ExternalBankData.cs b/Logic/Financial/ExternalBankData.cs index 17542a80..78c43d90 100644 --- a/Logic/Financial/ExternalBankData.cs +++ b/Logic/Financial/ExternalBankData.cs @@ -38,7 +38,7 @@ namespace Swarmops.Logic.Financial throw new InvalidOperationException ("Cannot call LoadData before a profile has been set"); } - if (Profile.BankDataAccountReader != StockBankDataReaders.TabSeparatedValuesAccountReader) + if (Profile.BankDataAccountReader != StockBankDataReaders.CommaSeparatedValuesAccountReader) { throw new NotImplementedException ("Only tab separated values are supported at this point"); } diff --git a/Logic/Financial/ExternalBankDataProfile.cs b/Logic/Financial/ExternalBankDataProfile.cs index c286f178..03c74d04 100644 --- a/Logic/Financial/ExternalBankDataProfile.cs +++ b/Logic/Financial/ExternalBankDataProfile.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; +using Swarmops.Common.Interfaces; using Swarmops.Logic.Structure; namespace Swarmops.Logic.Financial { - public class ExternalBankDataProfile + public class ExternalBankDataProfile: IHasIdentity { public FeeSignage FeeSignage; public LatestTransactionLocation LatestTransactionLocation; @@ -50,6 +51,11 @@ namespace Swarmops.Logic.Financial get { return 3; } } + public static int CZFioId + { + get { return 4; } + } + public string Name { get; set; } public Country Country { get; set; } public string Culture { get; set; } @@ -58,12 +64,15 @@ namespace Swarmops.Logic.Financial public string BankDataPaymentsReader { get; set; } public int IgnoreInitialLines { get; set; } public string InitialReplacements { get; set; } + public int ExternalBankDataProfileId { get; set; } + public int Identity { get { return ExternalBankDataProfileId; } } public Dictionary FieldNames { get; private set; } public static ExternalBankDataProfile FromIdentity (int externalBankDataProfileId) { ExternalBankDataProfile result = new ExternalBankDataProfile(); + result.ExternalBankDataProfileId = externalBankDataProfileId; // Ugly hack for now @@ -83,7 +92,7 @@ namespace Swarmops.Logic.Financial result.FeeSignage = FeeSignage.Unknown; // no inline fees result.Precision = ExternalBankDateTimePrecision.Day; - result.BankDataAccountReader = StockBankDataReaders.TabSeparatedValuesAccountReader; + result.BankDataAccountReader = StockBankDataReaders.CommaSeparatedValuesAccountReader; result.BankDataPaymentsReader = StockBankDataReaders.SEPaymentsBankgiroReader; return result; @@ -110,7 +119,7 @@ namespace Swarmops.Logic.Financial result.FeeSignage = FeeSignage.Negative; result.Precision = ExternalBankDateTimePrecision.Second; - result.BankDataAccountReader = StockBankDataReaders.TabSeparatedValuesAccountReader; + result.BankDataAccountReader = StockBankDataReaders.CommaSeparatedValuesAccountReader; result.BankDataPaymentsReader = null; // No aggregated payments with Paypal return result; @@ -134,12 +143,23 @@ namespace Swarmops.Logic.Financial result.FeeSignage = FeeSignage.Unknown; // no inline fees result.Precision = ExternalBankDateTimePrecision.Day; - result.BankDataAccountReader = StockBankDataReaders.TabSeparatedValuesAccountReader; - result.BankDataPaymentsReader = null; // No aggregated payments with Paypal + result.BankDataAccountReader = StockBankDataReaders.CommaSeparatedValuesAccountReader; + result.BankDataPaymentsReader = null; // No aggregated payments with Postbank return result; } + if (externalBankDataProfileId == CZFioId) + { + // Czech Fio Bank + + result.Name = "CZ Fio"; + result.Country = Structure.Country.FromCode("CZ"); + result.Culture = "cz-CZ"; + + result.FieldNames[ExternalBankDataFieldName.Date] = "...Continue here..."; + } + throw new ArgumentException ("Unrecognized profile Id"); } } diff --git a/Logic/Financial/FinancialAccountAutomationProfile.cs b/Logic/Financial/FinancialAccountAutomationProfile.cs new file mode 100644 index 00000000..83c6f5ab --- /dev/null +++ b/Logic/Financial/FinancialAccountAutomationProfile.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; +using Newtonsoft.Json; +using Swarmops.Common.Interfaces; +using Swarmops.Logic.Structure; + +namespace Swarmops.Logic.Financial +{ + [Serializable] + public class FinancialAccountAutomationProfile: IHasIdentity + { + public int FinancialAccountAutomationProfileId { get; set; } + public string Name { get; set; } + public bool CanRetrieve { get; set; } + + [XmlIgnore] + public Country Country + { + get { return CountryId != 0? Country.FromIdentity(CountryId): null; } + set { this.CountryId = (value == null? 0: value.Identity); } + } + + [XmlIgnore] + public Currency Currency + { + get { return CurrencyId != 0? Currency.FromIdentity(CurrencyId): null; } + set { this.CurrencyId = (value == null? 0: value.Identity); } + } + + [XmlIgnore] + public ExternalBankDataProfile BankDataProfile + { + get { return BankDataProfileId != 0 ? ExternalBankDataProfile.FromIdentity(BankDataProfileId): null; } + set { this.BankDataProfileId = (value == null ? 0 : value.Identity); } + } + + protected int BankDataProfileId { get; set; } + protected int CountryId { get; set; } + protected int CurrencyId { get; set; } + + [XmlIgnore] + public int Identity { get { return FinancialAccountAutomationProfileId; } } + } + + + + public enum FinancialAccountAutomationProfileHardIds + { + Unknown = 0, + BitcoinHotwallet = 1, + BitcoinCashArmory = 2, + BitcoinCoreArmory = 3, + BankPaypal = 4, + BankSwedenSeb = 5, + BankGermanyPostbank = 6, + BankCzechFio = 7 + } +} diff --git a/Logic/Financial/StockBankDataReaders.cs b/Logic/Financial/StockBankDataReaders.cs index 906c63fa..241d19c8 100644 --- a/Logic/Financial/StockBankDataReaders.cs +++ b/Logic/Financial/StockBankDataReaders.cs @@ -3,9 +3,9 @@ // ReSharper disable InconsistentNaming internal class StockBankDataReaders { - public static string TabSeparatedValuesAccountReader + public static string CommaSeparatedValuesAccountReader { - get { return "TabSeparatedValuesReader"; } + get { return "CommaSeparatedValuesReader"; } } public static string SemicolonSeparatedValuesAccountReader diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index a7d3f1a4..b8ae382a 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -135,6 +135,7 @@ + diff --git a/Site/Pages/v5/Ledgers/AccountPlan.aspx b/Site/Pages/v5/Ledgers/AccountPlan.aspx index 877f1ff1..d73a988c 100644 --- a/Site/Pages/v5/Ledgers/AccountPlan.aspx +++ b/Site/Pages/v5/Ledgers/AccountPlan.aspx @@ -525,8 +525,10 @@ function onToggleChange(newValue, cookie) { if (newValue) { $(".DivEditAutomationControls").slideDown(); + $(".DivEditNonautomationControls").slideUp(); } else { $(".DivEditAutomationControls").slideUp(); + $(".DivEditNonautomationControls").slideDown(); } } @@ -621,9 +623,8 @@
 
- -
-
+
+
@@ -653,8 +654,8 @@


-

-
Initial Balance (XXX)
+
+

diff --git a/Site/Pages/v5/Ledgers/AccountPlan.aspx.cs b/Site/Pages/v5/Ledgers/AccountPlan.aspx.cs index 0d3c8d76..77a7b9d9 100644 --- a/Site/Pages/v5/Ledgers/AccountPlan.aspx.cs +++ b/Site/Pages/v5/Ledgers/AccountPlan.aspx.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Collections.Generic; using System.Globalization; using System.Web; +using System.Web.Management; using System.Web.Services; using System.Web.UI.WebControls; using Resources; @@ -101,9 +102,12 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers // Hardcoded automation profiles for the time being - this.DropAccountAutomationProfile.Items.Add(new ListItem("[CZ CZK] Fio CSV", "3")); - this.DropAccountAutomationProfile.Items.Add(new ListItem("[DE EUR] Postbank CSV", "2")); - this.DropAccountAutomationProfile.Items.Add(new ListItem("[SE SEK] SEB CSV", "1")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[BTC] Bitcoin Core - Armory", "3")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[BCH] Bitcoin Cash - Armory", "2")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[BCH] Bitcoin Cash Hotwallet", "1")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[CZ CZK] Fio CSV", "7")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[DE EUR] Postbank CSV", "6")); + this.DropAccountAutomationProfile.Items.Add(new ListItem("[SE SEK] SEB CSV", "5")); } PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write); @@ -561,7 +565,19 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers private static AutomationData GetAccountAutomationData(int profileId) { - + AutomationData result = new AutomationData(); + + result.AutomationProfileCustomXml = string.Empty; + result.AutomaticRetrievalPossible = false; + result.AutomationProfileId = profileId; + result.AutomationEnabled = (profileId != 0); + + if (result.AutomationEnabled) + { + + } + + return result; } @@ -642,9 +658,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers public bool AutomationEnabled { get; set; } public int AutomationProfileId { get; set; } public string AutomationCurrencyCode { get; set; } + public string AutomationCountryCode { get; set; } public bool NonPresentationCurrency { get; set; } + public bool SetInitialBalance { get; set; } public bool AutomaticRetrievalPossible { get; set; } // always false for now public string AutomationProfileCustomXml { get; set; } // always empty for now + + public FinancialAccountAutomationProfile Profile { get; set; } } [Serializable] diff --git a/Site/Pages/v5/Ledgers/AccountPlan.aspx.designer.cs b/Site/Pages/v5/Ledgers/AccountPlan.aspx.designer.cs index 1324800c..4e612636 100644 --- a/Site/Pages/v5/Ledgers/AccountPlan.aspx.designer.cs +++ b/Site/Pages/v5/Ledgers/AccountPlan.aspx.designer.cs @@ -165,15 +165,6 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { /// protected global::Swarmops.Frontend.Controls.Financial.CurrencyTextBox CurrencyInitialBalance; - /// - /// CurrencyInitialBalanceForex control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Swarmops.Frontend.Controls.Financial.CurrencyTextBox CurrencyInitialBalanceForex; - /// /// ToggleAssetAutomation control. ///