using System.Collections.Generic; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.WebServices.Sales.Receipts.ReceiptSearch; using Centron.Data.Entities.Administration.Logins; using Centron.Data.WebServices.Sales.Receipts.ReceiptSearch; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Interfaces.Sales.Receipts.ReceiptSearch; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket129019; public class Ticket129019Tests : EndToEndTest { public Ticket129019Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } private const int InvoiceNumber = 40221; public override void Execute() { this.PrepareDatabase(); // The problem in this ticket is, that you got duplicate receipts from SearchReceipts // This happened, when you had a Projectnumber of 0, and multiple CRM-Projects with that number var invoices = this.GetInvoices(); Assert.Single(invoices); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.RechKopf SET ProjNr = 0 WHERE Nummer = {InvoiceNumber}"); } private List GetInvoices() { using var session = new BLSession(); var user = session.GetBL().GetAppUser(f => f.I3D == 11); var filter = new ReceiptSearchFilter { ReceiptKinds = new List { CentronObjectKindNumeric.InvoiceClass }, IncludeClosedReceipts = true, }; var result = session.GetBL().SearchReceipts(new LoggedInUser(user), filter, 1, int.MaxValue).ThrowIfError(); return result.Result .Where(f => f.Number == InvoiceNumber) .ToList(); } }