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

257 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Centron.Tests.EndToEnd.Infrastructure;
using Xunit.Abstractions;
using Centron.BusinessLogic.Warehousing.InventoryManagement;
using Centron.Data.WebServices.Sales.Receipts.Offers;
using Centron.Data.WebServices.Sales.Receipts.Orders;
using Centron.Interfaces;
using Centron.Interfaces.BL;
using Centron.Interfaces.Sales.Receipts.ReceiptSearch;
using Centron.BusinessLogic;
using Centron.BusinessLogic.WebServices.Sales.Receipts.ReceiptSearch;
using Centron.BusinessLogic.EmployeeArea;
using Centron.Data.Entities.Administration.Logins;
using Centron.BusinessLogic.WebServices.Warehousing.ArticleManagement;
using Centron.BusinessLogic.WebServices.Warehousing.InventoryManagement;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.BusinessLogic.WebServices.Warehousing;
namespace Centron.Tests.EndToEnd.Tests.ArticleConvert
{
public class ArticleConvertTest : EndToEndTest
{
private const int ARTICLEI3D_EXTERNAL = 1;
private const int ARTICLEI3D_NEW = 2;
public ArticleConvertTest(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public override void Execute()
{
this.ConvertArticleOffer(ARTICLEI3D_EXTERNAL, 20833, true);
this.ConvertArticleOffer(ARTICLEI3D_NEW, 18887, false);
this.ConvertArticleOrder(ARTICLEI3D_EXTERNAL, 5824,true);
this.ConvertArticleOrder(ARTICLEI3D_NEW, 6939,false);
}
#region Offer
private void ConvertArticleOffer(int articleI3D, int articleHistoryI3D, bool isExternal)
{
var articleHistoryListExternal = this.WithSession(f => f.GetBL<ArticleHistoryWebServiceBL>().GetArticleOfferHistory(articleI3D));
var articelHistory = articleHistoryListExternal.FirstOrDefault(f => f.I3D == articleHistoryI3D);
if (articelHistory == null)
{
throw new Exception("articleHistory (Offer) is null");
}
var user = this.WithSession(d => d.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11));
var receipt = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), new ReceiptSearchFilter {ReceiptNumber = articelHistory?.Number}, 1, int.MaxValue));
if (receipt.Status == ResultStatus.Error || receipt.Data == null)
{
throw new Exception("receipt (Offer) is null");
}
var materialFilter = new MaterialGroupFilter()
{
State = 1,
MaterialMarkupsState = 1,
SecondaryMaterialGroupsState = 1,
SecondaryMaterialMarkupsState = 1
};
var materialGroupList = this.WithSession(f => f.GetBL<MaterialGroupBL>().GetMaterialGroups(materialFilter));
var selectedMaterialGroup = materialGroupList.FirstOrDefault(f => f.I3D == 1);
if (selectedMaterialGroup == null)
{
throw new Exception("selectedMaterialGroup (Offer) is null");
}
var selectedSecondaryMaterialGroup = selectedMaterialGroup.SecMaterialGroupList.FirstOrDefault();
if (selectedSecondaryMaterialGroup == null)
{
throw new Exception("selectedSecondaryMaterialGroup (Offer) is null");
}
var article = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetNewArticle(new LoggedInUser(user).UserI3D));
article.MaterialGroupI3D = selectedMaterialGroup.I3D;
article.SecondaryMaterialGroupI3D = selectedSecondaryMaterialGroup.I3D;
article.ArticleCode = articelHistory.ManufacturerCode;
article.Description = articelHistory.Text;
article.ShortDescription = "Lorem ipsum";
article.ManufacturerCode = article.ManufacturerCode;
var filter = new ReceiptSearchFilter()
{
ReceiptNumber = articleHistoryListExternal.OrderByDescending(f => f.I3D).First().Number,
ReceiptKinds = new List<CentronObjectKindNumeric>() { CentronObjectKindNumeric.OfferClass},
IncludeClosedReceipts = true
};
var savedArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(article, new LoggedInUser(user))).Data;
if (isExternal)
{
this.Verifier.Verify("ConvertArticleOfferExternal", savedArticle);
var offersBeforeArticleChangeExternal = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, 1, 1));
var receiptI3D = offersBeforeArticleChangeExternal.Data.Result.First().I3D;
var offerBeforeChangeExternal = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OfferClass));
this.Verifier.Verify("01_OfferBeforeChangeExternal", offerBeforeChangeExternal);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticlePositionFromArticleChange(
user,
savedArticle.I3D,
savedArticle.ArticleCode,
savedArticle.ManufacturerCode,
0, //offer & external -> 0
article.ManufacturerCode
));
var offerAfterChangeExternal = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OfferClass));
this.Verifier.Verify("02_OfferAfterChangeExternal", offerAfterChangeExternal);
}
else
{
this.Verifier.Verify("ConvertArticleOfferNew", savedArticle);
var offersBeforeArticleChangeNew = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, 1, int.MaxValue));
var receiptI3D = offersBeforeArticleChangeNew.Data.Result.First().I3D;
var offerBeforeChangeNew = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OfferClass));
this.Verifier.Verify("03_OfferBeforeChangeNew", offerBeforeChangeNew);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticlePositionFromArticleChange(
user,
savedArticle.I3D,
savedArticle.ArticleCode,
savedArticle.ManufacturerCode,
2, //offer & new -> 2
article.ManufacturerCode
));
var offerAfterChangeNew = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OfferClass));
this.Verifier.Verify("04_OfferAfterChangeNew", offerAfterChangeNew);
}
}
#endregion
#region Order
private void ConvertArticleOrder(int articleI3D, int articleHistoryI3D, bool isExternal)
{
var articleHistoryList = this.WithSession(f => f.GetBL<ArticleHistoryWebServiceBL>().GetArticleOrderHistory(articleI3D));
var articelHistory = articleHistoryList.FirstOrDefault(f => f.I3D == articleHistoryI3D);
if (articelHistory == null)
{
throw new Exception("no articleHistory (Order) found");
}
var user = this.WithSession(d => d.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11));
var receipt = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), new ReceiptSearchFilter {ReceiptNumber = articelHistory?.Number}, 1, int.MaxValue));
if (receipt.Status == ResultStatus.Error || receipt.Data == null)
{
throw new Exception("no receipt (Order) found");
}
var materialFilter = new MaterialGroupFilter()
{
State = 1,
MaterialMarkupsState = 1,
SecondaryMaterialGroupsState = 1,
SecondaryMaterialMarkupsState = 1
};
var materialGroupList = this.WithSession(f => f.GetBL<MaterialGroupWebServiceBL>().GetMaterialGroups(materialFilter));
var selectedMaterialGroup = materialGroupList.FirstOrDefault(f => f.I3D == 1);
if (selectedMaterialGroup == null)
{
throw new Exception("selectedMaterialGroup (Order) is null");
}
var selectedSecondaryMaterialGroup = selectedMaterialGroup.SecMaterialGroupList.FirstOrDefault();
if (selectedSecondaryMaterialGroup == null)
{
throw new Exception("selectedSecondaryMaterialGroup (Order) is null");
}
var article = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetNewArticle(new LoggedInUser(user).UserI3D));
article.MaterialGroupI3D = selectedMaterialGroup.I3D;
article.SecondaryMaterialGroupI3D = selectedSecondaryMaterialGroup.I3D;
article.ArticleCode = articelHistory.ManufacturerCode;
article.Description = articelHistory.Text;
article.ShortDescription = "Lorem ipsum";
article.ManufacturerCode = article.ManufacturerCode;
var savedArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(article, new LoggedInUser(user))).Data;
var filter = new ReceiptSearchFilter()
{
ReceiptNumber = articleHistoryList.OrderByDescending(f => f.I3D).First().Number,
ReceiptKinds = new List<CentronObjectKindNumeric>() { CentronObjectKindNumeric.OrderClass},
IncludeClosedReceipts = true
};
if (isExternal)
{
this.Verifier.Verify("ConvertArticleOrderExternal", savedArticle);
var ordersBeforeArticleChangeExternal = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, 1, 1));
var receiptI3D = ordersBeforeArticleChangeExternal.Data.Result.First().I3D;
var orderBeforeChangeExternal = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OrderClass));
this.Verifier.Verify("05_OrderBeforeChangeExternal", orderBeforeChangeExternal);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticlePositionFromArticleChange(
user,
savedArticle.I3D,
savedArticle.ArticleCode,
savedArticle.ManufacturerCode,
1, //order & external -> 1
article.ManufacturerCode
));
var orderAfterChangeExternal = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OrderClass));
this.Verifier.Verify("06_OrderAfterChangeExternal", orderAfterChangeExternal);
}
else
{
this.Verifier.Verify("ConvertArticleOrderNew", savedArticle);
var ordersBeforeArticleChangeNew = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter, 1, 1));
var receiptI3D = ordersBeforeArticleChangeNew.Data.Result.First().I3D;
var orderBeforeChangeExternal = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OrderClass));
this.Verifier.Verify("07_OrderBeforeChangeExternal", orderBeforeChangeExternal);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticlePositionFromArticleChange(
user,
savedArticle.I3D,
savedArticle.ArticleCode,
savedArticle.ManufacturerCode,
3, //order & new -> 3
article.ManufacturerCode
));
var orderBeforeChangeNew = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptI3D, CentronObjectKindNumeric.OrderClass));
this.Verifier.Verify("08_OrderBeforeChangeExternal", orderBeforeChangeNew);
}
}
#endregion
}
}