Example #1
0
        private TestWaybillLine CreateBodyLine()
        {
            var documentLog = new TestDocumentLog {
                Supplier     = testSupplier,
                Client       = testUser.Client,
                DocumentType = DocumentType.Waybill,
                LogTime      = DateTime.Now,
                FileName     = Path.GetRandomFileName() + ".txt"
            };

            var document = new TestWaybill(documentLog);

            var documentLine = new TestWaybillLine();

            documentLine.Waybill = document;

            document.Lines.Add(documentLine);

            using (new TransactionScope()) {
                document.Save();
            }

            Assert.That(document.Lines.Count, Is.EqualTo(1));
            Assert.That(document.Lines[0].Id, Is.GreaterThan(0));

            return(documentLine);
        }
Example #2
0
        public override void Execute(ISession session)
        {
            var random = new Random();
            var user   = User(session);
            var order  = session.Query <TestOrder>().Where(o => o.User == user)
                         .OrderByDescending(o => o.WriteTime)
                         .FirstOrDefault();

            if (order == null)
            {
                throw new Exception("Не заказов для формирования накладной");
            }
            var log = new TestDocumentLog(order.Price.Supplier, order.Address);

            Waybill = new TestWaybill(log);
            session.Save(Waybill);
            session.Save(new TestDocumentSendLog(user, log));

            foreach (var orderline in order.Items)
            {
                var line = new TestWaybillLine(Waybill);
                line.Product      = orderline.Product.FullName;
                line.Quantity     = orderline.Quantity;
                line.SupplierCost = (decimal?)orderline.Cost;
                line.Period       = DateTime.Today.AddDays(random.Next(5 * 365)).ToShortDateString();
                Waybill.Lines.Add(line);
                session.Save(line);
                session.CreateSQLQuery("insert into Documents.WaybillOrders(DocumentLineId, OrderLineId) values (:documentLineId, :orderLineId)")
                .SetParameter("documentLineId", line.Id)
                .SetParameter("orderLineId", orderline.Id)
                .ExecuteUpdate();
            }
        }
        public void Parse_waybill()
        {
            var ids     = ParseFile("1008fo.pd");
            var waybill = TestWaybill.Find(ids.Single());

            Assert.That(waybill.Lines.Count, Is.EqualTo(1));
        }
Example #4
0
        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);
        }
Example #5
0
        public override void Execute(ISession session)
        {
            var user = User(session);

            Waybill = Service.Test.TestHelpers.DataMother.CreateWaybill(session, user);
            var products = session.Query <TestProduct>().Where(x => !x.Hidden && x.CatalogProduct.Pharmacie).Take(1).ToArray();

            Waybill.Lines.Clear();
            Waybill.Lines.Add(new TestWaybillLine(Waybill)
            {
                Product                = products[0].FullName,
                CatalogProduct         = products[0],
                Certificates           = "РОСС BE.ФМ11.Д06711",
                CertificatesDate       = "01.16.2013",
                Period                 = "30.09.2014",
                Producer               = "Алкон-Куврер н.в. с.а.",
                Country                = "БЕЛЬГИЯ",
                RetailCost             = 600,
                RetailCostMarkup       = 5,
                SupplierCostWithoutNDS = 536.17m,
                SupplierCost           = 589.79m,
                Quantity               = 1,
                SerialNumber           = "A 565",
                Amount                 = 589.79m,
                NDS       = 10,
                NDSAmount = 53.62m,
            });
            Document = Waybill.Log;
            session.Save(Waybill);
            SendLog = new TestDocumentSendLog(user, Document);
            session.Save(SendLog);
        }
        private TestWaybillLine CreateBodyLine(string serialNumber = null, TestProduct product = null)
        {
            var user = TestUser.Queryable.First(u => u.AvaliableAddresses.Count > 0);

            if (product == null)
            {
                product = TestProduct.Queryable.First();
            }

            var documentLog = new TestDocumentLog(testSupplier, user.Client)
            {
                FileName = Path.GetRandomFileName() + ".txt"
            };

            var document = new TestWaybill(documentLog);

            var documentLine = new TestWaybillLine {
                Waybill        = document,
                SerialNumber   = serialNumber,
                CatalogProduct = product
            };

            document.Lines = new List <TestWaybillLine>();
            document.Lines.Add(documentLine);

            document.Save();

            Assert.That(document.Lines.Count, Is.EqualTo(1));
            Assert.That(document.Lines[0].Id, Is.GreaterThan(0));

            return(documentLine);
        }
        public override void Execute(ISession session)
        {
            var reject = session.Query <TestReject>().First(r => r.Product != null && r.Producer != null &&
                                                            r.CancelDate == null);

            Doc = Service.Test.TestHelpers.DataMother.CreateWaybill(session, User(session));
            Doc.ProviderDocumentId = "reject";
            Doc.Lines.Add(new TestWaybillLine(Doc)
            {
                Product                = reject.Product.CatalogProduct.Name,
                CatalogProduct         = reject.Product,
                Producer               = reject.Producer.Name,
                ProducerId             = reject.Producer.Id,
                Quantity               = 10,
                SupplierCost           = 100,
                SupplierCostWithoutNDS = 90,
                NDS          = 10,
                SerialNumber = reject.Series
            });
            var log = Doc.Log;

            session.Save(Doc);
            var sendLog = new TestDocumentSendLog(User(session), log);

            session.Save(sendLog);
        }
        public void Check_SetProductId_if_synonym_not_exists()
        {
            var ids = ParseFile("14356_4.dbf");

            var waybill = TestWaybill.Find(ids.Single());

            Assert.That(waybill.Lines.Count, Is.EqualTo(1));
            Assert.IsTrue(waybill.Lines[0].CatalogProduct == null);
            Assert.IsTrue(waybill.Lines[0].ProducerId == null);
        }
