Search in sources :

Example 26 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class CreditTransferExportService_Test method isFirstUseBankAccount_works_when_just_invoices_in_transfer_found.

@Test
public void isFirstUseBankAccount_works_when_just_invoices_in_transfer_found() throws Exception {
    // given
    CreditTransferExportService service = new CreditTransferExportService();
    service.incomingInvoiceRepository = mockIncomingInvoiceRepository;
    CreditTransfer transfer = new CreditTransfer();
    // when
    IncomingInvoice invoiceInPaymentLine1 = new IncomingInvoice();
    IncomingInvoice invoiceInPaymentLine2 = new IncomingInvoice();
    PaymentLine line1 = new PaymentLine();
    line1.setInvoice(invoiceInPaymentLine1);
    PaymentLine line2 = new PaymentLine();
    line2.setInvoice(invoiceInPaymentLine2);
    transfer.setLines(Arrays.asList(line1, line2));
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockIncomingInvoiceRepository).findByBankAccount(transfer.getSellerBankAccount());
            // when ..
            will(returnValue(Arrays.asList(invoiceInPaymentLine1, invoiceInPaymentLine2)));
        }
    });
    // then
    Assertions.assertThat(service.isFirstUseBankAccount(transfer)).isTrue();
}
Also used : Expectations(org.jmock.Expectations) CreditTransfer(org.estatio.module.capex.dom.payment.CreditTransfer) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine) Test(org.junit.Test)

Example 27 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class CreditTransferExportService_Test method isFirstUseBankAccount_works_when_other_invoices_than_in_transfer_found.

@Test
public void isFirstUseBankAccount_works_when_other_invoices_than_in_transfer_found() throws Exception {
    // given
    CreditTransferExportService service = new CreditTransferExportService();
    service.incomingInvoiceRepository = mockIncomingInvoiceRepository;
    CreditTransfer transfer = new CreditTransfer();
    // when
    IncomingInvoice invoiceInPaymentLine1 = new IncomingInvoice();
    IncomingInvoice invoiceInPaymentLine2 = new IncomingInvoice();
    PaymentLine line1 = new PaymentLine();
    line1.setInvoice(invoiceInPaymentLine1);
    PaymentLine line2 = new PaymentLine();
    line2.setInvoice(invoiceInPaymentLine2);
    transfer.setLines(Arrays.asList(line1, line2));
    IncomingInvoice otherInvoice = new IncomingInvoice();
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockIncomingInvoiceRepository).findByBankAccount(transfer.getSellerBankAccount());
            // when ..
            will(returnValue(Arrays.asList(invoiceInPaymentLine1, invoiceInPaymentLine2, otherInvoice)));
        }
    });
    // then
    Assertions.assertThat(service.isFirstUseBankAccount(transfer)).isFalse();
}
Also used : Expectations(org.jmock.Expectations) CreditTransfer(org.estatio.module.capex.dom.payment.CreditTransfer) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) PaymentLine(org.estatio.module.capex.dom.payment.PaymentLine) Test(org.junit.Test)

Example 28 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class BuyerFinder_Test method testerWhenNullOrTooShort.

private void testerWhenNullOrTooShort(final String documentName) {
    // given
    IncomingInvoice invoice = new IncomingInvoice();
    BuyerFinder finder = new BuyerFinder();
    finder.partyRepository = mockPartyRepository;
    finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
    Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
            will(returnValue(optional));
        }
    });
    // when
    finder.buyerDerivedFromDocumentName(invoice);
}
Also used : Expectations(org.jmock.Expectations) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 29 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.

the class BuyerFinder_Test method testWhenParamIsInvoice.

private void testWhenParamIsInvoice(final String documentName, final String derivedPartyReference) {
    // given
    IncomingInvoice invoice = new IncomingInvoice();
    BuyerFinder finder = new BuyerFinder();
    finder.partyRepository = mockPartyRepository;
    finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
    Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
            will(returnValue(optional));
            oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
        }
    });
    // when
    finder.buyerDerivedFromDocumentName(invoice);
}
Also used : Expectations(org.jmock.Expectations) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 30 with IncomingInvoice

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_multiple_bankaccounts_multiple_preferred.

@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_multiple_preferred() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    BankAccount bankAccount1 = new BankAccount();
    bankAccount1.setPreferred(true);
    BankAccount bankAccount2 = new BankAccount();
    bankAccount2.setPreferred(true);
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount1);
    bankAccounts.add(bankAccount2);
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(bankAccounts));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Aggregations

IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)57 Test (org.junit.Test)27 Expectations (org.jmock.Expectations)20 BankAccount (org.estatio.module.financial.dom.BankAccount)14 Action (org.apache.isis.applib.annotation.Action)11 BigDecimal (java.math.BigDecimal)9 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)9 Organisation (org.estatio.module.party.dom.Organisation)9 Party (org.estatio.module.party.dom.Party)9 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)8 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)7 Document (org.incode.module.document.dom.impl.docs.Document)7 LocalDate (org.joda.time.LocalDate)7 ArrayList (java.util.ArrayList)5 Programmatic (org.apache.isis.applib.annotation.Programmatic)5 Property (org.estatio.module.asset.dom.Property)3 UpcomingPaymentTotal (org.estatio.module.capex.app.invoice.UpcomingPaymentTotal)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 IncomingInvoiceApprovalStateTransition (org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition)3 OrderItem (org.estatio.module.capex.dom.order.OrderItem)3