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
201 lines
8.2 KiB
C#
201 lines
8.2 KiB
C#
using System.Linq;
|
|
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.Sales.Receipts;
|
|
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
|
|
using Centron.BusinessLogic.Sales.Receipts.Internal;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.BL;
|
|
using Centron.Interfaces.Sales.Receipts;
|
|
using Centron.Interfaces.Sales.Receipts.Invoices;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Centron.Tests.EndToEnd.Infrastructure.Verifier;
|
|
using CentronSoftware.Centron.WebServices.Entities.Sales.Receipts;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.TicketTests.Ticket145005;
|
|
|
|
public class Ticket145005Tests : EndToEndTest
|
|
{
|
|
public Ticket145005Tests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
this.Verifier.Settings.IgnoreColumn("GroupID");
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase();
|
|
|
|
this.OwnServiceArticlesOnly();
|
|
this.SingleServiceArticleEmployee();
|
|
this.MultipleServiceArticleEmployee();
|
|
this.ComplexCase();
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
using var session = new BLSession();
|
|
|
|
// We have to create a test-schema, so the new schema-based provision is enabled
|
|
session.GetBL<ReceiptProvisionSchemaWebServiceBL>().SaveProvisionSchema(new ReceiptProvisionSchemaDTO
|
|
{
|
|
Name = "Test-Schema"
|
|
}, this.GetLoggedInUser());
|
|
}
|
|
|
|
private void OwnServiceArticlesOnly()
|
|
{
|
|
const int InvoiceI3D = 8;
|
|
|
|
// This invoice has a bunch of different service-articles
|
|
// Article 8 (SERMP) -> Employee 24 -> 5 * 125 € = 625 €
|
|
// Article 7 (SERHM-GA) -> Employee 23 -> 3 * 0 € = 0 €
|
|
// Article 6 (SERHM-KU) -> Employee 23 -> 8 * 0 € = 0 €
|
|
// Article 11 (SERMAHE) -> Employee 25 -> 6 * 125 € = 750 €
|
|
// Article 12 (SERMAHE-KU) -> Employee 25 -> 2 * 0 € = 0 €
|
|
//
|
|
// That means, the provision should be:
|
|
// Employee 24 -> 625 €
|
|
// Employee 23 -> 0 €
|
|
// Employee 25 -> 750 €
|
|
|
|
using var session = new BLSession();
|
|
|
|
var invoice = (IReceiptInvoice)session.GetBL<ReceiptBL>().GetReceiptByI3D(CentronObjectKindNumeric.InvoiceClass, InvoiceI3D);
|
|
invoice.Provision.Clear();
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.FixedEmployee,
|
|
EmployeeI3D = 24,
|
|
Source = ReceiptProvisionSource.OwnServiceArticlesOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.FixedEmployee,
|
|
EmployeeI3D = 23,
|
|
Source = ReceiptProvisionSource.OwnServiceArticlesOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.FixedEmployee,
|
|
EmployeeI3D = 25,
|
|
Source = ReceiptProvisionSource.OwnServiceArticlesOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
|
|
var saveReceiptBuilder = new SaveReceiptResultBuilder();
|
|
session.GetBL<ReceiptProvisionBL>().SaveProvision(invoice, null, new SaveReceiptData { IgnoreCallbacks = true }, saveReceiptBuilder);
|
|
saveReceiptBuilder.GetResult().ThrowIfError();
|
|
|
|
this.Verifier.VerifyTable("OwnServiceArticlesOnly", "ReceiptProvisionItems", $"ReceiptI3D = {InvoiceI3D} AND ReceiptKind = 4");
|
|
}
|
|
|
|
private void SingleServiceArticleEmployee()
|
|
{
|
|
const int InvoiceI3D = 6565;
|
|
|
|
// This invoice has a single service-articles
|
|
// Article 5 (SERHM) -> Employee 23 -> 1 * 20 € = 20 €
|
|
//
|
|
// That means, the provision should be:
|
|
// Employee 23 -> 20 €
|
|
|
|
using var session = new BLSession();
|
|
|
|
var invoice = (IReceiptInvoice)session.GetBL<ReceiptBL>().GetReceiptByI3D(CentronObjectKindNumeric.InvoiceClass, InvoiceI3D);
|
|
invoice.Provision.Clear();
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.ServiceArticleEmployee,
|
|
EmployeeI3D = null,
|
|
Source = ReceiptProvisionSource.OwnServiceArticlesOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
|
|
var saveReceiptBuilder = new SaveReceiptResultBuilder();
|
|
session.GetBL<ReceiptProvisionBL>().SaveProvision(invoice, null, new SaveReceiptData { IgnoreCallbacks = true }, saveReceiptBuilder);
|
|
saveReceiptBuilder.GetResult().ThrowIfError();
|
|
|
|
this.Verifier.VerifyTable("SingleServiceArticleEmployee", "ReceiptProvisionItems", $"ReceiptI3D = {InvoiceI3D} AND ReceiptKind = 4");
|
|
}
|
|
|
|
private void MultipleServiceArticleEmployee()
|
|
{
|
|
const int InvoiceI3D = 8;
|
|
|
|
// This invoice has a bunch of different service-articles
|
|
// Article 8 (SERMP) -> Employee 24 -> 5 * 125 € = 625 €
|
|
// Article 7 (SERHM-GA) -> Employee 23 -> 3 * 0 € = 0 €
|
|
// Article 6 (SERHM-KU) -> Employee 23 -> 8 * 0 € = 0 €
|
|
// Article 11 (SERMAHE) -> Employee 25 -> 6 * 125 € = 750 €
|
|
// Article 12 (SERMAHE-KU) -> Employee 25 -> 2 * 0 € = 0 €
|
|
//
|
|
// That means, the provision should be:
|
|
// Employee 24 -> 625 €
|
|
// Employee 23 -> 0 €
|
|
// Employee 25 -> 750 €
|
|
|
|
using var session = new BLSession();
|
|
|
|
var invoice = (IReceiptInvoice)session.GetBL<ReceiptBL>().GetReceiptByI3D(CentronObjectKindNumeric.InvoiceClass, InvoiceI3D);
|
|
invoice.Provision.Clear();
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.ServiceArticleEmployee,
|
|
Source = ReceiptProvisionSource.OwnServiceArticlesOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
|
|
var saveReceiptBuilder = new SaveReceiptResultBuilder();
|
|
session.GetBL<ReceiptProvisionBL>().SaveProvision(invoice, null, new SaveReceiptData { IgnoreCallbacks = true }, saveReceiptBuilder);
|
|
saveReceiptBuilder.GetResult().ThrowIfError();
|
|
|
|
this.Verifier.VerifyTable("MultipleServiceArticleEmployee", "ReceiptProvisionItems", $"ReceiptI3D = {InvoiceI3D} AND ReceiptKind = 4");
|
|
|
|
Assert.Single(invoice.Provision.Where(f => string.IsNullOrWhiteSpace(f.GroupID) is false).GroupBy(f => f.GroupID));
|
|
}
|
|
|
|
private void ComplexCase()
|
|
{
|
|
// Yep, we use this one again, but keep the previously saved provision, to also test the GroupID-Input case
|
|
const int InvoiceI3D = 8;
|
|
|
|
using var session = new BLSession();
|
|
|
|
var invoice = (IReceiptInvoice)session.GetBL<ReceiptBL>().GetReceiptByI3D(CentronObjectKindNumeric.InvoiceClass, InvoiceI3D);
|
|
Assert.Equal(3, invoice.Provision.Count);
|
|
|
|
invoice.Provision.Add(new ReceiptProvision
|
|
{
|
|
Receiver = ReceiptProvisionReceiver.FixedEmployee,
|
|
EmployeeI3D = 13,
|
|
Source = ReceiptProvisionSource.ServiceOnly,
|
|
Value = ReceiptProvisionValue.Sales,
|
|
SharePercentage = 100,
|
|
ProvisionPercentage = 100,
|
|
});
|
|
|
|
var saveReceiptBuilder = new SaveReceiptResultBuilder();
|
|
session.GetBL<ReceiptProvisionBL>().SaveProvision(invoice, null, new SaveReceiptData { IgnoreCallbacks = true }, saveReceiptBuilder);
|
|
saveReceiptBuilder.GetResult().ThrowIfError();
|
|
|
|
this.Verifier.VerifyTable("ComplexCase", "ReceiptProvisionItems", $"ReceiptI3D = {InvoiceI3D} AND ReceiptKind = 4");
|
|
|
|
Assert.Single(invoice.Provision, f => string.IsNullOrWhiteSpace(f.GroupID));
|
|
Assert.Single(invoice.Provision.Where(f => string.IsNullOrWhiteSpace(f.GroupID) is false).GroupBy(f => f.GroupID));
|
|
}
|
|
} |