using System.Collections.Generic; using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Administration.Settings; using Centron.BusinessLogic.EmployeeArea; using Centron.BusinessLogic.Sales.CustomerAssets.TimerBilling; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Data.WebServices.Sales.Receipts; using Centron.Interfaces; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Sales.CustomerAssets.TimerBilling; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket140509; public class Ticket140509Tests : EndToEndTest { public Ticket140509Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } private const int HelpdeskNumber = 12504; public override void Execute() { // In this ticket the problem was that the TimerBillingSettingsDTO.InsertTimerTime setting // was not respected for special-articles (remote or drive articles) // So the timers itself would not have their time, but the special-articles would have their time // That was incorrect, the setting should be respected in both cases this.PrepareDatabase(); var timerI3Ds = this.FindTimers(HelpdeskNumber); var settings = new TimerBillingSettingsDTO { InsertHelpdeskDescription = false, InsertHelpdeskShortDescription = false, InsertTimerText = true, InsertTimerTime = false, // The important setting InsertTheFollowingAreTimersFromHelpdeskText = true, Sorting = Interfaces.Sales.Receipts.TimerBilling.TimerSorting.ChronologicalUp, ReceiptKind = CentronObjectKindNumeric.InvoiceClass, AdditionalText = "Hier mein Text!" }; var invoice = this.CreateReceipt(timerI3Ds, settings); this.Verifier.Verify("Invoice", invoice); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.hlpdsk_timer SET Geplant = 0 WHERE RequestI3D = (SELECT I3D FROM dbo.hlpdsk_requests WHERE Nummer = {HelpdeskNumber})"); this.WithSession(s => { var bl = s.GetBL(); var settingsForUpdate = bl.GetSettingsForUpdate(AppSettingsConst.HelpdeskTimerStartTimeFormat, AppSettingsConst.HelpdeskTimerEndTimeFormat); settingsForUpdate.UpdateString(AppSettingsConst.HelpdeskTimerStartTimeFormat, "HH:mm"); settingsForUpdate.UpdateString(AppSettingsConst.HelpdeskTimerEndTimeFormat, "HH:mm"); settingsForUpdate.SaveSettings(); }); } private List FindTimers(int helpdeskNumber) { using (var session = new BLSession()) { var filter = new TimerBillingFilter { HelpdeskNumber = helpdeskNumber }; var timers = session.GetBL().SearchTimers(filter); return timers.Select(f => f.I3D).ToList(); } } private ReceiptBaseDTO CreateReceipt(List timerI3Ds, TimerBillingSettingsDTO settings) { using (var session = new BLSession()) { var user = session.GetBL().GetAppUser(f => f.I3D == 11); var invoiceResult = session.GetBL().CreateNewReceiptForHelpdekTimers(timerI3Ds, settings, user); return invoiceResult.Data; } } }