using System.Collections.Generic; 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.Data.WebServices.Sales.Receipts.Invoices; using Centron.Interfaces; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Sales.CustomerAssets.TimerBilling; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket119415 { public class Ticket119415Test : EndToEndTest { public Ticket119415Test(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { this.Verifier.Settings.IgnoreProperty(f => f.BalanceID); } public override void Execute() { // We used to ignore the timer-type in timer-billing when billing special-articles, but as of Ticket 119415 that is not quite correct // If the timer doesn't have the checkbox set for special-articles, then we should also ignore all special-articles that are in the table this.PrepareDatabase(); // This timer has special-articles, but timer-type NULL this.CreateReceipt(7454); // This timer has special-articles, and a timer-type this.CreateReceipt(10509); } private void PrepareDatabase() { this.Sql("UPDATE dbo.hlpdsk_timer_typen SET WithAddressSpecialArticle = 0, WithCustomerSpecialArticle = 0"); this.Sql($"UPDATE dbo.Stammdat SET WertText = 'g' WHERE I3D = {(int)AppSettingsConst.HelpdeskTimerStartTimeFormat}"); this.Sql($"UPDATE dbo.Stammdat SET WertText = 'g' WHERE I3D = {(int)AppSettingsConst.HelpdeskTimerEndTimeFormat}"); } private ReceiptBaseDTO CreateReceipt(int timerI3D) { var timerI3Ds = new List { timerI3D }; var settings = new TimerBillingSettingsDTO { InsertHelpdeskDescription = true, InsertHelpdeskShortDescription = true, InsertTimerText = true, InsertTimerTime = true, InsertTheFollowingAreTimersFromHelpdeskText = true, Sorting = Interfaces.Sales.Receipts.TimerBilling.TimerSorting.ChronologicalUp, ReceiptKind = CentronObjectKindNumeric.InvoiceClass, AdditionalText = "Hier mein Text!" }; using (var session = new BLSession()) { var timers = session.GetBL().SearchTimers(new TimerBillingFilter { HelpdeskTimerI3Ds = timerI3Ds }); this.Verifier.Verify($"TimerBillingSearch_{timerI3D}", timers); var user = session.GetBL().GetAppUser(f => f.I3D == 11); var invoiceResult = session.GetBL().CreateNewReceiptForHelpdekTimers(timerI3Ds, settings, user); this.Verifier.Verify($"TimerI3D_{timerI3D}", invoiceResult); return invoiceResult.Data; } } } }