Ejemplo n.º 1
0
        private static void SetupTurnoverData(XElement turnoverdata, RarFormF6 formF6)
        {
            RarSubdevision subdevision = new RarSubdevision();

            subdevision.Name = (string)turnoverdata.Attribute("Наим");
            subdevision.KPP  = (string)turnoverdata.Attribute("КППЮЛ");
            //subdevision.SalePresented = (bool)turnoverdata.Attribute("НаличиеПоставки");
            //subdevision.ReturnPresented = (bool)turnoverdata.Attribute("НаличиеВозврата");
            subdevision.Adress = SetupAdress(turnoverdata.Element("АдрОрг"));
            formF6.OurCompany.SubdevisionList.Add(subdevision);
            foreach (XNode nodeAlcoCode in turnoverdata.Elements("Оборот"))
            {
                XElement elAlcoCode = (XElement)nodeAlcoCode;
                foreach (XNode nodeManufacturer in elAlcoCode.Elements("СведПроизвИмпорт"))
                {
                    XElement   elManufacturer = (XElement)nodeManufacturer;
                    string     manufacturID   = (string)elManufacturer.Attribute("ИдПроизвИмп");
                    RarCompany manufacturer   = formF6.ManufacturersList.Where(p => p.ID == manufacturID).First();
                    foreach (XNode nodeBuyer in elManufacturer.Elements("Получатель"))
                    {
                        XElement   elBuyer = (XElement)nodeBuyer;
                        string     buyerID = (string)elBuyer.Attribute("ИдПолучателя");
                        RarCompany buyer   = formF6.BuyersList.Where(p => p.ID == buyerID).First();
                        buyer.IsUsed = true;
                        string     licenseID = (string)elBuyer.Attribute("ИдЛицензии");
                        RarLicense license   = buyer.LicensesList.Where(s => s.ID == licenseID).FirstOrDefault();

                        foreach (XNode nodeDocument in elBuyer.Elements("Поставка"))
                        {
                            XElement elDocument = (XElement)nodeDocument;

                            RarTurnoverData data = new RarTurnoverData();
                            data.Subdevision  = subdevision;
                            data.AlcoCode     = (string)elAlcoCode.Attribute("П000000000003");
                            data.Manufacturer = manufacturer;
                            data.Buyer        = buyer;
                            data.License      = license;

                            //data.NotificationDate=      DateTime.Parse(el.Element("СведПроизвИмпорт").Element("Получатель").Element("Поставка").Attribute("П000000000015").Value);
                            //data.NotificationNumber =   (string)el.Element("СведПроизвИмпорт").Element("Получатель").Element("Поставка").Attribute("П000000000016");
                            //data.NotificationTurnover = (double)el.Element("СведПроизвИмпорт").Element("Получатель").Element("Поставка").Attribute("П000000000017");
                            data.DocumentDate   = DateTime.Parse(elDocument.Attribute("П000000000018").Value);
                            data.DocumentNumber = (string)elDocument.Attribute("П000000000019");
                            //data.CustomsDeclarationNumber = (string)el.Element("СведПроизвИмпорт").Element("Получатель").Element("Поставка").Attribute("П000000000020");
                            data.Turnover = (double)elDocument.Attribute("П000000000021");
                            formF6.TurnoverDataList.Add(data);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void SetupManufacturers(XElement references, RarFormF6 formF6)
        {
            foreach (XNode node in references.Elements("ПроизводителиИмпортеры"))
            {
                XElement   el = (XElement)node;
                RarCompany rc = new RarCompany();
                rc.ID   = (string)el.Attribute("ИдПроизвИмп");
                rc.Name = (string)el.Attribute("П000000000004");
                rc.INN  = (string)el.Attribute("П000000000005");
                rc.KPP  = (string)el.Attribute("П000000000006");


                formF6.ManufacturersList.Add(rc);
            }
        }
Ejemplo n.º 3
0
        private static void SetupBuyers(XElement references, RarFormF6 formF6)
        {
            foreach (XNode node in references.Elements("Контрагенты"))
            {
                XElement   el = (XElement)node;
                RarCompany rc = new RarCompany();
                rc.Name = el.Attribute("П000000000007").Value;
                rc.ID   = el.Attribute("ИдКонтр").Value;

                XElement resident = el.Element("Резидент");
                if (resident != null)
                {
                    rc.CounryID = "643"; //  ?????????????????????
                    SetupLisences(rc, resident.Element("Лицензии"));
                    XElement adress = resident.Element("П000000000008");
                    rc.Adress = SetupAdress(adress);

                    XElement company = resident.Element("ЮЛ");
                    if (company != null)
                    {
                        rc.INN = (string)company.Attribute("П000000000009");
                        rc.KPP = (string)company.Attribute("П000000000010");
                    }
                    else
                    {
                        XElement individual = resident.Element("ФЛ");
                        if (individual != null)
                        {
                            rc.INN = (string)individual.Attribute("П000000000009");
                        }
                    }
                }
                else
                {
                    XElement foreigner = el.Element("Иностр");
                    if (foreigner != null)
                    {
                        rc.CounryID = (string)foreigner.Attribute("П000000000081");
                        rc.INN      = (string)foreigner.Attribute("Номер");
                        rc.Adress   = new RarAdress((string)foreigner.Attribute("П000000000082"));
                    }
                }

                formF6.BuyersList.Add(rc);
            }
        }
Ejemplo n.º 4
0
        public static void Parse(string fileName, RarFormF6 formF6)
        {
            XDocument xdoc = XDocument.Load(fileName);

            if (!IsDocumentValid(xdoc))
            {
                throw new Exception("Не соответствует схеме");
            }

            XElement root = xdoc.Root;

            formF6.ProgramName  = (string)root.Attribute("НаимПрог");
            formF6.Version      = (string)root.Attribute("ВерсФорм");
            formF6.DocumentDate = DateTime.Parse(root.Attribute("ДатаДок").Value);

            formF6.FormNumber   = (string)root.Element("ФормаОтч").Attribute("НомФорм");
            formF6.ReportPeriod = (string)root.Element("ФормаОтч").Attribute("ПризПериодОтч");
            formF6.YearReport   = (string)root.Element("ФормаОтч").Attribute("ГодПериодОтч");

            XElement corrections = root.Element("ФормаОтч").Element("Корректирующая");

            if (corrections == null)
            {
                formF6.CorrectionNumber = "";
            }
            else
            {
                formF6.CorrectionNumber = (string)corrections.Attribute("НомерКорр");
            }

            SetupOrganization(root.Element("Документ").Element("Организация"), formF6.OurCompany);

            XElement references = root.Element("Справочники");

            SetupBuyers(references, formF6);
            SetupManufacturers(references, formF6);
            SetupTurnoverData(root.Element("Документ").Element("ОбъемОборота"), formF6);
        }