public void performAutoMovement(Collection<PayerData> payersData,
Collection<User> consumers) {
//Write off
Map<ZECurrency, BigDecimal> currencyToAmount = new HashMap<ZECurrency, BigDecimal>();
for(PayerData payerData: payersData) {
ZECurrency payerCurrency = payerData.getCurrency();
BigDecimal payerAmount = payerData.getAmount();
CurrencyManager moneyAmountProvider = getCurrencyManager(payerCurrency);
if(moneyAmountProvider != null) {
moneyAmountProvider.writeOn(
payerData.getAmount().negate(), payerCurrency, payerData.getPayer());
BigDecimal writeOffAmount = currencyToAmount.get(payerCurrency);
currencyToAmount.put(payerCurrency,
writeOffAmount == null ? payerAmount : writeOffAmount.add(payerAmount));
}
}
//Write on
for(Map.Entry<ZECurrency, BigDecimal> entry: currencyToAmount.entrySet()) {
ZECurrency currency = entry.getKey();
BigDecimal writeOnValue = entry.getValue().divide(BigDecimal.valueOf(consumers.size()), RoundingMode.HALF_UP);
for(User consumer: consumers) {
CurrencyManager moneyAmountProvider = getCurrencyManager(currency);
if(moneyAmountProvider != null) {