in src/payments/src/main/java/com/google/abmedge/payments/util/BillGenerator.java [115:134]
private static String billItem(int itemIndex, PaymentUnit paymentUnit) {
StringBuilder sb = new StringBuilder();
UUID unitId = paymentUnit.getItemId();
String unitName = paymentUnit.getName();
Number totalUnitValue = paymentUnit.getTotalCost();
BigDecimal unitQuantity = paymentUnit.getQuantity();
String leadingStr =
String.format(" %s. %sx %s (%s):", itemIndex, unitQuantity, unitName, unitId);
// get length of the current line so far
int leadingLength = leadingStr.length();
// get length of the total cost for this item
int costLength = totalUnitValue.toString().length();
// calculate the number of spaces between the item description and the total cost
// -2 for the dollar $ sign and the newline
int middleSpaces = BILL_HEADER.length() - leadingLength - costLength - 2;
sb.append(leadingStr);
sb.append(spaces(middleSpaces));
sb.append(String.format("$%s\n", totalUnitValue));
return sb.toString();
}