using System.Linq; using Centron.BusinessLogic.Sales.Receipts.DataAndResults; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Extensions; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket138750; public class Ticket138750Tests : EndToEndTest { public Ticket138750Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int OfferTemplateI3D = 5503; public const int ArticleI3D = 122; public const decimal ArticlePrice = 5; public const decimal VolumePrice = 20; public const int CustomerI3D = 10000; public override void Execute() { // In this ticket the problem was: // - you have a receipt-template // - in there is a article // - that article has a volume-price // - you use the receipt-template for a new receipt // - and you say "I want to update the prices" // => the volume-price was not used this.PrepareDatabase(); var copiedReceipt = this.WithSession(s => s.GetBL().CopyReceipt( CentronObjectKindNumeric.OfferClass, this.GetLoggedInUser().User, new CopyReceiptData { TakeoverOption = ReceiptItemTakeoverOption.None, IgnoreCallbacks = true, CreateReceiptData = new() { IgnoreCallbacks = true, }, CreateReceiptItemsFromExistingItemsData = new() { IgnoreCallbacks = true, }, }, OfferTemplateI3D, CustomerI3D, addressI3D: null, contactPersonI3D: null)).ThrowIfError(); var item = copiedReceipt.Receipt.GetReceiptItems().Single(f => f.ArticleI3D == ArticleI3D); // Should be volume-price now Assert.Equal(VolumePrice, item.BasePrice); } private void PrepareDatabase() { // Update offer-receipt-template to have the article with the volume-price this.Sql($"UPDATE dbo.AngPos SET ArtikelI3D = {ArticleI3D} WHERE AngKopfI3D = {OfferTemplateI3D} AND ArtikelI3D IS NOT NULL"); // Make volume-prices a bit nicer this.Sql($"UPDATE dbo.ArtikStaffelpreise SET VK_1 = {VolumePrice}, VK_2 = {VolumePrice}, VK_3 = {VolumePrice}, VK_4 = {VolumePrice} WHERE I3D = 3"); // And give the article some prices too this.Sql($"UPDATE dbo.Artik SET VK_1 = {ArticlePrice}, VK_2 = {ArticlePrice}, VK_3 = {ArticlePrice}, VK_4 = {ArticlePrice} WHERE I3D = {ArticleI3D}"); } }