From be0b4ebc2677fc7ea1e0d27a2cfe3a32ad7bdc34 Mon Sep 17 00:00:00 2001 From: Paolo Bassi Date: Sun, 7 Jan 2024 15:13:04 +0100 Subject: [PATCH 1/3] Add static class with all predefined accounts --- .../ConnectorTests/PredefinedAccountsTests.cs | 31 ++- .../PredefinedAccountName.cs | 215 ++++++++++++++++++ 2 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs diff --git a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs index c75abedb..1815960b 100644 --- a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs +++ b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs @@ -1,7 +1,9 @@ -using System.Linq; -using System.Threading.Tasks; using Fortnox.SDK; +using Fortnox.SDK.Entities.Predefined_Accounts; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; namespace FortnoxSDK.Tests.ConnectorTests; @@ -16,10 +18,10 @@ public async Task Test_PredefinedAccounts_CRUD() var connector = FortnoxClient.PredefinedAccountsConnector; //Get - var bygAccount = await connector.GetAsync("CONSTRUCTION_DEB"); + var bygAccount = await connector.GetAsync(PredefinedAccountName.ReverseChargeSEDebit); Assert.AreEqual(2647, bygAccount.Account); - var patentAccount = await connector.GetAsync("PRODUCT_DEB"); + var patentAccount = await connector.GetAsync(PredefinedAccountName.ReverseChargeGoodsEUDebit); Assert.AreEqual(2645, patentAccount.Account); //Update @@ -52,4 +54,25 @@ public async Task Test_Find() Assert.AreEqual(42, limitedCollection.TotalResources); */ } + + /// + /// It looks like that not all the Fortnox account have all accounts + /// so this test may fail + /// + /// + [TestMethod] + public async Task Test_FindAllAccounts() + { + var connector = FortnoxClient.PredefinedAccountsConnector; + + var fields = typeof(PredefinedAccountName) + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(fi => fi.IsLiteral && !fi.IsInitOnly); + + foreach (var field in fields) + { + var predefineradAccount = await connector.GetAsync((string?)field.GetValue(null)); + Assert.IsNotNull(predefineradAccount); + } + } } \ No newline at end of file diff --git a/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs b/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs new file mode 100644 index 00000000..d3a96b66 --- /dev/null +++ b/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs @@ -0,0 +1,215 @@ +namespace Fortnox.SDK.Entities.Predefined_Accounts +{ + public static class PredefinedAccountName + { + #region Payment Accounts / Betalkonton + /// + /// Bankgiro + /// + public const string Bankgiro = "BG"; + /// + /// Plusgiro + /// + public const string Plusgiro = "PG"; + /// + /// Kontantbetalning + /// + public const string Cash = "CASH"; + /// + /// Kontantbet. via kontokort + /// + public const string CashByCard = "CASHBYCARD"; + /// + /// Autogiro + /// + public const string Autogiro = "AG"; + #endregion + + #region Purchase Accounts / Inköp + /// + /// Inköp + /// + public const string Purchases = "PURCASE"; + /// + /// Leverantörsskuld + /// + public const string AccountsPayable = "SUPDEBT"; + /// + /// Faktureringsavgift levfakt + /// + public const string PurchasesInvoiceFee = "SUPADMFEE"; + /// + /// Frakt levfakt + /// + public const string PurchasesFreight = "SUPFREIGHT"; + /// + /// Kassarabatt, erhållen + /// + public const string PurchasesCashDiscount = "CASHDISCOUNTIN"; + #endregion + + #region Sale Accounts / Försäljning + /// + /// Försäljning 25% vara + /// + public const string Sales25Goods = "SALES_25_SE"; + /// + /// Försäljning 25% tjänst + /// + public const string Sales25Services = "SALES_25_SE2"; + /// + /// Försäljning 12% vara + /// + public const string Sales12Goods = "SALES_12_SE"; + /// + /// Försäljning 12% tjänst + /// + public const string Sales12Services = "SALES_12_SE2"; + /// + /// Försäljning 6% vara + /// + public const string Sales6Goods = "SALES_6_SE"; + /// + /// Försäljning 6% tjänst + /// + public const string Sales6Services = "SALES_6_SE2"; + /// + /// Försäljning 0% vara + /// + public const string Sales0Goods = "SALES_0_SE"; + /// + /// Försäljning 0% tjänst + /// + public const string Sales0Services = "SALES_0_SE2"; + /// + /// Försäljning SE, omvänd skattskyldighet + /// + public const string SalesSEReverseCharge = "SALESCONSTR2"; + /// + /// Försäljning EU vara, omvänd skattskyldighet + /// + public const string SalesEUGoodsReverseCharge = "SALESEUREV"; + /// + /// Försäljning EU tjänst, omvänd skattskyldighet + /// + public const string SalesEUServicesReverseCharge = "SALESEUREV2"; + /// + /// Försäljning EU vara, momspliktig + /// + public const string SalesEUGoodsVat = "SALESEUVAT"; + /// + /// Försäljning EU tjänst, momspliktig + /// + public const string SalesEUServicesVat = "SALESEUVAT2"; + /// + /// Försäljning Export vara + /// + public const string SalesExtraEUGoods = "SALESEXPORT"; + /// + /// Försäljning Export tjänst + /// + public const string SalesExtraEUServices = "SALESEXPORT2"; + /// + /// Kundfordran + /// + public const string AccountsReceivable = "CUSTCLAIM"; + /// + /// Faktureringsavgift + /// + public const string SalesInvoiceFee = "ADMFEE"; + /// + /// Frakt + /// + public const string SalesFreight = "FREIGHT"; + /// + /// Kassarabatt, lämnad + /// + public const string SalesCashDiscount = "CASHDISCOUNTOUT"; + /// + /// Påminnelseavgift + /// + public const string ReminderFee = "DEMAND"; + /// + /// Dröjsmålsränta + /// + public const string PenaltyInterest = "INTEREST"; + /// + /// Avrundning + /// + public const string Rounding = "ROUNDOFF"; + #endregion + + #region Vat Accounts / Moms + /// + /// Utgående Moms MP1 25% + /// + public const string SalesVat1 = "OUTVAT_MP1"; + /// + /// Utgående Moms MP2 12% + /// + public const string SalesVat2 = "OUTVAT_MP2"; + /// + /// Utgående Moms MP3 6% + /// + public const string SalesVat3 = "OUTVAT_MP3"; + /// + /// Ingående moms + /// + public const string PurchasesVat = "INVAT"; + /// + /// Vara unionsinternt förvärv debit + /// + public const string ReverseChargeGoodsEUDebit = "PRODUCT_DEB"; + /// + /// Vara unionsinternt förvärv credit + /// + public const string ReverseChargeGoodsEUCredit = "PRODUCT_CRE"; + /// + /// Tjänst unionsinternt förvärv debit + /// + public const string ReverseChargeServicesEUDebit = "SERVICE_DEB"; + /// + /// Tjänst unionsinternt förvärv credit + /// + public const string ReverseChargeServicesEUCredit = "SERVICE_CRE"; + /// + /// Inköp SE, omvänd skattskyldighet debit + /// + public const string ReverseChargeSEDebit = "CONSTRUCTION_DEB"; + /// + /// Inköp SE, omvänd skattskyldighet credit + /// + public const string ReverseChargeSECredit = "CONSTRUCTION_CRE"; + #endregion + + #region Accrual Accounts / Periodisering + /// + /// Periodiseringskonto levfakt + /// + public const string AccrualAccountSupplierInvoice = "ACCRSINVOICE"; + /// + /// Periodiseringskonto kundfakt + /// + public const string AccrualAccountCustomerInvoice = "ACCRINVOICE"; + /// + /// Intäktskonto periodisering + /// + public const string AccruedIncome = "ACCRINCOME"; + /// + /// Kostnadskonto periodisering + /// + public const string AccruedCost = "ACCRCOST"; + #endregion + + #region Other Accounts / Övrigt + /// + /// Valutakursvinster + /// + public const string ExchangeGain = "CURRENCYWIN"; + /// + /// Valutakursförluster + /// + public const string ExchangeLoss = "CURRENCYLOSS"; + #endregion + } +} From 035998f3d0ffab370839d214d5bab7fd6acf3b3c Mon Sep 17 00:00:00 2001 From: Paolo Bassi Date: Sun, 21 Jan 2024 13:01:27 +0100 Subject: [PATCH 2/3] Removed a test that doesn't always work --- .../ConnectorTests/PredefinedAccountsTests.cs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs index 1815960b..f3c16240 100644 --- a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs +++ b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs @@ -2,7 +2,6 @@ using Fortnox.SDK.Entities.Predefined_Accounts; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Linq; -using System.Reflection; using System.Threading.Tasks; namespace FortnoxSDK.Tests.ConnectorTests; @@ -57,22 +56,22 @@ public async Task Test_Find() /// /// It looks like that not all the Fortnox account have all accounts - /// so this test may fail + /// so this test may fail. Further investigations are needed in this regard. /// /// - [TestMethod] - public async Task Test_FindAllAccounts() - { - var connector = FortnoxClient.PredefinedAccountsConnector; + //[TestMethod] + //public async Task Test_FindAllAccounts() + //{ + // var connector = FortnoxClient.PredefinedAccountsConnector; - var fields = typeof(PredefinedAccountName) - .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) - .Where(fi => fi.IsLiteral && !fi.IsInitOnly); + // var fields = typeof(PredefinedAccountName) + // .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + // .Where(fi => fi.IsLiteral && !fi.IsInitOnly); - foreach (var field in fields) - { - var predefineradAccount = await connector.GetAsync((string?)field.GetValue(null)); - Assert.IsNotNull(predefineradAccount); - } - } + // foreach (var field in fields) + // { + // var predefineradAccount = await connector.GetAsync((string?)field.GetValue(null)); + // Assert.IsNotNull(predefineradAccount); + // } + //} } \ No newline at end of file From 033fb7eb79b269a73135abd001900319c05b7111 Mon Sep 17 00:00:00 2001 From: Paolo Bassi Date: Tue, 23 Jan 2024 08:06:05 +0100 Subject: [PATCH 3/3] Changed the namespace to better fit the project schema. --- .../ConnectorTests/PredefinedAccountsTests.cs | 2 +- .../PredefinedAccountName.cs | 415 +++++++++--------- 2 files changed, 208 insertions(+), 209 deletions(-) diff --git a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs index f3c16240..7ead8302 100644 --- a/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs +++ b/FortnoxSDK.Tests/ConnectorTests/PredefinedAccountsTests.cs @@ -1,5 +1,5 @@ using Fortnox.SDK; -using Fortnox.SDK.Entities.Predefined_Accounts; +using Fortnox.SDK.Entities; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Linq; using System.Threading.Tasks; diff --git a/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs b/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs index d3a96b66..7e235172 100644 --- a/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs +++ b/FortnoxSDK/Entities/Predefined Accounts/PredefinedAccountName.cs @@ -1,215 +1,214 @@ -namespace Fortnox.SDK.Entities.Predefined_Accounts +namespace Fortnox.SDK.Entities; + +public static class PredefinedAccountName { - public static class PredefinedAccountName - { - #region Payment Accounts / Betalkonton - /// - /// Bankgiro - /// - public const string Bankgiro = "BG"; - /// - /// Plusgiro - /// - public const string Plusgiro = "PG"; - /// - /// Kontantbetalning - /// - public const string Cash = "CASH"; - /// - /// Kontantbet. via kontokort - /// - public const string CashByCard = "CASHBYCARD"; - /// - /// Autogiro - /// - public const string Autogiro = "AG"; - #endregion + #region Payment Accounts / Betalkonton + /// + /// Bankgiro + /// + public const string Bankgiro = "BG"; + /// + /// Plusgiro + /// + public const string Plusgiro = "PG"; + /// + /// Kontantbetalning + /// + public const string Cash = "CASH"; + /// + /// Kontantbet. via kontokort + /// + public const string CashByCard = "CASHBYCARD"; + /// + /// Autogiro + /// + public const string Autogiro = "AG"; + #endregion - #region Purchase Accounts / Inköp - /// - /// Inköp - /// - public const string Purchases = "PURCASE"; - /// - /// Leverantörsskuld - /// - public const string AccountsPayable = "SUPDEBT"; - /// - /// Faktureringsavgift levfakt - /// - public const string PurchasesInvoiceFee = "SUPADMFEE"; - /// - /// Frakt levfakt - /// - public const string PurchasesFreight = "SUPFREIGHT"; - /// - /// Kassarabatt, erhållen - /// - public const string PurchasesCashDiscount = "CASHDISCOUNTIN"; - #endregion + #region Purchase Accounts / Inköp + /// + /// Inköp + /// + public const string Purchases = "PURCASE"; + /// + /// Leverantörsskuld + /// + public const string AccountsPayable = "SUPDEBT"; + /// + /// Faktureringsavgift levfakt + /// + public const string PurchasesInvoiceFee = "SUPADMFEE"; + /// + /// Frakt levfakt + /// + public const string PurchasesFreight = "SUPFREIGHT"; + /// + /// Kassarabatt, erhållen + /// + public const string PurchasesCashDiscount = "CASHDISCOUNTIN"; + #endregion - #region Sale Accounts / Försäljning - /// - /// Försäljning 25% vara - /// - public const string Sales25Goods = "SALES_25_SE"; - /// - /// Försäljning 25% tjänst - /// - public const string Sales25Services = "SALES_25_SE2"; - /// - /// Försäljning 12% vara - /// - public const string Sales12Goods = "SALES_12_SE"; - /// - /// Försäljning 12% tjänst - /// - public const string Sales12Services = "SALES_12_SE2"; - /// - /// Försäljning 6% vara - /// - public const string Sales6Goods = "SALES_6_SE"; - /// - /// Försäljning 6% tjänst - /// - public const string Sales6Services = "SALES_6_SE2"; - /// - /// Försäljning 0% vara - /// - public const string Sales0Goods = "SALES_0_SE"; - /// - /// Försäljning 0% tjänst - /// - public const string Sales0Services = "SALES_0_SE2"; - /// - /// Försäljning SE, omvänd skattskyldighet - /// - public const string SalesSEReverseCharge = "SALESCONSTR2"; - /// - /// Försäljning EU vara, omvänd skattskyldighet - /// - public const string SalesEUGoodsReverseCharge = "SALESEUREV"; - /// - /// Försäljning EU tjänst, omvänd skattskyldighet - /// - public const string SalesEUServicesReverseCharge = "SALESEUREV2"; - /// - /// Försäljning EU vara, momspliktig - /// - public const string SalesEUGoodsVat = "SALESEUVAT"; - /// - /// Försäljning EU tjänst, momspliktig - /// - public const string SalesEUServicesVat = "SALESEUVAT2"; - /// - /// Försäljning Export vara - /// - public const string SalesExtraEUGoods = "SALESEXPORT"; - /// - /// Försäljning Export tjänst - /// - public const string SalesExtraEUServices = "SALESEXPORT2"; - /// - /// Kundfordran - /// - public const string AccountsReceivable = "CUSTCLAIM"; - /// - /// Faktureringsavgift - /// - public const string SalesInvoiceFee = "ADMFEE"; - /// - /// Frakt - /// - public const string SalesFreight = "FREIGHT"; - /// - /// Kassarabatt, lämnad - /// - public const string SalesCashDiscount = "CASHDISCOUNTOUT"; - /// - /// Påminnelseavgift - /// - public const string ReminderFee = "DEMAND"; - /// - /// Dröjsmålsränta - /// - public const string PenaltyInterest = "INTEREST"; - /// - /// Avrundning - /// - public const string Rounding = "ROUNDOFF"; - #endregion + #region Sale Accounts / Försäljning + /// + /// Försäljning 25% vara + /// + public const string Sales25Goods = "SALES_25_SE"; + /// + /// Försäljning 25% tjänst + /// + public const string Sales25Services = "SALES_25_SE2"; + /// + /// Försäljning 12% vara + /// + public const string Sales12Goods = "SALES_12_SE"; + /// + /// Försäljning 12% tjänst + /// + public const string Sales12Services = "SALES_12_SE2"; + /// + /// Försäljning 6% vara + /// + public const string Sales6Goods = "SALES_6_SE"; + /// + /// Försäljning 6% tjänst + /// + public const string Sales6Services = "SALES_6_SE2"; + /// + /// Försäljning 0% vara + /// + public const string Sales0Goods = "SALES_0_SE"; + /// + /// Försäljning 0% tjänst + /// + public const string Sales0Services = "SALES_0_SE2"; + /// + /// Försäljning SE, omvänd skattskyldighet + /// + public const string SalesSEReverseCharge = "SALESCONSTR2"; + /// + /// Försäljning EU vara, omvänd skattskyldighet + /// + public const string SalesEUGoodsReverseCharge = "SALESEUREV"; + /// + /// Försäljning EU tjänst, omvänd skattskyldighet + /// + public const string SalesEUServicesReverseCharge = "SALESEUREV2"; + /// + /// Försäljning EU vara, momspliktig + /// + public const string SalesEUGoodsVat = "SALESEUVAT"; + /// + /// Försäljning EU tjänst, momspliktig + /// + public const string SalesEUServicesVat = "SALESEUVAT2"; + /// + /// Försäljning Export vara + /// + public const string SalesExtraEUGoods = "SALESEXPORT"; + /// + /// Försäljning Export tjänst + /// + public const string SalesExtraEUServices = "SALESEXPORT2"; + /// + /// Kundfordran + /// + public const string AccountsReceivable = "CUSTCLAIM"; + /// + /// Faktureringsavgift + /// + public const string SalesInvoiceFee = "ADMFEE"; + /// + /// Frakt + /// + public const string SalesFreight = "FREIGHT"; + /// + /// Kassarabatt, lämnad + /// + public const string SalesCashDiscount = "CASHDISCOUNTOUT"; + /// + /// Påminnelseavgift + /// + public const string ReminderFee = "DEMAND"; + /// + /// Dröjsmålsränta + /// + public const string PenaltyInterest = "INTEREST"; + /// + /// Avrundning + /// + public const string Rounding = "ROUNDOFF"; + #endregion - #region Vat Accounts / Moms - /// - /// Utgående Moms MP1 25% - /// - public const string SalesVat1 = "OUTVAT_MP1"; - /// - /// Utgående Moms MP2 12% - /// - public const string SalesVat2 = "OUTVAT_MP2"; - /// - /// Utgående Moms MP3 6% - /// - public const string SalesVat3 = "OUTVAT_MP3"; - /// - /// Ingående moms - /// - public const string PurchasesVat = "INVAT"; - /// - /// Vara unionsinternt förvärv debit - /// - public const string ReverseChargeGoodsEUDebit = "PRODUCT_DEB"; - /// - /// Vara unionsinternt förvärv credit - /// - public const string ReverseChargeGoodsEUCredit = "PRODUCT_CRE"; - /// - /// Tjänst unionsinternt förvärv debit - /// - public const string ReverseChargeServicesEUDebit = "SERVICE_DEB"; - /// - /// Tjänst unionsinternt förvärv credit - /// - public const string ReverseChargeServicesEUCredit = "SERVICE_CRE"; - /// - /// Inköp SE, omvänd skattskyldighet debit - /// - public const string ReverseChargeSEDebit = "CONSTRUCTION_DEB"; - /// - /// Inköp SE, omvänd skattskyldighet credit - /// - public const string ReverseChargeSECredit = "CONSTRUCTION_CRE"; - #endregion + #region Vat Accounts / Moms + /// + /// Utgående Moms MP1 25% + /// + public const string SalesVat1 = "OUTVAT_MP1"; + /// + /// Utgående Moms MP2 12% + /// + public const string SalesVat2 = "OUTVAT_MP2"; + /// + /// Utgående Moms MP3 6% + /// + public const string SalesVat3 = "OUTVAT_MP3"; + /// + /// Ingående moms + /// + public const string PurchasesVat = "INVAT"; + /// + /// Vara unionsinternt förvärv debit + /// + public const string ReverseChargeGoodsEUDebit = "PRODUCT_DEB"; + /// + /// Vara unionsinternt förvärv credit + /// + public const string ReverseChargeGoodsEUCredit = "PRODUCT_CRE"; + /// + /// Tjänst unionsinternt förvärv debit + /// + public const string ReverseChargeServicesEUDebit = "SERVICE_DEB"; + /// + /// Tjänst unionsinternt förvärv credit + /// + public const string ReverseChargeServicesEUCredit = "SERVICE_CRE"; + /// + /// Inköp SE, omvänd skattskyldighet debit + /// + public const string ReverseChargeSEDebit = "CONSTRUCTION_DEB"; + /// + /// Inköp SE, omvänd skattskyldighet credit + /// + public const string ReverseChargeSECredit = "CONSTRUCTION_CRE"; + #endregion - #region Accrual Accounts / Periodisering - /// - /// Periodiseringskonto levfakt - /// - public const string AccrualAccountSupplierInvoice = "ACCRSINVOICE"; - /// - /// Periodiseringskonto kundfakt - /// - public const string AccrualAccountCustomerInvoice = "ACCRINVOICE"; - /// - /// Intäktskonto periodisering - /// - public const string AccruedIncome = "ACCRINCOME"; - /// - /// Kostnadskonto periodisering - /// - public const string AccruedCost = "ACCRCOST"; - #endregion + #region Accrual Accounts / Periodisering + /// + /// Periodiseringskonto levfakt + /// + public const string AccrualAccountSupplierInvoice = "ACCRSINVOICE"; + /// + /// Periodiseringskonto kundfakt + /// + public const string AccrualAccountCustomerInvoice = "ACCRINVOICE"; + /// + /// Intäktskonto periodisering + /// + public const string AccruedIncome = "ACCRINCOME"; + /// + /// Kostnadskonto periodisering + /// + public const string AccruedCost = "ACCRCOST"; + #endregion - #region Other Accounts / Övrigt - /// - /// Valutakursvinster - /// - public const string ExchangeGain = "CURRENCYWIN"; - /// - /// Valutakursförluster - /// - public const string ExchangeLoss = "CURRENCYLOSS"; - #endregion - } + #region Other Accounts / Övrigt + /// + /// Valutakursvinster + /// + public const string ExchangeGain = "CURRENCYWIN"; + /// + /// Valutakursförluster + /// + public const string ExchangeLoss = "CURRENCYLOSS"; + #endregion }