using Centron.BusinessLogic; using Centron.BusinessLogic.Sales.Support; using Centron.BusinessLogic.WebServices.Sales.Support; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket127331; public class Ticket127331Tests : EndToEndTest { public Ticket127331Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { this.Verifier.Settings.IgnoreColumn("Richtext"); } // There is a customer 10020 with a contract 22 and special prices in that contract for article 5 // So take a timer from that customer (timer 180), and book this article for it private const int ContractI3D = 22; private const int ArticleI3D = 5; private const int TimerI3D = 180; public override void Execute() { // The problem in this ticket is that when booking additional articles for a timer (HelpdeskTimerArticleBookingBL) // then special prices from the contract of the timer would not be applied this.PrepareDatabase(); using (var session = new BLSession()) { var bookResult = session.GetBL().BookArticles( CentronObjectKindNumeric.DeliveryListClass, TimerI3D, ArticleI3D, isExternalArticle:false, quantity:4, barcodes:null, warehouseI3D:-1, customizedArticleText:null, this.GetLoggedInUser().User); bookResult.ThrowIfError(); } using (var session = new BLSession()) { var result = session.GetBL().GetBookedArticles(new HelpdeskTimerBookedArticlesFilter { HelpdeskTimerI3Ds = new [] { TimerI3D } }); this.Verifier.Verify("BookedArticlesResult", result); var itemI3D = result.Data[0].ReceiptItemI3D; this.Verifier.VerifySql("BookedArticle_LiefPos", $"SELECT LP.* FROM dbo.LiefPos LP WHERE LP.I3D = {itemI3D}"); } } private void PrepareDatabase() { // The article is currently a service-article, which is ignored in the GetBookedArticles logic // So move that article into the "Hardware" material group this.Sql($"UPDATE dbo.ARTIK SET Warengruppe = 5 WHERE I3D = {ArticleI3D}"); // Also change the article price to something more visible this.Sql($"UPDATE dbo.ARTIK SET VK_1 = 5000, VK_2 = 6000, VK_3 = 7000, VK_4 = 8000 WHERE I3D = {ArticleI3D}"); // And make sure the timer has the contract referenced this.Sql($"UPDATE dbo.hlpdsk_timer SET ContractI3D = {ContractI3D} WHERE I3D = {TimerI3D}"); } }