public void Check_max_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var supplier3 = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var client1 = TestClient.CreateNaked(session); session.CreateSQLQuery("update customers.intersection set AgencyEnabled = 0 where PriceId not in (:ids) and ClientId = :clientId") .SetParameter("clientId", client.Id) .SetParameterList("ids", supplier1.Prices.Select(p => p.Id).ToArray()) .ExecuteUpdate(); Property("PriceCode", supplier1.Prices[0].Id); Property("ProducerAccount", false); Property("AllAssortment", false); Property("WithWithoutProperties", false); Property("ShowCodeC", false); Property("ShowCodeCr", false); Property("FirmCodeEqual", new List <long> { supplier1.Id, supplier2.Id, supplier3.Id }); Property("Clients", new List <long> { client.Id, client1.Id }); //проверяем что не возникает ошибка //Для клиента ... получено фактическое количество прайс листов меньше трех, получено прайс-листов 1 ProcessReport(typeof(PricesOfCompetitorsReport)); }
public void Show_junk() { supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); order = new TestOrder(client.Users[0], supplier.Prices[0]); order.WriteTime = order.WriteTime.AddDays(-1); var offer = supplier.Prices[0].Core[0]; offer.Junk = true; order.AddItem(offer, 10); session.Save(order); Property("ProductNamePosition", 0); Property("MnnPosition", 1); Property("ShowCode", true); Property("ByPreviousMonth", false); Property("ReportInterval", 1); Property("SourceFirmCode", (int)supplier.Id); Property("HideJunk", false); var sheet = ReadReport <MixedReport>(); var text = ToText(sheet); Assert.That(text, Does.Contain(offer.Code)); Assert.That(text, Is.Not.StringContaining("Из отчета исключены уцененные товары и товары с ограниченным сроком годност")); }
public void Region_filter() { var supplier = TestSupplier.CreateNaked(session); supplier.AddRegion(session.Load <TestRegion>(512ul)); var client = TestClient.CreateNaked(session, 512, 512); var order = CreateOrder(client, supplier); session.Save(order); var client1 = TestClient.CreateNaked(session); var order1 = CreateOrder(client1, supplier); session.Save(order1); Property("ReportInterval", 7); Property("ByPreviousMonth", false); Property("RegionEqual", new List <long> { 512 }); var report = ReadReport <OrdersStatistics>(); var result = ToText(report); Assert.That(result, Is.Not.StringContaining("Воронеж")); }
public void ErrorOnAllowedExtensions() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@supplier.test", supplier.Id); PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( "test AllowedExtensions", "body AllowedExtensions", new string[] { "{0}@docs.analit.net".Format(user.AvaliableAddresses[0].Id) }, new[] { from }, new string[] { @"..\..\Data\Waybills\70983_906384.zip" }); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); try { handler.CheckMime(message); Assert.Fail("Должно было возникнуть исключение MiniMailOnAllowedExtensionsException"); } catch (MiniMailOnAllowedExtensionsException exception) { Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnAllowedExtensions)); Assert.That(exception.ErrorExtention, Is.EqualTo(".zip").IgnoreCase); Assert.That(exception.AllowedExtensions, Is.EqualTo("doc, xls, gif, tiff, tif, jpg, pdf, txt").IgnoreCase); SendErrorToProvider(handler, exception, message); } }
public void Parent_synonym_test() { session.Transaction.Begin(); var supplier2 = TestSupplier.CreateNaked(); supplier2.Prices[0].ParentSynonym = supplier.Prices[0].Id; session.Save(supplier2); session.Transaction.Commit(); form.Form1_Load(form, null); var cbSynonym = ((ComboBox)form.Controls.Find("cbSynonym", true)[0]); foreach (var item in cbSynonym.Items) { var row = (DataRowView)item; if (Convert.ToUInt32(row[0]) == supplier.Id) { cbSynonym.SelectedItem = row; } } form.tmrSearch_Tick(null, null); var indgvFirm = Grid("indgvFirm"); var index = indgvFirm.Rows.Cast <DataGridViewRow>().IndexOf(r => Convert.ToUInt32(((DataRowView)r.DataBoundItem)["CCode"]) == supplier2.Id); indgvFirm.CurrentCell = indgvFirm[0, index]; var grid = Grid("indgvPrice"); var views = grid.Rows.Cast <DataGridViewRow>().Select(r => r.DataBoundItem).Cast <DataRowView>().ToList(); var dataGridViewRow = views.First(); Assert.AreEqual(dataGridViewRow.DataView[0][0], supplier.Prices[0].Id); }
public void Map_catalog_id() { var clientCatalogId = Generator.Random().First(); var product = session.Query <TestProduct>().First(); var mapSupplier = TestSupplier.CreateNaked(session, TestRegion.Inforoom); mapSupplier.Prices[0].PriceType = PriceType.Assortment; var core = mapSupplier.AddCore(product); core.Code = clientCatalogId.ToString(); session.Save(mapSupplier); client.Settings.CatalogMapPrice = mapSupplier.Prices[0]; var supplier = TestSupplier.CreateNaked(session); supplier.AddFullCore(session, product); session.Save(supplier); user.Client.MaintainIntersection(session); session.Transaction.Commit(); var data = service.GetOffers(new[] { "fullcode" }, new[] { product.CatalogProduct.Id.ToString() }, false, new string[0], new string[0], 100, 0); Assert.That(data.Tables[0].Rows.Count, Is.GreaterThan(0), "код каталожного товара {0} пользователь {1}", product.CatalogProduct.Id, user.Id); Assert.That(data.Tables[0].Rows[0]["ClientCatalogId"], Is.EqualTo(clientCatalogId.ToString()), "код каталожного товара {0} пользователь {1}", product.CatalogProduct.Id, user.Id); }
private void SetUp(IList <TestUser> users, TestRegion region, string subject, string body, IList <string> fileNames) { var info = new DocSourceHandlerTestInfo(); var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@supplier.test", supplier.Id); PrepareSupplier(supplier, from); info.Supplier = supplier; var toList = users.Select(u => "{0}@docs.analit.net".Format(u.AvaliableAddresses[0].Id)).ToList(); if (region != null) { toList.Add(region.ShortAliase + "@docs.analit.net"); } var message = ImapHelper.BuildMessageWithAttachments( subject, body, toList.ToArray(), new[] { from }, fileNames != null ? fileNames.ToArray() : null); info.Mime = message; info.Region = region; info.Users = users; _info = info; }
public void LipetskFormaciaExporter() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var settings = session.Load <WaybillSettings>(client.Id); settings.AssortimentPriceId = supplier.Prices[0].Id; settings.WaybillConvertFormat = WaybillFormat.LipetskFarmacia; settings.IsConvertFormat = true; var path = @"..\..\Data\Waybills\446406_0.dbf"; var startLog = new DocumentReceiveLog(session.Load <Supplier>(supplier.Id), session.Load <Address>(client.Addresses[0].Id)) { DocumentType = DocType.Waybill, LogTime = DateTime.Now, }; session.Save(startLog); var document = WaybillParser.Parse(path, startLog); document.Log = startLog; document.DocumentDate = DateTime.Now; document.Log.IsFake = true; session.Save(document); //test var log = Exporter.ConvertAndSave(document, WaybillFormat.LipetskFarmacia, settings); Assert.That(log.FileName.Substring(log.FileName.Length - 4), Is.EqualTo(".xls")); Assert.That(document.Log.IsFake, Is.EqualTo(false)); }
public void LipetskFormaciaProtekExport() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var settings = session.Load <WaybillSettings>(client.Id); settings.AssortimentPriceId = supplier.Prices[0].Id; settings.WaybillConvertFormat = WaybillFormat.LipetskFarmacia; settings.IsConvertFormat = true; var path = @"..\..\Data\Waybills\446406_0.dbf"; var startLog = new DocumentReceiveLog(session.Load <Supplier>(supplier.Id), session.Load <Address>(client.Addresses[0].Id)) { DocumentType = DocType.Waybill, LogTime = DateTime.Now, }; session.Save(startLog); var document = WaybillParser.Parse(path, startLog); document.Log = startLog; document.DocumentDate = DateTime.Now; document.Log.IsFake = true; session.Save(document); //test Exporter.SaveProtek(document); var dblogs = session.Query <DocumentReceiveLog>().Where(i => i.ClientCode == client.Id).ToList(); Assert.That(dblogs.Count, Is.EqualTo(2)); Assert.That(dblogs[0].IsFake, Is.False); Assert.That(dblogs[1].IsFake, Is.False); }
public void Process_message_if_from_contains_more_than_one_address() { client = TestClient.CreateNaked(session); address = client.Addresses[0]; supplier = TestSupplier.CreateNaked(session); supplier.WaybillSource.EMailFrom = String.Format("edata{0}@msk.katren.ru", supplier.Id); supplier.WaybillSource.SourceType = TestWaybillSourceType.Email; session.Save(supplier); FileHelper.DeleteDir(Settings.Default.DocumentPath); ImapHelper.ClearImapFolder(); var mime = PatchTo(@"..\..\Data\Unparse.eml", String.Format("{0}@waybills.analit.net", address.Id), String.Format("edata{0}@msk.katren.ru,[email protected]", supplier.Id)); ImapHelper.StoreMessage(mime.ToByteData()); Process(); var files = GetFileForAddress(DocType.Waybill); Assert.That(files.Length, Is.EqualTo(1), "не обработали документ"); }
public void SetUp(IList <string> fileNames) { client = TestClient.CreateNaked(session); supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@test.test", client.Id); PrepareSupplier(supplier, from); byte[] bytes; if (IsEmlFile) { bytes = File.ReadAllBytes(fileNames[0]); } else { var message = ImapHelper.BuildMessageWithAttachments( String.Format("{0}@waybills.analit.net", client.Addresses[0].Id), from, fileNames.ToArray()); bytes = message.ToByteData(); } ImapHelper.StoreMessage( Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, Settings.Default.IMAPSourceFolder, bytes); }
public void Ignore_document_for_wrong_address() { var begin = DateTime.Now; var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@test.test", supplier.Id); PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( String.Format("{0}@waybills.analit.net", "1"), from, new[] { @"..\..\Data\Waybills\bi055540.DBF" }); var bytes = message.ToByteData(); ImapHelper.StoreMessage( Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, Settings.Default.IMAPSourceFolder, bytes); this.supplier = supplier; Process(); var docs = session.Query <TestDocumentLog>().Where(d => d.LogTime > begin).ToList(); Assert.That(docs.Count, Is.EqualTo(0)); }
public void Configure_min_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); Property("ReportType", 0); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ReportIsFull", false); Property("MinSupplierCount", 2); Property("FirmCodeEqual", new List <ulong> { supplier1.Id, supplier2.Id }); // http://redmine.analit.net/issues/52707 Property("FirmCodeEqual2", new List <ulong> { supplier2.Id }); Property("Clients", new List <ulong> { client.Id }); BuildReport(reportType: typeof(SpecShortReport)); Assert.IsTrue(File.Exists("test.xls")); }
public void Check_max_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var supplier3 = TestSupplier.CreateNaked(session); var client1 = TestClient.CreateNaked(session); var client2 = TestClient.CreateNaked(session); client2.Users[0].CleanPrices(session, supplier3); session.CreateSQLQuery("update customers.intersection set AgencyEnabled = 0 where PriceId not in (:ids) and ClientId = :clientId") .SetParameter("clientId", client1.Id) .SetParameterList("ids", supplier1.Prices.Select(p => p.Id).ToArray()) .ExecuteUpdate(); Property("ReportType", 0); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ReportIsFull", false); Property("FirmCodeEqual", new List <ulong> { supplier1.Id, supplier2.Id, supplier3.Id }); Property("Clients", new List <ulong> { client1.Id, client2.Id }); //проверяем отсутствие исключения Фактическое количество прайс листов меньше трех, получено прайс-листов 1 BuildReport(reportType: (typeof(SpecShortReport))); }
public void Lower_limit_by_actual_sum() { var supplier = TestSupplier.CreateNaked(session); var price = supplier.Prices[0]; supplier.CreateSampleCore(session); price.Costs[0].PriceItem.PriceDate = DateTime.Now.AddDays(-10); session.Save(supplier); supplier.Maintain(session); var address = session.Load <Address>(user.AvaliableAddresses[0].Id); var limit = new OrderLimit(session.Load <Supplier>(supplier.Id), 1000) { Today = 500 }; address.OrderLimits.Add(limit); var settings = session.Load <ClientSettings>(user.Client.Id); settings.AllowDelayOfPayment = true; var offer = price.Core[0]; var clientOrder = ToClientOrder(offer); clientOrder.Orders[0].Items[0].ResultCost = 150; session.Flush(); PostOrder(clientOrder); session.Refresh(limit); Assert.AreEqual(900, limit.Value); Assert.AreEqual(500, limit.Today); }
public void Setup() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); address = client.CreateAddress(); user = client.Users.First(); session.Save(address); ServiceContext.GetUserName = () => user.Login; var container = new WindsorContainer(); container.AddComponent("RepositoryInterceptor", typeof(RepositoryInterceptor)); container.AddComponent("OfferRepository", typeof(IOfferRepository), typeof(OfferRepository)); container.AddComponent("Repository", typeof(IRepository <>), typeof(Repository <>)); var holder = new SessionFactoryHolder(); holder .Configuration .AddInputStream(HbmSerializer.Default.Serialize(Assembly.Load("Common.Models"))); container.Kernel.AddComponentInstance <ISessionFactoryHolder>(holder); IoC.Initialize(container); IoC.Container.Register( Component.For <IInforoomOnlineService>() .ImplementedBy <InforoomOnlineService>() .Interceptors(InterceptorReference.ForType <ContextLoaderInterceptor>()) .Anywhere, Component.For <ContextLoaderInterceptor>(), Component.For <IClientLoader>().ImplementedBy <ClientLoader>()); service = IoC.Resolve <IInforoomOnlineService>(); }
public void Drop_duplicate_order() { var supplier = TestSupplier.CreateNaked(session); var price = supplier.Prices[0]; supplier.CreateSampleCore(session); price.Costs[0].PriceItem.PriceDate = DateTime.Now.AddDays(-10); session.Save(supplier); supplier.Maintain(session); //нужно что бы сохранить синонимы session.Flush(); var offer = price.Core[0]; var request = ToClientOrder(offer); var results = PostOrder(request); var orders = session.Query <TestOrder>() .Where(x => x.User.Id == user.Id).ToArray(); Assert.AreEqual(results[0].ClientOrderId, request.Orders[0].ClientOrderId); Assert.AreEqual(results[0].Result, OrderResultStatus.OK); Assert.AreEqual(results[0].ServerOrderId, orders[0].Id); results = PostOrder(ToClientOrder(offer)); Assert.AreEqual(results[0].ClientOrderId, request.Orders[0].ClientOrderId); Assert.AreEqual(results[0].Result, OrderResultStatus.OK); Assert.AreEqual(results[0].ServerOrderId, orders[0].Id); orders = session.Query <TestOrder>() .Where(x => x.User.Id == user.Id).ToArray(); Assert.AreEqual(1, orders.Length); }
public void Setup() { var client = TestClient.CreateNaked(session); var address = client.Addresses[0]; supplier = TestSupplier.CreateNaked(session); var waybill = new TestWaybill(new TestDocumentLog(supplier, address)); product1 = session.Query <TestProduct>().First(); product2 = session.Query <TestProduct>().Skip(1).First(); waybill.Lines.Add(new TestWaybillLine(waybill) { Product = "Аксетин", CatalogProduct = product1, Quantity = 10, SerialNumber = "4563", EAN13 = "5290931004832", ProducerCost = 56, SupplierCost = 100, }); waybill.Lines.Add(new TestWaybillLine(waybill) { Product = "Аксетин", CatalogProduct = product2, Quantity = 10, SerialNumber = "4563", EAN13 = "5290931004832", ProducerCost = 56, SupplierCost = 70, }); session.Save(waybill); }
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 GetAllNamesTest() { var supplier = TestSupplier.CreateNaked(); var price = supplier.Prices[0]; priceItem = price.Costs.First().PriceItem; var format = price.Costs.Single().PriceItem.Format; format.PriceFormat = PriceFormatType.NativeDelim; format.Delimiter = ";"; format.FName1 = "F2"; format.FFirmCr = "F3"; format.FQuantity = "F5"; format.FRequestRatio = "F6"; var costFormRule = price.Costs.Single().FormRule; costFormRule.FieldName = "F4"; session.Save(price); Close(); File.Copy(Path.GetFullPath(@"..\..\Data\222.txt"), Path.Combine(basepath, priceItem.Id + ".txt")); var item = PriceProcessItem.GetProcessItem(priceItem.Id); var names = item.GetAllNames(); Assert.That(names.Count(), Is.EqualTo(35)); }
public void NotFoundError() { var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@supplier.test", supplier.Id); PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( "test NotFound", "body NotFound", new string[] { "*****@*****.**" }, new[] { from }, null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); try { handler.CheckMime(message); Assert.Fail("Должно было возникнуть исключение MiniMailOnEmptyRecipientsException"); } catch (MiniMailOnEmptyRecipientsException exception) { Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnEmptyRecipients)); Assert.That(exception.CauseList, Is.EqualTo("[email protected] : " + RecipientStatus.NotFound.GetDescription())); SendErrorToProvider(handler, exception, message); } }
public void DeleteSynonymProducerWithretransTest() { var supplier = TestSupplier.CreateNaked(session); var price = supplier.Prices[0]; price.Costs[0].PriceItem.Format.PriceFormat = PriceFormatType.NativeDbf; var producer = new TestProducer { Name = "Тестовый производитель" }; Save(producer); var producerSynonym = price.AddProducerSynonym(producer.Name, producer); var cr = new TestCore(price.AddProductSynonym("Тестовый синоним2"), producerSynonym) { Price = price, Quantity = "1", Code = "123", Period = "123" }; Save(cr); Flush(); Reopen(); service.DeleteProducerSynonymWithRetrans(producerSynonym.Id); var savedSynonym = session.Query <ProducerSynonym>().Where(s => s.Id == producerSynonym.Id).ToList(); Assert.That(savedSynonym.Count, Is.EqualTo(0)); Assert.That(PriceRetrans.Retranses.Count, Is.EqualTo(1)); Assert.That(PriceRetrans.Retranses.First(), Is.EqualTo(price.Costs[0].PriceItem.Id)); }
public void ErrorOnEmptyLetter() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var supplier = TestSupplier.CreateNaked(session); var from = $"{supplier.Id}@supplier.test"; PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( " ", " ", new string[] { "{0}@docs.analit.net".Format(user.AvaliableAddresses[0].Id) }, new[] { from }, null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); try { handler.CheckMime(message); Assert.Fail("Должно было возникнуть исключение MiniMailOnEmptyLetterException"); } catch (MiniMailOnEmptyLetterException exception) { Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnEmptyLetter)); SendErrorToProvider(handler, exception, message); } }
private void CreateExclude() { var supplier = TestSupplier.CreateNaked(this.session); this.session.Transaction.Commit(); this.session.BeginTransaction(); using (var session = sessionFactory.OpenSession()) { var price = session.Load <Price>(supplier.Prices[0].Id); var producerSynonym = new ProducerSynonym { Name = "Тетовый синоним", Price = price, Producer = session.Query <Producer>().First() }; var productSynonym = new Synonym { Name = "Тетовый синоним", Price = price, ProductId = session.Query <CatalogProduct>().First().Id }; var exclude = new Exclude { CatalogProduct = session.Query <CatalogProduct>().First(), Price = price, ProducerSynonym = "Тетовый синоним", OriginalSynonym = productSynonym, }; session.Save(producerSynonym); session.Save(productSynonym); session.Save(exclude); } }
public void Remove_duplicate_codes() { supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); order = new TestOrder(client.Users[0], supplier.Prices[0]); order.WriteTime = order.WriteTime.AddDays(-1); var offer = supplier.Prices[0].Core[0]; order.AddItem(offer, 10); session.Save(order); Property("ProductNamePosition", 0); Property("MnnPosition", 1); Property("ByPreviousMonth", false); Property("ShowCode", true); Property("ReportInterval", 1); Property("SourceFirmCode", (int)supplier.Id); var sheet = ReadReport <MixedReport>(); var text = ToText(sheet); var row = FindRowByProduct(sheet, offer.Product); Assert.AreEqual(offer.Code, row.GetCell(0).StringCellValue, text); }
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 Import_order_xml() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); Program.SupplierIdForCodeLookup = supplier.Id; var price = supplier.Prices[0]; var client = TestClient.CreateNaked(session); var address = client.Addresses[0]; var intersection = session.Query <TestAddressIntersection>().First(a => a.Address == address && a.Intersection.Price == price); intersection.SupplierDeliveryId = "02"; intersection.Intersection.SupplierClientId = "1"; session.Save(intersection); FlushAndCommit(); var root = Directory.CreateDirectory($"tmp/{client.Users[0].Id}/orders/"); using (var zip = new ZipFile()) { zip.AddEntry("1.xml", OrderPacket(price.Core.Select(x => (object)x.Id).Take(2).ToArray())); zip.Save(Path.Combine(root.FullName, "order.zip")); } Program.ProcessUser(config, client.Users[0].Id, ProtocolType.Xml); var orders = session.Query <TestOrder>().Where(x => x.Client.Id == client.Id).ToList(); Assert.AreEqual(1, orders.Count); }
public void Get_orders() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); var offer = supplier.Prices[0].Core[0]; testClient.MaintainIntersection(); service.PostOrder(new[] { offer.Id }, new uint[] { 1 }, new[] { "" }, new[] { offer.ProducerSynonym.Id }, new[] { offer.ProductSynonym.Id }, new[] { false }); var order = session.Query <TestOrder>().First(o => o.Client == testClient); order.WriteTime = order.WriteTime.AddHours(-1); session.Save(order); session.Flush(); var lines = service.GetOrderItems(DateTime.Now.AddDays(-1), DateTime.Now.AddMinutes(-30)); var row = lines.Tables[0].Rows[0]; Assert.AreEqual(1, lines.Tables[0].Rows.Count); Assert.IsInstanceOf <string>(row["WriteTime"]); Assert.IsInstanceOf <string>(row["WriteDate"]); }
public void FreeOrdersTest() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var product = new TestProduct("Тестовый продукт"); session.Save(product); var order = new TestOrder(client.Users.First(), supplier.Prices[0]); order.AddItem(product, 1, 100); session.Save(order); var result = ExecuteReport(); var sum1 = result.AsEnumerable().Where(r => r["OrdersSum"] != DBNull.Value).Sum(r => (decimal)r["OrdersSum"]); var freeOrdersQuery = session.CreateSQLQuery( String.Format("INSERT INTO billing.freeorders VALUES({0}, {1});", order.Address.Payer.Id, supplier.Payer.Id)); freeOrdersQuery.ExecuteUpdate(); result = ExecuteReport(); var sum2 = result.AsEnumerable().Where(r => r["OrdersSum"] != DBNull.Value).Sum(r => (decimal)r["OrdersSum"]); Assert.That(sum2, Is.EqualTo(sum1 - 100)); }
public void Build_excel_report() { var supplier = TestSupplier.CreateNaked(session); var product = session.Query <TestProduct>().First(p => p.CatalogProduct.Pharmacie); var core1 = supplier.AddFullCore(session, product); var core2 = supplier.AddFullCore(session, product, session.Query <TestProducer>().First()); core2.Code = Generator.Random().First().ToString(); var client = TestClient.CreateNaked(session); session.CreateSQLQuery("delete from Customers.UserPrices where PriceId <> :priceId and UserId = :userId") .SetParameter("priceId", supplier.Prices[0].Id) .SetParameter("userId", client.Users[0].Id) .ExecuteUpdate(); Property("ReportType", (int)DefReportType.ByNameAndFormAndFirmCr); Property("RegionEqual", new List <ulong> { client.RegionCode }); Property("ClientCode", client.Id); Property("UserCode", client.Users[0].Id); Property("PriceCode", supplier.Prices[0].Id); var report = ReadReport <DefReport>(); var result = ToText(report); Assert.That(result, Does.Contain("|Код|Наименование|Форма выпуска|Производитель|")); }