use of org.incode.module.communications.dom.impl.commchannel.CommunicationChannel in project estatio by estatio.
the class InvoiceForLeaseRepository method newInvoice.
@Programmatic
public InvoiceForLease newInvoice(final ApplicationTenancy applicationTenancy, final Party seller, final Party buyer, final PaymentMethod paymentMethod, final Currency currency, final LocalDate dueDate, final Lease lease, final String interactionId) {
InvoiceForLease invoice = newTransientInstance();
invoice.setApplicationTenancyPath(applicationTenancy.getPath());
invoice.setBuyer(buyer);
invoice.setSeller(seller);
invoice.setPaymentMethod(paymentMethod);
invoice.setStatus(InvoiceStatus.NEW);
invoice.setCurrency(currency);
invoice.setLease(lease);
invoice.setDueDate(dueDate);
invoice.setRunId(interactionId);
// copy down form the agreement, we require all invoice items to relate
// back to this (root) fixed asset
invoice.setPaidBy(lease.getPaidBy());
invoice.setFixedAsset(lease.getProperty());
// copy over the current invoice address (if any)
final CommunicationChannel sendTo = firstCurrentTenantInvoiceAddress(lease);
invoice.setSendTo(sendTo);
invoice.updateDescriptions();
persistIfNotAlready(invoice);
getContainer().flush();
return invoice;
}
Aggregations