use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.
the class PaymentBatchManager method addInvoiceToPayByBankAccount.
@Action(semantics = SemanticsOf.IDEMPOTENT, publishing = Publishing.DISABLED)
public PaymentBatchManager addInvoiceToPayByBankAccount(final IncomingInvoice incomingInvoice, final BankAccount debtorBankAccount) {
PaymentBatch paymentBatch = paymentBatchRepository.findOrCreateNewByDebtorBankAccount(debtorBankAccount);
paymentBatch.addLineIfRequired(incomingInvoice);
return new PaymentBatchManager();
}
use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.
the class PaymentBatchManager method removeNegativeTransfers.
/**
* Removes (deletes) all {@link PaymentLine line}s that correspond to a transfer which is a net negative.
*/
private void removeNegativeTransfers(PaymentBatch paymentBatch) {
final List<PaymentLine> paymentLines = paymentBatch.getTransfers().stream().filter(x -> x.getAmount().compareTo(BigDecimal.ZERO) <= 0).map(CreditTransfer::getLines).flatMap(Collection::stream).collect(Collectors.toList());
// seems to be necessary to flush everything through both before and after, presumably to deal with the
// dependent collection (else get DN error about having added a deleted object to the batch's lines collection)
flushTransaction();
// this is sufficient, because PaymentBatch#lines is a dependent collection
for (PaymentLine paymentLine : paymentLines) {
paymentBatch.getLines().remove(paymentLine);
}
// see discussion above.
flushTransaction();
if (paymentBatch.getLines().isEmpty()) {
paymentBatch.remove();
}
}
use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.
the class PaymentBatchManager method downloadExcelExportForCompletedBatches.
@Action(semantics = SemanticsOf.SAFE, commandPersistence = CommandPersistence.NOT_PERSISTED, publishing = Publishing.DISABLED)
public Blob downloadExcelExportForCompletedBatches(@Nullable final String documentName, final LocalDate startExecutionDate, final LocalDate endExecutionDate) {
List<PaymentLineForExcelExportV1> lineVms = new ArrayList<>();
List<PaymentBatch> batchesToExport = getCompletedBatches().stream().filter(x -> x.getRequestedExecutionDate().toLocalDate().isAfter(startExecutionDate.minusDays(1)) && x.getRequestedExecutionDate().toLocalDate().isBefore(endExecutionDate.plusDays(1))).collect(Collectors.toList());
for (PaymentBatch batch : batchesToExport) {
lineVms.addAll(batch.paymentLinesForExcelExport());
}
String name = documentName != null ? documentName.concat(".xlsx") : "export.xlsx";
return excelService.toExcel(lineVms, PaymentLineForExcelExportV1.class, "export", name);
}
use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.
the class PaymentBatchApprovalStateSubscriber method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(PaymentBatch.ObjectPersistedEvent ev) {
// nb: note that the batch at this stage has no lines attached to it,
// so there is a limit as to what we can safely do.
// however, it *is* ok to just create the state chart for the domain object.
final PaymentBatch paymentBatch = ev.getSource();
PaymentBatchApprovalState approvalState = paymentBatch.getApprovalState();
if (approvalState == PaymentBatchApprovalStateTransitionType.INSTANTIATE.getToState()) {
// ie was set in the persisting callback
stateTransitionService.trigger(paymentBatch, PaymentBatchApprovalStateTransitionType.INSTANTIATE, null, null);
}
}
use of org.estatio.module.capex.dom.payment.PaymentBatch in project estatio by estatio.
the class EstatioAppHomePage method findIncomingInvoicesWithin.
private List<IncomingInvoice> findIncomingInvoicesWithin(final List<PaymentBatch> batches) {
final List<IncomingInvoice> invoices = Lists.newArrayList();
for (PaymentBatch completedBatch : batches) {
invoices.addAll(Lists.newArrayList(completedBatch.getLines()).stream().map(PaymentLine::getInvoice).collect(Collectors.toList()));
}
invoices.sort(Ordering.natural().nullsLast().onResultOf(IncomingInvoice::getInvoiceDate));
return invoices;
}
Aggregations