final List<InvoiceLine> invoiceLines = new LinkedList<InvoiceLine>();
for(final Element currentLineElement : lineElements) {
// create invoice line
final InvoiceLine invoiceLine = InvoiceLineFactory.getInstance();
// get elements value
final String qty = getElementValue(currentLineElement, "qty", false);
final String unitPrice = getElementValue(currentLineElement, "unitPrice", false);
final String discount = getElementValue(currentLineElement, "discount", false);
final String tax = getElementValue(currentLineElement, "tax", false);
final String lineTaxAmount = getElementValue(currentLineElement, "lineTaxAmount", false);
final String lineTotal = getElementValue(currentLineElement, "lineTotal", false);
// itemNo (required)
invoiceLine.setItemNo(Integer.parseInt(getElementValue(currentLineElement, "itemNo", true)));
// qty
if(qty != null && qty.trim().length() > 0) {
invoiceLine.setQty(new BigDecimal(qty));
}
// prodCode
invoiceLine.setProdCode(getElementValue(currentLineElement, "prodCode", false));
// desc
invoiceLine.setDesc(getElementValue(currentLineElement, "desc", false));
// unitPrice
if(unitPrice != null && unitPrice.trim().length() > 0) {
invoiceLine.setUnitPrice(new BigDecimal(unitPrice));
}
// discount
if(discount != null && discount.trim().length() > 0) {
invoiceLine.setDiscount(new BigDecimal(discount));
}
// tax
if(tax != null && tax.trim().length() > 0) {
invoiceLine.setTax(Integer.parseInt(tax));
}
// lineTaxAmount
if(lineTaxAmount != null && lineTaxAmount.trim().length() > 0) {
invoiceLine.setLineTaxAmount(new BigDecimal(lineTaxAmount));
}
// lineTotal
if(lineTotal != null && lineTotal.trim().length() > 0) {
invoiceLine.setLineTotal(new BigDecimal(lineTotal));
}
invoiceLines.add(invoiceLine);
}