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,849 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Centron.BusinessLogic;
using Centron.BusinessLogic.Administration.Rights;
using Centron.BusinessLogic.EmployeeArea;
using Centron.BusinessLogic.Warehousing;
using Centron.BusinessLogic.Warehousing.InventoryManagement;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.BusinessLogic.WebServices.Sales.Receipts.ReceiptSearch;
using Centron.BusinessLogic.WebServices.Warehousing;
using Centron.BusinessLogic.WebServices.Warehousing.InventoryManagement;
using Centron.BusinessLogic.WebServices.Warehousing.StockManagement;
using Centron.Core;
using Centron.Core.Extensions;
using Centron.Data.Entities.Administration.Logins;
using Centron.Data.Entities.Merchandise.Articles;
using Centron.Data.Entities.Warehousing;
using Centron.Data.Entities.Warehousing.ArticleManagement;
using Centron.Data.Entities.Warehousing.StockManagement;
using Centron.Data.WebServices.Administration.MasterData;
using Centron.Data.WebServices.ImageFactory.WebsuiteImages;
using Centron.Data.WebServices.Warehousing;
using Centron.Interfaces;
using Centron.Interfaces.BL;
using Centron.Interfaces.Logistics.Warehousing;
using Centron.Interfaces.Sales.BillingCenter.Contracts;
using Centron.Interfaces.Sales.Receipts.ReceiptSearch;
using Centron.Interfaces.Warehousing.ArticleManagement;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Warehousing;
using CentronSoftware.Centron.WebServices.Entities.Warehousing.ArticleManagement;
using Microsoft.Graph;
using Xunit;
using Xunit.Abstractions;
using ArticleFilter = Centron.BusinessLogic.Warehousing.ArticleFilter;
namespace Centron.Tests.EndToEnd.Tests.Article
{
public class ArticleTest : EndToEndTest
{
private const int APPUSERI3D = 11;
private const int MATERIALGROUP = 3; //Dienstleistung
private const int SECONDARYMATERIALGROUP = 4; //Garantie
private const int MATERIALGROUP2 = 7; //Drucker
private const int MATERIALGROUP3 = 2; //Software
private const int SECONDARYMATERIALGROUP2 = 11; //Druckerwartung
private const int ARTICLE1 = 50; //ArticleCode 9673A003 -> some scanner
private const string EANCODEFORARTICLE1 = "4528472100968";
private const string MANUFACTURERFORARTICLE1 = "9673A003";
private const int ARTICLE2 = 92; // ArticleCode CB436A -> some printer cartridge
private const string EANCODEFORARTICLE2 = "0882780905221";
private const string MANUFACTURERFORARTICLE2 = "CB436A";
private const int PartListArticle = 69;
public ArticleTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
public override void Execute()
{
this.PrepareDB();
var newArticleI3D = this.CreateNewArticle();
var copyArticleI3D = this.CopyArticle(newArticleI3D);
this.UpdateMaterialGroups(new[] { newArticleI3D, copyArticleI3D, ARTICLE2 });
this.GetArticleRelatedStuff();
this.ChangeArticleRelatedStuff(copyArticleI3D);
this.GetAndSearchArticles(copyArticleI3D);
this.ChangeStuffWithPartLists();
this.TryAndFailToSaveAnArticle();
this.ArticleRightTest();
}
public void PrepareDB()
{
//Set the default Mwst for all secondary-/materialgroups
this.Sql("UPDATE WAREN SET MwstI3D = 4");
this.Sql("UPDATE UNTERWAREN SET MwstI3D = 4");
//set different Mwst for specific secondary-/materialgroups, so we can see a difference later
this.Sql($"UPDATE WAREN SET MwstI3D = 2 WHERE I3D = {MATERIALGROUP2}");
this.Sql($"UPDATE UNTERWAREN SET MwstI3D = 1 WHERE I3D = {SECONDARYMATERIALGROUP2} ");
}
public int CreateNewArticle()
{
var user = this.WithSession(f => f.GetBL<AppUserBL>().GetAppUser(f => f.I3D == APPUSERI3D));
var newArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetNewArticle(user.I3D));
newArticle.PurchasePrice = 5;
newArticle.ArticleCode = "Ein Männlein steht im Walde ";
newArticle.Description = @"Ganz still und stumm,
Es hat von lauter Purpur
Ein Mäntlein um.";
newArticle.WebCartAdditionalInfo = "Info die im Web-Cart angezeigt werden sollte";
//this should throw an error because the material group is missing
var newArticleSaveError = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("00_newArticleSaveError", newArticleSaveError);
newArticle.Color = new ColorDTO()
{
A = 1,
B = 191,
G = 0,
R = 230
};
newArticle.ASupplierI3D = 70010;
newArticle.ArticleUnitI3D = 27;
newArticle.ArticleWeight = "0";
newArticle.BSupplierI3D = 70016;
newArticle.Blocked = false;
newArticle.CSupplierI3D = 70000;
newArticle.CarrierI3D = 0;
newArticle.CarrierLimit = 0;
newArticle.ChangeStock = false;
newArticle.ChangeableText = 1;
newArticle.ClassI3D1 = 0;
newArticle.ClassI3D2 = 0;
newArticle.ContractArticleDurationKind = BillingIntervalKinds.Daily;
newArticle.ContractArticleDurationTime = 1;
newArticle.CostCenter = new CostCenterDTO() { I3D = 2 };
newArticle.CostObject = new CostObjectDTO() { I3D = 2 };
newArticle.Country = new CountryDTO() { I3D = 1 };
newArticle.CurrencyFactor = 1;
newArticle.DefaultArticleSearchQuantity = 1;
newArticle.EOL = false;
newArticle.EVP = 5.5M;
newArticle.EkIsVk = true;
newArticle.ExpenseAccount = 5400;
newArticle.ListPrice = 0;
newArticle.Maintenance = 5;
newArticle.MaintenanceKind = MaintenanceKindEnum.Percent;
newArticle.MaintenanceArticleI3D = 167;
newArticle.MinimumOrderQuantity = 10;
newArticle.NetWeight = 123.7M;
newArticle.NoMixedEk = PurchasePriceAsKind.MixedPurchasePrice;
newArticle.NoPriceUpdate = true;
newArticle.NoProductFamilyDuty = true;
newArticle.Precision = 2;
newArticle.RevenueAccount = 4400;
newArticle.RevenueAccountEU = 4400;
newArticle.RevenueAccountOverseas = 4400;
newArticle.State = "A";
newArticle.StorePlaceI3D = 6;
newArticle.StorePositionI3D = 12;
newArticle.VAT = new ValueAddedTaxDTO() { I3D = 4 };
newArticle.Volume = 40;
newArticle.Vpe = 1;
newArticle.Warranty1Kind = 1;
newArticle.Warranty1Value = 3;
newArticle.Warranty2Kind = 2;
newArticle.Warranty2Value = 5;
newArticle.WorkUnitFactor = 1;
newArticle.WorkUnitRounding = WorkUnitRounding.RoundUp;
newArticle.Height = 3.14;
newArticle.Length = 15.92;
newArticle.Width = 65.35;
newArticle.MaterialGroupI3D = MATERIALGROUP;
newArticle.SecondaryMaterialGroupI3D = SECONDARYMATERIALGROUP;
//materialgroup
var materialGroups = this.WithSession(f => f.GetBL<MaterialGroupWebServiceBL>().GetMaterialGroups(new MaterialGroupFilter() { I3D = MATERIALGROUP }));
var materialGroup = materialGroups.First(f => f.I3D == MATERIALGROUP);
var newArticleSaveResult = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("01_newArticleSaveResult", newArticleSaveResult);
var updateArticleByMaterialGroupResult = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticleMaterialGroupByTakeOnSettings(
new[] { newArticleSaveResult.Data.I3D },
materialGroup,
this.GetArticleTakeOnOption(0),
user));
if (updateArticleByMaterialGroupResult.Status == ResultStatus.Error)
throw new Exception(updateArticleByMaterialGroupResult.Message);
var updateArticleBySecondaryMaterialGroupResult = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticleSecondaryMaterialGroupByTakeOnSettings(
new[] { newArticleSaveResult.Data.I3D },
materialGroup.SecMaterialGroupList.First(f => f.I3D == SECONDARYMATERIALGROUP),
this.GetArticleTakeOnOption(2),
user));
if (updateArticleBySecondaryMaterialGroupResult.Status == ResultStatus.Error)
throw new Exception(updateArticleBySecondaryMaterialGroupResult.Message);
var savedArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(newArticleSaveResult.Data.I3D));
this.Verifier.Verify("02_savedArticle", savedArticle);
return savedArticle.I3D;
}
public int CopyArticle(int articleI3DToCopy)
{
Result<int> copyArticle1I3D;
copyArticle1I3D = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().CopyArticle(
articleI3DToCopy,
this.GetArticleCopyOptions(true, "978020137962"),
base.GetLoggedInUser()));
var copiedArticle1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(copyArticle1I3D.Data));
this.Verifier.Verify("03_copiedArticle1", copiedArticle1);
var destinationArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(ARTICLE1));
// We are copying the article. So reset the I3D and created / changed properties
destinationArticle.I3D = 0;
destinationArticle.ChangedDate = DateTime.Now;
destinationArticle.CreationDate = DateTime.Now;
destinationArticle.CreatedFromI3D = null;
destinationArticle.ChangedFromI3D = null;
//change the manufacuterer code here to something unique, otherwise the save will be denied
destinationArticle.ManufacturerCode += "_UNIQUE";
var copyArticle2I3D = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().CopyArticle(
articleI3DToCopy,
this.GetArticleCopyOptions(false),
base.GetLoggedInUser(),
destinationArticle).ThrowIfError());
var copiedArticle2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(copyArticle2I3D));
this.Verifier.Verify("04_copiedArticle2", copiedArticle2);
return copiedArticle2.I3D;
}
public void UpdateMaterialGroups(int[] articleI3Ds)
{
this.UpdateMainMaterialGroup(articleI3Ds);
this.UpdateSecondaryMaterialGroup(articleI3Ds);
}
private void UpdateMainMaterialGroup(int[] articleI3Ds)
{
var user = this.WithSession(f => f.GetBL<AppUserBL>().GetAppUser(f => f.I3D == APPUSERI3D));
var materialGroups = this.WithSession(f => f.GetBL<MaterialGroupWebServiceBL>().GetMaterialGroups(new MaterialGroupFilter() { I3D = MATERIALGROUP2 }));
var materialGroup = materialGroups.First(f => f.I3D == MATERIALGROUP2);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticleMaterialGroupByTakeOnSettings(
articleI3Ds,
materialGroup,
this.GetArticleTakeOnOption(2),
user
));
var articlesWithChangedMaterialGroup = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticlesThroughPaging(
ArticlePreviewSort.ArticleCode,
isDescending: true,
new ArticleCompactFilter
{
I3D = articleI3Ds
},
page: 1,
entriesPerPage: Int32.MaxValue));
this.Verifier.Verify("05_articlesWithChangedMaterialGroup", articlesWithChangedMaterialGroup);
}
private void UpdateSecondaryMaterialGroup(int[] articleI3Ds)
{
var user = this.WithSession(f => f.GetBL<AppUserBL>().GetAppUser(f => f.I3D == APPUSERI3D));
var materialGroups = this.WithSession(f => f.GetBL<MaterialGroupWebServiceBL>().GetMaterialGroups(new MaterialGroupFilter() { I3D = MATERIALGROUP2 }));
var materialGroup = materialGroups.First(f => f.I3D == MATERIALGROUP2);
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticleSecondaryMaterialGroupByTakeOnSettings(
articleI3Ds,
materialGroup.SecMaterialGroupList.First(f => f.I3D == SECONDARYMATERIALGROUP2),
this.GetArticleTakeOnOption(0),
user
));
var articlesWithChangedSecondaryMaterialGroup = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticlesThroughPaging(
ArticlePreviewSort.ArticleCode,
isDescending: true,
new ArticleCompactFilter
{
I3D = articleI3Ds
},
page: 1,
entriesPerPage: Int32.MaxValue));
this.Verifier.Verify("06_articlesWithChangedSecondaryMaterialGroup", articlesWithChangedSecondaryMaterialGroup);
}
public void GetArticleRelatedStuff()
{
var priceMAtrixItems1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPriceMatrixItems(MANUFACTURERFORARTICLE1, EANCODEFORARTICLE1));
this.Verifier.Verify("07_priceMatrixItems1", priceMAtrixItems1);
var priceMAtrixItems2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPriceMatrixItems(MANUFACTURERFORARTICLE2, EANCODEFORARTICLE2));
this.Verifier.Verify("08_priceMatrixItems2", priceMAtrixItems2);
var purchasePriceExample1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPurchasePriceExamples(MANUFACTURERFORARTICLE1));
this.Verifier.Verify("09_purchasePriceExample1", purchasePriceExample1);
var purchasePriceExample2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPurchasePriceExamples(MANUFACTURERFORARTICLE2));
this.Verifier.Verify("10_purchasePriceExample2", purchasePriceExample2);
}
public void ChangeArticleRelatedStuff(int copyArticleI3D)
{
var user = this.WithSession(f => f.GetBL<AppUserBL>().GetAppUser(f => f.I3D == APPUSERI3D));
var articlePriceInReceipts2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticlePriceInReceipts(ARTICLE2).ForEach(f => f.IsChecked = true).OrderByDescending(f => f.I3D).ToList());
this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticlePriceInReceipts(
articlePriceInReceipts2,
42,
ARTICLE2,
user
));
var firstReceiptWithArticle2 = articlePriceInReceipts2.First();
var filter2 = new ReceiptSearchFilter()
{
ReceiptNumber = firstReceiptWithArticle2.Number,
ReceiptKinds = new List<CentronObjectKindNumeric>() { firstReceiptWithArticle2.ReceiptKind }
};
var receiptsWithArticle2AfterPriceUpdate = this.WithSession(f => f.GetBL<ReceiptSearchWebServiceBL>().SearchReceipts(new LoggedInUser(user), filter2, 1, 10).Data.Result.First());
var receiptWithArticle2AfterPriceUpdate = this.WithSession(f => f.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(receiptsWithArticle2AfterPriceUpdate.I3D, firstReceiptWithArticle2.ReceiptKind));
this.Verifier.Verify("11_receiptWithArticle1AfterPriceUpdate", receiptWithArticle2AfterPriceUpdate);
var updateArticlesEOL = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().UpdateArticleEOL(
new List<ArticleAutoEOLModelDTO>()
{
new ArticleAutoEOLModelDTO()
{
I3D = copyArticleI3D
},
new ArticleAutoEOLModelDTO()
{
I3D = ARTICLE2
}
}
, user));
this.Verifier.Verify("12_updateArticlesEOL", updateArticlesEOL);
}
public void GetAndSearchArticles(int copyArticleI3D)
{
var articleInLiefPosAndVertrag1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().FindArticleInLiefPosAndVertrag(copyArticleI3D));
this.Verifier.Verify("13_articleInLiefPosAndVertrag1", articleInLiefPosAndVertrag1);
var articleInLiefPosAndVertrag2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().FindArticleInLiefPosAndVertrag(ARTICLE2));
this.Verifier.Verify("14_articleInLiefPosAndVertrag2", articleInLiefPosAndVertrag2);
var articlePreview1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticlecode("Das Männlein steht im Walde Und hat auf seinem Haupte ")); //Article 1
this.Verifier.Verify("15_articlePreview1", articlePreview1);
var articlePreview2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticlecode("CB436A")); //Article 2
this.Verifier.Verify("16_articlePreview2", articlePreview2);
var searchedArticles = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SearchArticle("Männlein"));
this.Verifier.Verify("17_searchedArticles", searchedArticles);
var searchedArticleWithPaging = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SearchArticlesWithPaging(
new ArticleFilter()
{
DistributorI3D = -1,
SearchText = "ne"
},
Int32.MaxValue,
1));
this.Verifier.Verify("18_searchedArticleWithPaging", searchedArticleWithPaging);
var arrivalArticles = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArrivalArticles());
this.Verifier.Verify("19_arrivalArticles", arrivalArticles);
var articlePriceInReceipts = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticlePriceInReceipts(ARTICLE2));
this.Verifier.Verify("20_articlePriceInReceipts", articlePriceInReceipts);
var receiptTemplates = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleReceiptTemplates(2));
this.Verifier.Verify("21_receiptTemplates", receiptTemplates);
var articlesAutoEol = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleAutoEOL(new DateTime(2008, 01, 01)));
this.Verifier.Verify("22_articlesAutoEol", articlesAutoEol);
var articlePreview = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticlePreviewByArticleI3D(copyArticleI3D));
this.Verifier.Verify("23_articlePreview", articlePreview);
//this should always be null/empty bc an article can not have divisble and scanbarcode active at the same time
var articlesPreviewEmpty = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPreviewArticles(new ArticleCompactFilter()
{
Divisible = true,
ScanBarcode = true
}));
this.Verifier.Verify("24_articlesPreviewEmpty", articlesPreviewEmpty);
var articlesPreview = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetPreviewArticles(new ArticleCompactFilter()
{
Divisible = true,
IsWorkUnitArticle = true
}));
this.Verifier.Verify("25_articlesPreview", articlesPreview);
var articleMainStorage1 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleMainStorageStocks(copyArticleI3D));
this.Verifier.Verify("26_articleMainStorage1", articleMainStorage1);
var articleMainStorage2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleMainStorageStocks(ARTICLE2));
this.Verifier.Verify("27_articleMainStorage2", articleMainStorage2);
var articleStockDemandByArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleStockDemandByArticle(new List<int>() { copyArticleI3D, ARTICLE2 }));
this.Verifier.Verify("28_articleStockDemandByArticle", articleStockDemandByArticle);
var isRentArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().IsRentArticleInUse(copyArticleI3D));
this.Verifier.Verify("29_isRentArticle", isRentArticle);
}
public void TryAndFailToSaveAnArticle()
{
//make some adjustment to the DB, so we run into more failures
this.Sql("UPDATE ApplicationSettings SET ValueBool = 1 WHERE I3D = 10168"); //make CostCenter mandatory for an article;
this.Sql("UPDATE ApplicationSettings SET ValueBool = 1 WHERE I3D = 10169"); //make CostObject mandatory for an article;
this.Sql($"UPDATE WAREN SET ProduktfamilienPflicht = 1 WHERE I3D = {MATERIALGROUP}"); // make the product family necessary for the material group
var user = this.WithSession(f => f.GetBL<AppUserBL>().GetAppUser(f => f.I3D == APPUSERI3D));
var newArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetNewArticle(user.I3D));
newArticle.VAT = null;
newArticle.IsWorkUnitArticle = true;
newArticle.Precision = 42;
newArticle.ChangeStock = true;
newArticle.Vpe = 0;
var newArticleSaveErrorZero = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("30_failedArticleSave_missingArticleCode", newArticleSaveErrorZero);
newArticle.ArticleCode = "What do you call a party with developers?";
var newArticleSaveErrorOne = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("31_failedArticleSave_missingVAT", newArticleSaveErrorOne);
newArticle.VAT = new ValueAddedTaxDTO() { I3D = 4 };
var newArticleSaveErrorTwo = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("32_failedArticleSave_missingMaterialGroup", newArticleSaveErrorTwo);
newArticle.MaterialGroupI3D = MATERIALGROUP;
var newArticleSaveErrorThree = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("33_failedArticleSave_missingDescription", newArticleSaveErrorThree);
newArticle.Description = "A git together";
var newArticleSaveErrorFour = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("34_failedArticleSave_wrongPrecision", newArticleSaveErrorFour);
newArticle.Precision = 7;
var newArticleSaveErrorFive = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("35_failedArticleSave_WorkUnitMissing", newArticleSaveErrorFive);
newArticle.IsWorkUnitArticle = false;
var newArticleSaveErrorSix = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("36_failedArticleSave_NoProductFamiliy", newArticleSaveErrorSix);
newArticle.NoProductFamilyDuty = true;
var newArticleSaveErrorSeven = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("37_failedArticleSave_CostCenterMissing", newArticleSaveErrorSeven);
newArticle.CostCenter = new CostCenterDTO() { I3D = 2 };
var newArticleSaveErrorEight = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("38_failedArticleSave_CostObjectMissing", newArticleSaveErrorEight);
newArticle.CostObject = new CostObjectDTO() { I3D = 2 };
var newArticleSaveErrorNine = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("39_failedArticleSave_VPEWrong", newArticleSaveErrorNine);
newArticle.ChangeStock = false;
newArticle.ManufacturerCode = "What do you call a group of coders?";
var notAnError = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
Assert.Equal(ResultStatus.Success, notAnError.Status);
newArticle.I3D = 0;
var newArticleSaveErrorTen = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("40_failedArticleSave_ManufacturerCodeAlreadyExisting", newArticleSaveErrorTen);
newArticle.ManufacturerCode = "A git of programmers or a repository of developers?";
var newArticleSaveErrorEleven = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("41_failedArticleSave_ArticleCodeAlreadyExisting", newArticleSaveErrorEleven);
newArticle.EANCode = "12345678";
var newArticleSaveErrorTwelfe = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("42_failedArticleSave_EanCodeWrongFormat", newArticleSaveErrorTwelfe);
newArticle.EANCode = "978020137962";
var newArticleSaveErrorThirteen = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(newArticle, new LoggedInUser(user)));
this.Verifier.Verify("43_failedArticleSave_EanCOdeAlreadyUsed", newArticleSaveErrorThirteen);
}
public void ChangeStuffWithPartLists()
{
//change the StkListeFesteVKs, so the price of the part list is calculated from the prices of the articles in it
this.Sql("UPDATE ARTIK SET StkListeFesteVKs = 0 WHERE I3D = 1200");
var partListFilter = new PartListArticlePreviewFilter { ArticleI3Ds = new List<int>() { PartListArticle } };
var partListArticle = this.WithSession(f => f.GetBL<PartListArticleWebServiceBL>().SearchPartListArticlePreviews(partListFilter));
Assert.Single(partListArticle);
var articleInPartList = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(partListArticle.First().ArticleI3D));
//update only the purchase price and the description
articleInPartList.UpdateVKsInPartList = false;
articleInPartList.PurchasePrice = 83d;
articleInPartList.Description = "Why did the tomato turn red?";
var savedArticleInPartList = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(articleInPartList, this.GetLoggedInUser()));
Assert.Equal(ResultStatus.Success, savedArticleInPartList.Status);
var updatedPartListArticle = this.WithSession(f => f.GetBL<PartListArticleWebServiceBL>().SearchPartListArticlePreviews(partListFilter));
this.Verifier.Verify("44_updatedPartListArticle_NoVkUpdate", updatedPartListArticle);
var updatedParentArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(partListArticle.First().ParentArticleI3D));
this.Verifier.Verify("45_parentPartListArticle_NoVkUpdate", updatedParentArticle);
//reload the article so the changed date fits and we don't run in the trigger for it
articleInPartList = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(partListArticle.First().ArticleI3D));
//update the vks as well, so the price of the parent article is changed as well
articleInPartList.UpdateVKsInPartList = true;
articleInPartList.Description = "Because it saw the salad dressing!";
articleInPartList.Price1 = 111d;
articleInPartList.Price2 = 222d;
articleInPartList.Price3 = 333d;
articleInPartList.Price4 = 444d;
var savedArticleInPartListWithVkUpdate = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().SaveArticle(articleInPartList, this.GetLoggedInUser()));
Assert.Equal(ResultStatus.Success, savedArticleInPartListWithVkUpdate.Status);
updatedPartListArticle = this.WithSession(f => f.GetBL<PartListArticleWebServiceBL>().SearchPartListArticlePreviews(partListFilter));
this.Verifier.Verify("46_updatedPartListArticle_WithVkUpdate", updatedPartListArticle);
updatedParentArticle = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(partListArticle.First().ParentArticleI3D));
this.Verifier.Verify("47_parentPartListArticle_WithVkUpdate", updatedParentArticle);
}
private void ArticleRightTest()
{
//UserRightsConst.Purchase.StockList.EDIT_MaterialGroup
this.ArticleCanChangeMaterialGroupTest();
//UserRightsConst.Purchase.StockList.NOT_CHANGEABLE_ARTICLE_PROPERTIES,
this.ArticleCanNotChangePropertiesTest();
}
private void ArticleCanChangeMaterialGroupTest()
{
var user = this.GetLoggedInUser();
var articlePreview = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(92)); //Article 2
articlePreview.CostCenter = new CostCenterDTO() { I3D = 2 };
articlePreview.CostObject = new CostObjectDTO() { I3D = 2 };
articlePreview.Vpe = 1;
articlePreview.MaterialGroupI3D = MATERIALGROUP2;
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Purchase.StockList.EDIT_MaterialGroup));
Assert.True(currentUserHasRightTrue);
RunTest("ArticleCanChangeMaterialGroupTest_TRUE_Test", this.GetLoggedInUser(), articlePreview);
// And add the "only-own" right
this.Sql($"DELETE FROM dbo.Sichtrus WHERE Gruppe = 6 And Recht = {UserRightsConst.Purchase.StockList.EDIT_MaterialGroup}");
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Purchase.StockList.EDIT_MaterialGroup));
Assert.False(currentUserHasRightFalse);
var articlePreview2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(92)); //Article 2
articlePreview2.MaterialGroupI3D = MATERIALGROUP3;
RunTest("ArticleCanChangeMaterialGroupTest_FALSE_Test", this.GetLoggedInUser(), articlePreview2);
}
private void ArticleCanNotChangePropertiesTest()
{
var user = this.GetLoggedInUser();
var articlePreview = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(92)); //Article 2
articlePreview.CostCenter = new CostCenterDTO() { I3D = 2 };
articlePreview.CostObject = new CostObjectDTO() { I3D = 2 };
articlePreview.Vpe = 1;
articlePreview.ArticleUnitI3D = 7; // Kilogramm
articlePreview.Mounted = true;
var currentUserHasRightFalse = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Purchase.StockList.NOT_CHANGEABLE_ARTICLE_PROPERTIES));
Assert.False(currentUserHasRightFalse);
RunTest("ArticleCanNotChangePropertiesTest_TRUE_Test", this.GetLoggedInUser(), articlePreview);
// And add the "only-own" right
this.Sql($"INSERT INTO dbo.Sichtrus (Gruppe, Recht) VALUES (6, {UserRightsConst.Purchase.StockList.NOT_CHANGEABLE_ARTICLE_PROPERTIES})");
var currentUserHasRightTrue = this.WithSession(f => f.GetBL<AppRightsBL>().HasUserRight(user.UserI3D.Value, UserRightsConst.Purchase.StockList.NOT_CHANGEABLE_ARTICLE_PROPERTIES));
Assert.True(currentUserHasRightTrue);
var articlePreview2 = this.WithSession(f => f.GetBL<ArticleWebServiceBL>().GetArticleByArticleI3D(92)); //Article 2
articlePreview2.ArticleUnitI3D = 6; // Gramm
articlePreview2.Mounted = false;
RunTest("ArticleCanNotChangePropertiesTest_FALSE_Test", this.GetLoggedInUser(), articlePreview2);
}
void RunTest(string name, LoggedInUser currentUser, ArticleDTO article)
{
using (var session = new BLSession())
{
var saveResult = session.GetBL<ArticleWebServiceBL>().SaveArticle(article, currentUser);
Assert.Equal(ResultStatus.Success, saveResult.Status);
Assert.NotNull(saveResult.Data);
this.Verifier.Verify(name, saveResult.Data);
}
}
#region private
/// <param name="mode">0 -> returns everything as true, 1 -> returns everything as false, 2 -> returns mixed</param>
private ArticleTakeOnOptions GetArticleTakeOnOption(int mode)
{
if (mode == 0)
{
return new ArticleTakeOnOptions()
{
Available = true,
Debiting = true,
Markup = true,
Mounted = true,
Picking = true,
Splitable = true,
Unit = true,
Vpe = true,
ChangeableText = true,
CostCenter = true,
CostObject = true,
DecimalPlace = true,
DeliveryTime = true,
EkisVk = true,
ExpenseAccount = true,
ForeignCurrency = true,
IsReversecharge = true,
RevenueAccount = true,
ScanBarcode = true,
StorePlace = true,
StorePosition = true,
VarAttributes = null,
WarrantyDuration1 = true,
WarrantyDuration2 = true,
IsServiceArticle = true,
NoMixedEk = true,
NoPriceUpdate = true,
VAT = true,
EndOfLifeAuto = true,
SelectedAccountOptionIndex = 0, //all acounts
WEEE = true
};
}
if (mode == 1)
{
return new ArticleTakeOnOptions()
{
Available = false,
Debiting = false,
Markup = false,
Mounted = false,
Picking = false,
Splitable = false,
Unit = false,
Vpe = false,
ChangeableText = false,
CostCenter = false,
CostObject = false,
DecimalPlace = false,
DeliveryTime = false,
EkisVk = false,
ExpenseAccount = false,
ForeignCurrency = false,
IsReversecharge = false,
RevenueAccount = false,
ScanBarcode = false,
StorePlace = false,
StorePosition = false,
VarAttributes = null,
WarrantyDuration1 = false,
WarrantyDuration2 = false,
IsServiceArticle = false,
NoMixedEk = false,
NoPriceUpdate = false,
VAT = false,
EndOfLifeAuto = false,
SelectedAccountOptionIndex = 0, //all acounts
WEEE = false
};
}
if (mode == 2)
{
return new ArticleTakeOnOptions()
{
Available = false,
Debiting = true,
Markup = false,
Mounted = true,
Picking = false,
Splitable = true,
Unit = false,
Vpe = true,
ChangeableText = false,
CostCenter = true,
CostObject = false,
DecimalPlace = true,
DeliveryTime = false,
EkisVk = true,
ExpenseAccount = false,
ForeignCurrency = true,
IsReversecharge = false,
RevenueAccount = true,
ScanBarcode = false,
StorePlace = true,
StorePosition = false,
VarAttributes = null,
WarrantyDuration1 = false,
WarrantyDuration2 = true,
IsServiceArticle = false,
NoMixedEk = true,
NoPriceUpdate = false,
VAT = true,
EndOfLifeAuto = false,
SelectedAccountOptionIndex = 0, //all acounts
WEEE = true
};
}
throw new Exception("invalid number for the mode");
}
private ArticleCopyOptions GetArticleCopyOptions(bool value, string eanCode = "")
{
return new ArticleCopyOptions()
{
Blocked = value,
Color = value,
Currency = value,
Deliverable = value,
Divisible = value,
Eol = value,
Height = value,
Length = value,
Manufacturer = value,
Mounted = value,
Payer = value,
Picking = value,
Precision = value,
Production = value,
Productline = value,
Purchase = value,
Reversecharge = value,
Volume = value,
Vpe = value,
Warranty1 = value,
Warranty2 = value,
Width = value,
ArticlecodeText = "Das Männlein steht im Walde" + (value ? " Auf Einem Bein " : " Und hat auf seinem Haupte "),
ArticleKind = value,
ArticleUnit = value,
ASupplier = value,
BSupplier = value,
ChangeableText = value,
ChangeStock = value,
CostCenter = value,
CSupplier = value,
DeliveryTime = value,
DescriptionText = "Schwarz Käpplein klein.",
DistributionInfo = value,
ExpenseAccounts = value,
FollowingArticle = value,
FreeSpecifications = value,
GoodsNumber = value,
GrossWeight = value,
ListPrice = value,
MaterialGroup = value,
MinimumHolding = value,
MinimumPrice = value,
NetWeight = value,
NotDiscountable = value,
ProductFamily = value,
PurchasePrice = value,
RentArticle = value,
RevenueAccount = value,
ScanBarcode = value,
SellPrice1 = value,
SellPrice2 = value,
SellPrice3 = value,
SellPrice4 = value,
SpecialWeight = value,
TaxRate = value,
VarAttribute1 = value,
VarAttribute2 = value,
VarAttribute3 = value,
CountryOfOrigin = value,
DistributionInfoVisible = value,
EanCodeText = eanCode ?? "Sagt, wer mag das Männlein sein,",
EMailNotifications = value,
EVP = value,
IsCarepackArticle = value,
IsContractArticle = value,
IsPartList = value,
MinimumOrderQuantity = value,
NoPriceUpdate = value,
PurchasePriceAs = value,
QualityAssuranceInstructions = value,
SecondaryMaterialGroup = value,
ShortDescriptionText = "Das da steht im Wald’ allein",
WorkUnitArticle = value,
EndOfLifeAuto = value,
NoProductFamilyMandatory = value,
WithProjectOffersText = value,
PurchasePriceIsSellPrice = value
};
}
#endregion
}
}