diff --git a/ZUGFeRD/InvoiceDescriptor21Writer.cs b/ZUGFeRD/InvoiceDescriptor21Writer.cs index 8073fb4b..a064a79f 100644 --- a/ZUGFeRD/InvoiceDescriptor21Writer.cs +++ b/ZUGFeRD/InvoiceDescriptor21Writer.cs @@ -1178,37 +1178,37 @@ private void _writeOptionalLegalOrganization(ProfileAwareXmlTextWriter writer, s // all profiles break; case PartyTypes.ShipToTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.UltimateShipToTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.ShipFromTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.InvoiceeTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.PayeeTradeParty: // all profiles break; case PartyTypes.SalesAgentTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.BuyerTaxRepresentativeTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.ProductEndUserTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.BuyerAgentTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.InvoicerTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.PayerTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } // extended profile only + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; default: return; @@ -1258,37 +1258,37 @@ private void _writeOptionalParty(ProfileAwareXmlTextWriter writer, PartyTypes pa case PartyTypes.BuyerTradeParty: break; case PartyTypes.ShipToTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.UltimateShipToTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.ShipFromTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.InvoiceeTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.PayeeTradeParty: if (this.Descriptor.Profile == Profile.Minimum) { return; } // party is written for all profiles but minimum break; case PartyTypes.SalesAgentTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.BuyerTaxRepresentativeTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.ProductEndUserTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.BuyerAgentTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.InvoicerTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; case PartyTypes.PayerTradeParty: - if (this.Descriptor.Profile != Profile.Extended) { return; } + if ((this.Descriptor.Profile != Profile.Extended) && (this.Descriptor.Profile != Profile.XRechnung1) && (this.Descriptor.Profile != Profile.XRechnung)) { return; } // extended, XRechnung1, XRechnung profile only break; default: return; @@ -1368,11 +1368,7 @@ private void _writeOptionalParty(ProfileAwareXmlTextWriter writer, PartyTypes pa } _writeOptionalLegalOrganization(writer, "ram:SpecifiedLegalOrganization", party.SpecifiedLegalOrganization, partyType); - - if (contact != null) - { - _writeOptionalContact(writer, "ram:DefinedTradeContact", contact, Profile.Extended | Profile.XRechnung1 | Profile.XRechnung); - } + _writeOptionalContact(writer, "ram:DefinedTradeContact", contact, Profile.Extended | Profile.XRechnung1 | Profile.XRechnung); writer.WriteStartElement("ram:PostalTradeAddress"); writer.WriteElementString("ram:PostcodeCode", party.Postcode); // BT-53 @@ -1424,43 +1420,46 @@ private void _writeOptionalParty(ProfileAwareXmlTextWriter writer, PartyTypes pa private void _writeOptionalContact(ProfileAwareXmlTextWriter writer, string contactTag, Contact contact, Profile profile = Profile.Unknown) { - if (contact != null) + if (contact == null) { - writer.WriteStartElement(contactTag, profile); + return; + } - if (!String.IsNullOrEmpty(contact.Name)) - { - writer.WriteElementString("ram:PersonName", contact.Name); - } - if (!String.IsNullOrEmpty(contact.OrgUnit)) - { - writer.WriteElementString("ram:DepartmentName", contact.OrgUnit); - } + writer.WriteStartElement(contactTag, profile); - if (!String.IsNullOrEmpty(contact.PhoneNo)) - { - writer.WriteStartElement("ram:TelephoneUniversalCommunication"); - writer.WriteElementString("ram:CompleteNumber", contact.PhoneNo); - writer.WriteEndElement(); - } + if (!String.IsNullOrEmpty(contact.Name)) + { + writer.WriteElementString("ram:PersonName", contact.Name); + } - if (!String.IsNullOrEmpty(contact.FaxNo)) - { - writer.WriteStartElement("ram:FaxUniversalCommunication", ALL_PROFILES ^ (Profile.XRechnung1 | Profile.XRechnung)); - writer.WriteElementString("ram:CompleteNumber", contact.FaxNo); - writer.WriteEndElement(); - } + if (!String.IsNullOrEmpty(contact.OrgUnit)) + { + writer.WriteElementString("ram:DepartmentName", contact.OrgUnit); + } - if (!String.IsNullOrEmpty(contact.EmailAddress)) - { - writer.WriteStartElement("ram:EmailURIUniversalCommunication"); - writer.WriteElementString("ram:URIID", contact.EmailAddress); - writer.WriteEndElement(); - } + if (!String.IsNullOrEmpty(contact.PhoneNo)) + { + writer.WriteStartElement("ram:TelephoneUniversalCommunication"); + writer.WriteElementString("ram:CompleteNumber", contact.PhoneNo); + writer.WriteEndElement(); + } + + if (!String.IsNullOrEmpty(contact.FaxNo)) + { + writer.WriteStartElement("ram:FaxUniversalCommunication", ALL_PROFILES ^ (Profile.XRechnung1 | Profile.XRechnung)); + writer.WriteElementString("ram:CompleteNumber", contact.FaxNo); + writer.WriteEndElement(); + } + if (!String.IsNullOrEmpty(contact.EmailAddress)) + { + writer.WriteStartElement("ram:EmailURIUniversalCommunication"); + writer.WriteElementString("ram:URIID", contact.EmailAddress); writer.WriteEndElement(); } + + writer.WriteEndElement(); } // !_writeOptionalContact() diff --git a/ZUGFeRD/ZUGFeRD.csproj b/ZUGFeRD/ZUGFeRD.csproj index 5cbabf85..a70a8842 100644 --- a/ZUGFeRD/ZUGFeRD.csproj +++ b/ZUGFeRD/ZUGFeRD.csproj @@ -1,7 +1,7 @@  netstandard2.0;net461;net480 - 12.3.0 + 12.3.1 Stephan Stapel s2 industries ZUGFeRD and it's successor Factur-X/ XRechnung are initiatives from German (respectively European) government to foster electronic invoices. @@ -22,15 +22,16 @@ https://github.com/stephanstapel/ZUGFeRD-csharp https://github.com/stephanstapel/ZUGFeRD-csharp/ zugferd xml Stephan Stapel, s2 industries, 2023 - 12.3.0 + 12.3.1 http://www.s2-industries.com - 12.3.0.0 + 12.3.1.0 true s2industries.ZUGFeRD true ZUGFeRD.snk true - 12.3.0: enhanced standard conformance for all party types + 12.3.1: bug fix for all party types +12.3.0: enhanced standard conformance for all party types true ZUGFeRD-csharp README.md