Example #9
0
        public override void Execute(ISession session)
        {
            var user = User(session);

            Waybill = Service.Test.TestHelpers.DataMother.CreateWaybill(session, user);
            Waybill.DocumentDate = DateTime.Now.AddYears(-1);
            Document             = Waybill.Log;
            session.Save(Waybill);
            SendLog = new TestDocumentSendLog(user, Document);
            session.Save(SendLog);
        }
        public override void Execute(ISession session)
        {
            var supplier = TestSupplier.CreateNaked(session, TestRegion.Inforoom);
            var data     = @"
2	Нафазолин	Нафтизина раствор	Капли назальные	Флакон-капельницы пластиковые	1 мг/мл 15 мл №1	Славянская Аптека ООО
3	Нимесулид	Найз	Таблетки	Упаковка контурная ячейковая	100 мг №20	Dr.Reddy'S Laboratories Ltd
4	Ацетилсалициловая кислота+Кофеин+Парацетамол	Цитрамон П	Таблетки	Упаковка контурная ячейковая	№10	Уралбиофарм ОАО"                ;
            var map      = new[] {
                "Code",
                "Note",
                "Doc",
                "Series",
                "Unit",
                "Volume",
                "",
                //ClNm - Производитель
                "CodeCr",
            };
            var producers = session.Query <TestProducer>().Take(10).ToList();
            var products  = session.Query <TestProduct>().Fetch(p => p.CatalogProduct).Where(p => !p.CatalogProduct.Hidden).Take(10).ToList();

            var maxProducer = producers.Count();
            var maxProduct  = products.Count();

            var randomProducts  = Generator.Random(maxProduct).SelectMany(i => products.Skip(i).Take(1));
            var randomProducers = Generator.Random(maxProducer).SelectMany(i => producers.Skip(i).Take(1));
            var price           = supplier.Prices[0];

            foreach (var line in data.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                var offer = supplier.AddCore(randomProducts.First(), randomProducers.First());
                price.Core.Add(offer);
                session.Save(offer);
                session.Flush();
                var parts  = line.Split('\t');
                var update = parts.Where((p, i) => !String.IsNullOrEmpty(map[i])).Select((p, i) => String.Format("{0} = '{1}'", map[i], p)).Implode();
                session.CreateSQLQuery(String.Format("update Farm.Core0 set {0} where id = {1}", update, offer.Id)).ExecuteUpdate();
            }

            var user    = User(session);
            var waybill = new TestWaybill(new TestDocumentLog(supplier, user.AvaliableAddresses[0]));

            waybill.DocumentDate = waybill.DocumentDate.AddDays(-7);
            var waybillLine = waybill.AddLine(price.Core[0].Product, price.Core[0].Producer);

            waybillLine.SupplierCostWithoutNDS = 90;
            session.Save(waybill);
            session.Save(new TestDocumentSendLog(user, waybill.Log));

            session.CreateSQLQuery("delete from Customers.AppConfig").ExecuteUpdate();
            session.CreateSQLQuery("insert into Customers.AppConfig (`key`, `value`) value('RegulatorRegistryPriceId', :id)")
            .SetParameter("id", price.Id)
            .ExecuteUpdate();
        }
