From f76d9dce61e549f51bb42a22d8cdf5616090a393 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 28 Apr 2018 17:08:22 +0200 Subject: [PATCH] Added more fields for Fio; custom date format --- Logic/Financial/ExternalBankData.cs | 52 +++++++++++++++++++++- Logic/Financial/ExternalBankDataProfile.cs | 2 + Logic/Financial/ExternalBankDataRecord.cs | 2 + 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Logic/Financial/ExternalBankData.cs b/Logic/Financial/ExternalBankData.cs index bc9ed5bd..a2c34e7f 100644 --- a/Logic/Financial/ExternalBankData.cs +++ b/Logic/Financial/ExternalBankData.cs @@ -155,6 +155,48 @@ namespace Swarmops.Logic.Financial } } + // Check if there's counterparty information + + if (fieldNameLookup.ContainsKey(ExternalBankDataFieldName.CounterpartyName)) + { + string counterpartyName = + StripQuotes(lineFields[fieldNameLookup[ExternalBankDataFieldName.CounterpartyName]]); + + if (newRecord.Description != counterpartyName) + { + newRecord.CounterpartyName = counterpartyName; + } + } + + if (fieldNameLookup.ContainsKey(ExternalBankDataFieldName.CounterpartyBank)) + { + string counterpartyBank = + StripQuotes(lineFields[fieldNameLookup[ExternalBankDataFieldName.CounterpartyBank]]); + + if (!string.IsNullOrEmpty(counterpartyBank)) + { + newRecord.CounterpartyBankAccount = counterpartyBank; + } + } + + if (fieldNameLookup.ContainsKey(ExternalBankDataFieldName.CounterpartyAccount)) + { + string counterpartyAccount = + StripQuotes(lineFields[fieldNameLookup[ExternalBankDataFieldName.CounterpartyAccount]]); + + if (!string.IsNullOrEmpty(counterpartyAccount)) + { + if (!string.IsNullOrEmpty(newRecord.CounterpartyBankAccount)) + { + newRecord.CounterpartyBankAccount += "|"; + } + + newRecord.CounterpartyBankAccount += counterpartyAccount; + } + } + + + if (fieldNameLookup.ContainsKey (ExternalBankDataFieldName.AccountBalance)) { // Dividing up to step-by-step statements instead of one long statement assists debugging @@ -184,7 +226,15 @@ namespace Swarmops.Logic.Financial if (fieldNameLookup.ContainsKey (ExternalBankDataFieldName.Date)) { string dateString = StripQuotes (lineFields[fieldNameLookup[ExternalBankDataFieldName.Date]]); - dateTime = DateTime.Parse (dateString, new CultureInfo (Profile.Culture)); + + if (!String.IsNullOrEmpty(Profile.DateTimeCustomFormatString)) + { + dateTime = DateTime.ParseExact(dateString, Profile.DateTimeCustomFormatString, new CultureInfo(Profile.Culture)); + } + else + { + dateTime = DateTime.Parse(dateString, new CultureInfo(Profile.Culture)); + } if (fieldNameLookup.ContainsKey (ExternalBankDataFieldName.Time)) { diff --git a/Logic/Financial/ExternalBankDataProfile.cs b/Logic/Financial/ExternalBankDataProfile.cs index 2df71fb7..8561c968 100644 --- a/Logic/Financial/ExternalBankDataProfile.cs +++ b/Logic/Financial/ExternalBankDataProfile.cs @@ -90,6 +90,7 @@ namespace Swarmops.Logic.Financial public string InitialReplacements { get; set; } public int ExternalBankDataProfileId { get; set; } public char FieldDelimiter { get; set; } + public string DateTimeCustomFormatString { get; set; } public int Identity { get { return ExternalBankDataProfileId; } } public Dictionary FieldNames { get; private set; } @@ -199,6 +200,7 @@ namespace Swarmops.Logic.Financial result.LatestTransactionLocation = LatestTransactionLocation.Bottom; result.FeeSignage = FeeSignage.Unknown; // no inline fees result.Precision = ExternalBankDateTimePrecision.Day; + result.DateTimeFormatString = "dd.MM.yyyy"; result.BankDataAccountReader = StockBankDataReaders.CommaSeparatedValuesAccountReader; result.BankDataPaymentsReader = null; // No aggregated payments with Postbank diff --git a/Logic/Financial/ExternalBankDataRecord.cs b/Logic/Financial/ExternalBankDataRecord.cs index 81872dc5..38682ad1 100644 --- a/Logic/Financial/ExternalBankDataRecord.cs +++ b/Logic/Financial/ExternalBankDataRecord.cs @@ -10,6 +10,8 @@ namespace Swarmops.Logic.Financial public long AccountBalanceCents; public DateTime DateTime; // UTC! public string Description; + public string CounterpartyName; + public string CounterpartyBankAccount; public long FeeCents; public string NotUniqueId;