Search in sources :

Example 1 with InvoiceItem

use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.

the class IncomingDocAsInvoiceViewModel method reasonNotEditableIfAny.

@Override
protected String reasonNotEditableIfAny() {
    final ReasonBuffer2 buf = ReasonBuffer2.forSingle();
    buf.append(getIncomingInvoiceType() == null, "Incoming invoice type is required");
    buf.append(() -> getIncomingInvoiceType().validateProperty(getProperty()));
    buf.append(() -> {
        final Object viewContext = IncomingDocAsInvoiceViewModel.this;
        return getDomainObject().reasonDisabledDueToState(viewContext);
    });
    buf.append(() -> {
        final IncomingInvoice incomingInvoice = getDomainObject();
        SortedSet<InvoiceItem> items = incomingInvoice.getItems();
        return items.size() > 1 ? "Only simple invoices with 1 item can be maintained using this view" : null;
    });
    return buf.getReason();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) DomainObject(org.apache.isis.applib.annotation.DomainObject) ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2)

Example 2 with InvoiceItem

use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.

the class InvoiceAttributesVM method getChargeDescriptions.

@Programmatic
public String getChargeDescriptions() {
    final StringBuilder buf = new StringBuilder();
    SortedSet<InvoiceItem> invoiceItems = invoice.getItems();
    Set<String> descriptions = FluentIterable.from(invoiceItems).transform(x -> {
        Charge charge = x.getCharge();
        return charge != null ? charge.getDescription() : null;
    }).filter(Objects::nonNull).toSortedSet(Ordering.natural());
    final List<String> items = Lists.newArrayList(descriptions);
    final int numItems = items.size();
    for (int i = 0; i < numItems; i++) {
        buf.append(items.get(i));
        if (i == numItems - 2) {
            buf.append(" e ");
        } else if (i != numItems - 1) {
            buf.append(", ");
        }
    }
    return buf.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 3 with InvoiceItem

use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.

the class IncomingInvoice method reasonItemsIncomplete.

@Programmatic
public String reasonItemsIncomplete() {
    StringBuffer buffer = new StringBuffer();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem incomingInvoiceItem = (IncomingInvoiceItem) item;
        if (incomingInvoiceItem.reasonIncomplete() != null) {
            buffer.append("(on item ");
            buffer.append(incomingInvoiceItem.getSequence().toString());
            buffer.append(") ");
            buffer.append(incomingInvoiceItem.reasonIncomplete());
        }
    }
    return buffer.length() == 0 ? null : buffer.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with InvoiceItem

use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.

the class IncomingInvoice method getPropertySummary.

@Programmatic
public String getPropertySummary() {
    List<Property> distinctProperties = new ArrayList<>();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem iitem = (IncomingInvoiceItem) item;
        if (iitem.getFixedAsset() != null && !distinctProperties.contains(iitem.getFixedAsset())) {
            distinctProperties.add((Property) iitem.getFixedAsset());
        }
    }
    StringBuffer summary = new StringBuffer();
    for (Property property : distinctProperties) {
        if (summary.length() > 0) {
            summary.append(" | ");
        }
        summary.append(property.getName());
    }
    return summary.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) ArrayList(java.util.ArrayList) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with InvoiceItem

use of org.estatio.module.invoice.dom.InvoiceItem in project estatio by estatio.

the class IncomingInvoice method getProjectSummary.

@Programmatic
public String getProjectSummary() {
    List<Project> distinctProjects = new ArrayList<>();
    for (InvoiceItem item : getItems()) {
        IncomingInvoiceItem iitem = (IncomingInvoiceItem) item;
        if (iitem.getProject() != null && !distinctProjects.contains(iitem.getProject())) {
            distinctProjects.add(iitem.getProject());
        }
    }
    StringBuffer summary = new StringBuffer();
    for (Project project : distinctProjects) {
        if (summary.length() > 0) {
            summary.append(" | ");
        }
        summary.append(project.getName());
    }
    return summary.toString();
}
Also used : Project(org.estatio.module.capex.dom.project.Project) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) ArrayList(java.util.ArrayList) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)9 Programmatic (org.apache.isis.applib.annotation.Programmatic)7 ArrayList (java.util.ArrayList)3 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 FixedAsset (org.estatio.module.asset.dom.FixedAsset)1 Property (org.estatio.module.asset.dom.Property)1 Unit (org.estatio.module.asset.dom.Unit)1 ReasonBuffer2 (org.estatio.module.base.platform.applib.ReasonBuffer2)1 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)1 Project (org.estatio.module.capex.dom.project.Project)1 Charge (org.estatio.module.charge.dom.Charge)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)1 Lease (org.estatio.module.lease.dom.Lease)1 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)1 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1 LocalDate (org.joda.time.LocalDate)1 Months (org.joda.time.Months)1