Example #11
0
        public override void Execute(ISession session)
        {
            var user = User(session);

            Waybill  = Service.Test.TestHelpers.DataMother.CreateWaybill(session, user);
            Document = Waybill.Log;
            session.Save(Waybill);
            SendLog = new TestDocumentSendLog(user, Document);
            session.Save(SendLog);
            if (createFile)
            {
                Filename = Waybill.Log.CreateFile(Config.DocsPath, "waybill content");
            }
        }
        private TestWaybill SetupWaybill(TestSupplier supplier, TestClient client, out TestDocumentSendLog sendLog)
        {
            var log = new TestDocumentLog(supplier, client);

            session.Save(log);
            var doc     = new TestWaybill(log);
            var product = session.Query <TestProduct>().First(x => !x.Hidden);

            doc.AddLine(product);
            doc.ProviderDocumentId = "G1";
            session.Save(doc);
            sendLog = new TestDocumentSendLog(client.Users[0], log);
            session.Save(sendLog);
            return(doc);
        }
        public void DeleteTempFolderTest()
        {
            var rostaSource = new RostaCertificateSource();
            var product     = session.Query <Product>().First(p => p.CatalogProduct != null);
            var documentLog = new TestDocumentLog {
                Supplier     = _testSupplier,
                Client       = _testUser.Client,
                DocumentType = DocumentType.Waybill,
                LogTime      = DateTime.Now,
                FileName     = Path.GetRandomFileName() + ".txt"
            };
            var document = new TestWaybill(documentLog);

            session.Save(document);

            var realDocument = session.Load <Document>(document.Id);

            var task = new CertificateTask {
                SerialNumber   = "123",
                CatalogProduct = product.CatalogProduct,
            };

            task.CertificateSource = _source;
            task.DocumentLine      = new DocumentLine {
                Code          = "000002",
                SerialNumber  = "C392764",
                Document      = realDocument,
                ProductEntity = product
            };
            Save(task.DocumentLine);
            Save(task);

            var certificsteCatalog = new CertificateSourceCatalog {
                CertificateSource = _source,
                SerialNumber      = task.DocumentLine.SerialNumber,
                SupplierCode      = task.DocumentLine.Code,
                OriginFilePath    = "005/0052602p-0.gif",
                CatalogProduct    = product.CatalogProduct
            };

            Save(certificsteCatalog);
            Reopen();
            rostaSource.GetCertificateFiles(task, session);
            // Проверяем, что временная папка удалена
            Assert.That(Directory.Exists(rostaSource.TMPDownloadDir), Is.False);
        }
