Skip to content

Commit

Permalink
Merge pull request #391 from quotschmacher/PostalAddressOptionalFields
Browse files Browse the repository at this point in the history
Made some more fields optional
  • Loading branch information
stephanstapel authored Oct 10, 2024
2 parents cae2ffe + 6c0e8f9 commit c86e4ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 13 additions & 9 deletions ZUGFeRD/InvoiceDescriptor22UBLWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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");

Expand Down
14 changes: 5 additions & 9 deletions ZUGFeRD/Party.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Detailed information about a party that has a certain role within an invoice
/// </summary>
public class Party
/// <summary>
/// Detailed information about a party that has a certain role within an invoice
/// </summary>
public class Party
{
/// <summary>
/// Party identifier
Expand Down Expand Up @@ -65,6 +60,7 @@ public class Party

/// <summary>
/// Street name and number
/// e.g. used for BT-35
/// </summary>
public string Street { get; set; }
/// <summary>
Expand Down

0 comments on commit c86e4ee

Please sign in to comment.