public LiquidityForecast calculateExpectedTimeOfPayments(final Collection<RechnungDO> list)
{
if (list == null) {
return this;
}
final KontoCache accountCache = Registry.instance().getKontoCache();
for (final RechnungDO invoice : list) {
final DayHolder date = new DayHolder(invoice.getDatum());
final DayHolder dateOfPayment = new DayHolder(invoice.getBezahlDatum());
if (date == null || dateOfPayment == null) {
continue;
}
final int timeForPayment = date.daysBetween(dateOfPayment);
final int amount = invoice.getGrossSum().intValue();
// Store values for different groups:
final Integer projectId = invoice.getProjektId();
if (projectId != null) {
ensureAndAddDebitorPaymentValue("project#" + projectId, timeForPayment, amount);
}
final Integer customerId = invoice.getKundeId();
if (customerId != null) {
ensureAndAddDebitorPaymentValue("customer#" + customerId, timeForPayment, amount);
}
final KontoDO account = accountCache.getKonto(invoice);
final Integer accountId = account != null ? account.getId() : null;
if (accountId != null) {
ensureAndAddDebitorPaymentValue("account#" + accountId, timeForPayment, amount);
}
String customerText = invoice.getKundeText();