- // 3) amount must balance to 0, or
- // 3a) there must be exactly one empty amount (with account)
- if (Misc.isZero(balance)) {
- for (Item item : items) {
- item.setAmountHint(null);
- }
- }
- else {
- int balanceReceiversCount = itemsWithAccountAndEmptyAmount.size();
- if (balanceReceiversCount != 1) {
- Logger.debug("submittable", (balanceReceiversCount == 0) ?
- "Transaction not submittable: non-zero balance " +
- "with no empty amounts with accounts" :
- "Transaction not submittable: non-zero balance " +
- "with multiple empty amounts with accounts");
- submittable = false;
+ // 3) for each commodity:
+ // 3a) amount must balance to 0, or
+ // 3b) there must be exactly one empty amount (with account)
+ for (String balCurrency : balance.keySet()) {
+ Float bal = balance.get(balCurrency);
+ float currencyBalance = (bal == null) ? 0f : bal;
+ if (Misc.isZero(currencyBalance)) {
+ // remove hints from all amount inputs in that currency
+ for (Item item : items) {
+ final String itemCurrency = item.getCurrency()
+ .getName();
+ if (((balCurrency == null) && (null == itemCurrency)) ||
+ ((balCurrency != null) && balCurrency.equals(itemCurrency)))
+ item.setAmountHint(null);
+ }