Invoice ${OrderID}

Date: ${OrderDate}
Customer: ${CustomerID} (${CompanyName!'N/A'})

Details

<#assign subtotal = 0> <#if details??> <#list details as item> <#-- Handle potential nulls in item map --> <#assign qty = (item.Quantity!0)> <#assign price = (item.UnitPrice!0)> <#assign discount = (item.Discount!0)> <#assign lineTotal = (qty * price * (1 - discount)) > <#assign subtotal = subtotal + lineTotal> <#-- Assuming Tax is calculated or provided --> <#assign freightVal = (Freight!0)> <#assign tax = (subtotal + freightVal) * 0.08 > <#-- Example Tax Calc -->
Product Quantity Unit Price Discount Line Total
${item.ProductName!'N/A'} ${qty} ${price?string("0.00")} ${discount?string("0%")} ${lineTotal?string("0.00")}
Subtotal: ${subtotal?string("0.00")}
Freight: ${(Freight!0)?string("0.00")}
Tax (8%): ${tax?string("0.00")}
Grand Total: ${(subtotal + freightVal + tax)?string("0.00")}