Search in sources :

Example 6 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class CommunicationChannelSubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final CommunicationChannel.RemoveEvent ev) {
    CommunicationChannel sourceCommunicationChannel = ev.getSource();
    CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
    List<Invoice> notYetInvoiced;
    List<Invoice> alreadyInvoiced;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            List<Invoice> invoices = invoiceRepository.findBySendTo(sourceCommunicationChannel);
            notYetInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() == null).collect(Collectors.toList());
            alreadyInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() != null).collect(Collectors.toList());
            scratchpad.put("notYetInvoiced", notYetInvoiced);
            scratchpad.put("alreadyInvoiced", alreadyInvoiced);
            // (it doesn't matter if no replacement was provided only for already-invoiced invoices)
            if (replacementCommunicationChannel == null && !notYetInvoiced.isEmpty()) {
                ev.invalidate(TranslatableString.tr("Communication channel is being used (as the 'sendTo' channel for {num} invoice(s); " + "provide a replacement", "num", notYetInvoiced.size()));
            }
            break;
        case EXECUTING:
            notYetInvoiced = (List<Invoice>) scratchpad.get("notYetInvoiced");
            alreadyInvoiced = (List<Invoice>) scratchpad.get("alreadyInvoiced");
            for (Invoice invoice : notYetInvoiced) {
                invoice.setSendTo(replacementCommunicationChannel);
            }
            for (Invoice invoice : alreadyInvoiced) {
                if (invoice.getInvoiceNumber() != null) {
                    // just blank out
                    invoice.setSendTo(null);
                }
            }
            break;
        default:
            break;
    }
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 7 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class InvoiceSummaryForPropertyDueDateStatus_sendByEmailAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
    final List<InvoiceAndDocument> invoiceAndDocuments = invoiceAndDocumentsToSend();
    for (InvoiceAndDocument invoiceAndDocument : invoiceAndDocuments) {
        final Invoice invoice = invoiceAndDocument.getInvoice();
        final Document document = invoiceAndDocument.getDocument();
        final InvoiceForLease_sendByEmail invoice_sendByEmail = invoice_email(invoice);
        final EmailAddress emailAddress = invoice_sendByEmail.default1$$(document);
        final String cc = invoice_sendByEmail.default2$$(document);
        final String bcc = invoice_sendByEmail.default5$$(document);
        invoice_sendByEmail.$$(document, emailAddress, cc, null, null, bcc, null);
    }
    return this.invoiceSummary;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease_sendByEmail(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail) Document(org.incode.module.document.dom.impl.docs.Document) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 8 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class InvoiceImportLine method importData.

@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
    List<Object> result = new ArrayList<>();
    Lease lease = fetchLease(getLeaseReference());
    PaymentMethod paymentMethod = fetchPaymentMethod(getPaymentMethod());
    String atPath = lease.getApplicationTenancyPath().concat("/").concat(lease.getPrimaryParty().getReference());
    ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(atPath);
    Invoice invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, lease.getPrimaryParty(), lease.getSecondaryParty(), paymentMethod, currencyRepository.findCurrency("EUR"), getDueDate(), lease, null);
    InvoiceItem invoiceItem = factoryService.mixin(InvoiceForLease._newItem.class, invoice).$$(fetchCharge(getItemChargeReference()), BigDecimal.ONE, getItemNetAmount(), getItemStartDate(), getItemEndDate());
    if (getItemDescription() != null) {
        invoiceItem.setDescription(getItemDescription());
    }
    result.add(invoice);
    return result;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) ArrayList(java.util.ArrayList) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) DomainObject(org.apache.isis.applib.annotation.DomainObject) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 9 with Invoice

use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.

the class CreateRetroInvoices method createAndApprove.

// //////////////////////////////////////
private ExecutionContext createAndApprove(final InvoiceCalculationParameters parameters, final ExecutionContext executionContext) {
    invoiceCalculationService.calculateAndInvoice(parameters);
    for (Invoice invoice : invoiceRepository.findByStatus(InvoiceStatus.NEW)) {
        factoryService.mixin(InvoiceForLease._saveAsHistoric.class, invoice).$$();
        executionContext.addResult(this, invoice.getInvoiceNumber(), invoice);
    }
    return executionContext;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice)

Aggregations

Invoice (org.estatio.module.invoice.dom.Invoice)9 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)4 Action (org.apache.isis.applib.annotation.Action)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Document (org.incode.module.document.dom.impl.docs.Document)3 HiddenException (org.apache.isis.applib.services.wrapper.HiddenException)2 Blob (org.apache.isis.applib.value.Blob)2 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)2 Lease (org.estatio.module.lease.dom.Lease)2 InvoiceForLease_sendByPost (org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByPost)2 Party (org.estatio.module.party.dom.Party)2 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 PostalAddress (org.incode.module.communications.dom.impl.commchannel.PostalAddress)2 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)2 Resources (com.google.common.io.Resources)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1