using Centron.BusinessLogic; using Centron.BusinessLogic.Sales.Receipts.Internal; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.RevenueAndExpenseAccounts; public class GetRevenueAccountTests : EndToEndTest { public GetRevenueAccountTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { PrepareDB(); using var session = new BLSession(); var itemBL = session.GetBL(); // Case: Inland, Company, RC:false // Expected: default revenue account 4400 var account = itemBL.GetProfitAndLossAccount(true, 10000, 1, null, false, 4361, base.GetLoggedInUser().User, false); Assert.Equal(4400, account.GetValueOrDefault(0)); // Case: Inland, Company, RC:true // Expected: RC account 4335 account = itemBL.GetProfitAndLossAccount(true, 10000, 1, null, false, 4361, base.GetLoggedInUser().User, true); Assert.Equal(4335, account.GetValueOrDefault(0)); // Case: Inland, Privat Person (has no ustID), RC:false // Expected: default revenue account 4400 account = itemBL.GetProfitAndLossAccount(true, 10022, 1, null, false, 4361, base.GetLoggedInUser().User, false); Assert.Equal(4400, account.GetValueOrDefault(0)); // Case: Inland, Privat Person (has no ustID), RC:true // Expected: default revenue account 4400 (because: privat person has no ustid. There is no RC) account = itemBL.GetProfitAndLossAccount(true, 10022, 1, null, false, 4361, base.GetLoggedInUser().User, true); Assert.Equal(4400, account.GetValueOrDefault(0)); // Case: EU, Company, RC:false // Expected: default revenue account for eu 4401 account = itemBL.GetProfitAndLossAccount(true, 10003, 5, null, false, 4361, base.GetLoggedInUser().User, false); Assert.Equal(4401, account.GetValueOrDefault(0)); // Case: EU, Company, RC:true // Expected: default revenue account for eu 4401 (Erika T. : there is no RC diff. in EU trading) account = itemBL.GetProfitAndLossAccount(true, 10003, 5, null, false, 4361, base.GetLoggedInUser().User, true); Assert.Equal(4401, account.GetValueOrDefault(0)); // Case: Not EU, Company, RC:false // Expected: default revenue account for not EU 4402 account = itemBL.GetProfitAndLossAccount(true, 10007, 19, null, false, 4361, base.GetLoggedInUser().User, false); Assert.Equal(4402, account.GetValueOrDefault(0)); // Case: NOT EU, Company, RC:true // Expected: default revenue account for not EU 4402 account = itemBL.GetProfitAndLossAccount(true, 10007, 19, null, false, 4361, base.GetLoggedInUser().User, true); Assert.Equal(4402, account.GetValueOrDefault(0)); // Case: Inland, Company, RC:false, Branch 1 // Expected: branch revenue account 4780 account = itemBL.GetProfitAndLossAccount(true, 10000, 1, 1, false, 4361, base.GetLoggedInUser().User, false); Assert.Equal(4780, account.GetValueOrDefault(0)); } private void PrepareDB() { base.Sql(@"UPDATE ARTIK SET RCErloesKTO = 4335, RCAufwandKTO = 5335 WHERE I3D = 4361"); base.Sql("INSERT INTO ArtikelBranchErloeskonto (ArtikelI3D, BranchI3D, ErloesKonto, EUErloeskonto, AuslandErloeskonto) VALUES (4361, 1, 4780, 4781, 4782)"); } }