package gw.lang.enhancements uses gw.api.util.MultiCurrencySummation uses gw.pl.currency.MonetaryAmount /** * Adds multi-currency summation enhancements. */ @ReadOnly enhancement PCIterableMonetaryAmountSumEnhancement : java.lang.Iterable { /** * Sums up the values of the target of the mapper argument converting * monetary amounts of currencies different than the specified currency. */ function sumDifferentCurriences(currency : Currency, mapper(elt:T) : MonetaryAmount) : MonetaryAmount { // sum up like currencies var summation = new MultiCurrencySummation() for (elt in this) { summation.add(mapper(elt)) } // sum up like currency summations converted to currency return summation.sum(currency) } }