Search in sources :

Example 1 with MemberOrder

use of org.apache.isis.applib.annotation.MemberOrder in project estatio by estatio.

the class IncomingInvoice_switchView method act.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION, // not sure why this isn't being picked up from isis-non-changing.properties
cssClassFa = "fa-exchange")
@MemberOrder(sequence = "1")
public IncomingDocAsInvoiceViewModel act() {
    Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(incomingInvoice);
    // guaranteed to return, hidden if none
    Document document = documentIfAny.get();
    final IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel(incomingInvoice, document);
    serviceRegistry2.injectServicesInto(viewModel);
    viewModel.init();
    return viewModel;
}
Also used : Document(org.incode.module.document.dom.impl.docs.Document) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 2 with MemberOrder

use of org.apache.isis.applib.annotation.MemberOrder in project estatio by estatio.

the class IncomingDocAsOrderViewModel method save.

@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "1")
public Order save() {
    Order order = getDomainObject();
    order.setOrderNumber(getOrderNumber());
    order.setSellerOrderReference(getSellerOrderReference());
    order.setEntryDate(clockService.now());
    order.setOrderDate(getOrderDate());
    order.setSeller(getSeller());
    order.setBuyer(getBuyer());
    Optional<OrderItem> firstItemIfAny = getFirstItemIfAny();
    if (firstItemIfAny.isPresent()) {
        OrderItem orderItem = firstItemIfAny.get();
        orderItem.setCharge(getCharge());
        orderItem.setDescription(getDescription());
        orderItem.setNetAmount(getNetAmount());
        orderItem.setVatAmount(getVatAmount());
        orderItem.setGrossAmount(getGrossAmount());
        orderItem.setTax(getTax());
        orderItem.setStartDate(getStartDateFromPeriod());
        orderItem.setEndDate(getEndDateFromPeriod());
        orderItem.setProperty(getProperty());
        orderItem.setProject(getProject());
        orderItem.setBudgetItem(getBudgetItem());
    } else {
        order.addItem(getCharge(), getDescription(), getNetAmount(), getVatAmount(), getGrossAmount(), getTax(), getPeriod(), getProperty(), getProject(), getBudgetItem());
    }
    return order;
}
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) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 3 with MemberOrder

use of org.apache.isis.applib.annotation.MemberOrder in project estatio by estatio.

the class IncomingDocAsInvoiceViewModel method save.

@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "1")
public IncomingInvoice save() {
    IncomingInvoice incomingInvoice = getDomainObject();
    IncomingInvoiceType previousType = incomingInvoice.getType();
    incomingInvoice.setType(getIncomingInvoiceType());
    incomingInvoice.setInvoiceNumber(getInvoiceNumber());
    incomingInvoice.setBuyer(getBuyer());
    incomingInvoice.setSeller(getSeller());
    incomingInvoice.setInvoiceDate(getInvoiceDate());
    incomingInvoice.setDueDate(getDueDate());
    incomingInvoice.setPaymentMethod(getPaymentMethod());
    incomingInvoice.setCurrency(getCurrency());
    incomingInvoice.setDateReceived(getDateReceived());
    incomingInvoice.setBankAccount(getBankAccount());
    incomingInvoice.setNetAmount(getNetAmount());
    incomingInvoice.setGrossAmount(getGrossAmount());
    // if changed the type, then we need to re-evaluate the state machine
    if (previousType != getIncomingInvoiceType()) {
        stateTransitionService.trigger(incomingInvoice, IncomingInvoiceApprovalStateTransition.class, null, null, null);
    }
    // upsert invoice item
    // this will also update the parent header's property with that from the first item
    Optional<IncomingInvoiceItem> firstItemIfAny = getFirstItemIfAny();
    IncomingInvoiceItem firstItem;
    if (firstItemIfAny.isPresent()) {
        IncomingInvoiceItem item = firstItemIfAny.get();
        item.setIncomingInvoiceType(getIncomingInvoiceType());
        item.setCharge(getCharge());
        item.setDescription(getDescription());
        item.setNetAmount(getNetAmount());
        item.setVatAmount(getVatAmount());
        item.setGrossAmount(getGrossAmount());
        item.setTax(getTax());
        item.setStartDate(getStartDateFromPeriod());
        item.setEndDate(getEndDateFromPeriod());
        item.setFixedAsset(getProperty());
        item.setProject(getProject());
        item.setBudgetItem(getBudgetItem());
        firstItem = item;
    } else {
        firstItem = incomingInvoiceItemRepository.create(incomingInvoice.nextItemSequence(), incomingInvoice, incomingInvoiceType, getCharge(), getDescription(), getNetAmount(), getVatAmount(), getGrossAmount(), getTax(), getDueDate(), getStartDateFromPeriod(), getEndDateFromPeriod(), getProperty(), getProject(), getBudgetItem());
    }
    // 'switch view' will not be available subsequently because the Invoice/Item is "too complex")
    if (getOrderItem() != null) {
        Order order = getOrderItem().getOrdr();
        Charge chargeFromWrapper = getOrderItem().getCharge();
        OrderItem orderItemToLink = orderItemRepository.findByOrderAndCharge(order, chargeFromWrapper);
        orderItemInvoiceItemLinkRepository.findOrCreateLink(orderItemToLink, firstItem, firstItem.getNetAmount());
    } else {
        // remove all (or the one and only) link.
        final Optional<OrderItemInvoiceItemLink> links = orderItemInvoiceItemLinkRepository.findByInvoiceItem(firstItem);
        links.ifPresent(link -> {
            link.remove();
        });
    }
    return incomingInvoice;
}
Also used : Order(org.estatio.module.capex.dom.order.Order) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) IncomingInvoiceType(org.estatio.module.capex.dom.invoice.IncomingInvoiceType) OrderItem(org.estatio.module.capex.dom.order.OrderItem) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Charge(org.estatio.module.charge.dom.Charge) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 4 with MemberOrder

