iter = adjustments.iterator();
while (iter.hasNext()) {
GenericValue orderAdjustment = (GenericValue) iter.next();
BigDecimal amount = orderAdjustment.getBigDecimal("amount");
BigDecimal sourcePercentage = orderAdjustment.getBigDecimal("sourcePercentage");
XModel adjustmentLine = Journal.appendNode(model, "tr", "adjustment", "");
Journal.appendNode(adjustmentLine, "td", "sku", "");
Journal.appendNode(adjustmentLine, "td", "desc",
UtilProperties.getMessage(PosTransaction.resource, "PosSalesDiscount",defaultLocale));
if (UtilValidate.isNotEmpty(amount)) {
Journal.appendNode(adjustmentLine, "td", "qty", "");
Journal.appendNode(adjustmentLine, "td", "price", UtilFormatOut.formatPrice(amount));
} else if (UtilValidate.isNotEmpty(sourcePercentage)) {
BigDecimal percentage = sourcePercentage.movePointLeft(2).negate(); // sourcePercentage is negative and must be show as a positive value (it's a discount not an amount)
Journal.appendNode(adjustmentLine, "td", "qty", UtilFormatOut.formatPercentage(percentage));
amount = cart.getItemTotal().add(itemsAdjustmentsAmount).multiply(percentage); // itemsAdjustmentsAmount is negative
Journal.appendNode(adjustmentLine, "td", "price", UtilFormatOut.formatPrice(amount.negate())); // amount must be shown as a negative value
}
Journal.appendNode(adjustmentLine, "td", "index", "-1");
}
}
XModel taxLine = Journal.appendNode(model, "tr", "tax", "");
Journal.appendNode(taxLine, "td", "sku", "");
Journal.appendNode(taxLine, "td", "desc", UtilProperties.getMessage(PosTransaction.resource,"PosSalesTax",defaultLocale));
Journal.appendNode(taxLine, "td", "qty", "");
Journal.appendNode(taxLine, "td", "price", UtilFormatOut.formatPrice(taxAmount));
Journal.appendNode(taxLine, "td", "index", "-1");
XModel totalLine = Journal.appendNode(model, "tr", "total", "");
Journal.appendNode(totalLine, "td", "sku", "");
Journal.appendNode(totalLine, "td", "desc", UtilProperties.getMessage(PosTransaction.resource,"PosGrandTotal",defaultLocale));
Journal.appendNode(totalLine, "td", "qty", "");
Journal.appendNode(totalLine, "td", "price", UtilFormatOut.formatPrice(total));
Journal.appendNode(totalLine, "td", "index", "-1");