use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class BankMandate_Test method changeBankAccount.
@Test
public void changeBankAccount() throws Exception {
// given
final BankMandate bankMandate = new BankMandate();
final BankAccount bankAccount = new BankAccount();
bankMandate.setBankAccount(bankAccount);
// when
final BankAccount newBankAccount = new BankAccount();
bankMandate.changeBankAccount(newBankAccount);
// then
assertThat(bankMandate.getBankAccount()).isSameAs(newBankAccount);
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class TaskIncomingDocumentPdfService method doLookupPdfFor.
private Blob doLookupPdfFor(final Task task) {
StateTransition<?, ?, ?, ?> stateTransition = stateTransitionService.findFor(task);
if (stateTransition == null) {
return null;
}
if (stateTransition instanceof IncomingDocumentCategorisationStateTransition) {
IncomingDocumentCategorisationStateTransition idcst = (IncomingDocumentCategorisationStateTransition) stateTransition;
final Document document = idcst.getDocument();
if (document == null) {
return null;
}
if (!Objects.equals(document.getMimeType(), "application/pdf")) {
return null;
}
return document.getBlob();
}
if (stateTransition instanceof OrderApprovalStateTransition) {
final OrderApprovalStateTransition oast = (OrderApprovalStateTransition) stateTransition;
final Order order = oast.getOrdr();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupOrderPdfFrom(order);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof IncomingInvoiceApprovalStateTransition) {
final IncomingInvoiceApprovalStateTransition iiast = (IncomingInvoiceApprovalStateTransition) stateTransition;
final IncomingInvoice invoice = iiast.getInvoice();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
if (stateTransition instanceof BankAccountVerificationStateTransition) {
final BankAccountVerificationStateTransition bavst = (BankAccountVerificationStateTransition) stateTransition;
final BankAccount bankAccount = bavst.getBankAccount();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIbanProofPdfFrom(bankAccount);
return documentIfAny.map(DocumentAbstract::getBlob).orElse(null);
}
return null;
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class UpcomingPaymentService_Test method getUpcomingPayments_works_when_bankAccount_found.
@Test
public void getUpcomingPayments_works_when_bankAccount_found() throws Exception {
// given
UpcomingPaymentService service = new UpcomingPaymentService();
service.incomingInvoiceRepository = mockIncomingInvoiceRepository;
service.debtorBankAccountService = mockDebtorBankAccountService;
IncomingInvoice completedInvoice = new IncomingInvoice();
completedInvoice.setApprovalState(IncomingInvoiceApprovalState.COMPLETED);
final BigDecimal amountForCompleted = new BigDecimal("1234.56");
completedInvoice.setGrossAmount(amountForCompleted);
IncomingInvoice approvedInvoice = new IncomingInvoice();
approvedInvoice.setApprovalState(IncomingInvoiceApprovalState.APPROVED);
final BigDecimal amountForApproved = new BigDecimal("1000.00");
approvedInvoice.setGrossAmount(amountForApproved);
BankAccount bankAccountForPending = new BankAccount();
IncomingInvoice pendingInvoice = new IncomingInvoice();
pendingInvoice.setApprovalState(IncomingInvoiceApprovalState.PENDING_BANK_ACCOUNT_CHECK);
final BigDecimal amountForPending = new BigDecimal("2000.00");
pendingInvoice.setGrossAmount(amountForPending);
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.COMPLETED, PaymentMethod.BANK_TRANSFER);
will(returnValue(Arrays.asList(completedInvoice)));
oneOf(mockIncomingInvoiceRepository).findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.APPROVED, PaymentMethod.BANK_TRANSFER);
will(returnValue(Arrays.asList(approvedInvoice)));
oneOf(mockIncomingInvoiceRepository).findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.PENDING_BANK_ACCOUNT_CHECK, PaymentMethod.BANK_TRANSFER);
will(returnValue(Arrays.asList(pendingInvoice)));
allowing(mockDebtorBankAccountService).uniqueDebtorAccountToPay(completedInvoice);
will(returnValue(null));
allowing(mockDebtorBankAccountService).uniqueDebtorAccountToPay(approvedInvoice);
will(returnValue(null));
allowing(mockDebtorBankAccountService).uniqueDebtorAccountToPay(pendingInvoice);
will(returnValue(bankAccountForPending));
}
});
// when
List<UpcomingPaymentTotal> result = service.getUpcomingPayments();
// then
assertThat(result.size()).isEqualTo(2);
UpcomingPaymentTotal totalWithoutBankAccount = result.get(0);
assertThat(totalWithoutBankAccount.getDebtorBankAccount()).isNull();
assertThat(totalWithoutBankAccount.getUpcomingAmountForCompleted()).isEqualTo(amountForCompleted);
assertThat(totalWithoutBankAccount.getUpcomingAmountForApprovedByManager()).isEqualTo(amountForApproved);
assertThat(totalWithoutBankAccount.getUpcomingAmountForPendingBankAccountCheck()).isNull();
assertThat(totalWithoutBankAccount.getTotalUpcomingAmount()).isEqualTo(new BigDecimal("2234.56"));
UpcomingPaymentTotal totalWithBankAccount = result.get(1);
assertThat(totalWithBankAccount.getDebtorBankAccount()).isEqualTo(bankAccountForPending);
assertThat(totalWithBankAccount.getUpcomingAmountForCompleted()).isNull();
assertThat(totalWithBankAccount.getUpcomingAmountForApprovedByManager()).isNull();
assertThat(totalWithBankAccount.getUpcomingAmountForPendingBankAccountCheck()).isEqualTo(amountForPending);
assertThat(totalWithBankAccount.getTotalUpcomingAmount()).isEqualTo(amountForPending);
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method bankaccount_is_set_when_creating_seller.
@Test
public void bankaccount_is_set_when_creating_seller() {
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
viewModel.organisationRepository = mockOrganisationRepo;
viewModel.bankAccountRepository = mockBankAccountRepository;
Country country = new Country();
Organisation seller = new Organisation();
BankAccount bankAccount = new BankAccount();
String sellerName = "some name";
OrganisationNameNumberViewModel candidate = new OrganisationNameNumberViewModel(sellerName, null);
String iban = "NL02RABO0313246581";
// expect
context.checking(new Expectations() {
{
oneOf(mockOrganisationRepo).newOrganisation(null, true, sellerName, country);
will(returnValue(seller));
oneOf(mockBankAccountRepository).newBankAccount(seller, iban, null);
will(returnValue(bankAccount));
oneOf(mockBankAccountRepository).getFirstBankAccountOfPartyOrNull(seller);
will(returnValue(bankAccount));
}
});
// when
viewModel.createSeller(candidate, country, iban);
// then
Assertions.assertThat(viewModel.getSeller()).isEqualTo(seller);
Assertions.assertThat(viewModel.getBankAccount()).isEqualTo(bankAccount);
}
use of org.estatio.module.financial.dom.BankAccount in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_autoCompleteBankAccount_Test method autoCompleteBankAccount_works.
@Test
public void autoCompleteBankAccount_works() throws Exception {
List<BankAccount> result;
// given
IncomingDocAsInvoiceViewModel vm = new IncomingDocAsInvoiceViewModel() {
IncomingDocAsInvoiceViewModel setBankAccountRepository(BankAccountRepository bankAccountRepository) {
this.bankAccountRepository = bankAccountRepository;
return this;
}
}.setBankAccountRepository(mockBankAccountRepository);
BankAccount acc1 = new BankAccount();
BankAccount acc2 = new BankAccount();
Party owner = new Organisation();
acc2.setOwner(owner);
// expect
context.checking(new Expectations() {
{
allowing(mockBankAccountRepository).autoComplete(with(any(String.class)));
will(returnValue(Arrays.asList(acc1, acc2)));
oneOf(mockBankAccountRepository).findBankAccountsByOwner(owner);
will(returnValue(Arrays.asList(acc2)));
}
});
// when
result = vm.autoCompleteBankAccount("some searchstring");
// then
assertThat(result.size()).isEqualTo(2);
// and when seller is set
vm.setSeller(owner);
result = vm.autoCompleteBankAccount("3");
// then
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(acc2);
}
Aggregations