using System.Collections.Generic; using Centron.BusinessLogic.Administration.Settings; using Centron.BusinessLogic.Sales.Receipts.DataAndResults; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Core.Extensions; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Interfaces.Sales.Receipts.InsertReceipts; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.EntitiesWrongPlace.Sales.Receipts.DataAndResults; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket139552; public class Ticket139552Tests : EndToEndTest { public Ticket139552Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int OfferI3D = 4453; public const int ArticleI3D = 1210; public override void Execute() { // In this ticket the problem was, that we didn't show a warning message to the user when // he forwarded EOL articles from offer to order this.PrepareDatabase(); this.ExecuteMatrix( new [] {false, true}, new [] {CentronObjectKindNumeric.OrderClass, CentronObjectKindNumeric.DeliveryListClass}, new [] {InsertReceiptTakeoverOptions.Reference, InsertReceiptTakeoverOptions.Copy}, (eolSetting, receiptKind, takeoverOptions) => { // Update setting this.Sql($"UPDATE dbo.Stammdat SET Wert = {eolSetting.ToOneZeroInteger()} WHERE I3D = {(int)AppSettingsConst.CheckArticleEolAtAttachmentProcessing}"); // Forward receipt var result = this.WithSession(s => s.GetBL().ForwardReceipt( receiptKind, this.GetLoggedInUser().User, new ForwardReceiptData { IgnoreCallbacks = true, CreateReceiptData = new CreateReceiptData { IgnoreCallbacks = true, }, CreateReceiptItemsFromExistingItemsData = new List { new CreateReceiptItemsFromExistingItemsData { // Has to be false, because the warning message is only shown if it's false IgnoreCallbacks = false, } }, }, new List { new ReceiptToForward { ReceiptKind = CentronObjectKindNumeric.OfferClass, ReceiptI3D = OfferI3D, } }, null, takeoverOptions, onlyTakeoverAvailableQuantity: false, ignoreDefaultContract: true)); result.ThrowIfError(); // Assert var shouldHaveWarningMessage = eolSetting && receiptKind is CentronObjectKindNumeric.OrderClass; // InsertReceiptTakeoverOptions does not matter, the message should come in both cases (Reference and Copy) var expectedMessage = shouldHaveWarningMessage ? "Folgende Artikel sind EOL: 104" : ""; Assert.Equal(expectedMessage, result.Data.CreateReceiptItemsFromExistingItemsResults[0].Message); }); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.AngKopf SET Status = 1 WHERE I3D = {OfferI3D}"); this.Sql($"UPDATE dbo.ARTIK SET EOL = 1 WHERE I3D = {ArticleI3D}"); } }