Search in sources :

Example 41 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class OrderItem_Test method newIncomingInvoiceItem.

private IncomingInvoiceItem newIncomingInvoiceItem() {
    final IncomingInvoiceItem incomingInvoiceItem = new IncomingInvoiceItem();
    final IncomingInvoice incomingInvoice = new IncomingInvoice() {

        @Override
        protected EventBusService getEventBusService() {
            return mockEventBusService;
        }
    };
    context.ignoring(mockEventBusService);
    incomingInvoiceItem.setInvoice(incomingInvoice);
    return incomingInvoiceItem;
}
Also used : IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice)

Example 42 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class IncomingInvoiceDownloadManager method documentNumberFor.

String documentNumberFor(final IncomingInvoiceItem invoiceItem) {
    final IncomingInvoice invoice = (IncomingInvoice) invoiceItem.getInvoice();
    final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
    return documentIfAny.map(DocumentAbstract::getName).orElse(null);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 43 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class IncomingDocAsInvoiceViewModel method init.

@Programmatic
public void init() {
    IncomingInvoice incomingInvoice = getDomainObject();
    setIncomingInvoiceType(incomingInvoice.getType());
    setInvoiceNumber(incomingInvoice.getInvoiceNumber());
    setBuyer(incomingInvoice.getBuyer());
    setSeller(incomingInvoice.getSeller());
    setInvoiceDate(incomingInvoice.getInvoiceDate());
    setDueDate(incomingInvoice.getDueDate());
    setPaymentMethod(incomingInvoice.getPaymentMethod());
    setDateReceived(incomingInvoice.getDateReceived());
    setBankAccount(incomingInvoice.getBankAccount());
    setCurrency(incomingInvoice.getCurrency());
    final Optional<IncomingInvoiceItem> firstItemIfAny = getFirstItemIfAny();
    if (firstItemIfAny.isPresent()) {
        IncomingInvoiceItem invoiceItem = firstItemIfAny.get();
        setCharge(invoiceItem.getCharge());
        setDescription(invoiceItem.getDescription());
        setNetAmount(invoiceItem.getNetAmount());
        setVatAmount(invoiceItem.getVatAmount());
        setGrossAmount(invoiceItem.getGrossAmount());
        setTax(invoiceItem.getTax());
        setDueDate(invoiceItem.getDueDate());
        setPeriod(periodFrom(invoiceItem.getStartDate(), invoiceItem.getEndDate()));
        setProperty((org.estatio.module.asset.dom.Property) invoiceItem.getFixedAsset());
        setProject(invoiceItem.getProject());
        setBudgetItem(invoiceItem.getBudgetItem());
        final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(invoiceItem);
        linkIfAny.ifPresent(link -> {
            final OrderItem linkOrderItem = link.getOrderItem();
            IncomingDocAsInvoiceViewModel.this.setOrderItem(linkOrderItem);
        });
    } else {
        // for the first time we edit there will be no first item,
        // so we instead get the property from the header invoice
        setProperty(incomingInvoice.getProperty());
    }
}
Also used : OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) OrderItem(org.estatio.module.capex.dom.order.OrderItem) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 44 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class PaymentBatchManager method autoCreateBatches.

@Action(semantics = SemanticsOf.IDEMPOTENT, publishing = Publishing.DISABLED)
public PaymentBatchManager autoCreateBatches(@Nullable final List<IncomingInvoice> payableInvoices) {
    for (final IncomingInvoice payableInvoice : payableInvoices) {
        final BankAccount uniqueBankAccountIfAny = debtorBankAccountService.uniqueDebtorAccountToPay(payableInvoice);
        if (uniqueBankAccountIfAny != null && uniqueBankAccountIfAny.getBic() != null) {
            // should be true, because those that don't pass this are filtered out in choicesXxx anyway.
            PaymentBatch paymentBatch = paymentBatchRepository.findOrCreateNewByDebtorBankAccount(uniqueBankAccountIfAny);
            paymentBatch.addLineIfRequired(payableInvoice);
        }
    }
    final List<PaymentBatch> newBatches = getNewBatches();
    for (final PaymentBatch paymentBatch : newBatches) {
        removeNegativeTransfers(paymentBatch);
    }
    return new PaymentBatchManager(newBatches.isEmpty() ? null : 0);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) Action(org.apache.isis.applib.annotation.Action)

Example 45 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class UpcomingPaymentService method getUpcomingPayments.

@Programmatic
public List<UpcomingPaymentTotal> getUpcomingPayments() {
    List<IncomingInvoice> invoiceSelectionForUpcomingPayments = new ArrayList<>();
    invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.COMPLETED, PaymentMethod.BANK_TRANSFER));
    invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.APPROVED, PaymentMethod.BANK_TRANSFER));
    invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.PENDING_BANK_ACCOUNT_CHECK, PaymentMethod.BANK_TRANSFER));
    List<UpcomingPaymentTotal> upcomingPayments = new ArrayList<>();
    for (IncomingInvoice invoice : invoiceSelectionForUpcomingPayments) {
        UpcomingPaymentTotal upcomingPaymentTotal;
        if (paymentTotalForBankAccount(upcomingPayments, invoice).isEmpty()) {
            upcomingPaymentTotal = new UpcomingPaymentTotal(debtorBankAccountService.uniqueDebtorAccountToPay(invoice));
            upcomingPaymentTotal.addValue(invoice);
            upcomingPayments.add(upcomingPaymentTotal);
        } else {
            upcomingPaymentTotal = paymentTotalForBankAccount(upcomingPayments, invoice).get(0);
            upcomingPaymentTotal.addValue(invoice);
        }
    }
    return upcomingPayments;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) ArrayList(java.util.ArrayList) UpcomingPaymentTotal(org.estatio.module.capex.app.invoice.UpcomingPaymentTotal) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)57 Test (org.junit.Test)27 Expectations (org.jmock.Expectations)20 BankAccount (org.estatio.module.financial.dom.BankAccount)14 Action (org.apache.isis.applib.annotation.Action)11 BigDecimal (java.math.BigDecimal)9 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)9 Organisation (org.estatio.module.party.dom.Organisation)9 Party (org.estatio.module.party.dom.Party)9 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)8 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)7 Document (org.incode.module.document.dom.impl.docs.Document)7 LocalDate (org.joda.time.LocalDate)7 ArrayList (java.util.ArrayList)5 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 Property (org.estatio.module.asset.dom.Property)3 UpcomingPaymentTotal (org.estatio.module.capex.app.invoice.UpcomingPaymentTotal)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)3 OrderItem (org.estatio.module.capex.dom.order.OrderItem)3