From 76ef08ade5937251e368d2ededbe45300a3e480c Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 20 Jan 2025 23:19:56 +0100 Subject: [PATCH] starting to obsolete properties and go for methods #372 --- ZUGFeRD.Test/ZUGFeRD22Tests.cs | 4 +- ZUGFeRD/InvoiceDescriptor.cs | 109 ++++++++++++++++++++++-- ZUGFeRD/InvoiceDescriptor1Reader.cs | 34 +++----- ZUGFeRD/InvoiceDescriptor1Writer.cs | 38 ++++----- ZUGFeRD/InvoiceDescriptor20Reader.cs | 21 ++--- ZUGFeRD/InvoiceDescriptor20Writer.cs | 40 ++++----- ZUGFeRD/InvoiceDescriptor22UBLWriter.cs | 14 +-- ZUGFeRD/InvoiceDescriptor22UblReader.cs | 10 +-- ZUGFeRD/InvoiceDescriptor23CIIReader.cs | 42 ++++----- ZUGFeRD/InvoiceDescriptor23CIIWriter.cs | 16 ++-- ZUGFeRD/InvoiceDescriptor23Writer.cs | 2 +- ZUGFeRD/InvoiceValidator.cs | 6 +- 12 files changed, 205 insertions(+), 131 deletions(-) diff --git a/ZUGFeRD.Test/ZUGFeRD22Tests.cs b/ZUGFeRD.Test/ZUGFeRD22Tests.cs index ae946999..a1d74c87 100644 --- a/ZUGFeRD.Test/ZUGFeRD22Tests.cs +++ b/ZUGFeRD.Test/ZUGFeRD22Tests.cs @@ -2782,8 +2782,8 @@ public void TestBuyerOrderReferenceLineId() InvoiceDescriptor desc = InvoiceDescriptor.Load(s); s.Close(); - Assert.AreEqual(desc.TradeLineItems[0].BuyerOrderReferencedDocument.LineID, "1"); - Assert.AreEqual(desc.TradeLineItems[0].BuyerOrderReferencedDocument.ID, "ORDER84359"); + Assert.AreEqual(desc.GetTradeLineItems().First().BuyerOrderReferencedDocument.LineID, "1"); + Assert.AreEqual(desc.GetTradeLineItems().First().BuyerOrderReferencedDocument.ID, "ORDER84359"); } [TestMethod] diff --git a/ZUGFeRD/InvoiceDescriptor.cs b/ZUGFeRD/InvoiceDescriptor.cs index e8b4e507..4360a2b7 100644 --- a/ZUGFeRD/InvoiceDescriptor.cs +++ b/ZUGFeRD/InvoiceDescriptor.cs @@ -241,6 +241,7 @@ public class InvoiceDescriptor /// /// An aggregation of business terms containing information about individual invoice positions /// + [Obsolete("This property will not be available any more with version 18.0. Please use GetTradeLineItems() instead")] public List TradeLineItems { get; internal set; } = new List(); /// @@ -310,11 +311,13 @@ public class InvoiceDescriptor /// /// A group of business terms providing information about VAT breakdown by different categories, rates and exemption reasons /// - public List Taxes { get; internal set; } = new List(); + [Obsolete("This property will be removed in version 18.0. Please use GetApplicableTradeTaxes() instead")] + public List Taxes { get; internal set; } = new List(); /// /// Transport and packaging costs /// + [Obsolete("This property will be removed in version 18.0. Please use GetLogisticsServiceCharges() instead")] public List ServiceCharges { get; internal set; } = new List(); /// @@ -342,19 +345,22 @@ public class InvoiceDescriptor /// /// Detailed information about the accounting reference /// - public List ReceivableSpecifiedTradeAccountingAccounts { get; internal set; } = new List(); + [Obsolete("This property will be removed in version 18.0. Please use GetReceivableSpecifiedTradeAccountingAccounts() instead")] + public List _ReceivableSpecifiedTradeAccountingAccounts { get; internal set; } = new List(); /// /// Credit Transfer /// /// A group of business terms to specify credit transfer payments /// - public List CreditorBankAccounts { get; set; } = new List(); + [Obsolete("This property will be removed in version 18.0. Please use GetCreditorFinancialAccounts() instead")] + public List CreditorBankAccounts { get; internal set; } = new List(); /// /// Buyer bank information /// - public List DebitorBankAccounts { get; set; } = new List(); + [Obsolete("This property will be removed in version 18.0. Please use GetDebitorFinancialAccounts() instead")] + public List DebitorBankAccounts { get; internal set; } = new List(); /// /// Payment instructions @@ -808,6 +814,12 @@ public void AddLogisticsServiceCharge(decimal amount, string description, TaxTyp } // !AddLogisticsServiceCharge() + public List GetLogisticsServiceCharges() + { + return this.ServiceCharges; + } // !GetLogisticsServiceCharges() + + /// /// Adds an allowance or charge on document level. /// @@ -1039,6 +1051,18 @@ public void AddApplicableTradeTax(decimal basisAmount, } // !AddApplicableTradeTax() + public List GetApplicableTradeTaxes() + { + return this.Taxes; + } // !GetApplicableTradeTaxes() + + + public bool AnyApplicableTradeTaxes() + { + return this.Taxes.Any(); + } // !AnyApplicableTradeTaxes() + + private IInvoiceDescriptorWriter _selectInvoiceDescriptorWriter(ZUGFeRDVersion version) { switch (version) @@ -1304,6 +1328,30 @@ public TradeLineItem AddTradeLineItem(string lineID, } // !AddTradeLineItem() + internal void _AddTradeLineItem(TradeLineItem item) + { + this.TradeLineItems.Add(item); + } // !_AddTradeLineItem() + + + internal void _AddTradeLineItems(IEnumerable items) + { + this.TradeLineItems.AddRange(items); + } // !_AddTradeLineItems() + + + public List GetTradeLineItems() + { + return this.TradeLineItems; + } // !GetTradeLineItems() + + + public bool AnyTradeLineItems() + { + return this.TradeLineItems.Any(); + } // !AnyTradeLineItems() + + /// /// Sets up the payment means. /// @@ -1379,6 +1427,24 @@ public void AddCreditorFinancialAccount(string iban, string bic, string id = nul } // !AddCreditorFinancialAccount() + internal void _AddCreditorFinancialAccount(BankAccount bankAccount) + { + this.CreditorBankAccounts.Add(bankAccount); + } // !_AddCreditorFinancialAccount() + + + public List GetCreditorFinancialAccounts() + { + return this.CreditorBankAccounts; + } // !GetCreditorFinancialAccounts() + + + public bool AnyCreditorFinancialAccount() + { + return this.CreditorBankAccounts.Any(); + } // !AnyCreditorFinancialAccount() + + public void AddDebitorFinancialAccount(string iban, string bic, string id = null, string bankleitzahl = null, string bankName = null) { this.DebitorBankAccounts.Add(new BankAccount() @@ -1392,6 +1458,24 @@ public void AddDebitorFinancialAccount(string iban, string bic, string id = null } // !AddDebitorFinancialAccount() + internal void _AddDebitorFinancialAccount(BankAccount bankAccount) + { + this.DebitorBankAccounts.Add(bankAccount); + } // !_AddDebitorFinancialAccount() + + + public List GetDebitorFinancialAccounts() + { + return this.DebitorBankAccounts; + } // !GetDebitorFinancialAccounts() + + + public bool AnyDebitorFinancialAccount() + { + return this.DebitorBankAccounts.Any(); + } // !AnyDebitorFinancialAccount() + + public void AddReceivableSpecifiedTradeAccountingAccount(string AccountID) { AddReceivableSpecifiedTradeAccountingAccount(AccountID, AccountingAccountTypeCodes.Unknown); @@ -1400,12 +1484,25 @@ public void AddReceivableSpecifiedTradeAccountingAccount(string AccountID) public void AddReceivableSpecifiedTradeAccountingAccount(string AccountID, AccountingAccountTypeCodes AccountTypeCode) { - this.ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() + this._ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() { TradeAccountID = AccountID, TradeAccountTypeCode = AccountTypeCode }); - } + } // !AddReceivableSpecifiedTradeAccountingAccount() + + + public List GetReceivableSpecifiedTradeAccountingAccounts() + { + return this._ReceivableSpecifiedTradeAccountingAccounts; + } // !GetReceivableSpecifiedTradeAccountingAccounts() + + + public bool AnyReceivableSpecifiedTradeAccountingAccounts() + { + return this._ReceivableSpecifiedTradeAccountingAccounts.Any(); + } // !AnyReceivableSpecifiedTradeAccountingAccounts() + private string _getNextLineId() { diff --git a/ZUGFeRD/InvoiceDescriptor1Reader.cs b/ZUGFeRD/InvoiceDescriptor1Reader.cs index e7f8a7ee..66ddb2be 100644 --- a/ZUGFeRD/InvoiceDescriptor1Reader.cs +++ b/ZUGFeRD/InvoiceDescriptor1Reader.cs @@ -156,17 +156,12 @@ public override InvoiceDescriptor Load(Stream stream) { for (int i = 0; i < creditorFinancialAccountNodes.Count; i++) { - BankAccount account = new BankAccount() - { - ID = XmlUtils.NodeAsString(creditorFinancialAccountNodes[0], ".//ram:ProprietaryID", nsmgr), - IBAN = XmlUtils.NodeAsString(creditorFinancialAccountNodes[0], ".//ram:IBANID", nsmgr), - BIC = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:BICID", nsmgr), - Bankleitzahl = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:GermanBankleitzahlID", nsmgr), - BankName = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:Name", nsmgr), - Name = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:AccountName", nsmgr), - }; - - retval.CreditorBankAccounts.Add(account); + retval.AddCreditorFinancialAccount(iban: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:IBANID", nsmgr), + bic: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:BICID", nsmgr), + id: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:ProprietaryID", nsmgr), + bankleitzahl: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:GermanBankleitzahlID", nsmgr), + bankName: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:Name", nsmgr), + name: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:AccountName", nsmgr)); } // !for(i) } @@ -177,16 +172,11 @@ public override InvoiceDescriptor Load(Stream stream) { for (int i = 0; i < debitorFinancialAccountNodes.Count; i++) { - BankAccount account = new BankAccount() - { - ID = XmlUtils.NodeAsString(debitorFinancialAccountNodes[0], ".//ram:ProprietaryID", nsmgr), - IBAN = XmlUtils.NodeAsString(debitorFinancialAccountNodes[0], ".//ram:IBANID", nsmgr), - BIC = XmlUtils.NodeAsString(debitorFinancialInstitutions[0], ".//ram:BICID", nsmgr), - Bankleitzahl = XmlUtils.NodeAsString(debitorFinancialInstitutions[0], ".//ram:GermanBankleitzahlID", nsmgr), - BankName = XmlUtils.NodeAsString(debitorFinancialInstitutions[0], ".//ram:Name", nsmgr), - }; - - retval.DebitorBankAccounts.Add(account); + retval.AddDebitorFinancialAccount(iban: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:IBANID", nsmgr), + bic: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:BICID", nsmgr), + id: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:ProprietaryID", nsmgr), + bankleitzahl: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:GermanBankleitzahlID", nsmgr), + bankName: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:Name", nsmgr)); } // !for(i) } @@ -265,7 +255,7 @@ public override InvoiceDescriptor Load(Stream stream) foreach (XmlNode node in doc.SelectNodes("//ram:IncludedSupplyChainTradeLineItem", nsmgr)) { - retval.TradeLineItems.Add(_parseTradeLineItem(node, nsmgr)); + retval._AddTradeLineItem(_parseTradeLineItem(node, nsmgr)); } return retval; } // !Load() diff --git a/ZUGFeRD/InvoiceDescriptor1Writer.cs b/ZUGFeRD/InvoiceDescriptor1Writer.cs index 29203c52..5d7c4967 100644 --- a/ZUGFeRD/InvoiceDescriptor1Writer.cs +++ b/ZUGFeRD/InvoiceDescriptor1Writer.cs @@ -223,7 +223,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteOptionalElementString("ram", "PaymentReference", this.Descriptor.PaymentReference); - if (this.Descriptor.CreditorBankAccounts.Count == 0 && this.Descriptor.DebitorBankAccounts.Count == 0) + if (!this.Descriptor.AnyCreditorFinancialAccount() && ! this.Descriptor.AnyDebitorFinancialAccount()) { if (this.Descriptor.PaymentMeans != null) { @@ -247,7 +247,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } else { - foreach (BankAccount account in this.Descriptor.CreditorBankAccounts) + foreach (BankAccount creditorBankAccount in this.Descriptor.GetCreditorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans"); @@ -266,23 +266,23 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } Writer.WriteStartElement("ram", "PayeePartyCreditorFinancialAccount"); - Writer.WriteElementString("ram", "IBANID", account.IBAN); - if (!String.IsNullOrWhiteSpace(account.Name)) + Writer.WriteElementString("ram", "IBANID", creditorBankAccount.IBAN); + if (!String.IsNullOrWhiteSpace(creditorBankAccount.Name)) { - Writer.WriteOptionalElementString("ram", "AccountName", account.Name); + Writer.WriteOptionalElementString("ram", "AccountName", creditorBankAccount.Name); } - Writer.WriteOptionalElementString("ram", "ProprietaryID", account.ID); + Writer.WriteOptionalElementString("ram", "ProprietaryID", creditorBankAccount.ID); Writer.WriteEndElement(); // !PayeePartyCreditorFinancialAccount Writer.WriteStartElement("ram", "PayeeSpecifiedCreditorFinancialInstitution"); - Writer.WriteElementString("ram", "BICID", account.BIC); - Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", account.Bankleitzahl); - Writer.WriteOptionalElementString("ram", "Name", account.BankName); + Writer.WriteElementString("ram", "BICID", creditorBankAccount.BIC); + Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", creditorBankAccount.Bankleitzahl); + Writer.WriteOptionalElementString("ram", "Name", creditorBankAccount.BankName); Writer.WriteEndElement(); // !PayeeSpecifiedCreditorFinancialInstitution Writer.WriteEndElement(); // !SpecifiedTradeSettlementPaymentMeans } - foreach (BankAccount account in this.Descriptor.DebitorBankAccounts) + foreach (BankAccount debitorBankAccount in this.Descriptor.GetDebitorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans"); @@ -301,14 +301,14 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } Writer.WriteStartElement("ram", "PayerPartyDebtorFinancialAccount"); - Writer.WriteElementString("ram", "IBANID", account.IBAN); - Writer.WriteOptionalElementString("ram", "ProprietaryID", account.ID); + Writer.WriteElementString("ram", "IBANID", debitorBankAccount.IBAN); + Writer.WriteOptionalElementString("ram", "ProprietaryID", debitorBankAccount.ID); Writer.WriteEndElement(); // !PayerPartyDebtorFinancialAccount Writer.WriteStartElement("ram", "PayerSpecifiedDebtorFinancialInstitution"); - Writer.WriteElementString("ram", "BICID", account.BIC); - Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", account.Bankleitzahl); - Writer.WriteOptionalElementString("ram", "Name", account.BankName); + Writer.WriteElementString("ram", "BICID", debitorBankAccount.BIC); + Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", debitorBankAccount.Bankleitzahl); + Writer.WriteOptionalElementString("ram", "Name", debitorBankAccount.BankName); Writer.WriteEndElement(); // !PayerSpecifiedDebtorFinancialInstitution Writer.WriteEndElement(); // !SpecifiedTradeSettlementPaymentMeans } @@ -352,7 +352,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteEndElement(); } - foreach (ServiceCharge serviceCharge in this.Descriptor.ServiceCharges) + foreach (ServiceCharge serviceCharge in this.Descriptor.GetLogisticsServiceCharges()) { Writer.WriteStartElement("ram", "SpecifiedLogisticsServiceCharge"); Writer.WriteOptionalElementString("ram", "Description", serviceCharge.Description, Profile.Comfort | Profile.Extended); @@ -451,7 +451,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteEndElement(); // !ram:ApplicableSupplyChainTradeSettlement - foreach (TradeLineItem tradeLineItem in this.Descriptor.TradeLineItems) + foreach (TradeLineItem tradeLineItem in this.Descriptor.GetTradeLineItems()) { Writer.WriteStartElement("ram", "IncludedSupplyChainTradeLineItem"); @@ -693,7 +693,7 @@ internal override bool Validate(InvoiceDescriptor descriptor, bool throwExceptio if (descriptor.Profile != Profile.Extended) // check tax types, only extended profile allows tax types other than vat { - if (!descriptor.TradeLineItems.All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) + if (!descriptor.GetTradeLineItems().All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) { if (throwExceptions) { throw new UnsupportedException("Tax types other than VAT only possible with extended profile."); } return false; @@ -727,7 +727,7 @@ private void _writeElementWithAttribute(ProfileAwareXmlTextWriter writer, string private void _writeOptionalTaxes(ProfileAwareXmlTextWriter writer) { - foreach (Tax tax in this.Descriptor.Taxes) + foreach (Tax tax in this.Descriptor.GetApplicableTradeTaxes()) { writer.WriteStartElement("ram", "ApplicableTradeTax"); diff --git a/ZUGFeRD/InvoiceDescriptor20Reader.cs b/ZUGFeRD/InvoiceDescriptor20Reader.cs index 7ef1c8e8..4ddf460d 100644 --- a/ZUGFeRD/InvoiceDescriptor20Reader.cs +++ b/ZUGFeRD/InvoiceDescriptor20Reader.cs @@ -178,17 +178,12 @@ public override InvoiceDescriptor Load(Stream stream) { for (int i = 0; i < creditorFinancialAccountNodes.Count; i++) { - BankAccount account = new BankAccount() - { - ID = XmlUtils.NodeAsString(creditorFinancialAccountNodes[0], ".//ram:ProprietaryID", nsmgr), - IBAN = XmlUtils.NodeAsString(creditorFinancialAccountNodes[0], ".//ram:IBANID", nsmgr), - Name = XmlUtils.NodeAsString(creditorFinancialAccountNodes[0], ".//ram:AccountName", nsmgr), - BIC = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:BICID", nsmgr), - Bankleitzahl = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:GermanBankleitzahlID", nsmgr), - BankName = XmlUtils.NodeAsString(creditorFinancialInstitutions[0], ".//ram:Name", nsmgr), - }; - - retval.CreditorBankAccounts.Add(account); + retval.AddCreditorFinancialAccount(iban: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:IBANID", nsmgr), + bic: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:BICID", nsmgr), + id: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:ProprietaryID", nsmgr), + bankleitzahl: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:GermanBankleitzahlID", nsmgr), + bankName: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:Name", nsmgr), + name: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:AccountName", nsmgr)); } // !for(i) } @@ -215,7 +210,7 @@ public override InvoiceDescriptor Load(Stream stream) if (payerSpecifiedDebtorFinancialInstitutionNode != null) account.BIC = XmlUtils.NodeAsString(payerPartyDebtorFinancialAccountNode, ".//ram:BICID", nsmgr); - retval.DebitorBankAccounts.Add(account); + retval._AddDebitorFinancialAccount(account); } //XmlNodeList debitorFinancialAccountNodes = doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:PayerPartyDebtorFinancialAccount", nsmgr); @@ -326,7 +321,7 @@ public override InvoiceDescriptor Load(Stream stream) foreach (XmlNode node in doc.SelectNodes("//ram:IncludedSupplyChainTradeLineItem", nsmgr)) { - retval.TradeLineItems.Add(_parseTradeLineItem(node, nsmgr)); + retval._AddTradeLineItem(_parseTradeLineItem(node, nsmgr)); } //SellerOrderReferencedDocument diff --git a/ZUGFeRD/InvoiceDescriptor20Writer.cs b/ZUGFeRD/InvoiceDescriptor20Writer.cs index 14bf7ddb..983d8e2e 100644 --- a/ZUGFeRD/InvoiceDescriptor20Writer.cs +++ b/ZUGFeRD/InvoiceDescriptor20Writer.cs @@ -126,7 +126,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo #region SpecifiedSupplyChainTradeTransaction Writer.WriteStartElement("rsm", "SupplyChainTradeTransaction"); - foreach (TradeLineItem tradeLineItem in this.Descriptor.TradeLineItems) + foreach (TradeLineItem tradeLineItem in this.Descriptor.GetTradeLineItems()) { Writer.WriteStartElement("ram", "IncludedSupplyChainTradeLineItem"); @@ -577,7 +577,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } // 10. SpecifiedTradeSettlementPaymentMeans (optional) - if (this.Descriptor.CreditorBankAccounts.Count == 0 && this.Descriptor.DebitorBankAccounts.Count == 0) + if (!this.Descriptor.AnyCreditorFinancialAccount() && !this.Descriptor.AnyDebitorFinancialAccount()) { if (this.Descriptor.PaymentMeans != null) { @@ -601,7 +601,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } else { - foreach (BankAccount account in this.Descriptor.CreditorBankAccounts) + foreach (BankAccount creditorAccount in this.Descriptor.GetCreditorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans"); @@ -620,19 +620,19 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } Writer.WriteStartElement("ram", "PayeePartyCreditorFinancialAccount"); - Writer.WriteElementString("ram", "IBANID", account.IBAN); - Writer.WriteOptionalElementString("ram", "AccountName", account.Name); - Writer.WriteOptionalElementString("ram", "ProprietaryID", account.ID); + Writer.WriteElementString("ram", "IBANID", creditorAccount.IBAN); + Writer.WriteOptionalElementString("ram", "AccountName", creditorAccount.Name); + Writer.WriteOptionalElementString("ram", "ProprietaryID", creditorAccount.ID); Writer.WriteEndElement(); // !PayeePartyCreditorFinancialAccount Writer.WriteStartElement("ram", "PayeeSpecifiedCreditorFinancialInstitution"); - Writer.WriteElementString("ram", "BICID", account.BIC); - Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", account.Bankleitzahl); + Writer.WriteElementString("ram", "BICID", creditorAccount.BIC); + Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", creditorAccount.Bankleitzahl); Writer.WriteEndElement(); // !PayeeSpecifiedCreditorFinancialInstitution Writer.WriteEndElement(); // !SpecifiedTradeSettlementPaymentMeans } - foreach (BankAccount account in this.Descriptor.DebitorBankAccounts) + foreach (BankAccount debitorAccount in this.Descriptor.GetDebitorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans"); @@ -643,19 +643,19 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } Writer.WriteStartElement("ram", "PayerPartyDebtorFinancialAccount"); - Writer.WriteElementString("ram", "IBANID", account.IBAN); - Writer.WriteOptionalElementString("ram", "ProprietaryID", account.ID); + Writer.WriteElementString("ram", "IBANID", debitorAccount.IBAN); + Writer.WriteOptionalElementString("ram", "ProprietaryID", debitorAccount.ID); Writer.WriteEndElement(); // !PayerPartyDebtorFinancialAccount - if (!string.IsNullOrWhiteSpace(account.BIC) || - !string.IsNullOrWhiteSpace(account.Bankleitzahl) || - !string.IsNullOrWhiteSpace(account.BankName)) + if (!string.IsNullOrWhiteSpace(debitorAccount.BIC) || + !string.IsNullOrWhiteSpace(debitorAccount.Bankleitzahl) || + !string.IsNullOrWhiteSpace(debitorAccount.BankName)) { Writer.WriteStartElement("ram", "PayerSpecifiedDebtorFinancialInstitution"); - Writer.WriteOptionalElementString("ram", "BICID", account.BIC); - Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", account.Bankleitzahl); - Writer.WriteOptionalElementString("ram", "Name", account.BankName); + Writer.WriteOptionalElementString("ram", "BICID", debitorAccount.BIC); + Writer.WriteOptionalElementString("ram", "GermanBankleitzahlID", debitorAccount.Bankleitzahl); + Writer.WriteOptionalElementString("ram", "Name", debitorAccount.BankName); Writer.WriteEndElement(); // !PayerSpecifiedDebtorFinancialInstitution } @@ -743,7 +743,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } // 14. SpecifiedLogisticsServiceCharge (optional) - foreach (ServiceCharge serviceCharge in this.Descriptor.ServiceCharges) + foreach (ServiceCharge serviceCharge in this.Descriptor.GetLogisticsServiceCharges()) { Writer.WriteStartElement("ram", "SpecifiedLogisticsServiceCharge"); if (!String.IsNullOrWhiteSpace(serviceCharge.Description)) @@ -961,7 +961,7 @@ private void _writeElementWithAttribute(ProfileAwareXmlTextWriter writer, string private void _writeOptionalTaxes(ProfileAwareXmlTextWriter writer) { - foreach (Tax tax in this.Descriptor.Taxes) + foreach (Tax tax in this.Descriptor.GetApplicableTradeTaxes()) { writer.WriteStartElement("ram", "ApplicableTradeTax"); @@ -1174,7 +1174,7 @@ internal override bool Validate(InvoiceDescriptor descriptor, bool throwExceptio if (descriptor.Profile != Profile.Extended) // check tax types, only extended profile allows tax types other than vat { - if (!descriptor.TradeLineItems.All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) + if (!descriptor.GetTradeLineItems().All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) { if (throwExceptions) { throw new UnsupportedException("Tax types other than VAT only possible with extended profile."); } return false; diff --git a/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs b/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs index 2c1db82d..254c6624 100644 --- a/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs +++ b/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs @@ -312,7 +312,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } // PaymentMeans - if (this.Descriptor.CreditorBankAccounts.Count == 0 && this.Descriptor.DebitorBankAccounts.Count == 0) + if (!this.Descriptor.AnyCreditorFinancialAccount() && !this.Descriptor.AnyDebitorFinancialAccount()) { if (this.Descriptor.PaymentMeans != null) { @@ -336,7 +336,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } else { - foreach (BankAccount account in this.Descriptor.CreditorBankAccounts) + foreach (BankAccount account in this.Descriptor.GetCreditorFinancialAccounts()) { Writer.WriteStartElement("cac", "PaymentMeans", Profile.BasicWL | Profile.Basic | Profile.Comfort | Profile.Extended | Profile.XRechnung1 | Profile.XRechnung); @@ -378,7 +378,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } //[BR - 67] - An Invoice shall contain maximum one Payment Mandate(BG - 19). - foreach (BankAccount account in this.Descriptor.DebitorBankAccounts) + foreach (BankAccount account in this.Descriptor.GetDebitorFinancialAccounts()) { Writer.WriteStartElement("cac", "PaymentMeans", Profile.BasicWL | Profile.Basic | Profile.Comfort | Profile.Extended | Profile.XRechnung1 | Profile.XRechnung); @@ -491,12 +491,12 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo #endregion // Tax Total - if ((this.Descriptor.Taxes?.Any() == true) && (this.Descriptor.TaxTotalAmount != null)) + if (this.Descriptor.AnyApplicableTradeTaxes() && (this.Descriptor.TaxTotalAmount != null)) { Writer.WriteStartElement("cac", "TaxTotal"); _writeOptionalAmount(Writer, "cbc", "TaxAmount", this.Descriptor.TaxTotalAmount, forceCurrency: true); - foreach (Tax tax in this.Descriptor.Taxes) + foreach (Tax tax in this.Descriptor.GetApplicableTradeTaxes()) { Writer.WriteStartElement("cac", "TaxSubtotal"); _writeOptionalAmount(Writer, "cbc", "TaxableAmount", tax.BasisAmount, forceCurrency: true); @@ -535,7 +535,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteEndElement(); //!LegalMonetaryTotal - foreach (TradeLineItem tradeLineItem in this.Descriptor.TradeLineItems) + foreach (TradeLineItem tradeLineItem in this.Descriptor.GetTradeLineItems()) { //Skip items with parent line id because these are written recursively in the _WriteTradeLineItem method if (String.IsNullOrEmpty(tradeLineItem.AssociatedDocument.ParentLineID)) @@ -697,7 +697,7 @@ private void _WriteTradeLineItem(TradeLineItem tradeLineItem, bool isInvoice = t // TODO Add Tax Information for the tradeline item //Write sub invoice lines recursively - foreach (TradeLineItem subTradeLineItem in this.Descriptor.TradeLineItems.Where(t => t.AssociatedDocument.ParentLineID == tradeLineItem.AssociatedDocument.LineID)) + foreach (TradeLineItem subTradeLineItem in this.Descriptor.GetTradeLineItems().Where(t => t.AssociatedDocument.ParentLineID == tradeLineItem.AssociatedDocument.LineID)) { _WriteTradeLineItem(subTradeLineItem, isInvoice); } diff --git a/ZUGFeRD/InvoiceDescriptor22UblReader.cs b/ZUGFeRD/InvoiceDescriptor22UblReader.cs index 7764c19e..67c14219 100644 --- a/ZUGFeRD/InvoiceDescriptor22UblReader.cs +++ b/ZUGFeRD/InvoiceDescriptor22UblReader.cs @@ -307,13 +307,13 @@ public override InvoiceDescriptor Load(Stream stream) XmlNodeList creditorFinancialAccountNodes = doc.SelectNodes("//cac:PaymentMeans/cac:PayeeFinancialAccount", nsmgr); foreach (XmlNode node in creditorFinancialAccountNodes) { - retval.CreditorBankAccounts.Add(_nodeAsBankAccount(node, ".", nsmgr)); + retval._AddCreditorFinancialAccount(_nodeAsBankAccount(node, ".", nsmgr)); } XmlNodeList debitorFinancialAccountNodes = doc.SelectNodes("//cac:PaymentMeans/cac:PaymentMandate/cac:PayerFinancialAccount", nsmgr); foreach (XmlNode node in debitorFinancialAccountNodes) { - retval.DebitorBankAccounts.Add(_nodeAsBankAccount(node, ".", nsmgr)); + retval._AddDebitorFinancialAccount(_nodeAsBankAccount(node, ".", nsmgr)); } foreach (XmlNode node in doc.SelectNodes("//cac:TaxTotal/cac:TaxSubtotal", nsmgr)) @@ -386,7 +386,7 @@ public override InvoiceDescriptor Load(Stream stream) // TODO: Find value //foreach (XmlNode node in doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:ReceivableSpecifiedTradeAccountingAccount", nsmgr)) //{ - // retval.ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() + // retval._ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() // { // TradeAccountID = XmlUtils.NodeAsString(node, ".//ram:ID", nsmgr), // TradeAccountTypeCode = (AccountingAccountTypeCodes)_nodeAsInt(node, ".//ram:TypeCode", nsmgr), @@ -447,7 +447,7 @@ public override InvoiceDescriptor Load(Stream stream) foreach (XmlNode node in doc.SelectNodes(tradeLineItemSelector, nsmgr)) { - retval.TradeLineItems.AddRange(_parseTradeLineItem(node, nsmgr)); + retval._AddTradeLineItems(_parseTradeLineItem(node, nsmgr)); } return retval; @@ -618,7 +618,7 @@ private static List _parseTradeLineItem(XmlNode tradeLineItem, Xm // //TODO // break; // case "ram:ReceivableSpecifiedTradeAccountingAccount": - // // TODO: Find value //item.ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() + // // TODO: Find value //item._ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() // //{ // // TradeAccountID = XmlUtils.NodeAsString(LineTradeSettlementNode, "./ram:ID", nsmgr), // // TradeAccountTypeCode = (AccountingAccountTypeCodes)_nodeAsInt(LineTradeSettlementNode, ".//ram:TypeCode", nsmgr) diff --git a/ZUGFeRD/InvoiceDescriptor23CIIReader.cs b/ZUGFeRD/InvoiceDescriptor23CIIReader.cs index 6784eacf..0e1386b9 100644 --- a/ZUGFeRD/InvoiceDescriptor23CIIReader.cs +++ b/ZUGFeRD/InvoiceDescriptor23CIIReader.cs @@ -225,26 +225,19 @@ public override InvoiceDescriptor Load(Stream stream) XmlNodeList creditorFinancialAccountNodes = doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialAccount", nsmgr); XmlNodeList creditorFinancialInstitutions = doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeeSpecifiedCreditorFinancialInstitution", nsmgr); - int numberOfAccounts = creditorFinancialAccountNodes.Count > creditorFinancialInstitutions.Count ? creditorFinancialAccountNodes.Count : creditorFinancialInstitutions.Count; - for (int i = 0; i < numberOfAccounts; i++) - { - BankAccount account = new BankAccount(); - retval.CreditorBankAccounts.Add(account); - } - - for (int i = 0; i < creditorFinancialAccountNodes.Count; i++) - { - retval.CreditorBankAccounts[i].ID = XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:ProprietaryID", nsmgr); - retval.CreditorBankAccounts[i].IBAN = XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:IBANID", nsmgr); - retval.CreditorBankAccounts[i].Name = XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:AccountName", nsmgr); - } + int numberOfAccounts = Math.Min(creditorFinancialAccountNodes.Count, creditorFinancialInstitutions.Count); - for (int i = 0; i < creditorFinancialInstitutions.Count; i++) + for (int i = 0; i < numberOfAccounts; i++) { - retval.CreditorBankAccounts[i].BIC = XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:BICID", nsmgr); - retval.CreditorBankAccounts[i].Bankleitzahl = XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:GermanBankleitzahlID", nsmgr); - retval.CreditorBankAccounts[i].BankName = XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:Name", nsmgr); - } + retval.AddCreditorFinancialAccount( + iban: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:IBANID", nsmgr), + bic: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:BICID", nsmgr), + id: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:ProprietaryID", nsmgr), + bankleitzahl: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:GermanBankleitzahlID", nsmgr), + bankName: XmlUtils.NodeAsString(creditorFinancialInstitutions[i], ".//ram:Name", nsmgr), + name: XmlUtils.NodeAsString(creditorFinancialAccountNodes[i], ".//ram:AccountName", nsmgr) + ); + } // !for(i) var specifiedTradeSettlementPaymentMeansNodes = doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans", nsmgr); @@ -269,7 +262,7 @@ public override InvoiceDescriptor Load(Stream stream) if (payerSpecifiedDebtorFinancialInstitutionNode != null) account.BIC = XmlUtils.NodeAsString(payerPartyDebtorFinancialAccountNode, ".//ram:BICID", nsmgr); - retval.DebitorBankAccounts.Add(account); + retval._AddDebitorFinancialAccount(account); } foreach (XmlNode node in doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax", nsmgr)) @@ -351,11 +344,10 @@ public override InvoiceDescriptor Load(Stream stream) foreach (XmlNode node in doc.SelectNodes("//ram:ApplicableHeaderTradeSettlement/ram:ReceivableSpecifiedTradeAccountingAccount", nsmgr)) { - retval.ReceivableSpecifiedTradeAccountingAccounts.Add(new ReceivableSpecifiedTradeAccountingAccount() - { - TradeAccountID = XmlUtils.NodeAsString(node, ".//ram:ID", nsmgr), - TradeAccountTypeCode = XmlUtils.NodeAsEnum(node, ".//ram:TypeCode", nsmgr), - }); + retval.AddReceivableSpecifiedTradeAccountingAccount( + AccountID: XmlUtils.NodeAsString(node, ".//ram:ID", nsmgr), + AccountTypeCode: XmlUtils.NodeAsEnum(node, ".//ram:TypeCode", nsmgr) + ); } retval.OrderDate = DataTypeReader.ReadFormattedIssueDateTime(doc.DocumentElement, "//ram:ApplicableHeaderTradeAgreement/ram:BuyerOrderReferencedDocument/ram:FormattedIssueDateTime", nsmgr); @@ -389,7 +381,7 @@ public override InvoiceDescriptor Load(Stream stream) foreach (XmlNode node in doc.SelectNodes("//ram:IncludedSupplyChainTradeLineItem", nsmgr)) { - retval.TradeLineItems.Add(_parseTradeLineItem(node, nsmgr)); + retval._AddTradeLineItem(_parseTradeLineItem(node, nsmgr)); } return retval; diff --git a/ZUGFeRD/InvoiceDescriptor23CIIWriter.cs b/ZUGFeRD/InvoiceDescriptor23CIIWriter.cs index 5d613ec5..1806365d 100644 --- a/ZUGFeRD/InvoiceDescriptor23CIIWriter.cs +++ b/ZUGFeRD/InvoiceDescriptor23CIIWriter.cs @@ -132,7 +132,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteStartElement("rsm", "SupplyChainTradeTransaction"); #region IncludedSupplyChainTradeLineItem - foreach (TradeLineItem tradeLineItem in this.Descriptor.TradeLineItems) + foreach (TradeLineItem tradeLineItem in this.Descriptor.GetTradeLineItems()) { Writer.WriteStartElement("ram", "IncludedSupplyChainTradeLineItem"); @@ -858,7 +858,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo #region SpecifiedTradeSettlementPaymentMeans // 10. SpecifiedTradeSettlementPaymentMeans (optional), BG-16 - if (this.Descriptor.CreditorBankAccounts.Count == 0 && this.Descriptor.DebitorBankAccounts.Count == 0) + if (!this.Descriptor.AnyCreditorFinancialAccount() && !this.Descriptor.AnyDebitorFinancialAccount()) { if ((this.Descriptor.PaymentMeans != null) && (this.Descriptor.PaymentMeans.TypeCode != PaymentMeansTypeCodes.Unknown)) { @@ -878,7 +878,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } else { - foreach (BankAccount account in this.Descriptor.CreditorBankAccounts) + foreach (BankAccount account in this.Descriptor.GetCreditorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans", ALL_PROFILES ^ Profile.Minimum); @@ -912,7 +912,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteEndElement(); // !SpecifiedTradeSettlementPaymentMeans } - foreach (BankAccount account in this.Descriptor.DebitorBankAccounts) + foreach (BankAccount account in this.Descriptor.GetDebitorFinancialAccounts()) { Writer.WriteStartElement("ram", "SpecifiedTradeSettlementPaymentMeans", ALL_PROFILES ^ Profile.Minimum); // BG-16 @@ -1014,7 +1014,7 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo } // 14. SpecifiedLogisticsServiceCharge (optional) - foreach (ServiceCharge serviceCharge in this.Descriptor.ServiceCharges) + foreach (ServiceCharge serviceCharge in this.Descriptor.GetLogisticsServiceCharges()) { Writer.WriteStartElement("ram", "SpecifiedLogisticsServiceCharge", ALL_PROFILES ^ (Profile.XRechnung1 | Profile.XRechnung)); Writer.WriteOptionalElementString("ram", "Description", serviceCharge.Description); @@ -1196,9 +1196,9 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo #region ReceivableSpecifiedTradeAccountingAccount // Detailinformationen zur Buchungsreferenz, BT-19-00 - if (this.Descriptor.ReceivableSpecifiedTradeAccountingAccounts?.Any() == true) + if (this.Descriptor.AnyReceivableSpecifiedTradeAccountingAccounts()) { - foreach (var traceAccountingAccount in this.Descriptor.ReceivableSpecifiedTradeAccountingAccounts) + foreach (var traceAccountingAccount in this.Descriptor.GetReceivableSpecifiedTradeAccountingAccounts()) { if (string.IsNullOrWhiteSpace(traceAccountingAccount.TradeAccountID)) { @@ -1364,7 +1364,7 @@ private void _writeElementWithAttributeWithPrefix(ProfileAwareXmlTextWriter writ private void _writeOptionalTaxes(ProfileAwareXmlTextWriter writer) { - this.Descriptor.Taxes?.ForEach (tax => + this.Descriptor.GetApplicableTradeTaxes()?.ForEach (tax => { writer.WriteStartElement("ram", "ApplicableTradeTax"); diff --git a/ZUGFeRD/InvoiceDescriptor23Writer.cs b/ZUGFeRD/InvoiceDescriptor23Writer.cs index ae340a6b..40495729 100644 --- a/ZUGFeRD/InvoiceDescriptor23Writer.cs +++ b/ZUGFeRD/InvoiceDescriptor23Writer.cs @@ -71,7 +71,7 @@ internal override bool Validate(InvoiceDescriptor descriptor, bool throwExceptio if (descriptor.Profile != Profile.Extended) // check tax types, only extended profile allows tax types other than vat { - if (!descriptor.TradeLineItems.All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) + if (!descriptor.GetTradeLineItems().All(l => l.TaxType.Equals(TaxTypes.VAT) || l.TaxType.Equals(TaxTypes.Unknown))) { if (throwExceptions) { throw new UnsupportedException("Tax types other than VAT only possible with extended profile."); } return false; diff --git a/ZUGFeRD/InvoiceValidator.cs b/ZUGFeRD/InvoiceValidator.cs index d5bcc430..9118fd79 100644 --- a/ZUGFeRD/InvoiceValidator.cs +++ b/ZUGFeRD/InvoiceValidator.cs @@ -60,12 +60,12 @@ public static List Validate(InvoiceDescriptor descriptor) // line item summation retval.Add("Validating invoice monetary summation"); - retval.Add(String.Format("Starting recalculating line total from {0} items...", descriptor.TradeLineItems.Count)); + retval.Add(String.Format("Starting recalculating line total from {0} items...", descriptor.GetTradeLineItems().Count)); int lineCounter = 0; decimal lineTotal = 0m; Dictionary lineTotalPerTax = new Dictionary(); - foreach (TradeLineItem item in descriptor.TradeLineItems) + foreach (TradeLineItem item in descriptor.GetTradeLineItems()) { decimal total = 0m; if (item.NetUnitPrice.HasValue) @@ -153,7 +153,7 @@ public static List Validate(InvoiceDescriptor descriptor) decimal taxBasisTotal = 0m; - foreach (Tax tax in descriptor.Taxes) + foreach (Tax tax in descriptor.GetApplicableTradeTaxes()) { taxBasisTotal += tax.BasisAmount; }