From fe801581e4e817aac71e292eaf78f00b5176757e Mon Sep 17 00:00:00 2001 From: Stefan Grushko Date: Wed, 3 Apr 2024 23:03:30 +0200 Subject: [PATCH] feature: implement parsing from CZ paypal Resolves #65, #64 --- .../Transactions/TransactionsReader.cs | 11 +++--- ...ConvertsTransactions_PaypalCZ.verified.txt | 2 + .../IntegrationTests.cs | 6 +++ .../TestData/PayPalCZ.csv | 2 + Mapp.UI/Mapp.UI.csproj | 3 ++ .../TransactionsConfigPaypalCZ.json | 39 +++++++++++++++++++ 6 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.ConvertTransactions_ParsesAndConvertsTransactions_PaypalCZ.verified.txt create mode 100644 Mapp.BusinessLogic.Transactions.Tests/TestData/PayPalCZ.csv create mode 100644 Mapp.UI/Transactions Configs/TransactionsConfigPaypalCZ.json diff --git a/Mapp.BusinessLogic.Invoices/Transactions/TransactionsReader.cs b/Mapp.BusinessLogic.Invoices/Transactions/TransactionsReader.cs index cfb8658..b928dda 100644 --- a/Mapp.BusinessLogic.Invoices/Transactions/TransactionsReader.cs +++ b/Mapp.BusinessLogic.Invoices/Transactions/TransactionsReader.cs @@ -53,10 +53,10 @@ private IEnumerable GetAvailableMarketplaceConfig mapper.Map(data)); var marketPlaceIds = configs.Select(s => s.MarketPlaceId).ToList(); - if (marketPlaceIds.Distinct().Count() != marketPlaceIds.Count()) - { - throw new ArgumentException($"Chyba, duplicitni hodnota {nameof(marketPlaceIds)} v JSON konfiguracich!"); - } + //if (marketPlaceIds.Distinct().Count() != marketPlaceIds.Count()) // commented because we now have PaypalCZ and paypal + //{ + // throw new ArgumentException($"Chyba, duplicitni hodnota {nameof(marketPlaceIds)} v JSON konfiguracich!"); + //} return configs; } @@ -130,7 +130,8 @@ private IEnumerable ReadTransactions(string fileName) decimal transactionTotalValue = 0; foreach (var compColumnName in marketPlaceSetting.ValueComponentsColumnName) { - transactionTotalValue += decimal.Parse(transactionsDict[compColumnName][index], marketPlaceSetting.DateCultureInfo); + string val = transactionsDict[compColumnName][index]; + transactionTotalValue += decimal.Parse(val, marketPlaceSetting.DateCultureInfo); } var transactionType = ParseTransactionType(transactionsDict[marketPlaceSetting.TransactionTypeColumnName][index], marketPlaceSetting); diff --git a/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.ConvertTransactions_ParsesAndConvertsTransactions_PaypalCZ.verified.txt b/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.ConvertTransactions_ParsesAndConvertsTransactions_PaypalCZ.verified.txt new file mode 100644 index 0000000..24794af --- /dev/null +++ b/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.ConvertTransactions_ParsesAndConvertsTransactions_PaypalCZ.verified.txt @@ -0,0 +1,2 @@ +0740000002001353907Czech Goods s.r.o. 01111900000013280900+00000016514842+000000461730770000000494070190011300424FIO +07500000020013539210000000000000000000000000000000000895356611132876594000000000000000000000000000140711328765940000000124100623 \ No newline at end of file diff --git a/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.cs b/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.cs index eeede39..3a11b1d 100644 --- a/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.cs +++ b/Mapp.BusinessLogic.Transactions.Tests/IntegrationTests.cs @@ -25,6 +25,12 @@ public async Task ConvertTransactions_ParsesAndConvertsTransactions_Paypal() await IntegrationTestBase("PayPal"); } + [Fact] + public async Task ConvertTransactions_ParsesAndConvertsTransactions_PaypalCZ() + { + await IntegrationTestBase("PayPalCZ"); + } + [Fact] public async Task ConvertTransactions_ParsesAndConvertsTransactions_AmazonCA() { diff --git a/Mapp.BusinessLogic.Transactions.Tests/TestData/PayPalCZ.csv b/Mapp.BusinessLogic.Transactions.Tests/TestData/PayPalCZ.csv new file mode 100644 index 0000000..61fdfca --- /dev/null +++ b/Mapp.BusinessLogic.Transactions.Tests/TestData/PayPalCZ.csv @@ -0,0 +1,2 @@ +"Datum","Čas","Časové pásmo","Popis","Měna","Brutto ","Poplatek ","Netto","Zůstatek","ID transakce","E-mailová adresa odesílatele","Název","Název banky","Bankovní účet","Výše poštovného a balného","Daň z prodeje","ID faktury","Referenční ID transakce" +"10/6/2023","11:52:55","Europe/Prague","General Withdrawal - Bank Account","CZK","-89 535,66","0,00","-89 535,66","-89 535,66","0X14071132876594C","","","Fio banka, a.s.","3907","0,00","0,00","","" \ No newline at end of file diff --git a/Mapp.UI/Mapp.UI.csproj b/Mapp.UI/Mapp.UI.csproj index 46971e6..1e87761 100644 --- a/Mapp.UI/Mapp.UI.csproj +++ b/Mapp.UI/Mapp.UI.csproj @@ -217,6 +217,9 @@ Always + + Always + Always diff --git a/Mapp.UI/Transactions Configs/TransactionsConfigPaypalCZ.json b/Mapp.UI/Transactions Configs/TransactionsConfigPaypalCZ.json new file mode 100644 index 0000000..34ebf36 --- /dev/null +++ b/Mapp.UI/Transactions Configs/TransactionsConfigPaypalCZ.json @@ -0,0 +1,39 @@ +{ + "LinesToSkipBeforeColumnNames": 0, + "MarketPlaceId": 21, + "DistinctionPhrases": [ "Datum", "Čas", "Časové pásmo", "Popis" ], + "DateSubstring": "(.*)", + "TimeSeparatorOverride": null, + "DateCultureInfoName": "cs-CZ", + "OrderIdColumnName": "ID transakce", + "TransactionTypeColumnName": "Popis", + "DateTimeColumnNames": [ + "Datum", + "Čas" + ], + "ValueComponentsColumnName": [ + "Brutto", + "Daň z prodeje" + ], + "TransferTypeNames": [ + "General Withdrawal - Bank Account" + ], + "RefundTypeNames": [ + "Payment Refund" + ], + "OrderTypeNames": [ + "eBay Auction Payment", + "Express Checkout Payment", + "General Payment", + "Mobile Payment", + "Website Payment" + ], + "ServiceFeeTypeNames": [ + "General Currency Conversion", + "Tax collected by partner", + "Cancellation of Hold for Dispute Resolution", + "Hold on Balance for Dispute Investigation", + "PreApproved Payment Bill User Payment" + ], + "TotalPriceColumnName": "Brutto" +} \ No newline at end of file