Files
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
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
2026-08-26 07:43:51 +02:00

117 lines
5.0 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Centron.BusinessLogic;
using Centron.BusinessLogic.WebServices.Warehousing.Commissions;
using Centron.Data.WebServices.Sales.Receipts.DeliveryLists;
using Centron.Data.WebServices.Sales.Receipts.Orders;
using Centron.Interfaces;
using Centron.Interfaces.BL;
using Centron.Interfaces.Warehousing.Commissions;
using Centron.Tests.EndToEnd.Infrastructure;
using Centron.Tests.EndToEnd.Tests.PartListBarcodes;
using CentronSoftware.Centron.WebServices.Entities.Warehousing.Commissions;
using Xunit;
using Xunit.Abstractions;
using static Centron.Tests.EndToEnd.Tests.PartListBarcodes.PartListBarcodeTestHelper;
namespace Centron.Tests.EndToEnd.Tests.PartialCommission;
/// <summary>
/// Verifies that saving a delivery list which references a partial commission order updates the
/// commission items' <c>QuantityInDeliveryList</c> and flags the order as
/// <see cref="PartialCommissionOrderState.Delivered"/> once everything is contained in delivery lists -
/// and that the state reverts when the delivery lists no longer contains the positions (Ticket #168185).
/// </summary>
public class PartialCommissionDeliveryQuantityTest : EndToEndTest
{
public PartialCommissionDeliveryQuantityTest(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public override void Execute()
{
PartListBarcodeTestHelper.PrepareDatabase(this);
// 1. Create an order and a fully picked partial commission order for it.
var order = (ReceiptOrderDTO)SaveReceipt(CreateOrder());
var partialCommissionOrderI3D = this.CreateFullyPickedPartialCommissionOrder(order);
// 2. Forward the order into a delivery note, reference the partial commission on it and save.
var deliveryList = ForwardOrderToDeliveryList(order.I3D);
deliveryList.PartialCommissionOrderI3D = partialCommissionOrderI3D;
var savedDeliveryListI3D = SaveReceipt(deliveryList).I3D;
// 3. The commission items are now fully contained in the delivery note -> order is delivered.
this.AssertPartialCommissionOrder(
partialCommissionOrderI3D,
expectedState: PartialCommissionOrderState.Delivered,
expectFullyInDeliveryList: true);
// 4. Remove the positions from the delivery list again -> the delivery quantities and the
// state revert (back to the commissioned state).
var newDeliveryListVersion = (ReceiptDeliveryListDTO)CreateNewVersion(CentronObjectKindNumeric.DeliveryListClass, savedDeliveryListI3D);
newDeliveryListVersion.Items.Clear();
SaveReceipt(newDeliveryListVersion);
this.AssertPartialCommissionOrder(
partialCommissionOrderI3D,
expectedState: PartialCommissionOrderState.Complete,
expectFullyInDeliveryList: false);
}
private int CreateFullyPickedPartialCommissionOrder(ReceiptOrderDTO order)
{
using var session = new BLSession();
var commissionItems = order.Items
.Where(f => f.ArticleI3D != null)
.Select(f => new PartialCommissionOrderItemDTO
{
ReceiptOrderItemI3D = f.I3D,
TargetQuantity = f.QuantityComplete.GetValueOrDefault(0m),
CurrentQuantity = f.QuantityComplete.GetValueOrDefault(0m),
BarcodeRelations = new List<PartialCommissionItemToBarcodeRelationDTO>(),
})
.ToList();
var partialCommissionOrder = new PartialCommissionOrderDTO
{
ReceiptOrderI3D = order.I3D,
Caption = "Teilkommissionierung 1",
State = PartialCommissionOrderState.Incomplete,
CommissionItems = commissionItems,
};
var webServiceBL = session.GetBL<PartialCommissionOrderWebServiceBL>();
webServiceBL
.SaveOrUpdatePartialCommissionOrders(new List<PartialCommissionOrderDTO> { partialCommissionOrder }, CommonMethodsHelper.GetUser(session))
.ThrowIfError();
var saved = webServiceBL
.GetPartialCommissionOrdersByFilter(new GetPartialCommissionOrdersFilter { ReceiptOrderI3D = order.I3D })
.ThrowIfError()
.First();
return saved.I3D;
}
private void AssertPartialCommissionOrder(int partialCommissionOrderI3D, PartialCommissionOrderState expectedState, bool expectFullyInDeliveryList)
{
var partialCommissionOrder = this.WithSession(session => session.GetBL<PartialCommissionOrderWebServiceBL>()
.GetPartialCommissionOrder(partialCommissionOrderI3D)
.ThrowIfError());
Assert.NotEmpty(partialCommissionOrder.CommissionItems);
foreach (var item in partialCommissionOrder.CommissionItems)
{
var expectedQuantity = expectFullyInDeliveryList ? item.TargetQuantity : 0m;
Assert.Equal(expectedQuantity, item.QuantityInDeliveryList);
}
Assert.Equal(expectedState, partialCommissionOrder.State);
}
}