using Centron.BusinessLogic; using Centron.BusinessLogic.WebServices.Sales.Receipts; using Centron.Interfaces.Administration.Environment; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.TicketTests.Ticket133507; public class Ticket133507Tests : EndToEndTest { public Ticket133507Tests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public const int InvoiceI3D = 219; public override void Execute() { // In this ticket there was a problem cancelling a contract-invoice that had Nachberechnung = 2 // So we setup Invoice 219 to have Nachberechnung = 2, and try to cancel it this.PrepareDatabase(); using var session = new BLSession(); var cancelResult = session.GetBL().CancelInvoice(InvoiceI3D, CreatedThroughApplication.WebServices, this.GetLoggedInUser().User); Assert.Equal(ResultStatus.Success, cancelResult.Status); } private void PrepareDatabase() { // Drop the stupid column that shouldn't even be there this.Sql("ALTER TABLE RechKopf DROP COLUMN LcmStatus"); // The invoice is exported already. Reset it so we can cancel the invoice this.Sql($"DELETE FROM dbo.PORTRECH WHERE AnlageI3D = {InvoiceI3D} AND Art = 4"); // And now, we set the NachBerechnung to 2, to get the error this.Sql($"UPDATE dbo.VertragRechKopfZuordnung SET NachBerechnung = 2 WHERE RechKopfI3D = {InvoiceI3D}"); } }