DunningTemplate dunningTemplate = dunningGroup.getTemplateByDunningLevel(dunningLevel);
if ((dunningTemplate == null) && (logger.isDebugEnabled())) {
logger.warn("No dunning-template for level " + dunningLevel + " found in dunning-group " + dunningGroup.getId());
}
Dunning dunning = new Dunning();
dunning.setDunningLevel(dunningLevel);
dunning.setInvoice(invoice);
if (dunningTemplate != null) {
dunning.setDunningCharge(dunningTemplate.getDunningCharge());
dunning.setDunningDate(Calendar.getInstance());
dunning.setDunningTextsFromInvoice(dunningTemplate, invoice);
}
logger.debug("Dunning: Level " + dunning.getDunningLevel() + ", Invoice: " + dunning.getInvoice().getUserNumber());
this.createDataset(dunning, user, company);
createdDunnings.add(dunning);
}
return createdDunnings;
}