use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method notification_BuyerBarcodeMatchValidation_works.
@Test
public void notification_BuyerBarcodeMatchValidation_works() {
String notification;
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
Party buyerDerived = new Organisation();
BuyerFinder buyerFinder = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return buyerDerived;
}
};
IncomingInvoice invoice = new IncomingInvoice();
Party buyerOnViewmodel = new Organisation();
viewModel.setDomainObject(invoice);
viewModel.buyerFinder = buyerFinder;
viewModel.setBuyer(buyerOnViewmodel);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isEqualTo("Buyer does not match barcode (document name); ");
// and given (buyers matching)
viewModel.setBuyer(buyerDerived);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
// and given (no buyer derived)
BuyerFinder buyerFinderReturningNull = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return null;
}
};
viewModel.buyerFinder = buyerFinderReturningNull;
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
BankAccount bankAccount = new BankAccount();
BankAccount bankAccountForProperty = new BankAccount();
FixedAssetFinancialAccount fixedAssetFinancialAccount = new FixedAssetFinancialAccount();
fixedAssetFinancialAccount.setFinancialAccount(bankAccountForProperty);
List<BankAccount> bankAccounts = new ArrayList<>();
bankAccounts.add(bankAccount);
bankAccounts.add(bankAccountForProperty);
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
Property property = new Property();
invoice.setProperty(property);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(bankAccounts));
oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
will(returnValue(Arrays.asList(fixedAssetFinancialAccount)));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccountForProperty);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_one_bankaccount_and_no_property.
@Test
public void unique_Debtor_Account_To_Pay_works_when_one_bankaccount_and_no_property() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount = new BankAccount();
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(Arrays.asList(bankAccount)));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccount);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindByGrossAmount_negative_amounts_find_works.
@Test
public void filterOrFindByGrossAmount_negative_amounts_find_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
IncomingInvoice invoice2 = new IncomingInvoice();
IncomingInvoice invoice3 = new IncomingInvoice();
invoice1.setGrossAmount(new BigDecimal("-9.50"));
invoice2.setGrossAmount(new BigDecimal("-10.50"));
invoice3.setGrossAmount(new BigDecimal("-10.51"));
final BigDecimal amountSearchedFor = new BigDecimal("-10.00");
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).listAll();
will(returnValue(Arrays.asList(invoice1, invoice2, invoice3)));
}
});
// when
builder.filterOrFindByGrossAmount(amountSearchedFor);
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
Assertions.assertThat(builder.getResult()).contains(invoice1);
Assertions.assertThat(builder.getResult()).contains(invoice2);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindInvoiceDate_filter_works.
@Test
public void filterOrFindInvoiceDate_filter_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
IncomingInvoice invoice2 = new IncomingInvoice();
IncomingInvoice invoice3 = new IncomingInvoice();
invoice1.setInvoiceDate(new LocalDate(2017, 7, 15));
invoice2.setInvoiceDate(new LocalDate(2017, 7, 5));
invoice3.setInvoiceDate(new LocalDate(2017, 7, 16));
builder.setResult(Arrays.asList(invoice1, invoice2, invoice3));
final LocalDate dateSearchedFor = new LocalDate(2017, 7, 10);
Assertions.assertThat(builder.getResult().size()).isEqualTo(3);
// when
builder.filterOrFindByInvoiceDate(dateSearchedFor);
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
Assertions.assertThat(builder.getResult()).contains(invoice1);
Assertions.assertThat(builder.getResult()).contains(invoice2);
}
Aggregations