using System; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Sales.Receipts; using Centron.BusinessLogic.WebServices.Sales.CustomerAssets.TimerBilling; using Centron.BusinessLogic.WebServices.Sales.Support; using Centron.Data.Entities.Sales.Receipts.Invoices; using Centron.Data.WebServices.Sales.Support; using Centron.Interfaces; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Sales.CustomerAssets.TimerBilling; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket127691; public class Ticket127691Test : EndToEndTest { public Ticket127691Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { // In this ticket we had a exception with billing timers that came from flat-rate orders // All these tickets are about this issue: // Ticket 127691, Ticket 127397, Ticket 127699, Ticket 127747, Ticket 127785 this.PrepareDatabase(); using var session = new BLSession(); var timers = session.GetBL().SearchTimers(new TimerBillingFilter { HelpdeskNumber = 12499, ShowFlatRateHelpdesks = true}); Assert.Single(timers); // This is where the bug happens, an exception gets thrown var settings = new TimerBillingSettingsDTO { ReceiptKind = CentronObjectKindNumeric.InvoiceClass }; var receiptResult = session.GetBL().CreateNewReceiptForHelpdekTimers(timers.Select(f => f.I3D).ToList(), settings, this.GetLoggedInUser().User); Assert.NotNull(receiptResult); Assert.Equal(ResultStatus.Success, receiptResult.Status); } private void PrepareDatabase() { // Sadly there isn't a single flat-rate timer in the database // But there is a flat-rate ticket (with I3D 10485), so lets add a timer to it using var session = new BLSession(); var savedTimer = session.GetBL().SaveHelpdeskTimer(new HelpdeskTimerDTO { HelpdeskI3D = 10485, Calculable = true, Start = new DateTime(2020, 1, 1, 10, 0, 0), Stop = new DateTime(2020, 1, 1, 11, 0, 0), Timer = 3600, ArticleI3D = 94, ExternalNote = "Problemsuche", InternalNote = "Problemsuche Intern", }, this.GetLoggedInUser()); } }