Search in sources :

Example 11 with ReasonBuffer2

use of org.estatio.module.base.platform.applib.ReasonBuffer2 in project estatio by estatio.

the class IncomingInvoiceItem method projectIsImmutableReason.

String projectIsImmutableReason() {
    // nb: dimensions *are* allowed to change irrespective of state,
    // so we don't check IncomingInvoice#isImmutableDueToState()
    final ReasonBuffer2 buf = ReasonBuffer2.forAll("Project cannot be changed because");
    appendReasonIfReversalOrReported(buf);
    appendReasonIfLinkedToAnOrder(buf);
    return buf.getReason();
}
Also used : ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2)

Example 12 with ReasonBuffer2

use of org.estatio.module.base.platform.applib.ReasonBuffer2 in project estatio by estatio.

the class InvoiceItem method disableChangeTax.

public String disableChangeTax() {
    ReasonBuffer2 buf = ReasonBuffer2.forSingle("Can't change tax because");
    appendReasonChangeTaxDisabledIfAny(buf);
    return buf.getReason();
}
Also used : ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2)

Example 13 with ReasonBuffer2

use of org.estatio.module.base.platform.applib.ReasonBuffer2 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 14 with ReasonBuffer2

use of org.estatio.module.base.platform.applib.ReasonBuffer2 in project estatio by estatio.

the class ReasonBuffer2_Test method with_prefix_first_and_condition.

@Test
public void with_prefix_first_and_condition() throws Exception {
    final ReasonBuffer2 buf = ReasonBuffer2.forSingle("Cannot change");
    buf.append((() -> true), "reason #1");
    buf.append(false, "reason #2");
    buf.append(true, "reason #3");
    Assertions.assertThat(buf.getReason()).isEqualTo("Cannot change reason #1");
}
Also used : ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2) Test(org.junit.Test)

Example 15 with ReasonBuffer2

use of org.estatio.module.base.platform.applib.ReasonBuffer2 in project estatio by estatio.

the class ReasonBuffer2_Test method with_prefix_first.

@Test
public void with_prefix_first() throws Exception {
    final ReasonBuffer2 buf = ReasonBuffer2.forSingle("Cannot change");
    buf.append(true, "reason #1");
    buf.append(false, "reason #2");
    buf.append(true, "reason #3");
    Assertions.assertThat(buf.getReason()).isEqualTo("Cannot change reason #1");
}
Also used : ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2) Test(org.junit.Test)

Aggregations

ReasonBuffer2 (org.estatio.module.base.platform.applib.ReasonBuffer2)40 Test (org.junit.Test)10 DomainObject (org.apache.isis.applib.annotation.DomainObject)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)1 IncomingInvoiceItem (org.estatio.module.capex.dom.invoice.IncomingInvoiceItem)1 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)1