Ejemplo n.º 1
0
        public void Parse()
        {
            var document = WaybillParser.Parse("55865(2).DBF");

            Assert.That(document.Parser, Is.EqualTo("TekoSParser"));
            Assert.That(document.ProviderDocumentId, Is.EqualTo("ЦБ01-055865"));
            Assert.That(document.DocumentDate, Is.EqualTo(new DateTime(2015, 07, 07)));

            //проверяем что для разбора данного формата файла подходит только один парсер
            var detector = new WaybillFormatDetector();
            var parsers  = detector.GetSuitableParsers(@"..\..\Data\Waybills\r_03-068.DBF", null).ToList();

            Assert.That(parsers.ToList().Count, Is.EqualTo(1));

            var line0 = document.Lines[0];

            Assert.That(line0.Product, Is.EqualTo("Медицинский антисепт-кий р-р фл. 95% 100мл"));
            Assert.That(line0.Producer, Is.EqualTo("БиоФармКомбинат/Россия"));
            Assert.That(line0.SerialNumber, Is.EqualTo("070514"));
            Assert.That(line0.Period, Is.EqualTo("01.05.2019"));
            Assert.That(line0.Certificates, Is.EqualTo("POCC RU.ФМ08.Д07626"));
            Assert.That(line0.ProducerCostWithoutNDS, Is.EqualTo(22.43));
            Assert.That(line0.SupplierCostWithoutNDS, Is.EqualTo(13.12));
            Assert.That(line0.Nds, Is.EqualTo(10));
            Assert.That(line0.SupplierCost, Is.EqualTo(14.43));
            Assert.That(line0.Quantity, Is.EqualTo(40));
            Assert.That(line0.CodeCr, Is.EqualTo("24894"));
            Assert.That(line0.VitallyImportant, Is.True);
            Assert.That(line0.NdsAmount, Is.EqualTo(52.47));
            Assert.That(line0.Amount, Is.EqualTo(577.20));
            Assert.That(line0.Unit, Is.EqualTo("уп"));
            Assert.That(line0.BillOfEntryNumber, Is.Null);
            Assert.That(line0.EAN13, Is.EqualTo(4680006520908));
            var invoice = document.Invoice;

            Assert.That(invoice.InvoiceNumber, Is.EqualTo("55865"));
            Assert.That(invoice.InvoiceDate, Is.EqualTo(new DateTime(2015, 07, 07)));
            Assert.That(invoice.SellerAddress, Is.EqualTo("410065,г.Саратов,2-ой Красноармейский тупик,д.3"));
            Assert.That(invoice.SellerINN, Is.EqualTo("6453064469"));
            Assert.That(invoice.SellerKPP, Is.EqualTo("645301001"));
            Assert.That(invoice.RecipientName, Is.EqualTo("Воронеж Поворино Золотой век ООО"));
            //в связи с переполнением - null
            Assert.That(invoice.RecipientId, Is.Null);
            Assert.That(invoice.ShipperInfo, Is.EqualTo("Воронеж Поворино Золотой век ООО,397350, г.Поворино, ул.Московская, д.53 а"));
            Assert.That(invoice.BuyerId, Is.EqualTo(23067));
            Assert.That(invoice.BuyerName, Is.EqualTo("Воронеж Поворино Золотой век ООО"));
            Assert.That(invoice.BuyerAddress, Is.EqualTo("397350, г.Поворино, ул.Советская, д.85"));
            Assert.That(invoice.BuyerINN, Is.EqualTo("3623008451"));
            Assert.That(invoice.BuyerKPP, Is.EqualTo("362301001"));
            Assert.That(line0.CertificatesEndDate, Is.EqualTo(new DateTime(2019, 05, 01)));
        }
Ejemplo n.º 2
0
        public void ChechForPulsFK3996Parser()
        {
            var detector = new WaybillFormatDetector();
            var filePath = "pulse1.dbf";

            if (!File.Exists(filePath))
            {
                filePath = Path.Combine(@"..\..\Data\Waybills\", filePath);
            }
            var parsers = detector.GetSuitableParsers(filePath, null).ToList();

            Assert.That(parsers.Count, Is.EqualTo(1));
            Assert.That(parsers[0].Name, Is.EqualTo("PulsFK3996Parser"));
        }
Ejemplo n.º 3
0
        public void Parse()
        {
            var document = WaybillParser.Parse("белла-восток-F335064.DBF");

            Assert.That(document.Parser, Is.EqualTo("BellaVostokParser"));
            Assert.That(document.ProviderDocumentId.Trim(), Is.EqualTo("335064"));
            Assert.That(document.DocumentDate, Is.EqualTo(new DateTime(2016, 10, 13)));

            //проверяем что для разбора данного формата файла подходит только один парсер
            var detector = new WaybillFormatDetector();
            var parsers  = detector.GetSuitableParsers(@"..\..\Data\Waybills\белла-восток-F335064.DBF", null).ToList();

            Assert.That(parsers.ToList().Count, Is.EqualTo(1));

            var line0 = document.Lines[0];

            Assert.That(line0.Code, Is.EqualTo("190450"));
            Assert.That(line0.Product, Is.EqualTo("E.DEPIL Восков.полоски д/лица 20ш"));
            Assert.That(line0.EAN13, Is.EqualTo(8030009040075));
            Assert.That(line0.Quantity, Is.EqualTo(1));
            Assert.That(line0.Country, Is.EqualTo("Италия"));
            Assert.That(line0.Producer, Is.Null);
            Assert.That(line0.Period, Is.Null);
            Assert.That(line0.Nds, Is.EqualTo(18));
            Assert.That(line0.SupplierCost, Is.EqualTo(208.43));
            Assert.That(line0.SupplierCostWithoutNDS, Is.EqualTo(176.64));
            Assert.That(line0.VitallyImportant, Is.Null);
            Assert.That(line0.BillOfEntryNumber, Is.EqualTo("10110060/100810/0010685/0"));
            Assert.That(line0.Certificates, Is.EqualTo("РОСС IT ПК5 В36663 НИИ медицины Труда 16.12.14"));
            Assert.That(line0.CertificatesDate, Is.Null);
            Assert.That(line0.DateOfManufacture, Is.Null);
            Assert.That(line0.SerialNumber, Is.Null);

            var invoice = document.Invoice;

            Assert.That(invoice.InvoiceNumber, Is.Null);
            Assert.That(invoice.RecipientName, Is.Null);
            Assert.That(invoice.InvoiceDate, Is.Null);
        }
        public void Parse()
        {
            var document = WaybillParser.Parse("накл-беллаДон-bv006172.DBF");

            Assert.That(document.Parser, Is.EqualTo("BellaDonParser"));
            Assert.That(document.ProviderDocumentId, Is.EqualTo("В0000006172"));
            Assert.That(document.DocumentDate, Is.EqualTo(new DateTime(2015, 06, 04)));

            //проверяем что для разбора данного формата файла подходит только один парсер
            var detector = new WaybillFormatDetector();
            var parsers  = detector.GetSuitableParsers(@"..\..\Data\Waybills\r_03-068.DBF", null).ToList();

            Assert.That(parsers.ToList().Count, Is.EqualTo(1));

            var line0 = document.Lines[0];

            Assert.That(line0.Code, Is.EqualTo("SE-091-B010-J03"));
            Assert.That(line0.Product, Is.EqualTo("Гигиенические пеленки Seni Soft Basic 90*60 10 шт."));
            Assert.That(line0.EAN13, Is.EqualTo(5900516692469));
            Assert.That(line0.Quantity, Is.EqualTo(6));
            Assert.That(line0.Country, Is.EqualTo("РОССИЯ"));
            Assert.That(line0.Producer, Is.EqualTo("TZMO S.A."));
            Assert.That(line0.Period, Is.EqualTo("16.10.2016"));
            Assert.That(line0.Nds, Is.EqualTo(10));
            Assert.That(line0.SupplierCost, Is.EqualTo(175.58));
            Assert.That(line0.SupplierCostWithoutNDS, Is.EqualTo(159.62));
            Assert.That(line0.VitallyImportant, Is.False);
            Assert.That(line0.BillOfEntryNumber, Is.Null);
            Assert.That(line0.Certificates, Is.EqualTo("РОСС RU. ИМ09.Д00251"));
            Assert.That(line0.CertificatesDate, Is.EqualTo("03.12.2015"));
            Assert.That(line0.DateOfManufacture, Is.Null);
            Assert.That(line0.SerialNumber, Is.EqualTo("30999/00"));

            var invoice = document.Invoice;

            Assert.That(invoice.InvoiceNumber, Is.EqualTo("В0000006172"));
            Assert.That(invoice.RecipientName, Is.EqualTo("Фармспирт-1"));
            Assert.That(invoice.InvoiceDate, Is.EqualTo(new DateTime(2015, 06, 04)));
        }
Ejemplo n.º 5
0
        public void Parse()
        {
            var document = WaybillParser.Parse("66426.dbf");

            Assert.That(document.Parser, Is.EqualTo("MedSnabKchrParser"));
            Assert.That(document.ProviderDocumentId.Trim(), Is.EqualTo("66426"));
            Assert.That(document.DocumentDate, Is.EqualTo(new DateTime(2016, 09, 27)));

            var detector = new WaybillFormatDetector();
            var parsers  = detector.GetSuitableParsers(@"..\..\Data\Waybills\66426.dbf", null).ToList();

            Assert.That(parsers.ToList().Count, Is.EqualTo(1));

            var line0 = document.Lines[0];

            Assert.That(line0.Code, Is.EqualTo("18036,0000"));
            Assert.That(line0.RegistryCost, Is.EqualTo(155));
            Assert.That(line0.RegistryDate, Is.EqualTo(new DateTime(2016, 04, 04)));
            Assert.That(line0.Product, Is.EqualTo("Зодак капли 10мг/мл 20мл"));
            Assert.That(line0.EAN13, Is.EqualTo(8594739055209));
            Assert.That(line0.Quantity, Is.EqualTo(2.0000));
            Assert.That(line0.SupplierCost, Is.EqualTo(183.1000));
            Assert.That(line0.SupplierCostWithoutNDS, Is.EqualTo(183.1000));
            Assert.That(line0.Producer, Is.EqualTo("Зентива/Лечива"));
            Assert.That(line0.ProducerCost, Is.EqualTo(171.1700));
            Assert.That(line0.ProducerCostWithoutNDS, Is.EqualTo(155.6100));
            Assert.That(line0.VitallyImportant, Is.True);
            Assert.That(line0.BillOfEntryNumber, Is.EqualTo("10113100/190416/0019473/5"));
            Assert.That(line0.Certificates, Is.EqualTo("РОСС CZ.ФМ08.Д21991"));
            Assert.That(line0.CertificatesEndDate, Is.EqualTo(new DateTime(2019, 02, 28)));
            Assert.That(line0.SerialNumber, Is.EqualTo("3130316"));

            var invoice = document.Invoice;

            Assert.That(invoice.InvoiceNumber, Is.EqualTo("170560,0000"));
            Assert.That(invoice.RecipientName, Is.Null);
            Assert.That(invoice.InvoiceDate, Is.Null);
        }
        public static Document Parse(string filePath, DocumentReceiveLog log = null)
        {
            var detector = new WaybillFormatDetector();

            if (!File.Exists(filePath))
            {
                filePath = Path.Combine(@"..\..\Data\Waybills\", filePath);
            }
            var parser  = detector.DetectParser(filePath, log);
            var parsers = detector.GetSuitableParsers(filePath, log).ToList();

            if (parsers.Count > 1)
            {
                throw new Exception($"Для разбора данного формата подходит более одного парсера, {parsers.Implode()}");
            }
            if (parser == null)
            {
                return(null);
            }
            log = log ??
                  new DocumentReceiveLog(new Supplier(), new Address {
                Client = new Client()
            });
            if (log.ClientCode == null)
            {
                log.ClientCode = 0;
            }
            var document = new Document(log, parser.GetType().Name);
            var doc      = parser.Parse(filePath, document);

            if (doc != null)
            {
                doc.CalculateValues();
            }
            return(doc);
        }