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 intoOct 3, 2026
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
vatGroundis required at ISSUED when any line hasvatRate == 0. Nothing in the DSL could declare it -requiredWhenguards on the record's own properties (or one to-one hop),itemsComparereads every line but is warning-only and compares a line to a literal, and a roll-up flag would have needed an ordering operator inwhen:terms. A 0%-line invoice was issued without a legal requisite.The change - the issue's shape (a)
whenAnyItem:is thewhengrammar (<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.itemConditionTermstypes the terms;JavaLiterals.conditionExpressionrenders them; the DAO template loops the lines with the sameCriteriaqueryitemsMinuses.BigDecimal.compareTo) -vatRate == 0is the condition the kind exists for, and a boxed equality on a decimal column never holds. A newdecimalterm type carries that, scoped to line terms.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.whenandwhenAnyItemcompose (ANDed); either alone suffices.requiredWhenwithoutwhenAnyItemrenders byte-identically.Verified
engine-intent+ide-templateunit suites green, includingIntentParserTest.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.IntentEmissionCoverageITgreen end to end: the fixture'sEntrygainedvatGround+ the rule andEntryLinegainedvatRate; over REST, an entry carrying aVatRate: 0line 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:validategreen 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