use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceForLeaseBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
checkParam("lease", ec, Lease.class);
checkParam("seller", ec, Party.class);
checkParam("buyer", ec, Party.class);
checkParam("paymentMethod", ec, PaymentMethod.class);
checkParam("currency", ec, Currency.class);
checkParam("dueDate", ec, LocalDate.class);
defaultParam("invoiceDate", ec, getDueDate());
final String interactionId = null;
final InvoiceForLease invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, seller, buyer, paymentMethod, currency, dueDate, lease, interactionId);
invoice.setInvoiceDate(this.invoiceDate);
ec.addResult(this, invoice);
final Property property = lease.getProperty();
final String format = property.getReference() + "-%06d";
final BigInteger lastIncrement = BigInteger.ZERO;
this.numerator = numeratorForCollectionRepository.createInvoiceNumberNumerator(property, format, lastIncrement, applicationTenancy);
ec.addResult(this, numerator);
for (ItemsSpec itemSpec : itemSpecs) {
final List<InvoiceItemForLease> items = createInvoiceItemsForTermsOfFirstLeaseItemOfType(invoice, itemSpec.leaseItemType, itemSpec.startDate, itemSpec.interval, ec);
this.items.addAll(items);
}
object = invoice;
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceForLeaseBuilder method createInvoiceItemsForTermsOfFirstLeaseItemOfType.
private List<InvoiceItemForLease> createInvoiceItemsForTermsOfFirstLeaseItemOfType(final InvoiceForLease invoice, final LeaseItemType leaseItemType, final LocalDate startDate, final LocalDateInterval interval, final ExecutionContext ec) {
final Lease lease = invoice.getLease();
final LeaseItem firstLeaseItem = lease.findFirstItemOfType(leaseItemType);
final SortedSet<LeaseTerm> terms = firstLeaseItem.getTerms();
List<InvoiceItemForLease> items = Lists.newArrayList();
for (final LeaseTerm term : terms) {
InvoiceItemForLease item = invoiceItemForLeaseRepository.newInvoiceItem(term, interval, interval, interval, startDate, null);
item.setInvoice(invoice);
item.setSequence(invoice.nextItemSequence());
ec.addResult(this, item);
items.add(item);
}
return items;
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendAbstract method invoiceAndDocumentsToSend.
private List<InvoiceAndDocument> invoiceAndDocumentsToSend(Predicate<InvoiceAndDocument> filter) {
final List<InvoiceAndDocument> invoiceAndDocuments = Lists.newArrayList();
final List<InvoiceForLease> invoices = invoiceSummary.getInvoices();
for (InvoiceForLease invoice : invoices) {
appendTuplesToSend(invoice, filter, invoiceAndDocuments);
}
return invoiceAndDocuments;
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceSummaryAbstract method validate0InvoiceAll.
public String validate0InvoiceAll(final LocalDate invoiceDate) {
for (Invoice invoice : getInvoices()) {
try {
final InvoiceForLease._invoice mixin = mixin(InvoiceForLease._invoice.class, invoice);
wrapperFactory.wrapNoExecute(mixin).$$(invoiceDate);
} catch (InvalidException ex) {
final String reasonMessage = ex.getInteractionEvent() != null ? ex.getInteractionEvent().getReason() : null;
return titleService.titleOf(invoice) + ": " + (reasonMessage != null ? reasonMessage : ex.getMessage());
} catch (HiddenException | DisabledException ex) {
// ignore
}
}
return null;
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_backgroundPrepareAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
final List<InvoiceForLease> invoices = invoicesToPrepare();
for (Invoice invoice : invoices) {
final DocumentTemplate documentTemplate = documentTemplateFor(invoice);
factoryService.mixin(InvoiceForLease_backgroundPrepare.class, invoice).$$(documentTemplate);
}
return this.invoiceSummary;
}
Aggregations