private void PrepareTestDocumentLog()
        {
            var catalogName = new TestCatalogName {
                Name = "testName"
            };
            var catalogForm = new TestCatalogForm {
                Form = "testForm"
            };

            session.Save(catalogForm);
            session.Save(catalogName);

            var documentLog = new FullDocument(_document);
            var catalog     = new Catalog {
                Name = "testCatalog", NameId = catalogName.Id, FormId = catalogForm.Id
            };

            _product  = new Product(catalog);
            _producer = new Producer {
                Name = "testProducer"
            };
            session.Save(catalog);
            session.Save(_product);
            session.Save(_producer);
            _line = new DocumentLine {
                CatalogProducer = _producer,
                CatalogProduct  = _product,
                Product         = "123",
                Document        = documentLog
            };
            documentLog.Lines = new List <DocumentLine>();
            documentLog.Lines.Add(_line);
            session.Save(documentLog);
            session.Flush();
        }
        public void Setup()
        {
            client   = TestClient.CreateNaked(session);
            supplier = TestSupplier.CreateNaked(session);
            log      = new DocumentReceiveLog(session.Load <Supplier>(supplier.Id), session.Load <Address>(client.Addresses[0].Id))
            {
                FileName = "1234.dbf"
            };
            session.Save(log);
            document = new Document(log)
            {
                ProviderDocumentId = "11111"
            };
            session.Save(log);

            var catalogName = new TestCatalogName {
                Name = "testName"
            };
            var catalogForm = new TestCatalogForm {
                Form = "testForm"
            };

            session.Save(catalogForm);
            session.Save(catalogName);
            var catalog = new Catalog {
                Name = "testCatalog", NameId = catalogName.Id, FormId = catalogForm.Id
            };

            _product = new Product {
                CatalogProduct = catalog
            };
            _producer = new Producer {
                Name = "testProducer"
            };
            session.Save(catalog);
            session.Save(_product);
            session.Save(_producer);
            _line = new DocumentLine {
                ProducerId    = _producer.Id,
                ProductEntity = _product,
                Product       = "123",
                Document      = document
            };
            document.Lines.Add(_line);
            session.Save(document);
            client.Settings.IsConvertFormat      = true;
            client.Settings.WaybillConvertFormat = TestWaybillFormat.UniversalDbf;
            session.Save(client.Settings);
            session.Flush();
        }
Example #3
0
        public void Producer_in_document_detalization_for_position()
        {
            var catalogName = new TestCatalogName {
                Name = "testCatName"
            };
            var catalogForm = new TestCatalogForm {
                Form = "testForm"
            };

            Save(catalogName, catalogForm);

            document.FileName = "SpecialFileNameForThisReport";
            session.Save(document);
            var documentLog = new FullDocument(document);
            var catalog     = new Catalog {
                Name = "testCatalog", NameId = catalogName.Id, FormId = catalogForm.Id
            };
            var product  = new Product(catalog);
            var producer = new Producer {
                Name = "testProducer"
            };

            Save(catalog, producer, product);
            var line = new DocumentLine {
                CatalogProducer = producer,
                CatalogProduct  = product,
                Product         = "123",
                Document        = documentLog
            };

            documentLog.Lines = new List <DocumentLine>();
            documentLog.Lines.Add(line);
            session.Save(documentLog);

            Open("Logs/Documents?filter.Client.Id={0}", client.Id);

            Click("SpecialFileNameForThisReport");
            WaitAjax();
            Click("123");
            WaitForText("Сопоставлен с");
            AssertText("Сопоставлен с \"testCatName testForm\"");
            AssertText("По производителю с \"testProducer\"");
        }
        public void filterDocument()
        {
            var catalogName = new TestCatalogName {
                Name = "testName"
            };
            var catalogForm = new TestCatalogForm {
                Form = "testForm"
            };

            session.Save(catalogForm);
            session.Save(catalogName);
            var catalog = new Catalog {
                Name = "testCatalog", NameId = catalogName.Id, FormId = catalogForm.Id
            };

            _product  = new Product(catalog);
            _producer = new Producer {
                Name = "testProducer"
            };
            session.Save(catalog);
            session.Save(_product);
            session.Save(_producer);
            session.Flush();

            _document = new DocumentReceiveLog(_supplier)
            {
                FileName     = "test.sst",
                ForClient    = _client,
                Address      = _address,
                DocumentType = DocumentType.Reject,
                Reject       = new RejectHeader(),
            };
            session.Save(_document);

            var reject = new RejectHeader()
            {
                Address   = _address,
                Lines     = new List <RejectLine>(),
                Log       = _document,
                Parser    = "TestParser",
                Supplier  = _supplier,
                WriteTime = SystemTime.Now()
            };

            reject.Lines.Add(new RejectLine()
            {
                Code           = "testCode",
                CodeCr         = "testCodeCr",
                Cost           = 777,
                Header         = reject,
                OrderId        = 333,
                Ordered        = 111,
                Producer       = _producer.Name,
                ProducerEntity = _producer,
                Product        = _product.Catalog.Name,
                ProductEntity  = _product,
                Rejected       = 10
            });
            session.Save(reject);
            _document.Reject = reject;
            session.Save(_document);

            var sendLog = new DocumentSendLog(_user, _document)
            {
                Committed = true
            };

            session.Save(sendLog);
            session.Flush();

            _controller.Documents(new DocumentFilter()
            {
                Supplier = _supplier
            });
            var items = _controller.PropertyBag["logEntities"] as IList <DocumentLog>;

            Assert.AreEqual(1, items.Count(s => s.DocumentType == DocumentType.Waybill));
            Assert.AreEqual(1, items.Count(s => s.DocumentType == DocumentType.Reject));

            var rejectFromDocument = items.First(s => s.DocumentType == DocumentType.Reject);

            Assert.AreEqual("test.sst", rejectFromDocument.FileName);
            Assert.AreEqual(_address.Name, rejectFromDocument.Address);
            Assert.AreEqual("TestParser", rejectFromDocument.Parser);
            Assert.AreEqual(_client.Id.ToString(), rejectFromDocument.ClientId);
            Assert.AreEqual(_supplier.Id.ToString(), rejectFromDocument.SupplierId);
        }