using System.Collections.Generic; using Centron.BusinessLogic; 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.DeliveryLists; using Centron.Data.WebServices.Sales.Receipts.Invoices; 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.Ticket145580; public class Ticket145580Tests : EndToEndTest { public Ticket145580Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int TimerI3D = 2397; public const int HelpdeskI3D = 1301; public const string CrmProjectNumber = "80005"; public override void Execute() { // In this ticket the problem was, that the project number was taken from the ticket // if you billed a timer of that ticket. this.PrepareDatabase(); var receipt = (ReceiptDeliveryListDTO)this.CreateReceipt(TimerI3D, new TimerBillingSettingsDTO { ReceiptKind = CentronObjectKindNumeric.DeliveryListClass }); Assert.Equal(CrmProjectNumber, receipt.ProjectNumber); } private void PrepareDatabase() { this.Sql($"UPDATE dbo.hlpdsk_requests SET ProjectNumber = '{CrmProjectNumber}' WHERE I3D = {HelpdeskI3D}"); } private ReceiptBaseDTO CreateReceipt(int timerI3D, TimerBillingSettingsDTO settings) { using (var session = new BLSession()) { var user = session.GetBL().GetAppUser(f => f.I3D == 11); var invoiceResult = session.GetBL().CreateNewReceiptForHelpdekTimers([timerI3D], settings, user); return invoiceResult.ThrowIfError(); } } }