public class MonetarySummaryWithSplits extends MonetarySummary {
public static MonetarySummaryWithSplits summarize(Collection<Money> amounts, Currency currency, Multimap<Tag, Money> splits) {
int spendingCount = 0, earningsCount = 0;
Money spendingSum = Money.zero(currency), earningsSum = Money.zero(currency);
for (Money amount : amounts) {
if (amount.signum() > 0) {
earningsCount++;
earningsSum = earningsSum.add(amount);
} else if (amount.signum() < 0) {
spendingCount++;
spendingSum = spendingSum.add(amount.abs());
}
}
final ImmutableMap.Builder<Tag, MonetarySummary> splitSummaries = ImmutableMap.builder();
for (Tag tag : splits.keySet()) {