use of org.apache.isis.applib.annotation.MemberOrder in project estatio by estatio.

the class Lease_DownloadBudgetCalculationsForLease method downloadBudgetCalculationsForLease.

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(cssClassFa = "fa-download")
@MemberOrder(name = "budgetCalculationRuns", sequence = "1")
public Blob downloadBudgetCalculationsForLease(Budget budget, BudgetCalculationType type) {
    final String fileName = lease.getReference() + " - budget details" + ".xlsx";
    WorksheetSpec spec = new WorksheetSpec(DetailedCalculationResultViewmodel.class, "values for lease");
    WorksheetContent worksheetContent = new WorksheetContent(budgetAssignmentService.getDetailedCalculationResults(lease, budget, type), spec);
    return excelService.toExcelPivot(worksheetContent, fileName);
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) WorksheetContent(org.isisaddons.module.excel.dom.WorksheetContent) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 5 with MemberOrder

use of org.apache.isis.applib.annotation.MemberOrder in project estatio by estatio.

the class OrderInvoiceImportMenu method importOrdersAndInvoices.

@Action(semantics = SemanticsOf.SAFE)
@MemberOrder(sequence = "1")
public OrderInvoiceSheet importOrdersAndInvoices(final String sheetName, final Blob spreadSheet) {
    final List<OrderInvoiceLine> lines = orderInvoiceImportService.createLines(sheetName, spreadSheet);
    final OrderInvoiceSheet sheet = factoryService.instantiate(OrderInvoiceSheet.class);
    sheet.setLines(lines);
    return sheet;
}
Also used : OrderInvoiceSheet(org.estatio.module.capex.imports.OrderInvoiceSheet) OrderInvoiceLine(org.estatio.module.capex.imports.OrderInvoiceLine) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Aggregations

MemberOrder (org.apache.isis.applib.annotation.MemberOrder)34 Action (org.apache.isis.applib.annotation.Action)29 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)15 Document (org.incode.module.document.dom.impl.docs.Document)5 WorksheetSpec (org.isisaddons.module.excel.dom.WorksheetSpec)4 ArrayList (java.util.ArrayList)3 WorksheetContent (org.isisaddons.module.excel.dom.WorksheetContent)3 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Period (org.joda.time.Period)3 FixtureScript (org.apache.isis.applib.fixturescripts.FixtureScript)2 Order (org.estatio.module.capex.dom.order.Order)2 OrderItem (org.estatio.module.capex.dom.order.OrderItem)2 Lease (org.estatio.module.lease.dom.Lease)2 CreateRetroInvoices (org.estatio.module.lease.migrations.CreateRetroInvoices)2 LocalDateInterval (org.incode.module.base.dom.valuetypes.LocalDateInterval)2 DocumentType (org.incode.module.document.dom.impl.types.DocumentType)2 DateTime (org.joda.time.DateTime)2 LocalDate (org.joda.time.LocalDate)2 BigDecimal (java.math.BigDecimal)1 List (java.util.List)1