if (logger.isDebugEnabled()) {
logger.debug("Saving invoice " + invoice.getId());
logger.debug("Looking for existing invoice " + invoice.getId());
}
Invoice existingInvoice = manager.find(Invoice.class, invoice.getId());
if (logger.isDebugEnabled()) {
logger.debug("Position-Count: " + existingInvoice.getPayments().size());
logger.debug("Deleting positions that no longer exist.");
}
this.deleteOldPayments(manager, invoice, existingInvoice.getPayments());
invoice.calcPaymentSum();
invoice.calcLastPaymentDate();
super.updateDataset(manager, invoice, changeUser);
}