Search in sources :

Example 6 with IncomingInvoice

use of org.estatio.module.capex.dom.invoice.IncomingInvoice 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;
}
Also used : BankAccount_verify(org.estatio.module.capex.dom.bankaccount.verification.triggers.BankAccount_verify) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) IncomingInvoice_checkApprovalState(org.estatio.module.capex.dom.invoice.approval.tasks.IncomingInvoice_checkApprovalState) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 7 with IncomingInvoice

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

the class IncomingInvoice_approve method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-o-up")
public Object act(final String role, @Nullable final Person personToAssignNextTo, @Nullable final String comment, final boolean goToNext) {
    final IncomingInvoice next = nextAfterPendingIfRequested(goToNext);
    trigger(personToAssignNextTo, comment, null);
    return objectToReturn(next);
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 8 with IncomingInvoice

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

the class BankAccount_attachInvoiceAsIbanProof method choices0Act.

public List<Document> choices0Act() {
    final List<Document> documents = Lists.newArrayList();
    final List<IncomingInvoice> invoices = incomingInvoiceRepository.findByBankAccount(bankAccount);
    for (IncomingInvoice invoice : invoices) {
        final List<Document> attachedDocuments = lookupAttachedPdfService.lookupIncomingInvoicePdfsFrom(invoice);
        documents.addAll(attachedDocuments);
    }
    final List<Document> documentsCurrentlyAttachedAsIbanProof = paperclipRepository.findByAttachedToAndRoleName(bankAccount, ROLE_NAME_FOR_IBAN_PROOF).stream().map(Paperclip::getDocument).filter(Document.class::isInstance).map(Document.class::cast).collect(Collectors.toList());
    documents.removeAll(documentsCurrentlyAttachedAsIbanProof);
    return documents;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Document(org.incode.module.document.dom.impl.docs.Document)

Example 9 with IncomingInvoice

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

the class IncomingInvoiceMenu_Test method filterOrFindByGrossAmount_find_works.

@Test
public void filterOrFindByGrossAmount_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);
}
Also used : Expectations(org.jmock.Expectations) IncomingInvoiceMenu(org.estatio.module.capex.app.IncomingInvoiceMenu) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 10 with IncomingInvoice

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

the class CreditTransferExportService_Test method getApprovalStateTransitionSummary_works.

@Test
public void getApprovalStateTransitionSummary_works() throws Exception {
    // given
    CreditTransferExportService service = new CreditTransferExportService();
    IncomingInvoice invoice = new IncomingInvoice();
    invoice.stateTransitionRepository = mockStateTransitionRepo;
    IncomingInvoiceApprovalStateTransition transition1 = new IncomingInvoiceApprovalStateTransition();
    transition1.setCompletedBy("some manager");
    transition1.setCompletedOn(LocalDateTime.parse("2017-01-01"));
    transition1.setToState(IncomingInvoiceApprovalState.APPROVED);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockStateTransitionRepo).findByDomainObject(invoice);
            will(returnValue(Arrays.asList(transition1)));
        }
    });
    // when
    String result = service.getApprovalStateTransitionSummary(invoice);
    // then
    Assertions.assertThat(result).isEqualTo("some manager on 01-Jan-2017 00:00 \r\n");
}
Also used : Expectations(org.jmock.Expectations) IncomingInvoiceApprovalStateTransition(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) 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