Engine

3.4. Conditions🔗

A condition tests a history: it is true or false, never null. It is what requires, always and active hold.

🔗inductive type

A condition: an expression in rule text that evaluates to a Bool (two-valued, never null).

Spec.CondExpr.ever (s : Selector) : CondExpr

ever s: s picks at least one event

Spec.CondExpr.never (s : Selector) : CondExpr

never s: s picks none

Spec.CondExpr.qty (q : Quantity) (s : Selector) : CondExpr

at most n s, between n and m s, ...: s picks that many

Spec.CondExpr.isType (s : Selector) (t : String) : CondExpr

last of s is EventType (false if there is no such event)

Spec.CondExpr.cmp (op : CmpOp) (a b : ValueExpr) : CondExpr

a = b, a != b, a < b, ...; false if either side is null

Spec.CondExpr.isNull (a : ValueExpr) : CondExpr

value is null (is not null is not (value is null))

Spec.CondExpr.and (a b : CondExpr) : CondExpr

a and b

The groupings are shown with SameReading, see Grammar.

3.4.1. Quantities🔗

ever S and never S ask whether S picks any event; no, at least n, at most n, exactly n and between n and m compare how many it picks. On the folio history FolioOpened, ChargePosted, ChargeVoided, FolioClosed, FolioReopened:

Condition

Holds?

Claim

ever ChargePosted, never ChargeRefunded

yes, yes

A folio with a charge has ever had one and never had a refund.

at least 2 [FolioOpened, ChargePosted, ChargeVoided], at most 1 FolioClosed, exactly 2 FolioClosed, between 1 and 3 ChargePosted

yes, yes, no, yes

Quantities compare the number of picked events.

3.4.2. Last of🔗

last of S is T asks whether the latest event S picks has type T. It is how a state that can be undone is tested: here a folio is closed until it is reopened.

Condition

Holds?

Claim

last of [FolioClosed, FolioReopened] is FolioClosed, after the reopening and before it

no, yes

A reopened folio is not closed.

3.4.3. Null🔗

A comparison with a null value is false, != included; ask for null with is null.

Condition

Holds?

Claim

(last of Missing).x > 1, (last of Missing).x != 1, (last of Missing).x is null

no, no, yes

A comparison with null is false and is null is true.

3.4.4. Counting🔗

How the quantities relate, for writing a condition the short way.

3.4.5. Once true🔗

Use ever and never for things that happen once; for things that can be undone, last of [UserSuspended, UserReactivated] is UserSuspended.