Exemple #1
0
        public void Complex_double_firmalize_no_automatic_synonim()
        {
            session.CreateSQLQuery("delete from AutomaticProducerSynonyms")
            .ExecuteUpdate();

            var product = new TestProduct("9 МЕСЯЦЕВ КРЕМ ДЛЯ ПРОФИЛАКТИКИ И КОРРЕКЦИИ РАСТЯЖЕК 150МЛ");

            product.CatalogProduct.Pharmacie = true;
            product.CatalogProduct.Monobrend = true;
            session.Save(product);
            var producer = new TestProducer("Валента Фармацевтика/Королев Ф");

            session.Save(producer);
            price.AddProductSynonym("9 МЕСЯЦЕВ КРЕМ ДЛЯ ПРОФИЛАКТИКИ И КОРРЕКЦИИ РАСТЯЖЕК 150МЛ", product);
            price.CreateAssortmentBoundSynonyms(
                "5 ДНЕЙ ВАННА Д/НОГ СМЯГЧАЮЩАЯ №10 ПАК. 25Г",
                "Санкт-Петербургская ф.ф.");
            session.Save(price);
            TestAssortment.CheckAndCreate(session, product, producer);
            Reopen();

            Price(@"9 МЕСЯЦЕВ КРЕМ ДЛЯ ПРОФИЛАКТИКИ И КОРРЕКЦИИ РАСТЯЖЕК 150МЛ;Валента Фармацевтика/Королев Ф;2864;220.92;
5 ДНЕЙ ВАННА Д/НОГ СМЯГЧАЮЩАЯ №10 ПАК. 25Г;Санкт-Петербургская ф.ф.;24;73.88;");

            Formalize();
            Formalize();

            var count = session.CreateSQLQuery("select count(*) from AutomaticProducerSynonyms")
                        .UniqueResult <long>();

            Assert.That(count, Is.EqualTo(0));
        }
Exemple #2
0
        public void SetUp()
        {
            var priceParent = TestSupplier.CreateNaked(session).Prices[0];
            var price       = TestSupplier.CreateNaked(session).Prices[0];

            price.ParentSynonym = priceParent.Id;
            Save(price);
            _supplier = price.Supplier;
            var client      = TestClient.CreateNaked(session);
            var testAddress = client.Addresses[0];

            var order = new TestOrder();

            _product = new TestProduct("Виагра (табл.)");
            _product.CatalogProduct.Pharmacie = true;
            session.Save(_product);

            _producer = new TestProducer("Пфайзер");
            session.Save(_producer);
            session.Save(new TestSynonym()
            {
                Synonym = "Виагра", ProductId = _product.Id, PriceCode = (int?)price.Id
            });

            session.Save(new TestSynonymFirm()
            {
                Synonym = "Пфайзер", CodeFirmCr = (int?)_producer.Id, PriceCode = (int?)price.Id
            });

            TestAssortment.CheckAndCreate(session, _product, _producer);

            var log = new DocumentReceiveLog(session.Load <Supplier>(_supplier.Id), session.Load <Address>(testAddress.Id))
            {
                MessageUid   = 123,
                DocumentSize = 100
            };

            _doc = new Document(log)
            {
                OrderId      = order.Id,
                Address      = log.Address,
                DocumentDate = DateTime.Now
            };

            _supplierCode = new SupplierCode {
                Code       = "45678",
                Supplier   = session.Load <Supplier>(_supplier.Id),
                ProducerId = _producer.Id,
                Product    = session.Load <Product>(_product.Id),
                CodeCr     = string.Empty
            };
            session.Save(_supplierCode);

            // сопоставляется по коду
            _documentLine          = _doc.NewLine();
            _documentLine.Product  = "Виагра";
            _documentLine.Producer = " Тестовый производитель  ";
            _documentLine.Code     = "45678";
        }
        public void TestFillSupplierCode()
        {
            var expression = new TestUnrecExp("Тестовый продукт", "Тестовый производитель", price);

            expression.Code = new Random().Next().ToString();
            expression.Save();
            var product  = Pharmacie().First();
            var producer = TestProducer.Queryable.FirstOrDefault();

            TestAssortment.CheckAndCreate(session, product, producer);
            Load();
            Resolve(expression, product);
            Resolve(expression, producer);
            Save();
            session.Clear();
            var synonym       = session.Query <TestProductSynonym>().FirstOrDefault(s => s.Price == price);
            var synonymFirmCr = session.Query <TestProducerSynonym>().FirstOrDefault(s => s.Price == price);

            Assert.That(synonym, Is.Not.Null);
            Assert.That(synonymFirmCr, Is.Not.Null);
        }
        public void Setup()
        {
            supplier = TestSupplier.CreateNaked(session);
            supplier.CreateSampleCore(session);
            supplier.Prices[0].Core.Where(c => c.Producer != null)
            .Each(c => TestAssortment.CheckAndCreate(session, c.Product, c.Producer));
            var client = TestClient.CreateNaked(session);
            var order  = new TestOrder(client.Users[0], supplier.Prices[0]);

            order.Processed = false;
            order.WriteTime = DateTime.Today.AddDays(-1);
            order.AddItem(supplier.Prices[0].Core[0], 1);
            session.Save(order);
            supplier.Maintain(session);
            session.Transaction.Commit();

            calculator = new CostCalculator();

            ratings = RatingCalculator
                      .Caclucated(DateTime.Today.AddDays(-10), DateTime.Today)
                      .Take(3)
                      .ToArray();
        }
        public void DocumentSetIdTest()
        {
            var price       = TestSupplier.CreateTestSupplierWithPrice();
            var supplier    = price.Supplier;
            var client      = TestClient.CreateNaked();
            var testAddress = client.Addresses[0];

            var order = new TestOrder();

            var product1 = new TestProduct("Активированный уголь (табл.)");

            product1.CatalogProduct.Pharmacie = true;
            session.Save(product1);
            var product2 = new TestProduct("Виагра (табл.)");

            product2.CatalogProduct.Pharmacie = true;
            session.Save(product2);
            var product3 = new TestProduct("Крем для кожи (гель.)");

            product3.CatalogProduct.Pharmacie = false;
            session.Save(product3);
            var product4 = new TestProduct("Эластичный бинт");

            product4.CatalogProduct.Pharmacie = false;
            session.Save(product4);
            var product5 = new TestProduct("Стерильные салфетки");

            product5.CatalogProduct.Pharmacie = false;
            session.Save(product5);
            var product6 = new TestProduct("Аспирин (табл.)");

            product6.CatalogProduct.Pharmacie = false;
            session.Save(product6);

            var producer1 = new TestProducer("ВероФарм");

            session.Save(producer1);
            var producer2 = new TestProducer("Пфайзер");

            session.Save(producer2);
            var producer3 = new TestProducer("Воронежская Фармацевтическая компания");

            session.Save(producer3);
            session.Save(new TestSynonym {
                Synonym = "Активированный уголь", ProductId = product1.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Виагра", ProductId = product2.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Крем для кожи", ProductId = product3.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Аспирин", ProductId = product6.Id, PriceCode = (int?)price.Id
            });


            session.Save(new TestSynonymFirm {
                Synonym    = "ВероФарм",
                CodeFirmCr = (int?)producer1.Id,
                PriceCode  = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer1.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer2.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym    = "Верофарм",
                CodeFirmCr = (int?)producer2.Id,
                PriceCode  = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym    = "ВоронежФарм",
                CodeFirmCr = (int?)producer3.Id,
                PriceCode  = (int?)price.Id
            });

            TestAssortment.CheckAndCreate(product1, producer1);
            TestAssortment.CheckAndCreate(product2, producer2);

            var supplierCode2 = new SupplierCode {
                Code       = "45678",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer2.Id,
                Product    = session.Load <Product>(product2.Id),
                CodeCr     = "1"
            };

            session.Save(supplierCode2);
            var supplierCode4 = new SupplierCode {
                Code       = "789",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer2.Id,
                Product    = session.Load <Product>(product4.Id),
                CodeCr     = "2"
            };

            session.Save(supplierCode4);
            var supplierCode5 = new SupplierCode {
                Code       = "12345",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer3.Id,
                Product    = session.Load <Product>(product5.Id),
                CodeCr     = "3"
            };

            session.Save(supplierCode5);

            var log = new DocumentReceiveLog {
                Supplier     = session.Load <Supplier>(supplier.Id),
                ClientCode   = client.Id,
                Address      = session.Load <Address>(testAddress.Id),
                MessageUid   = 123,
                DocumentSize = 100
            };

            var doc = new Document(log)
            {
                OrderId      = order.Id,
                Address      = log.Address,
                DocumentDate = DateTime.Now
            };

            // сопоставляется по наименованию, фармацевтика, product1, producer1
            var line = doc.NewLine();

            line.Product  = "Активированный уголь";
            line.Producer = "ВероФарм";

            // сопоставляется по коду, product2, producer2
            line          = doc.NewLine();
            line.Product  = "Виагра";
            line.Producer = " Тестовый производитель  ";
            line.Code     = "45678";
            line.CodeCr   = "1";

            // сопоставляется по наименованию, product3, производитель - null
            line          = doc.NewLine();
            line.Product  = " КРЕМ ДЛЯ КОЖИ  ";
            line.Producer = "Тестовый производитель";

            // сопоставляется по коду, product4, producer2
            line          = doc.NewLine();
            line.Product  = "эластичный бинт";
            line.Producer = "Воронежфарм";
            line.Code     = "789";
            line.CodeCr   = "2";

            // сопоставляется по коду, product5, producer3
            line          = doc.NewLine();
            line.Product  = "Салфетки";
            line.Producer = "Воронежфарм";
            line.Code     = "12345";
            line.CodeCr   = "3";

            // сопоставляется по наименованию, потому как такого кода нет в базе, product6, producer3
            line          = doc.NewLine();
            line.Product  = "Аспирин";
            line.Producer = "Воронежфарм";
            line.Code     = "1952";

            // не сопоставляется, везде null
            line          = doc.NewLine();
            line.Product  = "Неизвестный продукт";
            line.Producer = "Воронежфарм";
            line.Code     = "1952";

            Reopen();

            doc.SetProductId();

            Assert.That(doc.Lines[0].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[0].ProductEntity.Id, Is.EqualTo(product1.Id));
            Assert.That(doc.Lines[0].ProducerId, Is.EqualTo(producer1.Id));
            Assert.That(doc.Lines[1].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[1].ProductEntity.Id, Is.EqualTo(product2.Id));
            Assert.That(doc.Lines[1].ProducerId, Is.EqualTo(producer2.Id));
            Assert.That(doc.Lines[2].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[2].ProductEntity.Id, Is.EqualTo(product3.Id));
            Assert.That(doc.Lines[2].ProducerId, Is.Null);
            Assert.That(doc.Lines[3].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[3].ProductEntity.Id, Is.EqualTo(product4.Id));
            Assert.That(doc.Lines[3].ProducerId, Is.EqualTo(producer2.Id));
            Assert.That(doc.Lines[4].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[4].ProductEntity.Id, Is.EqualTo(product5.Id));
            Assert.That(doc.Lines[4].ProducerId, Is.EqualTo(producer3.Id));
            Assert.That(doc.Lines[5].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[5].ProductEntity.Id, Is.EqualTo(product6.Id));
            Assert.That(doc.Lines[5].ProducerId, Is.EqualTo(producer3.Id));
            Assert.That(doc.Lines[6].ProductEntity, Is.Null);
            Assert.That(doc.Lines[6].ProducerId, Is.Null);
        }
        public void resolve_product_and_producer_for_farmacie()
        {
            var order = new TestOrder();

            var product1 = new TestProduct("Активированный уголь (табл.)");

            product1.CatalogProduct.Pharmacie = true;
            product1.CreateAndFlush();
            Thread.Sleep(100);
            var product2 = new TestProduct("Виагра (табл.)");

            product2.CatalogProduct.Pharmacie = true;
            product2.CreateAndFlush();
            Thread.Sleep(100);
            var product3 = new TestProduct("Крем для кожи (гель.)");

            product3.CatalogProduct.Pharmacie = false;
            product3.CreateAndFlush();
            Thread.Sleep(100);
            var product4 = new TestProduct("Эластичный бинт");

            product4.CatalogProduct.Pharmacie = false;
            product4.CreateAndFlush();
            Thread.Sleep(100);
            var product5 = new TestProduct("Стерильные салфетки");

            product5.CatalogProduct.Pharmacie = false;
            product5.CreateAndFlush();

            var producer1 = new TestProducer("ВероФарм");

            producer1.CreateAndFlush();
            var producer2 = new TestProducer("Пфайзер");

            producer2.CreateAndFlush();
            var producer3 = new TestProducer("Воронежская Фармацевтическая компания");

            producer3.CreateAndFlush();

            new TestSynonym {
                Synonym = "Активированный уголь", ProductId = product1.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonym {
                Synonym = "Виагра", ProductId = product2.Id, PriceCode = (int?)price.Id
            }.CreateAndFlush();
            new TestSynonym {
                Synonym = "Крем для кожи", ProductId = product3.Id, PriceCode = (int?)price.Id
            }.CreateAndFlush();
            new TestSynonym {
                Synonym = "Эластичный бинт", ProductId = product4.Id, PriceCode = (int?)price.Id
            }.CreateAndFlush();
            new TestSynonym {
                Synonym = "Тестовый", ProductId = null, PriceCode = (int?)price.Id, SupplierCode = "12345"
            }
            .CreateAndFlush();
            new TestSynonym {
                Synonym = "Тестовый2", ProductId = product5.Id, PriceCode = (int?)price.Id, SupplierCode = "12345"
            }
            .CreateAndFlush();

            new TestSynonymFirm {
                Synonym = "ВероФарм", CodeFirmCr = (int?)producer1.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer1.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer2.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym = "Верофарм", CodeFirmCr = (int?)producer2.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym = "ВоронежФарм", CodeFirmCr = (int?)producer3.Id, PriceCode = (int?)price.Id
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym = "Тестовый", CodeFirmCr = null, PriceCode = (int?)price.Id, SupplierCode = "12345"
            }
            .CreateAndFlush();
            new TestSynonymFirm {
                Synonym      = "Тестовый2",
                CodeFirmCr   = (int?)producer3.Id,
                PriceCode    = (int?)price.Id,
                SupplierCode = "12345"
            }.CreateAndFlush();

            TestAssortment.CheckAndCreate(session, product1, producer1);
            TestAssortment.CheckAndCreate(session, product2, producer2);

            var log = new DocumentReceiveLog {
                Supplier     = appSupplier,
                ClientCode   = client.Id,
                Address      = address,
                MessageUid   = 123,
                DocumentSize = 100
            };

            var doc = new Document(log)
            {
                OrderId      = order.Id,
                Address      = log.Address,
                DocumentDate = DateTime.Now
            };

            var line = doc.NewLine();

            line.Product  = "Активированный уголь";
            line.Producer = "ВероФарм";

            line          = doc.NewLine();
            line.Product  = "Виагра";
            line.Producer = " Верофарм  ";

            line          = doc.NewLine();
            line.Product  = " КРЕМ ДЛЯ КОЖИ  ";
            line.Producer = "Тестовый производитель";

            line          = doc.NewLine();
            line.Product  = "эластичный бинт";
            line.Producer = "Воронежфарм";

            line          = doc.NewLine();
            line.Product  = "Салфетки";
            line.Producer = "Воронежфарм";
            line.Code     = "12345";

            doc.SetProductId();

            Assert.That(doc.Lines[0].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[0].ProductEntity.Id, Is.EqualTo(product1.Id));
            Assert.That(doc.Lines[0].ProducerId, Is.EqualTo(producer1.Id));
            Assert.That(doc.Lines[1].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[1].ProductEntity.Id, Is.EqualTo(product2.Id));
            Assert.That(doc.Lines[1].ProducerId, Is.EqualTo(producer2.Id));
            Assert.That(doc.Lines[2].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[2].ProductEntity.Id, Is.EqualTo(product3.Id));
            Assert.That(doc.Lines[2].ProducerId, Is.Null);
            Assert.That(doc.Lines[3].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[3].ProductEntity.Id, Is.EqualTo(product4.Id));
            Assert.That(doc.Lines[3].ProducerId, Is.EqualTo(producer3.Id));
            Assert.That(doc.Lines[4].ProductEntity, Is.Null);
            Assert.That(doc.Lines[4].ProducerId, Is.Null);
        }