public void RarFormF6FormatterTest_SetupReportParametersPrimary() { // arrange string str = @"<ФормаОтч НомФорм=""06"" ПризПериодОтч=""0"" ГодПериодОтч=""2016""> <Первичная/> </ФормаОтч>"; XElement el = XDocument.Parse(str).Root; RarFormF6Formatter f6formatter = new RarFormF6Formatter(); var privateObject = new PrivateObject(f6formatter); RarFormF6 formF6 = new RarFormF6(); //act privateObject.Invoke("SetupReportParameters", el, formF6); string resultFormNumber = formF6.FormNumber; string resultReportPeriod = formF6.ReportPeriod; string resultReportYear = formF6.ReportYear; string resultCorrectionNumber = formF6.CorrectionNumber; //assert Assert.AreEqual("06", resultFormNumber, "FormNumber"); Assert.AreEqual("0", resultReportPeriod, "ReportPeriod"); Assert.AreEqual("2016", resultReportYear, "ReportYear"); Assert.AreEqual("0", resultCorrectionNumber, "CorrectionNumber"); }
public void RarFormF6FormatterTest_SetupManufacturers() { // arrange string str = @"<Справочники> <ПроизводителиИмпортеры ИдПроизвИмп=""61"" П000000000004=""ООО Фирма"" П000000000005=""7729681716"" П000000000006=""671245017""/> </Справочники>"; XElement el = XDocument.Parse(str).Root; RarFormF6Formatter f6formatter = new RarFormF6Formatter(); var privateObject = new PrivateObject(f6formatter); RarFormF6 formF6 = new RarFormF6(); //act privateObject.Invoke("SetupManufacturers", el, formF6); List <RarCompany> manufacturers = formF6.ManufacturerList; string resultId = manufacturers[0].ID; string resultName = manufacturers[0].Name; string resultINN = manufacturers[0].INN; string resultKPP = manufacturers[0].KPP; ////assert Assert.AreEqual("61", resultId, "Id"); Assert.AreEqual("ООО Фирма", resultName, "Name"); Assert.AreEqual("7729681716", resultINN, "INN"); Assert.AreEqual("671245017", resultKPP, "KPP"); }
public RarViewModel() { _RarFile = new RarFormF6(); AlcoCodesList = new ObservableCollection <string>(ParserF6.GetAlcoCodesListFromXSD()); TurnoverDataList = new ObservableCollection <RarTurnoverData>(_RarFile.TurnoverDataList); BuyersList = new ObservableCollection <RarCompany>(_RarFile.BuyersList); ManufacturersList = new ObservableCollection <RarCompany>(_RarFile.ManufacturersList); SavingCompaniesList = new ObservableCollection <RarCompany>(); }
private void SetupRootAttribute(XElement elm, RarFormF6 formF6) { if (elm == null || formF6 == null) { return; } formF6.ProgramName = GetAttributeStringValue(elm.Attribute("НаимПрог")); formF6.Version = GetAttributeStringValue(elm.Attribute("ВерсФорм")); formF6.DocumentDate = DateTime.Parse(elm.Attribute("ДатаДок").Value); }
public void RarFormF6FormatterTest_SetupAdress() { // arrange string str = @"<АдрОрг> <КодСтраны> 643 </КодСтраны> <Индекс> 124460 </Индекс> <КодРегион> 77 </КодРегион> <Район> Московский </Район> <Город> Зеленоград г </Город> <НаселПункт> Пункт </НаселПункт> <Улица> Западный 2-й проезд </Улица> <Дом> 8 </Дом> <Корпус> 12 </Корпус> <Литера> Б </Литера> <Кварт> 2 </Кварт> </АдрОрг>"; XElement el = XDocument.Parse(str).Root; RarFormF6Formatter f6formatter = new RarFormF6Formatter(); var privateObject = new PrivateObject(f6formatter); RarFormF6 formF6 = new RarFormF6(); //act RarAdress adress = (RarAdress)privateObject.Invoke("SetupAdress", el); string resultCountryId = adress.CountryId; string resultPostCode = adress.PostCode; string resultRegionId = adress.RegionId; string resultDistrict = adress.District; string resultCity = adress.City; string resultLocality = adress.Locality; string resultStreet = adress.Street; string resultBuilding = adress.Building; string resultBlock = adress.Block; string resultLitera = adress.Litera; string resultApartment = adress.Apartment; ////assert Assert.AreEqual("643", resultCountryId, "CountryId"); Assert.AreEqual("124460", resultPostCode, "PostCode"); Assert.AreEqual("77", resultRegionId, "RegionId"); Assert.AreEqual("Московский", resultDistrict, "District"); Assert.AreEqual("Зеленоград г", resultCity, "City"); Assert.AreEqual("Пункт", resultLocality, "Locality"); Assert.AreEqual("Западный 2-й проезд", resultStreet, "Street"); Assert.AreEqual("12", resultBlock, "Block"); Assert.AreEqual("Б", resultLitera, "Litera"); Assert.AreEqual("8", resultBuilding, "Building"); Assert.AreEqual("2", resultApartment, "Apartment"); }
private void SetupBuyers(XElement references, RarFormF6 formF6) { if (references == null || formF6 == null) { return; } foreach (XNode node in references.Elements("Контрагенты")) { XElement el = (XElement)node; RarCompany rc = new RarCompany(); rc.Name = GetAttributeStringValue(el.Attribute("П000000000007")); rc.ID = GetAttributeStringValue(el.Attribute("ИдКонтр")); XElement resident = el.Element("Резидент"); if (resident != null) { SetupLisences(resident.Element("Лицензии"), rc); XElement adress = resident.Element("П000000000008"); rc.Adress = SetupAdress(adress); XElement company = resident.Element("ЮЛ"); if (company != null) { rc.INN = GetAttributeStringValue(company.Attribute("П000000000009")); rc.KPP = GetAttributeStringValue(company.Attribute("П000000000010")); } else { XElement individual = resident.Element("ФЛ"); if (individual != null) { rc.INN = GetAttributeStringValue(individual.Attribute("П000000000009")); } } } else { XElement foreigner = el.Element("Иностр"); if (foreigner != null) { rc.INN = GetAttributeStringValue(foreigner.Attribute("Номер")); //Учетный номер rc.Adress = new RarAdress(); rc.Adress.StrictAdress = false; rc.Adress.AdressString = GetAttributeStringValue(foreigner.Attribute("П000000000082")); rc.Adress.CountryId = GetAttributeStringValue(foreigner.Attribute("П000000000081")); } } formF6.BuyerList.Add(rc); } }
private 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.ManufacturerList.Where(p => p.ID == manufacturID).First(); foreach (XNode nodeBuyer in elManufacturer.Elements("Получатель")) { XElement elBuyer = (XElement)nodeBuyer; string buyerID = (string)elBuyer.Attribute("ИдПолучателя"); RarCompany buyer = formF6.BuyerList.Where(p => p.ID == buyerID).First(); buyer.IsUsed = true; string licenseID = (string)elBuyer.Attribute("ИдЛицензии"); RarLicense license = buyer.LicenseList.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); } } } } }
public void RarFormF6FormatterTest_SetupBuyers() { // arrange string str = @"<Справочники> <Контрагенты ИдКонтр=""61"" П000000000007=""ООО Фирма""> <Резидент> <Лицензии> <Лицензия ИдЛицензии = ""61"" П000000000011 = ""67ЗАП0003590"" П000000000012 = ""03.04.2014"" П000000000013 = ""03.04.2019"" П000000000014 = ""ФС РАР"" /> </Лицензии> <П000000000008> <КодСтраны> 643 </КодСтраны> <Индекс > 214010 </Индекс> <КодРегион > 67 </КодРегион> <Район/> <Город> Смоленск г </Город> <НаселПункт /> <Улица> Октября ул </Улица> <Дом> 4 </Дом> <Корпус> Н </Корпус> <Литера /> <Кварт /> </П000000000008> <ЮЛ П000000000009 = ""7729681716"" П000000000010 = ""671245017"" /> </Резидент> </Контрагенты> </Справочники>"; XElement el = XDocument.Parse(str).Root; RarFormF6Formatter f6formatter = new RarFormF6Formatter(); var privateObject = new PrivateObject(f6formatter); RarFormF6 formF6 = new RarFormF6(); //act privateObject.Invoke("SetupBuyers", el, formF6); List <RarCompany> buyers = formF6.BuyerList; string resultId = buyers[0].ID; string resultName = buyers[0].Name; string resultINN = buyers[0].INN; string resultKPP = buyers[0].KPP; ////assert Assert.AreEqual("61", resultId, "Id"); Assert.AreEqual("ООО Фирма", resultName, "Name"); Assert.AreEqual("7729681716", resultINN, "INN"); Assert.AreEqual("671245017", resultKPP, "KPP"); }
public void RarFormF6Test() { // arrange RarOurCompany company = new RarOurCompany(); RarFormF6 formF6 = new RarFormF6(); // act //Assert Assert.IsNotNull(formF6.OurCompany); Assert.IsNotNull(formF6.BuyerList); Assert.IsNotNull(formF6.ManufacturerList); Assert.IsNotNull(formF6.TurnoverDataList); }
private void SetupManufacturers(XElement references, RarFormF6 formF6) { if (references == null || formF6 == null) { return; } foreach (XNode node in references.Elements("ПроизводителиИмпортеры")) { XElement el = (XElement)node; RarCompany rc = new RarCompany(); rc.ID = GetAttributeStringValue(el.Attribute("ИдПроизвИмп")); rc.Name = GetAttributeStringValue(el.Attribute("П000000000004")); rc.INN = GetAttributeStringValue(el.Attribute("П000000000005")); rc.KPP = GetAttributeStringValue(el.Attribute("П000000000006")); //необязат formF6.ManufacturerList.Add(rc); } }
public void DataServiceTests_GetData() { // arrange RarFormF6 result1 = new RarFormF6(); Exception result2 = new Exception(); DataService ds = new DataService(); //act ds.GetData( (data, error) => { result1 = data; result2 = error; }); //Assert Assert.AreSame(ds.RarFormF6Data, result1, "RarFormF6"); Assert.IsNull(result2, "Exception"); }
public object Deserialize(System.IO.Stream serializationStream) { RarFormF6 formF6 = new RarFormF6(); XDocument xdoc = XDocument.Load(serializationStream); if (!IsDocumentValid(xdoc)) { throw new Exception("Не соответствует схеме"); } SetupRootAttribute(xdoc.Root, formF6); SetupReportParameters(xdoc.Root.Element("ФормаОтч"), formF6); SetupBuyers(xdoc.Root.Element("Справочники"), formF6); SetupManufacturers(xdoc.Root.Element("Справочники"), formF6); SetupOrganization(xdoc.Root.Element("Документ").Element("Организация"), formF6.OurCompany); SetupTurnoverData(xdoc.Root.Element("Документ").Element("ОбъемОборота"), formF6); return(formF6); }
private void SetupReportParameters(XElement elm, RarFormF6 formF6) { //ФормаОтч if (elm == null || formF6 == null) { return; } formF6.FormNumber = GetAttributeStringValue(elm.Attribute("НомФорм")); formF6.ReportPeriod = GetAttributeStringValue(elm.Attribute("ПризПериодОтч")); formF6.ReportYear = GetAttributeStringValue(elm.Attribute("ГодПериодОтч")); XElement corrections = elm.Element("Корректирующая"); if (corrections == null) { formF6.CorrectionNumber = "0"; } else { formF6.CorrectionNumber = GetAttributeStringValue(corrections.Attribute("НомерКорр")); } }
public void RarFormF6FormatterTest_SetupRootAttribute() { // arrange string str = @"<Файл ДатаДок=""23.01.2017"" ВерсФорм=""4.31"" НаимПрог=""1С: ПРЕДПРИЯТИЕ 8.3 УТ 11.2.3.203""></Файл >"; XElement el = XDocument.Parse(str).Root; RarFormF6Formatter f6formatter = new RarFormF6Formatter(); var privateObject = new PrivateObject(f6formatter); RarFormF6 formF6 = new RarFormF6(); //act privateObject.Invoke("SetupRootAttribute", el, formF6); DateTime resultDateDoc = formF6.DocumentDate; //DateTime.Parse("23.01.2017"); string resultVersion = formF6.Version; string resultProgramName = formF6.ProgramName; //assert Assert.AreEqual(DateTime.Parse("23.01.2017"), resultDateDoc, "DateDoc"); Assert.AreEqual("4.31", resultVersion, "Version"); Assert.AreEqual("1С: ПРЕДПРИЯТИЕ 8.3 УТ 11.2.3.203", resultProgramName, "ProgrameName"); }