QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
170 lines
6.4 KiB
C#
170 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Administration.Company;
|
|
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
|
|
using Centron.BusinessLogic.WebServices.Administration.Company;
|
|
using Centron.BusinessLogic.WebServices.Administration.MasterData;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts;
|
|
using Centron.Data.WebServices.Administration.Company;
|
|
using Centron.Data.WebServices.Administration.MandatoryArea;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Interfaces.Sales.Receipts.InsertReceipts;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using CentronSoftware.Centron.WebServices.Entities.BranchArea;
|
|
using CentronSoftware.Centron.WebServices.EntitiesWrongPlace.Sales.Receipts.DataAndResults;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.TicketTests.Ticket143661;
|
|
|
|
public class Ticket143661Tests : EndToEndTest
|
|
{
|
|
public Ticket143661Tests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
public const int DeliveryListI3D = 5176;
|
|
public const int CustomerI3D = 10000;
|
|
public const int CurrentInvoiceNumber = 9999000;
|
|
|
|
public override void Execute()
|
|
{
|
|
// The issue in this ticket is as follows:
|
|
// 1. There's a delivery list in the main branch, with a number according to main-branch number-groups
|
|
// 2. A user from a different branch, which uses different number-groups, forwards the delivery list to an invoice
|
|
// 3. The invoice keeps the BranchI3D and BranchOrigin from the delivery list (good!)
|
|
// 5. However, the invoice number was incorrect, as it incorrectly used the user's branch
|
|
this.PrepareDatabase();
|
|
|
|
this.TestNewInvoice();
|
|
this.TestForwardDeliveryList();
|
|
}
|
|
|
|
private void TestNewInvoice()
|
|
{
|
|
var invoice = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().CreateNewReceipt(
|
|
CentronObjectKindNumeric.InvoiceClass,
|
|
this.GetLoggedInUser(),
|
|
CustomerI3D,
|
|
new CreateReceiptData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
addressI3D: null,
|
|
contactPersonI3D: null,
|
|
insertSalutationAndAgreement: false,
|
|
ignoreDefaultContract: false,
|
|
insertCustomerDiscount: false)).ThrowIfError().Receipt;
|
|
|
|
Assert.Equal(CurrentInvoiceNumber + 1, invoice.Number);
|
|
}
|
|
|
|
private void TestForwardDeliveryList()
|
|
{
|
|
var invoice = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().ForwardReceipt(
|
|
CentronObjectKindNumeric.InvoiceClass,
|
|
this.GetLoggedInUser().User,
|
|
new ForwardReceiptData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
CreateReceiptData = new CreateReceiptData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
CreateReceiptItemsFromExistingItemsData = new List<CreateReceiptItemsFromExistingItemsData>
|
|
{
|
|
new CreateReceiptItemsFromExistingItemsData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
},
|
|
},
|
|
new List<ReceiptToForward>
|
|
{
|
|
new ReceiptToForward
|
|
{
|
|
ReceiptKind = CentronObjectKindNumeric.DeliveryListClass,
|
|
ReceiptI3D = DeliveryListI3D,
|
|
},
|
|
},
|
|
null,
|
|
InsertReceiptTakeoverOptions.Reference,
|
|
onlyTakeoverAvailableQuantity: false,
|
|
ignoreDefaultContract: true)).ThrowIfError().Receipt;
|
|
|
|
// The Invoice should NOT have a number from that new number-group
|
|
// Because the delivery-list was created for the main-branch, and thus it should get a number from the main-branch number-groups
|
|
Assert.NotEqual(CurrentInvoiceNumber + 1, invoice.Number);
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
// We need a second branch with separate number-groups
|
|
var mandantI3D = this.CreateNewMandant();
|
|
var branchI3D = this.CreateNewBranch(mandantI3D);
|
|
var numberGroups = this.GetNumberGroups(mandantI3D, branchI3D);
|
|
|
|
var invoiceNumberGroup = numberGroups.Single(f => f.NumberKind == (int)NumberGroupEnum.Invoice);
|
|
invoiceNumberGroup.Current = CurrentInvoiceNumber;
|
|
invoiceNumberGroup.Interval = 1;
|
|
|
|
this.WithSession(s => s.GetBL<BranchWebServiceBL>().SaveNumberGroups(numberGroups).ThrowIfError());
|
|
|
|
// And now we need to assign the current user to that branch
|
|
this.Sql($"UPDATE dbo.Personal SET FilialI3D = {branchI3D} WHERE I3D = (SELECT Personal FROM dbo.Sichbenu WHERE I3D = 11)"); // Is the default user from this.GetLoggedInUser()
|
|
}
|
|
|
|
private int CreateNewMandant()
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var newMandant = new MandatoryExtendedDTO
|
|
{
|
|
Mandator = "Ticket 143661",
|
|
State = 1
|
|
};
|
|
|
|
var mandant = session.GetBL<MandatorWebServiceBL>().SaveMandatoryExtended(newMandant).ThrowIfError();
|
|
|
|
return mandant.I3D;
|
|
}
|
|
}
|
|
|
|
private int CreateNewBranch(int mandantI3D)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var country = session.GetBL<CountryWebServiceBL>().GetDefaultCountry();
|
|
var federalState = session.GetBL<FederalStateWebServiceBL>().GetFederalStates().FirstOrDefault();
|
|
|
|
var newBranch = new BranchDTO
|
|
{
|
|
Name = "Branch for Ticket 143661",
|
|
MandatorI3D = mandantI3D,
|
|
CountryI3D = country.I3D,
|
|
FederalState = federalState,
|
|
CreatedDate = DateTime.Now,
|
|
IsDefault = 0,
|
|
Status = 1,
|
|
};
|
|
|
|
var branch = session.GetBL<BranchWebServiceBL>().SaveBranchDetails(newBranch).ThrowIfError();
|
|
|
|
return branch.I3D;
|
|
}
|
|
}
|
|
|
|
private List<NumberGroupDTO> GetNumberGroups(int mandantI3D, int branchI3D)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
session.GetBL<MandatorWebServiceBL>().CreateNumberGroups(mandantI3D, branchI3D).ThrowIfError();
|
|
|
|
return session.GetBL<BranchWebServiceBL>().GetNumberGroupsForBranch(mandantI3D, branchI3D).ThrowIfError().ToList();
|
|
}
|
|
}
|
|
} |