using System.Collections.Generic; using Centron.BusinessLogic; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.Sales.Receipts.DataAndResults; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Data.WebServices.Sales.Receipts; using Centron.Data.WebServices.Sales.Receipts.Invoices; using Centron.Interfaces; using Centron.Interfaces.Administration.Environment; 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.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket121492 { public class Ticket121492Test : EndToEndTest { public Ticket121492Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { this.Verifier.Settings.IgnoreProperty(f => f.CentronVersion); } public override void Execute() { // The problem in Ticket 121492 is: // No ReceiptLog-entry is created when a receipt is closed because it got forwarded const int OrderI3D = 4382; var invoice = this.ForwardOrderToInvoice(OrderI3D); this.SaveInvoice(invoice); this.VerifyReceiptLogEntryGotCreated(OrderI3D); } private ReceiptInvoiceDTO ForwardOrderToInvoice(int orderI3D) { using (var session = new BLSession()) { var user = session.GetBL().GetAppUser(f => f.I3D == 11); var result = session.GetBL().ForwardReceipt( CentronObjectKindNumeric.InvoiceClass, user, new ForwardReceiptData { IgnoreCallbacks = true, CreateReceiptData = new CreateReceiptData { IgnoreCallbacks = true, }, CreateReceiptItemsFromExistingItemsData = new List { new() { IgnoreCallbacks = true, UsePickedQuantityFromItems = new List { new UsePickedQuantityFromItem { ReceiptKind = CentronObjectKindNumeric.OrderClass, ReceiptI3D = 4382, ReceiptItemI3D = 7337, UseOnlyPickedQuantity = false }, new UsePickedQuantityFromItem { ReceiptKind = CentronObjectKindNumeric.OrderClass, ReceiptI3D = 4382, ReceiptItemI3D = 7338, UseOnlyPickedQuantity = false } } }, }, }, new List { new() { ReceiptKind = CentronObjectKindNumeric.OrderClass, ReceiptI3D = orderI3D, ReceiptItemI3Ds = null } }, null, InsertReceiptTakeoverOptions.Reference, onlyTakeoverAvailableQuantity: false, ignoreDefaultContract: true).ThrowIfError(); return (ReceiptInvoiceDTO)result.Receipt; } } private void SaveInvoice(ReceiptInvoiceDTO invoice) { using (var session = new BLSession()) { var user = session.GetBL().GetAppUser(f => f.I3D == 11); session.GetBL().SaveReceipt( invoice, user, new SaveReceiptData { IgnoreCallbacks = true }, autoLockIfNewReceipt: false, CreatedThroughApplication.WebServices, receiptTemplateFolderI3D: null).ThrowIfError(); } } private void VerifyReceiptLogEntryGotCreated(int orderI3D) { using (var session = new BLSession()) { var logs = session.GetBL().GetLogs(orderI3D, CentronObjectKindNumeric.OrderClass); this.Verifier.Verify("ReceiptLogs", logs); } } } }