iter = adjustments.iterator();
while(iter.hasNext()){
GenericValue orderAdjustment = (GenericValue) iter.next();
Double amount = orderAdjustment.getDouble("amount");
Double sourcePercentage = orderAdjustment.getDouble("sourcePercentage");
XModel adjustmentLine = Journal.appendNode(model, "tr", "adjustment", "");
Journal.appendNode(adjustmentLine, "td", "sku", "");
Journal.appendNode(adjustmentLine, "td", "desc",
UtilProperties.getMessage("pos", "(SalesDiscount)",defaultLocale));
if (UtilValidate.isNotEmpty(amount)) {
Journal.appendNode(adjustmentLine, "td", "qty", "");
Journal.appendNode(adjustmentLine, "td", "price", UtilFormatOut.formatPrice(amount));
} else if (UtilValidate.isNotEmpty(sourcePercentage)) {
double percentage = - sourcePercentage.doubleValue()/100; // 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 = new Double((cart.getItemTotal() + itemsAdjustmentsAmount) * percentage); // itemsAdjustmentsAmount is negative
Journal.appendNode(adjustmentLine, "td", "price", UtilFormatOut.formatPrice(- amount)); // 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("pos","Sales_Tax",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("pos","Grand_Total",defaultLocale));
Journal.appendNode(totalLine, "td", "qty", "");
Journal.appendNode(totalLine, "td", "price", UtilFormatOut.formatPrice(total));
Journal.appendNode(totalLine, "td", "index", "-1");