Search in sources :

Example 56 with IncomingInvoice

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

the class IncomingInvoiceItemRepository_IntegTest method findByInvoiceAndChargeAndSequence_works.

@Test
public void findByInvoiceAndChargeAndSequence_works() throws Exception {
    // given
    IncomingInvoice invoice = createIncomingInvoiceAndTwoItemsWithSameCharge();
    // when
    Charge chargeToFindOnItem = charge;
    IncomingInvoiceItem item1 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(1L));
    IncomingInvoiceItem item2 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(2L));
    // then
    assertThat(item1.getInvoice()).isEqualTo(invoice);
    assertThat(item1.getCharge()).isEqualTo(charge);
    assertThat(item1.getSequence()).isEqualTo(BigInteger.valueOf(1L));
    assertThat(item2.getInvoice()).isEqualTo(invoice);
    assertThat(item2.getCharge()).isEqualTo(charge);
    assertThat(item2.getSequence()).isEqualTo(BigInteger.valueOf(2L));
    // and when
    Charge chargeNotToBeFoundOnItem = chargeRepository.findByReference("OTHER");
    IncomingInvoiceItem itemNotToBeFound = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeNotToBeFoundOnItem, BigInteger.valueOf(1L));
    // then
    assertThat(itemNotToBeFound).isNull();
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Charge(org.estatio.module.charge.dom.Charge) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Test(org.junit.Test)

Example 57 with IncomingInvoice

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

the class IncomingInvoiceItemRepository_IntegTest method createIncomingInvoiceAndTwoItemsWithSameCharge.

private IncomingInvoice createIncomingInvoiceAndTwoItemsWithSameCharge() {
    seller = OrganisationAndComms_enum.TopModelGb.findUsing(serviceRegistry);
    buyer = OrganisationAndComms_enum.HelloWorldGb.findUsing(serviceRegistry);
    property = propertyRepository.findPropertyByReference(Property_enum.OxfGb.getRef());
    invoiceNumber = "123";
    invoiceDate = new LocalDate(2017, 1, 1);
    dueDate = invoiceDate.minusMonths(1);
    paymentMethod = PaymentMethod.BANK_TRANSFER;
    invoiceStatus = InvoiceStatus.NEW;
    atPath = "/GBR";
    IncomingInvoice invoice = incomingInvoiceRepository.create(IncomingInvoiceType.CAPEX, invoiceNumber, property, atPath, buyer, seller, invoiceDate, dueDate, paymentMethod, invoiceStatus, null, null, IncomingInvoiceApprovalState.PAID);
    charge = chargeRepository.findByReference("WORKS");
    description = "some description";
    tax = taxRepository.findByReference("FRF");
    invoice.addItem(invoice.getType(), charge, description, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, tax, dueDate, null, null, null, null);
    invoice.addItem(invoice.getType(), charge, description, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, tax, dueDate, null, null, null, null);
    return invoice;
}
Also used : IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) LocalDate(org.joda.time.LocalDate)

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