Skip to content

feat(numbering): declared partition sources — labeled rows + counter seeding before first use (#6506) - #6507

Merged
delchev merged 1 commit into
masterfrom
feat/numbering-partition-source
Aug 4, 2026
Merged

feat(numbering): declared partition sources — labeled rows + counter seeding before first use (#6506)#6507
delchev merged 1 commit into
masterfrom
feat/numbering-partition-source

Conversation

@delchev

@delchev delchev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Closes #6506. Stacked on #6500 (numbering settings UX) - the diff includes it until #6500 merges; review the last commit only.

What

The platform did not know where a partitioned series' values come from, so the Document Numbering settings page showed raw ids (Sales Invoice [1]) and could not offer a partition's row before its first allocation - an operator could not seed a company's starting number before its first document.

  • .numbers gains an optional partition source. {"name": "Sales Invoice", "prefix": "SI", "size": 10, "partitions": {"table": "CRM_COMPANY", "key": "COMPANY_ID", "label": "COMPANY_NAME"}} - authored physical coordinates, the .csvim precedent. Identifiers are parse-validated to plain SQL names (a published artefact must not become an injection surface - they are quoted into one SELECT); a differing cross-module re-declaration fails the artefact loudly, exactly as for the shape; the synchronizer's provisioning and the DELETE contract are untouched.
  • Labeled rows (H2b). The endpoint joins each partition row's value against the declared source and the settings page renders Sales Invoice — ACME Ltd., falling back to the raw value in brackets when unresolvable.
  • Virtual rows (H2d). Every declared partition value with no materialized row is listed as a virtual: true row rendered with the base row's shape (next = 1). Saving one provisions it exactly as the first allocation would have - DocumentNumberService.setNext/setShape now ensurePartition first (base shape inherited at row birth, then the edit applied). The base-row shape-template semantics from fix(numbering): per-row save in settings; base row of a partitioned series offers no counter (#6499) #6500 extend naturally: a series with a declared source is partitioned even before any allocation.

Docs synced: root + engine-intent CLAUDE.md numbering sections, the intent assistant guide.

Test

NumberingSdkIT.aDeclaredPartitionSourceLabelsRowsAndSeedsCountersBeforeFirstUse (green locally alongside the #6500 settings-surface case): creates + seeds a real partition-source table, publishes the declaration, asserts the two labeled virtual rows and the base row's partitioned flag over GET /services/core/numbering, seeds one virtual row's Next to 42 (PUT provisions it), and asserts the FIRST allocated document renders exactly P-0042 - the outermost layer of the seeding contract.

🤖 Generated with Claude Code

…+ seeding counters before first use (#6506)

A partitioned series row rendered as 'Sales Invoice [1]' (the raw
partner id), and a partition's counter could not be seeded before its
first document: partition rows materialize on first allocation (correct
- partition values are data), so the row was not there to edit.

The .numbers declaration may now name its partition source -
"partitions": {"table", "key", "label"} - authored physical coordinates
exactly like a .csvim's table/columns; the identifiers are
parse-validated to plain SQL names (a published artefact must not
become an injection surface) and a differing cross-module
re-declaration fails the artefact as for the shape. The numbering
endpoint resolves each partition row's value to the entity's display
label and lists a VIRTUAL row for every declared value that has not
allocated yet, rendered with the base row's shape; saving a virtual row
provisions it exactly as the first allocation would have (base shape
inherited, then the edit applied - DocumentNumberService.setNext/
setShape ensure the partition row exists). The settings page renders
'Sales Invoice — ACME Ltd.' and offers every company's row up front.

NumberingSdkIT gains the end-to-end case: a declared partition source
over a real table lists labeled virtual rows, seeding one provisions
it, and the FIRST allocated document renders exactly the seeded number
(green locally, together with the settings-surface case).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delchev
delchev force-pushed the feat/numbering-partition-source branch from c1c2f9e to 95b39fc Compare August 4, 2026 15:08
@delchev
delchev merged commit 87b4260 into master Aug 4, 2026
9 checks passed
@delchev
delchev deleted the feat/numbering-partition-source branch August 4, 2026 15:09
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.

Document Numbering settings: partition rows show raw ids and counters cannot be seeded before first use

1 participant