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 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 Setup()
        {
            FileHelper.InitDir("tmp");
            supplier = TestSupplier.CreateNaked(session);
            supplier.CreateSampleCore(session);
            var client = TestClient.CreateNaked(session);

            Property("UserId", client.Users[0].Id);
        }
        public void Ignore_price_codes()
        {
            DefaultConf();

            //в orderlist поле ограничено 20 символами
            var code = Guid.NewGuid().ToString().Substring(0, 20);

            order.Items[0].Code = code;
            var item = order.Items[0];

            supplier.CreateSampleCore(session, new [] { item.Product });
            supplier.Prices[0].Core[0].Code = Guid.NewGuid().ToString();
            Property("CodeSource", 1);
            Property("ShowCode", true);
            Property("ShowCodeCr", false);
            var sheet = ReadReport <MixedReport>();

            var row = FindRowByProduct(sheet, item.Product);

            Assert.AreEqual(code, row.GetCell(0).StringCellValue);
        }
        public void Setup()
        {
            session.CreateSQLQuery("update Customers.Users set UseFtpGateway = 0").ExecuteUpdate();

            supplier = TestSupplier.CreateNaked(session);
            supplier.CreateSampleCore(session);
            client             = TestClient.CreateNaked(session);
            user               = client.Users[0];
            user.UseFtpGateway = true;
            user.FtpFileType   = 2;
            Program.SupplierIdForCodeLookup = supplier.Id;
        }
        public void Group_by_code()
        {
            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.Code   = "code-1";
            offer.CodeCr = "code-cr-1";
            var item = order.AddItem(offer, 10);

            Assert.IsNotNull(item.CodeFirmCr);

            item            = order.AddItem(offer, 5);
            item.CodeFirmCr = null;

            session.Save(order);

            Property("ShowCode", true);
            Property("ShowCodeCr", true);
            Property("ProductNamePosition", 0);
            Property("FirmCrPosition", 1);

            Property("ByPreviousMonth", false);
            Property("ReportInterval", 1);
            Property("SourceFirmCode", (int)supplier.Id);

            var sheet = ReadReport <MixedReport>();
            var text  = ToText(sheet);

            Assert.That(text, Does.Contain("|code-1|code-cr-1|"));
            var rowCount = sheet.Rows().Count(x => x.Cells[0].StringCellValue == "code-1" &&
                                              x.Cells[1].StringCellValue == "code-cr-1");

            Assert.AreEqual(1, rowCount, text, "строки должны быть сгруппированы по Code, CodeCr");
        }
        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();
        }