if (price != null) {
priceAmount = price.getPriceAmount();
if (priceAmount != null) {
invoiceLineTokens.addToken(new Token(
TextLabel.INV_ITEM_PRICE.toLowerCase(),
new CurrencyDecimal(priceAmount.getValue(), invoiceTypeCurrency, locale).format()));
}
}
BigDecimal lineExtensionAmount = invoiceLineType.getLineExtensionAmount().getValue();
invoiceLineTokens.addToken(new Token(
TextLabel.INV_ITEM_SUBTOTAL.toLowerCase(),
new CurrencyDecimal(lineExtensionAmount, invoiceTypeCurrency, locale).format()));
// Tax rate (VAT Rate)
// Adding the VAT rate either as a field in the invoice line or as a single token.
if (invoiceLineType.getItem().getClassifiedTaxCategory().size() > 0) {
Token vatRateToken = new Token(TextLabel.INV_ITEM_VAT_RATE.toLowerCase(),
getTaxRateAsFormattedNumber(invoiceLineType, locale).format());
if (ubl4JConfigurationBean.isIncludeVatRateInInvoiceLine()) {
invoiceLineTokens.addToken(vatRateToken);
} else {
template.addToken(vatRateToken);
}
}
BigDecimal taxTotal = invoiceLineType.getTaxTotal().get(0).getTaxAmount().getValue();
invoiceLineTokens.addToken(new Token(TextLabel.INV_ITEM_VAT.toLowerCase(),
new CurrencyDecimal(taxTotal, invoiceTypeCurrency, locale).format()));
BigDecimal total = lineExtensionAmount.add(taxTotal);
invoiceLineTokens.addToken(new Token(TextLabel.INV_ITEM_TOTAL.toLowerCase(),
new CurrencyDecimal(total, invoiceTypeCurrency, locale).format()));
template.addToken(invoiceLineTokens);
}
}