using Centron.BusinessLogic; 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.EntitiesWrongPlace.Sales.Receipts.DataAndResults; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.CopyReceipt; public class CopyReceiptTests : EndToEndTest { public CopyReceiptTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } private const int OfferI3D = 6643; private const int NewCustomerI3D = 10020; public override void Execute() { this.PrepareDatabase(); this.ExecuteMatrix(new [] { true, false }, (takeoverPrice) => { using var session = new BLSession(); var copy = session.GetBL().CopyReceipt( CentronObjectKindNumeric.OfferClass, this.GetLoggedInUser().User, new CopyReceiptData { IgnoreCallbacks = true, TakeoverOption = takeoverPrice ? ReceiptItemTakeoverOption.TakeoverArticlePrice : ReceiptItemTakeoverOption.None, CreateReceiptData = new CreateReceiptData { IgnoreCallbacks = true, }, CreateReceiptItemsFromExistingItemsData = new CreateReceiptItemsFromExistingItemsData { IgnoreCallbacks = true, }, }, OfferI3D, NewCustomerI3D, addressI3D: null, contactPersonI3D: null).ThrowIfError(); this.Verifier.Verify($"CopyReceipt_TakeoverPrice_{takeoverPrice}", copy.Receipt); }); } private void PrepareDatabase() { // Set the price to 100, so in the case where we don't takeover the price, we get the freshly calculated one this.Sql($"UPDATE dbo.AngPos SET VKBasisWert = 100 WHERE AngKopfI3D = {OfferI3D} AND VKKalk IS NOT NULL"); } }