Search in sources :

Example 16 with Order

use of org.estatio.module.capex.dom.order.Order in project estatio by estatio.

the class IncomingDocAsInvoiceViewModel method autoFillIn.

private void autoFillIn() {
    if (hasOrderItem()) {
        Order order = orderRepository.findByOrderNumber(getOrderItem().getOrdr().getOrderNumber());
        OrderItem orderItem = orderItemRepository.findByOrderAndCharge(order, getOrderItem().getCharge());
        if (!(hasNetAmount() && hasGrossAmount() && hasVatAmount())) {
            setNetAmount(orderItem.getNetAmount());
            setVatAmount(orderItem.getVatAmount());
            setGrossAmount(orderItem.getGrossAmount());
        }
        if (!hasTax()) {
            setTax(orderItem.getTax());
        }
        if (!hasBuyer()) {
            setBuyer(order.getBuyer());
        }
        if (!hasSeller()) {
            setSeller(order.getSeller());
            setBankAccount(bankAccountRepository.getFirstBankAccountOfPartyOrNull(order.getSeller()));
        }
        if (!hasDescription()) {
            setDescription(orderItem.getDescription());
        }
        if (orderItem.getCharge() != null) {
            setCharge(orderItem.getCharge());
        }
        if (orderItem.getProject() != null) {
            setProject(orderItem.getProject());
        }
        if (orderItem.getProperty() != null) {
            setProperty(orderItem.getProperty());
        }
        if (!hasBudgetItem()) {
            setBudgetItem(orderItem.getBudgetItem());
        }
        if (!hasPeriod()) {
            setPeriod(orderItem.getPeriod());
        }
    }
}
Also used : Order(org.estatio.module.capex.dom.order.Order) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) OrderItem(org.estatio.module.capex.dom.order.OrderItem)

Example 17 with Order

use of org.estatio.module.capex.dom.order.Order in project estatio by estatio.

the class Document_categoriseAsOrder method act.

@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "folder-open-o")
public Object act(@Nullable final Property property, @Nullable final String comment) {
    final Document document = getDomainObject();
    document.setType(DocumentTypeData.INCOMING_ORDER.findUsing(documentTypeRepository));
    // create order
    final Order order = orderRepository.create(property, // order number
    null, // sellerOrderReference
    null, // entryDate
    clockService.now(), // orderDate
    null, // seller
    null, // buyer
    buyerFinder.buyerDerivedFromDocumentName(document), document.getAtPath(), // approval state... will cause state transition to be created automatically by subscriber
    null);
    paperclipRepository.attach(document, null, order);
    trigger(comment, null);
    return order;
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 18 with Order

use of org.estatio.module.capex.dom.order.Order in project estatio by estatio.

the class OrderInvoiceImportHandlerTest method determine_ordernumber_works.

@Test
public void determine_ordernumber_works() throws Exception {
    // given
    OrderInvoiceImportHandler handler = new OrderInvoiceImportHandler();
    handler.setOrderDate(new LocalDate(2017, 01, 31));
    handler.orderRepository = orderRepository;
    // expect
    context.checking(new Expectations() {

        {
            oneOf(orderRepository).findByOrderNumber(with("20170131-001"));
            will(returnValue(new Order()));
            oneOf(orderRepository).findByOrderNumber(with("20170131-002"));
            will(returnValue(null));
        }
    });
    // when
    String orderNumber = handler.determineOrderNumber();
    // then
    assertThat(orderNumber).isEqualTo("20170131-002");
}
Also used : Expectations(org.jmock.Expectations) Order(org.estatio.module.capex.dom.order.Order) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

Order (org.estatio.module.capex.dom.order.Order)18 Test (org.junit.Test)8 Expectations (org.jmock.Expectations)7 OrderItem (org.estatio.module.capex.dom.order.OrderItem)6 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 LocalDate (org.joda.time.LocalDate)5 Action (org.apache.isis.applib.annotation.Action)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)3 Organisation (org.estatio.module.party.dom.Organisation)3 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)2 Document (org.incode.module.document.dom.impl.docs.Document)2 BigDecimal (java.math.BigDecimal)1 ToString (lombok.ToString)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 Order_switchView (org.estatio.module.capex.app.order.Order_switchView)1 BankAccountVerificationStateTransition (org.estatio.module.capex.dom.bankaccount.verification.BankAccountVerificationStateTransition)1 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)1 Document_categoriseAsOrder (org.estatio.module.capex.dom.documents.categorisation.triggers.Document_categoriseAsOrder)1 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)1