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);
}
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();
}
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);
}
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();
}
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();
}
Aggregations