Skip to content

Close SUM-PLAT-18: currency rates and UoM platform models - #121

Open
jay009id wants to merge 2 commits into
devfrom
feat/SUM-PLAT-18-currency-uom
Open

jay009id wants to merge 2 commits into
devfrom
feat/SUM-PLAT-18-currency-uom

Conversation

@jay009id

@jay009id jay009id commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #57

Summary

Platform primitives for transactional verticals (SUM-PLAT-18): transactional apps need FX and unit-of-measure support before they ship, and the currency model was catalog-only with no rates while UoM models did not exist at all.

  • core.currency.rate — per-currency rates effective from a date (currency_id, rate, date_from, active), with a (currency, date_from) natural key for idempotent data syncs. The core.currency catalog moves from addons/geo to addons/base (a single reference in the whole repo, no existing data → no migration), so catalog + rates + UoM ship as one always-on platform unit.
  • uom.category + uom.uom — units of measure with a factor relative to the reference unit of their category and a rounding precision, natural key (name, category).
  • Conversion helpers — sdk.ConvertCurrency, sdk.ConvertUom, and sdk.ConvertMoneyField (resolves the currency=<field> tag from the model registry — a tag that was parsed but never consumed before). Helpers use the newest rate with date_from <= the conversion date; cross-category UoM conversions are rejected explicitly.
  • Admin views in addons/base only (no accounting app) — a "Currencies & Units" menu (currencies, rates, UoM categories, units), 8 list/form views, 4 window actions, seed data: 8 currencies with bootstrap rates (USD reference 1.0), 5 UoM categories, 16 units.

Checklist

  • make from sumeru/ (lint, test, build) — full gate green, golangci-lint 0 issues, coverage 42.5% (min 42)
  • Sensitive fields → core/security/fields.go; bypass → AuditedBypass / WithElevated — no new sensitive fields; helpers act in the caller's context, no new bypass paths
  • Auth/session cookies → core/server/web/cookie_helpers.go — no cookie/auth changes
  • Tests under test/ or core/swc/tests/ where behavior changed — unit, addon, and integration tests added; no SWC changes

If applicable: make generate — ran, output committed · make test-modules — green · make test-integration — green against local PostgreSQL

Notes

  • Pre-existing first-time install bug (follow-up needed): install base failed: en_US.po: relation "sys_translation" does not exist — PO import runs before the sys_translation table (owned by the i18n addon) is created. Reproduced identically on dev; deserves its own issue.
  • make test-integration did not build on dev (orm.InitDB used as a value in test/module/integration/install_closure_test.go); the second commit of this PR fixes that and adds bypass contexts to both integration smoke tests.
  • Rates are global in this first iteration; verticals can layer company-scoped rates and rate providers on top.
  • Two workspace tests (TestWorkspaceAddonsPathOptional, TestRunWorkspaceGen_scopedWrites) used to fail on the dev machine due to the external sumeru_addons workspace (stock-orig folder) — fixed separately and now passing; unrelated to this PR.

jay009id and others added 2 commits October 4, 2026 04:14
Platform primitives for transactional verticals (issue #57):

- Move core.currency from addons/geo to addons/base so the catalog,
  its rates, and the UoM master data ship as one always-on platform unit.
- Add core.currency.rate (currency, rate, date_from, active) with
  (currency, date_from) natural keys for idempotent data syncs.
- Add uom.category and uom.uom (factor, rounding) with (name, category)
  natural keys.
- Add sdk.ConvertCurrency / sdk.ConvertUom / sdk.ConvertMoneyField:
  ConvertMoneyField resolves the currency=<field> tag from the model
  registry, so ORM float/money fields tagged as currency convert via
  the newest effective rate for the requested date.
- Seed data + admin views/menus/actions in addons/base (no accounting
  app): 8 currencies with bootstrap rates, 5 UoM categories, 16 units.
- Tests: pure math unit tests, addon registration tests, integration
  tests for conversions, and an isolated Addon.SyncToDB regression test
  covering cross-record refs and natural-key upserts.

Co-Authored-By: Claude Code <noreply@anthropic.com>
test/module/integration/install_closure_test.go no longer compiled
(orm.InitDB returns no value) and, with kernel models registered,
searches on sys.module without a bypass context fail access checks.
Give both integration smoke tests the model registry and a bypass
context so they pass against an initialized database.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@jay009id
jay009id requested a review from a team October 4, 2026 04:45
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.

3 participants