Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 9, 2023 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/916250feb62fa83b5676b592f0c00c5b to your computer and use it in GitHub Desktop.
Save bjoerntx/916250feb62fa83b5676b592f0c00c5b to your computer and use it in GitHub Desktop.
public byte[] ZugferdXML {
get {
var invoice = InvoiceDescriptor.CreateInvoice(this.Id.ToString(),
this.OrderDate, CurrencyCodes.USD);
invoice.SetBuyer(this.Buyer.Name,
this.Buyer.PostalCode,
this.Buyer.City,
this.Buyer.Address,
this.Buyer.CountryCodes,
this.Buyer.Id.ToString());
invoice.SetSeller(this.Seller.Name,
this.Seller.PostalCode,
this.Seller.City,
this.Seller.Address,
this.Seller.CountryCodes,
this.Seller.Id.ToString());
invoice.SetSellerContact($"{this.Seller.BuyerContact.FirstName} {this.Seller.BuyerContact.LastName}");
foreach (LineItem lineItem in this.LineItems) {
invoice.AddTradeLineItem(lineItem.Name, lineItem.Description, lineItem.QuantityCode, lineItem.Quantity, lineItem.GrossPrice, lineItem.GrossPrice, lineItem.Quantity);
}
invoice.LineTotalAmount = LineTotalAmount;
invoice.ChargeTotalAmount = invoice.LineTotalAmount;
invoice.AllowanceTotalAmount = Allowance;
invoice.TaxBasisAmount = invoice.ChargeTotalAmount;
invoice.TaxTotalAmount = TaxTotalAmount;
invoice.GrandTotalAmount = GrandTotalAmount;
MemoryStream ms = new MemoryStream();
invoice.Save(ms, ZUGFeRDVersion.Version1, Profile.Basic);
return ms.ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment