/// <summary> /// Devuelve la jerarquía estandar para importes. /// </summary> /// <returns>Jerarquía estandar para importes.</returns> private static TextParserHierarchy <decimal> GetTaxRateParser() { TextParserHierarchy <decimal> hierarchyAmount = new TextParserHierarchy <decimal>() { Parsers = new List <TextParser <decimal> >() { new TextParser <decimal>(@"\d{1,2},\d{2}(?=\s*%)", new DefaultAmountConverter()), // ImpuestoDosDec new TextParser <decimal>(@"\d{1,2},\d{1}(?=\s*%)", new DefaultAmountConverter()), // ImpuestoUnDec new TextParser <decimal>(@"\d{1,2}\.\d{2}(?=\s*%)", new DefaultAmountConverter()), // ImpuestoDosDecAnglo new TextParser <decimal>(@"\d{1,2}\.\d{1}(?=\s*%)", new DefaultAmountConverter()), // ImpuestoUnDecAnglo new TextParser <decimal>(@"\d{1,2}(?=\s*%)", new DefaultAmountConverter()), // ImpuestoDosNum new TextParser <decimal>(@"[\d.-]+,\d{2}", new DefaultAmountConverter()), // MonedaComun new TextParser <decimal>(@"[\d,-]+\.\d{2}", new DefaultAmountConverter()), // MonedaAnglo new TextParser <decimal>(@"[\d\s-]+,\d{2}", new DefaultAmountConverter()), // MonedaMillSpaceComun new TextParser <decimal>(@"[\d\s-]+\.\d{2}", new DefaultAmountConverter()), // MonedaMillSpaceAnglo new TextParser <decimal>(@"[\d.-]+,\d{1,2}", new DefaultAmountConverter()), // MonedaComunVarDec new TextParser <decimal>(@"[\d,-]+\.\d{1,2}", new DefaultAmountConverter()), // MonedaAngloVarDec new TextParser <decimal>(@"[\d.]+,\d{1,2}-{0,1}", new DefaultAmountConverter()), // MonedaComunVarDecNegFinal new TextParser <decimal>(@"[\d,]+\.\d{1,2}-{0,1}", new DefaultAmountConverter()), // MonedaAngloVarDecNegFinal new TextParser <decimal>(@"\d+", new DefaultAmountConverter()), // MonedaSinDecSinMill } }; return(hierarchyAmount); }
/// <summary> /// Devuelve la jerarquía estandard para fechas. /// </summary> /// <returns></returns> private static TextParserHierarchy <DateTime?> GetDateParser() { TextParserHierarchy <DateTime?> hierarchyDate = new TextParserHierarchy <DateTime?>() { Parsers = new List <TextParser <DateTime?> >() { new TextParser <DateTime?>(@"\d{2}\/\d{2}\/\d{4}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\.\d{2}\.\d{4}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}-\d{2}-\d{4}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\/\d{2}\/\d{2}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\.\d{2}\.\d{2}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}-\d{2}-\d{2}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\s{1}-\s{1}\d{2}\s{1}-\s{1}\d{4}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\s{1}-\s{1}\d{2}\s{1}-\s{1}\d{2}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\s{1}\/\s{1}\d{2}\s{1}\/\s{1}\d{4}", new DefaultDateConverter()), new TextParser <DateTime?>(@"\d{2}\s{1}\/\s{1}\d{2}\s{1}\/\s{1}\d{2}", new DefaultDateConverter()), } }; foreach (var months in ExtendedDateConverter.MonthNomenclatures) { string separator = ExtendedDateConverter.Separator; string pattern = $"\\d{{1,2}}{separator}({months}){separator}\\d{{4}}"; hierarchyDate.Parsers.Add(new TextParser <DateTime?>(pattern, new ExtendedDateConverter())); pattern = $"\\d{{1,2}}{separator}({months}){separator}\\d{{1}}\\.\\d{{3}}"; hierarchyDate.Parsers.Add(new TextParser <DateTime?>(pattern, new ExtendedDateConverter())); pattern = $"\\d{{1,2}}{separator}({months}){separator}\\d{{2}}"; hierarchyDate.Parsers.Add(new TextParser <DateTime?>(pattern, new ExtendedDateConverter())); } return(hierarchyDate); }
/// <summary> /// Construye un nuevo catálogo de jerarúías /// de analizadores de textos. /// </summary> public BusinessInvoiceHierarchySet() : base() { TextParserHierarchy <decimal> taxRateParser = GetTaxRateParser(); HierarchyByPropertyName.Add("TaxesOutputsRate01", taxRateParser); HierarchyByPropertyName.Add("TaxesOutputsRate02", taxRateParser); HierarchyByPropertyName.Add("TaxesOutputsRate03", taxRateParser); HierarchyByPropertyName.Add("TaxesOutputsRate04", taxRateParser); HierarchyByPropertyName.Add("TaxesWithholdingRate01", taxRateParser); }
/// <summary> /// Devuelve la jerarquía estandard para textos. /// </summary> /// <returns>Jerarquía estandard para textos.</returns> protected static TextParserHierarchy <string> GetTextParser() { TextParserHierarchy <string> hierarchyAmount = new TextParserHierarchy <string>() { Parsers = new List <TextParser <string> >() { new TextParser <string>(null, new DefaultTextConverter()) } }; return(hierarchyAmount); }