LOGGER.warn("impossible to create a new invoice for an order that has already an invoice");
return o.getInvoice();
}
InvoiceIdService idService = ServiceFactory.getInvoiceIdService();
InvoiceId invId = idService.newWOJIdent(o);
idService.validateIdent(invId);
Invoice i = (Invoice)DaoFactory.getInvoiceDao().newHandledObject();
o.setInvoice(i);
i.setPdf(InvoiceBuilderFactory.getBuilder().buildInvoicePDF(o, p, invId.getIdent()));
i.setIdent(invId.getIdent());
DaoFactory.getInvoiceDao().save(i);
DaoFactory.getOrderDao().save(o);
LOGGER.info(MessageFormat.format("new invoice[{0}] created for user[{1}]", new Object[] {new Long(i.getId()), o.getBuyer().getLogin()}));