diff --git a/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs b/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs index a0468e3..a390a4f 100644 --- a/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs +++ b/ZUGFeRD/InvoiceDescriptor22UBLWriter.cs @@ -250,17 +250,20 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream, ZUGFeRDFo Writer.WriteStartElement("cac:PayeeFinancialAccount"); Writer.WriteElementString("cbc:ID", account.IBAN); - Writer.WriteElementString("cbc:Name", account.Name); + Writer.WriteOptionalElementString("cbc:Name", account.Name); - Writer.WriteStartElement("cac:FinancialInstitutionBranch"); - Writer.WriteElementString("cbc:ID", account.BIC); + if (!string.IsNullOrWhiteSpace(account.BIC)) + { + Writer.WriteStartElement("cac:FinancialInstitutionBranch"); + Writer.WriteElementString("cbc:ID", account.BIC); - //[UBL - CR - 664] - A UBL invoice should not include the FinancialInstitutionBranch FinancialInstitution - //Writer.WriteStartElement("cac:FinancialInstitution"); - //Writer.WriteElementString("cbc:Name", account.BankName); + //[UBL - CR - 664] - A UBL invoice should not include the FinancialInstitutionBranch FinancialInstitution + //Writer.WriteStartElement("cac:FinancialInstitution"); + //Writer.WriteElementString("cbc:Name", account.BankName); - //Writer.WriteEndElement(); // !FinancialInstitution - Writer.WriteEndElement(); // !FinancialInstitutionBranch + //Writer.WriteEndElement(); // !FinancialInstitution + Writer.WriteEndElement(); // !FinancialInstitutionBranch + } Writer.WriteEndElement(); // !PayeeFinancialAccount } @@ -616,10 +619,11 @@ private void _writeOptionalParty(ProfileAwareXmlTextWriter writer, PartyTypes pa writer.WriteStartElement("cac:PostalAddress"); - Writer.WriteElementString("cbc:StreetName", party.Street); + Writer.WriteOptionalElementString("cbc:StreetName", party.Street); Writer.WriteOptionalElementString("cbc:AdditionalStreetName", party.AddressLine3); Writer.WriteElementString("cbc:CityName", party.City); Writer.WriteElementString("cbc:PostalZone", party.Postcode); + Writer.WriteOptionalElementString("cbc:CountrySubentity", party.CountrySubdivisionName); writer.WriteStartElement("cac:Country"); diff --git a/ZUGFeRD/Party.cs b/ZUGFeRD/Party.cs index 8dacb79..1cd882d 100644 --- a/ZUGFeRD/Party.cs +++ b/ZUGFeRD/Party.cs @@ -16,17 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - namespace s2industries.ZUGFeRD { - /// - /// Detailed information about a party that has a certain role within an invoice - /// - public class Party + /// + /// Detailed information about a party that has a certain role within an invoice + /// + public class Party { /// /// Party identifier @@ -65,6 +60,7 @@ public class Party /// /// Street name and number + /// e.g. used for BT-35 /// public string Street { get; set; } ///