Example #14
0
		public void Export_waybills()
		{
			var supplier = TestSupplier.CreateNaked(session);
			var client = TestClient.CreateNaked(session);
			var log = new TestDocumentLog(supplier, client);
			session.Save(log);
			var doc = new TestWaybill(log);
			var product = session.Query<TestProduct>().First(x => !x.Hidden);
			doc.AddLine(product);
			doc.ProviderDocumentId = "G1";
			session.Save(doc);
			var sendLog = new TestDocumentSendLog(client.Users[0], log);
			session.Save(sendLog);
			FlushAndCommit();
			Program.ProcessUser(config, client.Users[0].Id, ProtocolType.DbfAsna);
			Assert.IsTrue(File.Exists($"tmp/{client.Users[0].Id}/waybills/{doc.Id}.dbf"));
		}
        public void Build()
        {
            int orgId    = 0;
            var client   = TestClient.CreateNaked(session);
            var address  = client.Addresses[0];
            var supplier = TestSupplier.CreateNaked(session);

            orgId = (int)address.LegalEntity.Id;
            var waybill = new TestWaybill(new TestDocumentLog(supplier, address));

            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product      = "Аксетин",
                Quantity     = 10,
                SerialNumber = "4563",
                EAN13        = "5290931004832",
                ProducerCost = 56,
                SupplierCost = 100,
            });
            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product      = "Аксетин",
                Quantity     = 10,
                SerialNumber = "4563",
                EAN13        = "5290931004832",
                ProducerCost = 56,
                SupplierCost = 70,
            });
            session.Save(waybill);
            Property("ByPreviousMonth", false);
            Property("OrgId", orgId);
            report = new WaybillsReport(Conn, properties)
            {
                Format        = ReportFormats.CSV,
                ReportCaption = "test"
            };
            BuildOrderReport("test");
            var result = File.ReadAllText("test.csv");
            var data   =
                $"DrugID;Segment;Year;Month;Series;TotDrugQn;MnfPrice;PrcPrice;RtlPrice;Funds;VendorID;Remark;SrcOrg\r\n34413;1;{DateTime.Now.Year};{DateTime.Now.Month};\"4563\";10.00;61.60;70.00;76.80;0.00;{supplier.Id};;\r\n";

            Assert.That(result, Is.EqualTo(data));
        }
Example #16
0
        public void Export_prices()
        {
            FileHelper.InitDir("ftp");

            var log = new TestDocumentLog(supplier, client);

            session.Save(log);
            var doc     = new TestWaybill(log);
            var product = session.Query <TestProduct>().First(x => !x.Hidden);

            doc.AddLine(product);
            doc.ProviderDocumentId = "G1";
            session.Save(doc);
            var sendLog = new TestDocumentSendLog(user, log);

            session.Save(sendLog);

            session.Save(new FtpConfig(session.Load <User>(user.Id), session.Load <Supplier>(supplier.Id))
            {
                PriceUrl   = $"ftp://localhost:{port}/тестовый поставщик/common/PRICE.DBF",
                WaybillUrl = $"ftp://localhost:{port}/тестовый поставщик/in",
                OrderUrl   = $"ftp://localhost:{port}/тестовый поставщик/out",
            });

            FlushAndCommit();

            var job = new FtpExportJob();

            job.Execute(null);
            var prices = Directory.GetFiles("ftp/тестовый поставщик/common").Implode(Path.GetFileName);

            Assert.AreEqual("PRICE.DBF", prices);
            var waybills = Directory.GetFiles("ftp/тестовый поставщик/in").Implode(Path.GetFileName);

            Assert.AreEqual($"{log.Id}.dbf", waybills);
        }
        public void Check_SetProductId_if_synonym_exists()
        {
            var file = "14356_4.dbf";

            var log = CreateTestLog(file);

            var product = new TestProduct("тестовый товар");

            product.SaveAndFlush();

            var productSynonym = new TestSynonym {
                ProductId = product.Id,
                Synonym   = "Коринфар таб п/о 10мг № 50",
                PriceCode = (int?)price.Id
            };

            productSynonym.SaveAndFlush();

            productSynonym = new TestSynonym {
                ProductId = null,
                Synonym   = "Коринфар таб п/о 10мг № 50",
                PriceCode = (int?)price.Id
            };

            var producer1 = new TestProducer {
                Name = "Тестовый производитель"
            };

            producer1.SaveAndFlush();

            var producer2 = new TestProducer {
                Name = "Тестовый производитель"
            };

            producer2.SaveAndFlush();

            var producerSynonym = new TestProducerSynonym {
                Price    = price,
                Name     = "Плива Хрватска д.о.о./АВД фарма ГмбХ и Ко КГ",
                Producer = null
            };

            producerSynonym.SaveAndFlush();

            producerSynonym = new TestProducerSynonym {
                Price    = price,
                Name     = "Плива Хрватска д.о.о./АВД фарма ГмбХ и Ко КГ",
                Producer = producer1
            };
            producerSynonym.SaveAndFlush();

            producerSynonym = new TestProducerSynonym {
                Price    = price,
                Name     = "Плива Хрватска д.о.о./АВД фарма ГмбХ и Ко КГ",
                Producer = producer2
            };
            producerSynonym.SaveAndFlush();
            FlushAndCommit();

            var service = new WaybillService();
            var ids     = service.ParseWaybill(new[] { log.Id });

            var waybill = TestWaybill.Find(ids.Single());

            Assert.That(waybill.Lines.Count, Is.EqualTo(1));
            Assert.IsTrue(waybill.Lines[0].CatalogProduct != null);
            Assert.That(waybill.Lines[0].CatalogProduct.Id, Is.EqualTo(product.Id));
            Assert.That(waybill.Lines[0].ProducerId, Is.EqualTo(producer1.Id));
        }
