Long number = new Long(maxInvoiceNumber);
invoice.setNumber(number);
invoice.setDocumentDate(nowDay.getTime());
invoice.setSoldDate(nowDay.getTime());
PaymentKind pk = null;
if (invoice.getPaymentKindId() != null) {
pk = paymentKindsService.getPaymentKind(invoice.getPaymentKindId());
}
Date paymentDate = null;
if (pk != null) {
invoice.setPaymentKind(pk);
paymentDate = paymentKindsService.calculatePaymentDate(nowDay.getTime(), pk.getId());
invoice.setPaymentDate(paymentDate);
}
recalculateInvoice(invoice);
hrInvoiceNumberService.updateHRInvoiceNumber(invoice);