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
This commit is contained in:
Christoph Schwörer
2026-08-26 07:43:51 +02:00
parent 18edae75b6
commit f045b99a25
24664 changed files with 5846716 additions and 1 deletions
@@ -0,0 +1,116 @@
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);
}
}
@@ -0,0 +1,201 @@
using System.Collections.Generic;
using System.Linq;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Sales.Receipts;
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.BusinessLogic.WebServices.Warehousing.Commissions;
using Centron.Data.WebServices.Sales.Receipts;
using Centron.Data.WebServices.Sales.Receipts.DeliveryLists;
using Centron.Data.WebServices.Sales.Receipts.Orders;
using Centron.Interfaces;
using Centron.Interfaces.Administration.Environment;
using Centron.Interfaces.BL;
using Centron.Interfaces.Sales.Receipts.InsertReceipts;
using Centron.Interfaces.Warehousing.Commissions;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Warehousing.Commissions;
using CentronSoftware.Centron.WebServices.EntitiesWrongPlace.Sales.Receipts.DataAndResults;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.PartialCommission;
/// <summary>
/// Verifies that forwarding an order into a delivery note while referencing a partial commission order
/// never forwards more than the order position actually still holds.
///
/// A partial commission item's <c>CurrentQuantity</c> is a persisted snapshot maintained only by the
/// commissioning module. It is not recalculated when the order is changed elsewhere (e.g. the order
/// quantity is reduced below the commissioned quantity, or the order is closed). This test sets up such
/// a stale state - the order position only holds <see cref="OrderRemainingQuantity"/>, but the partial
/// commission still believes <see cref="StaleCommissionedQuantity"/> are commissioned - and asserts that
/// the forwarded quantity is clamped to the order's remaining quantity instead of over-delivering. (Ticket 165243)
/// </summary>
public class PartialCommissionForwardStaleQuantityTest : EndToEndTest
{
private const int CustomerI3D = 10026;
private const int ArticleI3D = 139;
private const decimal OrderRemainingQuantity = 2m;
private const decimal StaleCommissionedQuantity = 5m;
public PartialCommissionForwardStaleQuantityTest(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public override void Execute()
{
this.PrepareDatabase();
// 1. Create an order whose position only holds OrderRemainingQuantity (2).
var order = (ReceiptOrderDTO)this.SaveReceipt(this.CreateSingleArticleOrder(ArticleI3D, OrderRemainingQuantity));
var orderItem = order.Items.First(f => f.ArticleI3D == ArticleI3D);
// 2. Create a partial commission order whose (stale) snapshot believes StaleCommissionedQuantity (5)
// are commissioned - more than the order actually still holds.
var partialCommissionOrderI3D = this.CreateStalePartialCommissionOrder(order.I3D, orderItem.I3D);
// 3. Forward the order into a delivery note referencing that partial commission.
var deliveryList = this.ForwardOrderToDeliveryListWithPartialCommission(order.I3D, partialCommissionOrderI3D);
// 4. The forwarded quantity must be clamped to the order's remaining quantity (2), not the stale 5.
var deliveredItem = deliveryList.Items.Single(f => f.ArticleI3D == ArticleI3D);
Assert.Equal(OrderRemainingQuantity, deliveredItem.QuantityComplete.GetValueOrDefault());
}
private void PrepareDatabase()
{
// Make the article a plain article (no mandatory serial numbers / barcodes, no part list) so the
// forwarded quantity is driven by the commissioned quantity, not by a scanned barcode count or a
// part-list expansion.
this.Sql($"UPDATE dbo.ARTIK SET BarcodeScanen = 0, StkListe = 0, SNStueckliste = 0 WHERE I3D = {ArticleI3D}");
// Do not require a SEPA mandate when saving the receipt.
this.Sql("UPDATE dbo.Zahkond SET DTALastschrift = 0");
}
private ReceiptOrderDTO CreateSingleArticleOrder(int articleI3D, decimal quantity)
{
using var session = new BLSession();
var currentUser = CommonMethodsHelper.GetUser(session);
var order = (ReceiptOrderDTO)session.GetBL<ReceiptWebServiceBL>().CreateNewReceipt(
CentronObjectKindNumeric.OrderClass,
currentUser,
CustomerI3D,
new CreateReceiptData
{
IgnoreCallbacks = true,
},
addressI3D: null,
contactPersonI3D: null,
insertSalutationAndAgreement: false,
ignoreDefaultContract: true,
insertCustomerDiscount: false).ThrowIfError().Receipt;
var item = (ReceiptOrderItemDTO)session.GetBL<ReceiptItemWebServiceBL>().CreateArticleReceiptItems(
order,
isExternalArticle: false,
articleI3D,
externalArticleKind: null,
externalArticleId: null,
warehouseI3D: -1,
currentUser,
CreateArticleReceiptItemsConfig.None()).ThrowIfError().ReceiptItems.First();
item.InternalPosition = 0;
item.QuantityComplete = quantity;
order.Items = new List<ReceiptOrderItemDTO> { item };
return order;
}
private ReceiptBaseDTO SaveReceipt(ReceiptBaseDTO receipt)
{
using var session = new BLSession();
return session.GetBL<ReceiptWebServiceBL>().SaveReceipt(
receipt,
CommonMethodsHelper.GetUser(session).User,
new SaveReceiptData(),
autoLockIfNewReceipt: false,
CreatedThroughApplication.WebServices,
receiptTemplateFolderI3D: null).ThrowIfError().Receipt;
}
private int CreateStalePartialCommissionOrder(int orderI3D, int orderItemI3D)
{
using var session = new BLSession();
var partialCommissionOrder = new PartialCommissionOrderDTO
{
ReceiptOrderI3D = orderI3D,
Caption = "Teilkommissionierung (stale)",
State = PartialCommissionOrderState.Incomplete,
CommissionItems = new List<PartialCommissionOrderItemDTO>
{
new()
{
ReceiptOrderItemI3D = orderItemI3D,
TargetQuantity = StaleCommissionedQuantity,
CurrentQuantity = StaleCommissionedQuantity,
BarcodeRelations = new List<PartialCommissionItemToBarcodeRelationDTO>(),
},
},
};
var webServiceBL = session.GetBL<PartialCommissionOrderWebServiceBL>();
webServiceBL
.SaveOrUpdatePartialCommissionOrders(new List<PartialCommissionOrderDTO> { partialCommissionOrder }, CommonMethodsHelper.GetUser(session))
.ThrowIfError();
return webServiceBL
.GetPartialCommissionOrdersByFilter(new GetPartialCommissionOrdersFilter { ReceiptOrderI3D = orderI3D })
.ThrowIfError()
.First()
.I3D;
}
private ReceiptDeliveryListDTO ForwardOrderToDeliveryListWithPartialCommission(int orderI3D, int partialCommissionOrderI3D)
{
using var session = new BLSession();
return (ReceiptDeliveryListDTO)session.GetBL<ReceiptWebServiceBL>().ForwardReceipt(
CentronObjectKindNumeric.DeliveryListClass,
CommonMethodsHelper.GetUser(session).User,
new ForwardReceiptData
{
IgnoreCallbacks = true,
CreateReceiptData = new CreateReceiptData
{
IgnoreCallbacks = true,
},
CreateReceiptItemsFromExistingItemsData = new List<CreateReceiptItemsFromExistingItemsData>
{
new()
{
IgnoreCallbacks = true,
},
},
SelectedPartialCommissionOrderI3D = partialCommissionOrderI3D,
UseDeliveryAddressFromPartialCommissionOrder = false,
},
new List<ReceiptToForward>
{
new()
{
ReceiptKind = CentronObjectKindNumeric.OrderClass,
ReceiptI3D = orderI3D
},
},
receiptProjectLayoutItemI3DsToForward: null,
InsertReceiptTakeoverOptions.Reference,
onlyTakeoverAvailableQuantity: false,
ignoreDefaultContract: true).ThrowIfError().Receipt;
}
}