use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class PaymentBatch method doGetCreditTransfers.
private List<CreditTransfer> doGetCreditTransfers() {
List<CreditTransfer> transfers = Lists.newArrayList();
final Map<BankAccount, List<PaymentLine>> lineBySeller = Lists.newArrayList(getLines()).stream().sorted(Comparator.comparing(PaymentLine::getSequence)).collect(groupingBy(PaymentLine::getCreditorBankAccount, TreeMap::new, toSortedList(Comparator.comparing(PaymentLine::getSequence))));
for (Map.Entry<BankAccount, List<PaymentLine>> linesByBankAccount : lineBySeller.entrySet()) {
final CreditTransfer creditTransfer = new CreditTransfer();
creditTransfer.setBatch(this);
final BankAccount bankAccount = linesByBankAccount.getKey();
final List<PaymentLine> lines = linesByBankAccount.getValue();
final String sequenceNums = extractAndJoin(lines, line -> "" + line.getSequence(), "-");
final String endToEndId = String.format("%s-%s", getId(), sequenceNums);
creditTransfer.setEndToEndId(endToEndId);
creditTransfer.setSellerBankAccount(bankAccount);
creditTransfer.setLines(lines);
final BigDecimal amount = lines.stream().map(PaymentLine::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
if (!lines.isEmpty()) {
// should always be non-empty, just playing safe...
final PaymentLine firstLine = lines.get(0);
creditTransfer.setCurrency(firstLine.getCurrency());
}
creditTransfer.setAmount(amount);
// -PM-19229-12-2016-2-RO
// -2017-01-04-RO
// -L 17-01-302-RO
// -FC-1702CS1-0002-RO
// -AF1T2017ASL-RO
final String remittanceInformation = extractAndJoin(lines, line -> line.getInvoice().getInvoiceNumber(), ";");
creditTransfer.setRemittanceInformation(remittanceInformation);
creditTransfer.setSeller(bankAccount.getOwner());
creditTransfer.setSellerPostalAddressCountry(ctryFor(bankAccount.getOwner()));
transfers.add(creditTransfer);
}
return transfers;
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class EstatioAppHomePage_verifyBankAccounts method act.
@Action(semantics = SemanticsOf.IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING)
@ActionLayout(position = ActionLayout.Position.PANEL)
public EstatioAppHomePage act(final List<IncomingInvoice> invoices, @Nullable final String comment) {
for (IncomingInvoice invoice : invoices) {
final BankAccount bankAccount = invoice.getBankAccount();
factoryService.mixin(BankAccount_verify.class, bankAccount).act(comment);
factoryService.mixin(IncomingInvoice_checkApprovalState.class, invoice).act();
}
return homePage;
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class BankAccountVerificationChecker method isBankAccountVerifiedFor.
@Programmatic
public boolean isBankAccountVerifiedFor(final IncomingInvoice incomingInvoice) {
final BankAccount bankAccount = incomingInvoice.getBankAccount();
BankAccountVerificationState state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
return state == BankAccountVerificationState.VERIFIED;
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class BankAccountVerificationStateSubscriber method triggerBankVerificationState.
private void triggerBankVerificationState(final IncomingInvoice incomingInvoice) {
final BankAccount bankAccount = incomingInvoice.getBankAccount();
if (bankAccount == null) {
return;
}
if (stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class) == null) {
stateTransitionService.trigger(bankAccount, BankAccountVerificationStateTransitionType.INSTANTIATE, null, null);
}
// create the required pending transition, if none already.
stateTransitionService.triggerPending(bankAccount, BankAccountVerificationStateTransitionType.VERIFY_BANK_ACCOUNT);
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class BankAccountVerificationStateSubscriber method titleOf.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void titleOf(BankAccount.TitleUiEvent ev) {
final BankAccount bankAccount = ev.getSource();
final BankAccountVerificationState state = stateTransitionService.currentStateOf(bankAccount, BankAccountVerificationStateTransition.class);
final String title = String.format("%s - %s (%s)", bankAccount.getName(), bankAccount.getOwner().getReference(), Enums.getFriendlyNameOf(state));
ev.setTitle(title);
}
Aggregations