Search in sources :

Example 1 with InvoiceForLease

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;
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) BigInteger(java.math.BigInteger) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) ToString(lombok.ToString) Property(org.estatio.module.asset.dom.Property)

Example 2 with InvoiceForLease

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;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm)

Example 3 with InvoiceForLease

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;
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease)

Example 4 with InvoiceForLease

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;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) InvalidException(org.apache.isis.applib.services.wrapper.InvalidException) HiddenException(org.apache.isis.applib.services.wrapper.HiddenException)

Example 5 with InvoiceForLease

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;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DocumentTemplate(org.incode.module.document.dom.impl.docs.DocumentTemplate) InvoiceForLease_backgroundPrepare(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_backgroundPrepare) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)22 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)8 LocalDate (org.joda.time.LocalDate)8 Lease (org.estatio.module.lease.dom.Lease)7 Property (org.estatio.module.asset.dom.Property)6 Test (org.junit.Test)6 Property_calculateInvoices (org.estatio.module.lease.contributions.Property_calculateInvoices)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Unit (org.estatio.module.asset.dom.Unit)3 Invoice (org.estatio.module.invoice.dom.Invoice)3 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)3 Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)3 Before (org.junit.Before)3 Action (org.apache.isis.applib.annotation.Action)2 InvoiceDto (org.estatio.canonical.invoice.v1.InvoiceDto)2 FixedAsset (org.estatio.module.asset.dom.FixedAsset)2 Charge (org.estatio.module.charge.dom.Charge)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)2 Tax (org.estatio.module.tax.dom.Tax)2