Files
Masterarbeit/QuellCode/CentronERP/tests/Centron.Tests.EndToEnd/TicketTests/Ticket135186/Ticket135186Tests.cs
T
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

91 lines
3.5 KiB
C#

using System.Linq;
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.Data.WebServices.Sales.Receipts.CreditVouchers;
using Centron.Interfaces;
using Centron.Interfaces.Administration.Environment;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.TicketTests.Ticket135186;
public class Ticket135186Tests : EndToEndTest
{
public Ticket135186Tests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public const int CreditVoucherI3D = 17;
public const int CreditVoucherItemI3D = 105;
public const int ArticleI3D = 115;
public override void Execute()
{
this.PrepareDatabase();
// The problem in this ticket happens in the following situation
// You have a credit-voucher with a position with OnlyPriceValue = true
// When you created the credit-voucher, everything worked correctly, only the price value is used, no quantities are booked
// But if you remove that position from the credit-voucher, then it would book 10 quantities back into the warehouse
// That is incorrect, it shouldn't book anything
this.VerifyArticleQuantity("Before");
this.ChangeArticleQuantity(10); // Increase the quantity from 1 to 10, just to make sure that the article quantity doesn't change
this.VerifyArticleQuantity("IncreasedTo10");
this.ChangeArticleQuantity(5); // Reduce the quantity from 10 to 5, the article quantity should still not have changed
this.VerifyArticleQuantity("ReducingTo5");
this.ChangeArticleQuantity(null); // Remove the position from the credit-voucher, the article quantity should not change, but it did in this ticket
this.VerifyArticleQuantity("RemovedPosition");
}
private void PrepareDatabase()
{
this.Sql("ALTER TABLE GutKopf DROP COLUMN LcmStatus");
this.Sql($"UPDATE dbo.GutPos SET Abbuchung = 1 WHERE I3D = {CreditVoucherItemI3D}");
this.Sql($"UPDATE dbo.ARTIK SET Abbuchung = 'J' WHERE I3D = {ArticleI3D}");
}
private void VerifyArticleQuantity(string name)
{
this.Verifier.VerifySql(name, "SELECT A.cnt FROM dbo.cvw_ArticleCount A WHERE A.ArtikelI3D = 115 AND A.LagerI3D = -1");
}
private void ChangeArticleQuantity(int? newQuantity)
{
var newVersionData = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
CentronObjectKindNumeric.CreditVoucherClass,
CreditVoucherI3D,
version: null,
newContactPersonI3D: null,
this.GetLoggedInUser().User,
new CreateNewVersionData
{
IgnoreCallbacks = true
})).ThrowIfError();
var creditVoucher = (ReceiptCreditVoucherDTO)newVersionData.Receipt;
var item = creditVoucher.Items.First(f => f.ArticleI3D == ArticleI3D);
if (newQuantity is null)
{
creditVoucher.Items.Remove(item);
}
else
{
item.QuantityComplete = newQuantity.Value;
}
var saveData = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().SaveReceipt(
creditVoucher,
this.GetLoggedInUser().User,
new SaveReceiptData(),
autoLockIfNewReceipt: false,
CreatedThroughApplication.WebServices,
receiptTemplateFolderI3D: null)).ThrowIfError();
}
}