using Centron.BusinessLogic; using Centron.BusinessLogic.Administration.Settings; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Interfaces; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.UpdatePurchasePriceInReceipts; public class UpdatePurchasePriceInReceiptTests : EndToEndTest { public UpdatePurchasePriceInReceiptTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.PrepareDatabase(); this.TestReceipt(CentronObjectKindNumeric.OfferClass, 6691); this.TestReceipt(CentronObjectKindNumeric.OfferClass, 6675); this.TestReceipt(CentronObjectKindNumeric.OfferClass, 6716); this.TestReceipt(CentronObjectKindNumeric.OfferClass, 6716, suffix:"SecondTime"); } private void PrepareDatabase() { // Enable setting for "secondary warehouses have own purchase-prices" this.Sql($"UPDATE dbo.Stammdat SET Wert = 1 WHERE I3D = {(int)AppSettingsConst.SelfSecondstockPurchasePrice}"); // Enable "warehouse has own purchase-price" for warehouse 7 (which is used a lot in Offer 6691) this.Sql($"UPDATE dbo.Warehouses SET IsOwnPurchasePriceActive = 1 WHERE I3D = 7"); } private void TestReceipt(CentronObjectKindNumeric receiptKind, int receiptI3D, string suffix = "") { using (var session = new BLSession()) { var result = session.GetBL().UpdatePurchasePriceInReceipt( receiptI3D, receiptKind, saveUpdatedReceipt: true, this.GetLoggedInUser().User); this.Verifier.Verify($"{receiptKind}_{receiptI3D}_{suffix}", result); } } }