Skip to content

intent: a header value may be required when ANY line matches - the legal ground a zero-rated line calls for (#7560) - #7630

Merged
delchev merged 3 commits into
eclipse-dirigible:masterfrom
nedelcho-delchev-tues:issue-7560-required-when-any-item
Oct 3, 2026
Merged

delchev merged 3 commits into
eclipse-dirigible:masterfrom
nedelcho-delchev-tues:issue-7560-required-when-any-item

Conversation

@nedelcho-delchev-tues

@nedelcho-delchev-tues nedelcho-delchev-tues commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The rule

ЗДДС чл. 114 ал. 1 т. 12: when an invoice line is zero-rated (or reverse-charged), the document must state the legal ground. As a check: vatGround is required at ISSUED when any line has vatRate == 0. Nothing in the DSL could declare it - requiredWhen guards on the record's own properties (or one to-one hop), itemsCompare reads every line but is warning-only and compares a line to a literal, and a roll-up flag would have needed an ordering operator in when: terms. A 0%-line invoice was issued without a legal requisite.

The change - the issue's shape (a)

checks:
  - { kind: requiredWhen, field: vatGround, whenAnyItem: "vatRate == 0", status: ISSUED,
      message: "A zero-rated line needs its legal ground (VAT Act art. 114)" }
  • whenAnyItem: is the when grammar (<Property> ==|!= <literal>, a list = AND) read off each line of the document's items child, inside the repository's gate - the header value is required when any line matches. CheckSupport.itemConditionTerms types the terms; JavaLiterals.conditionExpression renders them; the DAO template loops the lines with the same Criteria query itemsMin uses.
  • An amount or a rate compares by value (BigDecimal.compareTo) - vatRate == 0 is the condition the kind exists for, and a boxed equality on a decimal column never holds. A new decimal term type carries that, scoped to line terms.
  • The status: gate is required. The lines are read where the document is persisted carrying it, which is also the only moment the question is complete; an ungated rule would read the lines on every REST write (where the controllers read only the row) and refuse a draft assembled line by line.
  • when and whenAnyItem compose (ANDed); either alone suffices.
  • Refused at parse, each because it would otherwise be inert or wrong: a hop in a line term (a line condition reads the line itself), a property the items entity does not declare, a type an equality is not exact on, a literal that is not a value of that type, an entity owning no items.
  • A requiredWhen without whenAnyItem renders byte-identically.

Verified

  • engine-intent + ide-template unit suites green, including IntentParserTest.aHeaderValueMayBeRequiredWhenAnyLineMatches (accept + five refusals), EdmIntentGeneratorTest.aRequiredWhenOverTheLinesEmitsTheItemsAndTheirTypedTerms, ModelParameterProcessorTest.aRequiredWhenOverTheLinesRendersItsItemConditionByValue.
  • RequiredWhenAnyItemRepositoryTemplateIT (new, 3): the repository template rendered through the platform's own Velocity engine - the items loop at the gate, the by-value comparison, the ANDed record condition, and the unchanged shape without a line condition.
  • IntentEmissionCoverageIT green end to end: the fixture's Entry gained vatGround + the rule and EntryLine gained vatRate; over REST, an entry carrying a VatRate: 0 line is refused at POSTED with the authored message, posted once the ground is given, and the plain entry whose lines carry no zero rate still posts with none.
  • mvn -T 1C formatter:validate green with the cache wiped.

Not run locally: the rest of the integration suite, the PostgreSQL leg.

Documentation

In-repo: the module guide, .claude/docs/intent-dsl-features.md, and the assistant guide. The three external repos (IntentFile/intent-specification, IntentFile/intentfile.github.io, dirigible-io/dirigible-io.github.io) still need their PRs.

Fixes #7560

nedelcho-delchev-tues and others added 3 commits October 2, 2026 13:13
…gal ground a zero-rated line calls for (eclipse-dirigible#7560)

ЗДДС чл. 114 ал. 1 т. 12: a zero-rated or reverse-charged line makes the document's
legal ground a requisite, and no check kind could say so. requiredWhen guarded on the
record's own properties (or one to-one hop), itemsCompare reads the lines but only
warns and compares a line to a literal, and a roll-up flag would have needed an ordering
operator in when:. So a 0%-line invoice was issued without a legal requisite.

  - { kind: requiredWhen, field: vatGround, whenAnyItem: "vatRate == 0", status: ISSUED,
      message: "A zero-rated line needs its legal ground" }

whenAnyItem is the when grammar read off each LINE of the document's items child, in the
repository's gate: the header value is required when any line matches. An amount or a
rate compares BY VALUE (BigDecimal.compareTo) - the condition the kind exists for is
vatRate == 0, and a boxed equality on a decimal column never holds. The status gate is
required: the lines are read where the document is persisted carrying it, and an ungated
rule would read them on every REST write - where the controllers read only the row - and
refuse a draft assembled line by line. when and whenAnyItem compose (ANDed).

Refused at parse: a hop in a line term, a property the items entity does not declare, a
type an equality is not exact on, a literal that is not a value of it, no items child.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…-when-any-item

# Conflicts:
#	components/template/template-application-dao-java/src/main/resources/META-INF/dirigible/template-application-dao-java/data/Repository.java.template
…-when-any-item

# Conflicts:
#	.claude/docs/intent-dsl-features.md
#	components/engine/engine-intent/src/test/java/org/eclipse/dirigible/components/intent/parser/IntentParserTest.java
@delchev
delchev merged commit f38f9fb into eclipse-dirigible:master Oct 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checks: a header value cannot be required when ANY line matches a condition (0% VAT line -> the legal ground is required at Issue)

2 participants