using System; using Centron.BusinessLogic.Warehousing; using Centron.BusinessLogic.Warehousing.StockManagement; using Centron.BusinessLogic.WebServices.Warehousing; using Centron.BusinessLogic.WebServices.Warehousing.StockManagement; using Centron.Data.WebServices.Administration.MandatoryArea; using Centron.Data.WebServices.Logistics.Warehousing; using Centron.Data.WebServices.Warehousing.StockManagement; using Centron.Tests.EndToEnd.Infrastructure; using CentronSoftware.Centron.WebServices.Entities.Logistics.Warehousing; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.SecondaryStockArticle { public class SecondaryStockTest : EndToEndTest { public SecondaryStockTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { this.PrepareDB(); this.GetAndEditSecondaryStockArticle(); this.BookInBookOut(); } private void PrepareDB() { //Delete corrupted entries this.Sql("DELETE FROM dbo.NebenlagerArtikel WHERE ArtikelI3D IS NULL OR ArtikelI3D <= 0"); //insert storage place and location this.Sql("INSERT INTO Lagerort (Kurzbezeichnung, Bezeichnung, NebenlagerI3D, Status) VALUES ('4.0', 'FourDotzero', 6,1)"); this.Sql("INSERT INTO Lagerplatz(LagerortI3D, Kurzbezeichnung, Bezeichnung, Status) VALUES (9,'666', 'NumberOfTheBeast', 1)"); } private void GetAndEditSecondaryStockArticle() { var activeFilter = new SecondaryStockArticleFilter() { State = true }; var articleFilter = new SecondaryStockArticleFilter() { ArticleI3Ds = new[] { 4354, 4355, 4356 } }; var stockFilter = new SecondaryStockArticleFilter() { SecondaryStockI3D = 7 }; var activeSecondaryStockArticles = this.WithSession(f => f.GetBL().GetSecondaryStockArticle(activeFilter)); this.Verifier.Verify("1_activeSecondaryStockArticles", activeSecondaryStockArticles); var articlesSecondaryStockArticles = this.WithSession(f => f.GetBL().GetSecondaryStockArticle(articleFilter)); this.Verifier.Verify("2_articlesSecondaryStockArticles", articlesSecondaryStockArticles); var stockSecondaryStockArticles = this.WithSession(f => f.GetBL().GetSecondaryStockArticle(stockFilter)); this.Verifier.Verify("3_stockSecondaryStockArticles", stockSecondaryStockArticles); for (int i = 0; i < articlesSecondaryStockArticles.Count; i++) { articlesSecondaryStockArticles[i].Stock = 5 + i; articlesSecondaryStockArticles[i].StockInOrder = 5 * i; articlesSecondaryStockArticles[i].OwnPurchasePrice = (5 + i % 2 == 0); articlesSecondaryStockArticles[i].PurchasePrice = 5 + i * 5 + i; articlesSecondaryStockArticles[i].RawEk1 = (5 * i) - (5 + i); this.WithSession(f => f.GetBL().SaveSecondaryStock(articlesSecondaryStockArticles[i])); } var articlesSecondaryStockArticlesAfterChange = this.WithSession(f => f.GetBL().GetSecondaryStockArticle(articleFilter)); this.Verifier.Verify("4_articlesSecondaryStockArticlesAfterChange", articlesSecondaryStockArticlesAfterChange); var newSecondaryStock = new SecondaryStockArticleDTO() { Article = new ArticleLightDTO() { I3D = 4339 }, Mandator = new MandatoryDTO() { I3D = 2 }, SecondaryStock = new StockDTO() { I3D = 6 }, StorageLocation = new StorageLocationDTO() { I3D = 9 }, StorageArea = new StorageAreaDTO() { I3D = 19 }, Intake = 1, Stock = 2.3, MinimumStock = 4.5, PurchasePrice = null, RawEk1 = 6.78m, RawEk2 = 9.11m, RealStock = 12.13, ArticleInProcure = 14.15, OwnPurchasePrice = true, RawEk1Date = new DateTime(2000, 1, 1), RawEk2Date = null, StockInDelivery = 16.17, StockInOrder = 18.19, StockInRepair = 20.21 }; this.WithSession(f => f.GetBL().SaveSecondaryStock(newSecondaryStock)); var newFilter = new SecondaryStockArticleFilter() { SecondaryStockI3D = 6 }; var newSecondaryStockArtcle = this.WithSession(f => f.GetBL().GetSecondaryStockArticle(newFilter)); this.Verifier.Verify("5_newSecondaryStockArticles", newSecondaryStockArtcle); } private void BookInBookOut() { int articleWithScanBarcodeActive = 4354; int articleWithoutScanBarcode = 58; //this is an article with scanbarcode active -> the amount is determined of the amount of the barcodes, so the quantity should not change here var articleWithScanBarcodeFilter = new ArticleStockInfoFilter() { ArticleI3D = articleWithScanBarcodeActive, StockI3D = 7 }; this.WithSession(f => f.GetBL().StockBookOrBookout(true, articleI3D: articleWithScanBarcodeActive, stockI3D: 7, amount: 10, "Was macht die Security in der Nudelfabrik? - Die Pasta auf.", appUserI3D: 11)); var bookInSerial = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleWithScanBarcodeFilter)); this.Verifier.Verify("6_bookInSerial", bookInSerial); this.WithSession(f => f.GetBL().StockBookOrBookout(false, articleI3D: articleWithScanBarcodeActive, stockI3D: 2, amount: 5, "Was trinkt die Chefin ? - Leitungswasser", appUserI3D: 11)); var bookOutSerial = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleWithScanBarcodeFilter)); this.Verifier.Verify("7_bookOutSerial", bookOutSerial); var articleWithoutScanBarcodeFilter = new ArticleStockInfoFilter() { ArticleI3D = articleWithoutScanBarcode, StockI3D = 7 }; this.WithSession(f => f.GetBL().StockBookOrBookout(true, articleI3D: articleWithoutScanBarcode, stockI3D: 7, amount: 10, "Meine Schwester hat eine Tochter bekommen...", appUserI3D: 11)); var bookIn = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleWithoutScanBarcodeFilter)); this.Verifier.Verify("8_bookIn", bookIn); this.WithSession(f => f.GetBL().StockBookOrBookout(false, articleI3D: articleWithoutScanBarcode, stockI3D: 7, amount: 5, "...Da wurde mein Wunsch nach einem Neffen zur Nichte gemacht", appUserI3D: 11)); var bookOut = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleWithoutScanBarcodeFilter)); this.Verifier.Verify("9_bookOut", bookOut); var articleMainStorage = new ArticleStockInfoFilter() { ArticleI3D = articleWithoutScanBarcode, StockI3D = -1 }; this.WithSession(f => f.GetBL().StockBookOrBookout(true, articleI3D: articleWithoutScanBarcode, stockI3D: -1, amount: 20, "Sagt ein Tischler zum anderen: 'Halt doch mal die Fräse'...", appUserI3D: 11)); var bookInMainStock = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleMainStorage)); this.Verifier.Verify("10_bookInMainStock", bookInMainStock); this.WithSession(f => f.GetBL().StockBookOrBookout(false, articleI3D: articleWithoutScanBarcode, stockI3D: -1, amount: 5, "..., sagt der andere: 'Aber ich hab doch gar nix gesägt!'", appUserI3D: 11)); var bookOutMainStock = this.WithSession(f => f.GetBL().SearchArticleStockInfos(articleMainStorage)); this.Verifier.Verify("11_bookOutMainStock", bookOutMainStock); } } }