feat(intent): generates.items supports a non-composition FK-referencing source item + decimal item defaults - #6368
Merged
Conversation
…ng source item + decimal item defaults An item create-from (generates with an items: block) assumed the item source is a composition child living in the source document's perspective package, and rendered numeric item defaults as bare literals. Two fixes so an item source that is a SEPARATE primary entity referencing the source document by FK (an aggregate document whose per-line detail is its own entity) works: - The source item's package resolves from its OWN perspective (a new fromItemPerspective, == fromPerspective for the composition-child case, so no change to existing create-froms); the template qualifies srcItem with it. - Item defaults use childAssignments (numeric -> BigDecimal), matching the schedule-children path, so a decimal line column (quantity/price) gets a compilable value. GlueGeneratesTest gains a non-composition-source case asserting the item perspective and the BigDecimal default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fixes #6366.
Problem
An item create-from (
generateswith anitems:block) assumed the item source is a composition child living in the source document's perspective package, and rendered numeric itemdefaults:as bare literals. That breaks when the item source is a separate primary entity referencing the source document by FK — an aggregate document whose per-line detail is its own entity (e.g. a period-aggregate document whose per-member detail rows are a standalone entity). The emitted code then references the item type in the wrong package (cannot find symbol), and a decimal item default likequantity: 1renders asitem.Quantity = 1;→incompatible types: int cannot be converted to java.math.BigDecimal.Fix
fromItemPerspective), not the source document's. For a composition-child item this equalsfromPerspective, so existing create-froms are byte-identical. The template qualifiessrcItemwith it.childAssignments(numeric →BigDecimal), the same path the scheduled-children generation already uses, so a decimal line column gets a compilable value.Three layers:
GlueIntentGenerator(glue),generateUtils.js(sanitized package var),Generate.java.template(uses it).Test
GlueGeneratesTest.nonCompositionSourceItemResolvesItsOwnPackageAndDecimalDefaultsasserts the item resolves its own perspective (distinct from the source document's) and the decimal default renders asBigDecimal. Existing generates tests unchanged (composition-child path is a no-op).Follow-up: extend
IntentEmissionCoverageITwith a non-composition item-source fixture asserting the emitted controller compiles and serves (the outermost layer); tracked in #6366.🤖 Generated with Claude Code