Пример #1
0
        public void FindWaybillsWithClientTest()
        {
            // Создаем двух клиентов и документы для них
            var client      = DataMother.CreateTestClientWithAddress();
            var documentLog = DataMother.CreateTestDocumentLog(supplier, client);
            var document    = DataMother.CreateTestDocument(supplier, client, documentLog);

            document.WriteTime             = DateTime.Now.AddDays(-1);
            document.Lines[0].SerialNumber = "123";
            var client1      = DataMother.CreateTestClientWithAddress();
            var documentLog1 = DataMother.CreateTestDocumentLog(supplier, client1);
            var document1    = DataMother.CreateTestDocument(supplier, client1, documentLog1);

            document1.WriteTime        = DateTime.Now.AddDays(-1);
            document1.Lines[0].Product = "123";
            Save(document);
            Save(document1);
            Flush();
            // Ищем накладные только для первого клиента
            var filter = new ParsedWaybillsFilter {
                Session    = session,
                Period     = new DatePeriod(DateTime.Now.AddDays(-7), DateTime.Now),
                ClientId   = client.Id,
                ClientName = client.Name
            };
            var documentsInfo = filter.Find();
            var testDocument  = documentsInfo.FirstOrDefault(d => ((ParsedWaybillsItem)d).SupplierCode == supplier.Id);

            Assert.That(testDocument, Is.Not.Null);
            Assert.That(((ParsedWaybillsItem)testDocument).SupplierCode, Is.EqualTo(supplier.Id));
            Assert.That(((ParsedWaybillsItem)testDocument).SerialNumber, Is.EqualTo("*"));
            Assert.That(((ParsedWaybillsItem)testDocument).Product, Is.Null);
        }
Пример #2
0
        public void Inventory()
        {
            var client   = DataMother.CreateTestClientWithAddressAndUser();
            var supplier = DataMother.CreateSupplier();

            DataMother.CreateTestDocument(supplier, client);
            controller.Inventory(client.Users[0].Id);
        }
        public void OnlyNoParcedWithDocumentTest()
        {
            // создаем фильтр, устанавливаем в качестве параметра созданного поставщика и "искать только неразобранные"
            var filter = new DocumentFilter();

            filter.Supplier     = _supplier;
            filter.OnlyNoParsed = true;
            // создаем документ для лога
            var document = DataMother.CreateTestDocument(_supplier, _client, _documentLog);

            Save(document);
            // не должны выбрать запись лога, так как уже есть документ
            var documents = filter.Find(session);

            Assert.That(documents.Count, Is.EqualTo(0));
        }
Пример #4
0
        public void FindWaybillsTest()
        {
            var client      = DataMother.CreateTestClientWithAddress();
            var documentLog = DataMother.CreateTestDocumentLog(supplier, client);
            var document    = DataMother.CreateTestDocument(supplier, client, documentLog);

            document.WriteTime             = DateTime.Now.AddDays(-1);
            document.Lines[0].SerialNumber = "123";
            Save(document);
            Flush();
            var filter = new ParsedWaybillsFilter {
                Session = session, Period = new DatePeriod(DateTime.Now.AddDays(-7), DateTime.Now)
            };
            var documentsInfo = filter.Find();
            var testDocument  = documentsInfo.FirstOrDefault(d => ((ParsedWaybillsItem)d).SupplierCode == supplier.Id);

            Assert.That(testDocument, Is.Not.Null);
            Assert.That(((ParsedWaybillsItem)testDocument).SupplierCode, Is.EqualTo(supplier.Id));
            Assert.That(((ParsedWaybillsItem)testDocument).SerialNumber, Is.EqualTo("*"));
        }
        public void Setup()
        {
            testClient = DataMother.CreateTestClientWithAddressAndUser();

            var user = testClient.Users.First();

            user.AvaliableAddresses.Add(testClient.Addresses.First());
            session.Save(user);
            testSupplier = DataMother.CreateSupplier();
            session.Save(testSupplier);
            var order = new ClientOrder(testClient.Users.First(), testSupplier.Prices[0]);

            session.Save(order);

            var product = new Product(session.Load <Catalog>(DataMother.CreateCatelogProduct()));
            var line    = new OrderLine(order, product, 100, 1);

            session.Save(product);
            session.Save(line);

            session.Save(order);
            testSupplier = DataMother.CreateSupplier();
            var documentLogEntity = DataMother.CreateTestDocumentLog(testSupplier, testClient);
            var updateLogEntity   = DataMother.CreateTestUpdateLogEntity(testClient);

            documentLogEntity.DocumentType = DocumentType.Waybill;
            session.SaveOrUpdate(updateLogEntity);
            documentLogEntity.SendUpdateLogEntity = updateLogEntity;
            session.Save(documentLogEntity);

            var document = DataMother.CreateTestDocument(testSupplier, testClient, documentLogEntity);

            session.Save(document);
            session.Flush();

            Open(testClient);
            AssertText("Клиент");
        }
Пример #6
0
        public void View_document_certificates()
        {
            var log      = DataMother.CreateTestDocumentLog(supplier, client);
            var document = DataMother.CreateTestDocument(supplier, client, log);
            var line     = document.Lines[0];
            //Добавим CertificateSource т.к. изменилась выборка для сертификатов - теперь необходим еще Id источника для CertificateFile
            var newCertificate = new CertificateSource {
                Supplier        = supplier,
                Name            = "Test_Source",
                SourceClassName = "Test_class_Name"
            };

            supplier.CertificateSource = newCertificate;
            session.Save(newCertificate);

            line.CatalogProduct = DataMother.Product();
            line.Product        = line.CatalogProduct.Catalog.Name;
            line.Certificate    = DataMother.Certificate(line.CatalogProduct.Catalog, newCertificate.Id.ToString());
            session.Save(line);

            var dir      = Directory.CreateDirectory(Path.Combine(DataRoot, "Certificates"));
            var filename = line.Certificate.Files[0].Filename;

            File.WriteAllText(Path.Combine(dir.FullName, filename), "");

            Open("Logs/Documents?filter.Client.Id={0}", client.Id);
            AssertText("Тестовый поставщик");
            Click("TestFile.txt");
            WaitForText("Страна");
            AssertText("Страна");
            Click(line.Product);
            WaitForText(filename);
            AssertText(filename);

            session.Delete(newCertificate);
        }
Пример #7
0
 private void Create_loaded_document_logs(out Client client, out Supplier supplier, out DocumentReceiveLog documentLogEntity,
                                          out Document document, out UpdateLogEntity updateLogEntity)
 {
     Create_loaded_document_logs_unparsed_document(out client, out supplier, out documentLogEntity, out updateLogEntity);
     document = DataMother.CreateTestDocument(supplier, client, documentLogEntity);
 }