Files
Masterarbeit/QuellCode/CentronERP/tests/Centron.Tests.EndToEnd/Tests/ContractSpecialPrices/ContractSpecialPricesTests.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
4.0 KiB
C#

using Centron.BusinessLogic;
using Centron.BusinessLogic.Sales.CustomerAssets.Contracts;
using Centron.BusinessLogic.Sales.Receipts.Internal;
using Centron.Data.Entities.Sales.CustomerAssets.Contracts;
using Centron.Data.Entities.Sales.Receipts.Articles;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.Tests.ContractSpecialPrices
{
public class ContractSpecialPricesTests : EndToEndTest
{
public ContractSpecialPricesTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
private const int ArticleI3D = 4352;
private const int ContractI3D = 30;
private const decimal DefaultSellPrice = 200;
private const decimal DefaultRecommendedSellPrice = 300;
private const decimal DefaultPurchasePrice = 100;
private const decimal DefaultListPrice = 300;
private const decimal ChangeValue = 50; // 50 €, or 50 % surcharge, depending on the ReceiptItemPriceBL.ContractSpecialPriceChangeKind of the contract-special-price
public override void Execute()
{
var priceKindInputs = new[]
{
ReceiptItemPriceBL.ContractSpecialPriceKind.FixedPrice,
ReceiptItemPriceBL.ContractSpecialPriceKind.ChangePurchasePrice,
ReceiptItemPriceBL.ContractSpecialPriceKind.ChangeRecommendedSellPrice,
ReceiptItemPriceBL.ContractSpecialPriceKind.ChangeSellPrice,
ReceiptItemPriceBL.ContractSpecialPriceKind.ChangeListPrice
};
var changeKindInputs = new[]
{
ReceiptItemPriceBL.ContractSpecialPriceChangeKind.Fixed,
ReceiptItemPriceBL.ContractSpecialPriceChangeKind.Percentage
};
this.ExecuteMatrix(priceKindInputs, changeKindInputs, (priceKind, changeKind) =>
{
this.PrepareDatabase(priceKind, changeKind);
this.CalculateArticlePrice($"PriceKind_{priceKind}_ChangeKind_{changeKind}");
});
}
private void CalculateArticlePrice(string name)
{
var fakeArticle = new SearchedArticle
{
I3D = ArticleI3D,
IsExternalArticle = false,
SellPrice1 = DefaultSellPrice,
SellPrice2 = DefaultSellPrice,
SellPrice3 = DefaultSellPrice,
SellPrice4 = DefaultSellPrice,
RecommendedSellPrice = DefaultRecommendedSellPrice,
ListPrice = DefaultListPrice,
PurchasePrice = DefaultPurchasePrice
};
using var session = new BLSession();
var (basePrice, discount) = session.GetBL<ReceiptItemPriceBL>().GetBasePrice(DefaultPurchasePrice, fakeArticle, null, ContractI3D);
this.Verifier.Verify(name, new { BasePrice = basePrice, Discount = discount });
}
private void PrepareDatabase(ReceiptItemPriceBL.ContractSpecialPriceKind priceKind, ReceiptItemPriceBL.ContractSpecialPriceChangeKind changeKind)
{
this.Sql("DELETE FROM dbo.KundenSonderpreise");
this.Sql("DELETE FROM dbo.VertragBepreisungArtikel");
this.Sql("DELETE FROM dbo.VertragBepreisungWaren");
var priceKindI3D = this.Sql<int>($"SELECT TOP 1 I3D FROM dbo.VertragBepreisungArt WHERE ItemIndex = {(int)priceKind}");
var changeKindI3D = this.Sql<int>($"SELECT TOP 1 I3D FROM dbo.VertragBepreisungWeise WHERE ItemIndex = {(int)changeKind}");
using var session = new BLSession();
session.GetBL<ContractBL>().SaveContractPricingArticle(new ContractPricingArticle
{
ContractI3D = ContractI3D,
ArticleI3D = ArticleI3D,
ChangeType = priceKindI3D,
ChangingWay = changeKindI3D,
ChangeValue = ChangeValue,
State = 1,
});
}
}
}