public void Generate_report() { var code = new string(Guid.NewGuid().ToString().Take(20).ToArray()); var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var price = supplier.Prices[0]; var order = new TestOrder(client.Users[0], price) { WriteTime = DateTime.Now.AddDays(-5) }; var productSynonym = price.AddProductSynonym(TestProduct.Random(session).First()); session.Save(productSynonym); var item = order.AddItem(TestProduct.RandomProducts(session).First(), 10, 456); item.SynonymCode = productSynonym.Id; item.Code = code; session.Save(order); Property("ReportInterval", 5); Property("SupplierId", supplier.Id); Property("Regions", new List <ulong> { client.RegionCode }); var AFCode = $"{item.Product.Id}_{item.CodeFirmCr ?? 0}"; var sheet = ReadReport <PulsOrderReport>(); var text = ToText(sheet); Assert.That(text, Does.Contain(AFCode)); }
public void Group_by_code_and_product() { var code = new string(Guid.NewGuid().ToString().Take(20).ToArray()); var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var price = supplier.Prices[0]; var order = new TestOrder(client.Users[0], price) { WriteTime = DateTime.Now.AddDays(-5) }; var productSynonym = price.AddProductSynonym(TestProduct.Random(session).First()); session.Save(productSynonym); var item = order.AddItem(TestProduct.RandomProducts(session).First(), 10, 456); item.SynonymCode = productSynonym.Id; item.Code = code; session.Save(order); Property("ReportInterval", 5); Property("SupplierProductCodePosition", 0); Property("SupplierProductNamePosition", 1); Property("FirmCodeEqual", new List <ulong> { supplier.Id }); var sheet = ReadReport <RatingReport>(); Assert.AreEqual("Оригинальный код товара", sheet.GetRow(2).GetCell(0).StringCellValue); Assert.AreEqual(code, sheet.GetRow(3).GetCell(0).StringCellValue); Assert.AreEqual("Оригинальное наименование товара", sheet.GetRow(2).GetCell(1).StringCellValue); Assert.AreEqual(productSynonym.Name, sheet.GetRow(3).GetCell(1).StringCellValue); }
public void Cache_optimized_costs() { var supplier = TestSupplier.CreateNaked(session); var products = TestProduct.RandomProducts(session).Take(2).ToArray(); supplier.CreateSampleCore(session, new[] { products[0] }); var supplier2 = TestSupplier.CreateNaked(session); supplier2.CreateSampleCore(session, new[] { products[1] }); var rule = new CostOptimizationRule(session.Load <Supplier>(supplier.Id), RuleType.MaxCost) { Diapasons = { new CostOptimizationDiapason(0, decimal.MaxValue, 20) }, Clients = { session.Load <Client>(client.Id) }, Concurrents = { session.Load <Supplier>(supplier2.Id) } }; session.Save(rule); client.Users[0].CleanPrices(session, supplier, supplier2); client.MaintainIntersection(session); session.Flush(); exporter.ExportDb(); exporter.Confirm(new ConfirmRequest(requestLog.Id)); var id = supplier.Prices[0].Core[0].Id; var offers = ParseData("offers").ToArray(); var offer = offers.First(x => Convert.ToUInt64(x[0]) == id); Assert.AreEqual(120, Convert.ToDecimal(GetColumnValue("Offers", "Cost", offer), CultureInfo.InvariantCulture)); //симулируем обновление прайс-листа supplier2.CreateSampleCore(session, new[] { products[0] }, new[] { supplier.Prices[0].Core[0].Producer }); supplier2.InvalidateCache(session, user.Id); Init(session.Load <AnalitfNetData>(user.Id).LastUpdateAt); exporter.ExportDb(); offers = ParseData("offers").ToArray(); offer = offers.First(x => Convert.ToUInt64(x[0]) == id); Assert.AreEqual(120, Convert.ToDecimal(GetColumnValue("Offers", "Cost", offer), CultureInfo.InvariantCulture)); }