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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations