using System.Collections.Generic; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Administration.Settings; using Centron.BusinessLogic.Sales.Receipts.DataAndResults; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Data.WebServices.Sales.Receipts.DeliveryLists; 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.Ticket129734; public class Ticket129734Tests : EndToEndTest { public Ticket129734Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int OrderI3D = 4371; public const int RoundingFixArticleI3D = 4359; public override void Execute() { // In this ticket, the problem was that the Rounding-Fix-Article gets forwarded from Order to Delivery-List // It should not be forwarded at all, because it is automatically managed by the receipt itself (added or removed, depending if it's necessary) this.PrepareDatabase(); using var session = new BLSession(); var forwardResult = session.GetBL().ForwardReceipt( CentronObjectKindNumeric.DeliveryListClass, this.GetLoggedInUser().User, new ForwardReceiptData { IgnoreCallbacks = true, CreateReceiptData = new CreateReceiptData { IgnoreCallbacks = true, }, CreateReceiptItemsFromExistingItemsData = new List { new() { IgnoreCallbacks = true, }, }, }, new List { new ReceiptToForward { ReceiptKind = CentronObjectKindNumeric.OrderClass, ReceiptI3D = OrderI3D } }, null, InsertReceiptTakeoverOptions.Reference, onlyTakeoverAvailableQuantity: false, ignoreDefaultContract: true).ThrowIfError(); var deliveryList = (ReceiptDeliveryListDTO)forwardResult.Receipt; Assert.False(deliveryList.Items.Any(f => f.ArticleI3D == RoundingFixArticleI3D), "The delivery-list is not supposed to contain the rounding-fix-article."); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.Stammdat SET Wert = {RoundingFixArticleI3D} WHERE I3D = {(int)AppSettingsConst.ReceiptItemRoundingFixArticle}"); } }