Example #18
0
        public static TestWaybill CreateWaybill(ISession session, TestUser user)
        {
            var supplier = user.GetActivePricesNaked(session).First().Price.Supplier;
            var log      = new TestDocumentLog(supplier, user.AvaliableAddresses[0], "");
            var waybill  = new TestWaybill(log);
            var products = session.Query <TestProduct>().Where(x => !x.Hidden).Take(32).ToArray();

            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product                = products[0].FullName,
                CatalogProduct         = products[0],
                Certificates           = "РОСС BE.ФМ11.Д06711",
                CertificatesDate       = "01.16.2013",
                Period                 = "30.09.2014",
                Producer               = "Алкон-Куврер н.в. с.а.",
                Country                = "БЕЛЬГИЯ",
                SupplierCostWithoutNDS = 536.17m,
                SupplierCost           = 589.79m,
                Quantity               = 1,
                SerialNumber           = "A 565",
                Amount                 = 589.79m,
                NDS       = 10,
                NDSAmount = 53.62m,
            });
            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product                = products[1].FullName,
                CatalogProduct         = products[1],
                Certificates           = "РОСС RU.ФМ08.Д38737",
                Period                 = "01.05.2017",
                Producer               = "Нью-Фарм Инк./Вектор-Медика ЗАО, РОССИЯ",
                ProducerCost           = 213.18m,
                RegistryCost           = 382.89m,
                SupplierPriceMarkup    = -5.746m,
                SupplierCostWithoutNDS = 200.93m,
                SupplierCost           = 221.03m,
                Quantity               = 2,
                VitallyImportant       = true,
                NDS               = 10,
                SerialNumber      = "21012",
                Amount            = 442.05m,
                NDSAmount         = 40.19m,
                BillOfEntryNumber = "10609010/101209/0004305/1",
                EAN13             = "4605635002748",
            });
            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product                = products[1].FullName,
                CatalogProduct         = products[1],
                Certificates           = "РОСС RU.ФМ08.Д38737",
                Period                 = "01.05.2017",
                Producer               = "Нью-Фарм Инк./Вектор-Медика ЗАО, РОССИЯ",
                ProducerCost           = 213.18m,
                RegistryCost           = 382.89m,
                SupplierPriceMarkup    = -5.746m,
                SupplierCostWithoutNDS = 200.93m,
                SupplierCost           = 221.03m,
                Quantity               = 2,
                VitallyImportant       = true,
                NDS               = 10,
                SerialNumber      = "21012",
                Amount            = 442.05m,
                NDSAmount         = 40.19m,
                BillOfEntryNumber = "10609010/101209/0004305/1",
                //для отчета по жизененно важным
                EAN13 = "4606915000379",
            });
            waybill.Lines.Add(new TestWaybillLine(waybill)
            {
                Product                = "Лопедиум капсулы 2 мг",
                CatalogProduct         = products[1],
                Period                 = "01.05.2018",
                Producer               = "Салютас Фарма",
                SupplierCostWithoutNDS = 23.5m,
                SupplierCost           = 25.86m,
                Quantity               = 2,
                SerialNumber           = "DR5963",
                EAN13 = "4030855000890",
            });
            for (var i = 0; i < 29; i++)
            {
                waybill.Lines.Add(new TestWaybillLine(waybill)
                {
                    Product                = products[i + 1].FullName,
                    CatalogProduct         = products[i + 1],
                    Certificates           = "РОСС RU.ФМ08.Д38737",
                    Period                 = "01.05.2017",
                    Producer               = "Нью-Фарм Инк./Вектор-Медика ЗАО, РОССИЯ",
                    SupplierCostWithoutNDS = 23.5m,
                    SupplierCost           = 25.86m,
                    Quantity               = 2,
                });
            }
            return(waybill);
        }