protected override List <TaxTotal> GetTaxesTotales(XDocument xdoc) { var taxes = xdoc.Root.Elements().Where(e => e.Name.LocalName == "TaxTotal").ToArray(); List <TaxTotal> _taxesTotales = new List <TaxTotal>(); bool error = false; foreach (var tax in taxes) { List <TaxSubtotal> _subtotals = new List <TaxSubtotal>(); string _taxAmount = string.Empty; var subtotals = tax.Elements().Where(e => e.Name.LocalName == "TaxSubtotal").ToArray(); foreach (var subtotal in subtotals) { //TaxCategory _categories string _schemeId = string.Empty; string _percent = string.Empty; var category = subtotal.Elements().Where(e => e.Name.LocalName == "TaxCategory").SingleOrDefault(); if (category == null) { error = true; break; } var schemeId = category.Elements().Where(e => e.Name.LocalName == "TaxScheme").SingleOrDefault()? .Elements().Where(e => e.Name.LocalName == "ID").SingleOrDefault(); if (schemeId == null || schemeId.Value == string.Empty) { error = true; break; } var percent = category.Elements().Where(e => e.Name.LocalName == "Percent").SingleOrDefault(); if (percent == null || percent.Value == string.Empty) { error = true; break; } _schemeId = schemeId.Value; _percent = percent.Value; TaxCategory c = new TaxCategory { SchemeID = _schemeId, Percent = _percent }; string _subtotalTaxAmount = string.Empty; var subTotaltaxAmount = subtotal.Elements().Where(e => e.Name.LocalName == "TaxAmount").SingleOrDefault(); if (subTotaltaxAmount == null || subTotaltaxAmount.Value == string.Empty) { error = true; break; } _subtotalTaxAmount = subTotaltaxAmount.Value; TaxSubtotal s = new TaxSubtotal { TaxCategory = c, TaxAmount = _subtotalTaxAmount }; _subtotals.Add(s); } if (error) { break; } var taxAmount = tax.Elements().Where(e => e.Name.LocalName == "TaxAmount").SingleOrDefault(); if (taxAmount == null || taxAmount.Value == string.Empty) { error = true; break; } _taxAmount = taxAmount.Value; TaxTotal t = new TaxTotal { TaxesSubtotals = _subtotals, TaxAmount = _taxAmount }; _taxesTotales.Add(t); } if (error) { _taxesTotales.Clear(); } return(_taxesTotales); //TaxesTotales = new List<TaxTotal>(_taxesTotales); }
public TaxTotal() { TaxableAmount = new PayableAmount(); TaxAmount = new PayableAmount(); TaxSubtotal = new TaxSubtotal(); }