protected virtual void SetTaxesInfo(XDocument xdoc) { TaxesInfo = null; var taxesList = GetTaxesTotales(xdoc); if (taxesList.Count == 0) { return; } TaxesInfo = new TaxesInfo { TaxesTotals = new List <TaxTotal>(taxesList.ToArray()) }; }
protected override void SetTaxesInfo(XDocument xdoc) { bool taxExcIsZero = false; TaxesInfo = null; var taxes = xdoc.Root.Elements().Where(e => e.Name.LocalName == "LegalMonetaryTotal").SingleOrDefault(); if (taxes == null) { return; } var lineExtensionAmount = taxes.Elements().Where(e => e.Name.LocalName == "LineExtensionAmount").SingleOrDefault(); if (lineExtensionAmount == null) { return; } var taxExclusiveAmount = taxes.Elements().Where(e => e.Name.LocalName == "TaxExclusiveAmount").SingleOrDefault(); if (taxExclusiveAmount == null) { return; } float value; if (!float.TryParse(taxExclusiveAmount.Value, out value)) { return; } taxExcIsZero = value == 0; var taxInclusiveAmount = taxes.Elements().Where(e => e.Name.LocalName == "TaxInclusiveAmount").SingleOrDefault(); if (taxInclusiveAmount == null) { return; } var allowanceTotalAmount = taxes.Elements().Where(e => e.Name.LocalName == "AllowanceTotalAmount").SingleOrDefault(); var chargeTotalAmount = taxes.Elements().Where(e => e.Name.LocalName == "ChargeTotalAmount").SingleOrDefault(); var payableAmount = taxes.Elements().Where(e => e.Name.LocalName == "PayableAmount").SingleOrDefault(); if (payableAmount == null) { return; } var taxesList = GetTaxesTotales(xdoc); if (!taxExcIsZero && taxesList.Count == 0) { return; } TaxesInfo = new TaxesInfo { LineExtensionAmount = lineExtensionAmount.Value, TaxExclusiveAmount = taxExclusiveAmount.Value, TaxInclusiveAmount = taxInclusiveAmount.Value, AllowanceTotalAmount = allowanceTotalAmount?.Value, ChargeTotalAmount = chargeTotalAmount?.Value, PayableAmount = payableAmount.Value, TaxesTotals = new List <TaxTotal>(taxesList.ToArray()) }; }