using Centron.BusinessLogic; using Centron.BusinessLogic.Sales.Customers; using Centron.BusinessLogic.Sales.Receipts.Internal; using Centron.BusinessLogic.Warehousing; using Centron.Interfaces.Accounts.SpecialPrices; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.SpecialPrices; public class SpecialPriceTests : EndToEndTest { public SpecialPriceTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int CustomerI3D = 10012; public const int ArticleI3D = 17; public override void Execute() { this.PrepareDatabase(); this.RunTest(SpecialPriceKind.SurchargePurchasePrice, 10); this.RunTest(SpecialPriceKind.ReduceRecommendedSellPrice, 10); this.RunTest(SpecialPriceKind.FixedPrice, 7.50m); this.RunTest(SpecialPriceKind.ReduceSellPrice, 10); this.RunTest(SpecialPriceKind.ReduceListPrice, 10); } private void RunTest(SpecialPriceKind kind, decimal value) { this.Sql($"UPDATE dbo.KundenSonderpreise SET Basis = {(int)kind}, Aufschlag = {value.ToString().Replace(",", ".")} WHERE ArtikelI3D = {ArticleI3D} AND KundenI3D = {CustomerI3D}"); using var session = new BLSession(); var article = session.GetBL().GetArticleByI3D(ArticleI3D, loadAdditionalInformations: false); var customer = session.GetBL().GetCustomer(CustomerI3D); var purchasePrice = session.GetBL().GetPurchaseBasePrice(article, warehouseI3D: -1, specialAgreementI3D: null); var (sellPrice, discount) = session.GetBL().GetBasePrice(purchasePrice, article, customer, contractI3D:null, specialAgreement:null); this.Verifier.Verify($"{kind}_{value}", new { PurchasePrice = purchasePrice, SellPrice = sellPrice, Discount = discount }); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.ARTIK SET VK_1 = 100, VK_2 = 200, VK_3 = 300, VK_4 = 400, EK = 50, EVK = 500, Listenpreis = 600 WHERE I3D = {ArticleI3D}"); } }