Search in sources :

Example 6 with PaymentBatch

use of org.estatio.module.capex.dom.payment.PaymentBatch 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 7 with PaymentBatch

use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.

the class PaymentBatchManager method removeAll.

@MemberOrder(name = "newBatches", sequence = "1")
public PaymentBatchManager removeAll() {
    for (PaymentBatch paymentBatch : getNewBatches()) {
        paymentBatch.clearLines();
        paymentBatch.remove();
    }
    return new PaymentBatchManager();
}
Also used : PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 8 with PaymentBatch

use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.

the class PaymentBatchManager method downloadExcelExportForNewBatches.

@Action(semantics = SemanticsOf.SAFE, commandPersistence = CommandPersistence.NOT_PERSISTED, publishing = Publishing.DISABLED)
public Blob downloadExcelExportForNewBatches(@Nullable final String documentName, @Nullable final List<PaymentBatch> newPaymentBatches) {
    List<PaymentLineForExcelExportV1> lineVms = new ArrayList<>();
    for (PaymentBatch batch : newPaymentBatches) {
        lineVms.addAll(batch.paymentLinesForExcelExport());
    }
    String name = documentName != null ? documentName.concat(".xlsx") : "export.xlsx";
    return excelService.toExcel(lineVms, PaymentLineForExcelExportV1.class, "export", name);
}
Also used : ArrayList(java.util.ArrayList) PaymentLineForExcelExportV1(org.estatio.module.capex.app.paymentline.PaymentLineForExcelExportV1) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) Action(org.apache.isis.applib.annotation.Action)

Example 9 with PaymentBatch

use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.

the class IncomingInvoice_reject method act.

@Action(domainEvent = IncomingInvoice_next.ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-o-down", cssClass = "btn-warning")
public Object act(final String role, @Nullable final Person personToAssignNextTo, final String reason) {
    final List<PaymentLine> paymentLines = paymentLineRepository.findByInvoice(incomingInvoice);
    // because of the disableXxx guard, this should return either 0 or 1 lines.
    for (PaymentLine paymentLine : paymentLines) {
        final PaymentBatch paymentBatch = paymentLine.getBatch();
        paymentBatch.removeLineFor(incomingInvoice);
    }
    trigger(personToAssignNextTo, reason, reason);
    return objectToReturn();
}
Also used : PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 10 with PaymentBatch

use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.

the class IncomingInvoice_reject method disableAct.

public String disableAct() {
    final List<PaymentLine> paymentLines = paymentLineRepository.findByInvoice(incomingInvoice);
    for (PaymentLine paymentLine : paymentLines) {
        final PaymentBatch paymentBatch = paymentLine.getBatch();
        final PaymentBatchApprovalState state = paymentBatch.getApprovalState();
        if (state != PaymentBatchApprovalState.NEW && state != PaymentBatchApprovalState.DISCARDED) {
            return String.format("Invoice is in batch %s", titleService.titleOf(paymentBatch));
        }
    }
    return reasonGuardNotSatisified();
}
Also used : PaymentBatchApprovalState(org.estatio.module.capex.dom.payment.approval.PaymentBatchApprovalState) PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine) PaymentBatch(org.estatio.module.capex.dom.payment.PaymentBatch)

Aggregations

PaymentBatch (org.estatio.module.capex.dom.payment.PaymentBatch)10 Action (org.apache.isis.applib.annotation.Action)6 PaymentLine (org.estatio.module.capex.dom.payment.PaymentLine)5 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)4 ArrayList (java.util.ArrayList)3 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)3 PaymentLineForExcelExportV1 (org.estatio.module.capex.app.paymentline.PaymentLineForExcelExportV1)3 BankAccount (org.estatio.module.financial.dom.BankAccount)3 Lists (com.google.common.collect.Lists)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Nullable (javax.annotation.Nullable)2 Inject (javax.inject.Inject)2 AccessLevel (lombok.AccessLevel)2 Getter (lombok.Getter)2 Setter (lombok.Setter)2