feat(dimensions): show the value's name after picking, and let an unused custom dimension be deleted (#2219) (#2255)
* feat(dimensions): show the value's name after picking, and let an unused custom dimension be deleted (#2219) Two things from the same Discord report, both in bookkeeping from the transaction view: 1. After picking a kostnadsställe the field showed only the code ("1"). DimensionCombobox now writes the value's full name under the field once a code is committed, exactly as AccountCombobox does for the account name (looked up in the full registry so an archived code stays readable). The input text itself stays the code: the blur/revert logic keys on it. 2. A self-created dimension could not be removed at all: the DB already allowed it (enforce_dimension_registry_guards lets a non-system dimension go when no posted/reversed line carries its number, and the value retention trigger fires on the cascade), but no route or UI asked. New DELETE /api/dimensions/[id]: 400 DIMENSION_SYSTEM_DELETE for kostnadsställe/projekt, the guard's own Swedish P0001 verbatim as 409 DIMENSION_REFERENCED, 404, and a happy path; the register gets a quiet "Ta bort dimension" link for the active custom dimension behind a DestructiveConfirmDialog. Keys added to sv and en. Closes #2219 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy * test: satisfy the TypeScript ratchet for two test files main inherited from #2247 and #2242 accounts-route.test.ts built SyncResult literals without the requestedFromDate / historyNarrowed fields #2247 added (vitest does not typecheck, so it passed locally); fiscal-periods route.test.ts got two more one-argument POST(req) calls from #2242 in a file already at its ratchet baseline. Both files now typecheck; the ratchet runs clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy --------- Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
Jakob Wennberg
parent
2c3ffaf51c
commit
a48508e5b0
@@ -508,6 +508,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
describe('inline initial backfill', () => {
|
||||
it('runs inline sync on pending_selection→active and writes initial-sync metadata', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 47,
|
||||
duplicates: 3,
|
||||
errors: 0,
|
||||
@@ -577,6 +579,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('suppresses auto-categorization and reconciles per ledger account when the window overlaps an SIE import (renewal-flood guard)', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 22,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -663,6 +667,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('runs no reconciliation sweep and keeps categorization on without SIE overlap', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 10,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -705,6 +711,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('gives viewers rawInsertOnly and no sweep even with SIE overlap (viewers cannot write links)', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 5,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -747,6 +755,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('skips the sweep for an account whose cash_accounts row did not resolve instead of widening to the pooled form', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 6,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -790,6 +800,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('keeps the backfill successful when the reconciliation sweep throws (non-critical)', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 8,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -823,6 +835,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('does NOT run inline sync when connection is already active (selection edit)', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 99,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -896,6 +910,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
it('clamps initial_lookback_days to [30, 365]', async () => {
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 0,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -931,6 +947,8 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
// show a retry warning; the cron will gate on initial_sync_completed_at IS NULL
|
||||
// and self-heal on its next run.
|
||||
mockedSync.mockResolvedValue({
|
||||
requestedFromDate: '2026-01-01',
|
||||
historyNarrowed: false,
|
||||
imported: 12,
|
||||
duplicates: 0,
|
||||
errors: 0,
|
||||
@@ -975,7 +993,7 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
|
||||
describe('per-account ledger mapping (account_mappings)', () => {
|
||||
it('persists ledger_account from account_mappings into accounts_data JSONB', async () => {
|
||||
mockedSync.mockResolvedValue({ imported: 0, duplicates: 0, errors: 0 })
|
||||
mockedSync.mockResolvedValue({ requestedFromDate: '2026-01-01', historyNarrowed: false, imported: 0, duplicates: 0, errors: 0 })
|
||||
|
||||
const stub: SupabaseStub = {
|
||||
authUser: { id: 'user-1' },
|
||||
@@ -1132,7 +1150,7 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
// the effective cash_accounts assignment, so the cleared account gets a
|
||||
// fresh allocation instead of an undefined that silently falls back to
|
||||
// 1930 at mirror time.
|
||||
mockedSync.mockResolvedValue({ imported: 0, duplicates: 0, errors: 0 })
|
||||
mockedSync.mockResolvedValue({ requestedFromDate: '2026-01-01', historyNarrowed: false, imported: 0, duplicates: 0, errors: 0 })
|
||||
|
||||
const stub: SupabaseStub = {
|
||||
authUser: { id: 'user-1' },
|
||||
@@ -1236,7 +1254,7 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
// claim release still point at the revoked connection. They must not
|
||||
// count as foreign claims: the save goes through and upsertFromPsd2
|
||||
// promotes the orphaned row in place.
|
||||
mockedSync.mockResolvedValue({ imported: 0, duplicates: 0, errors: 0 })
|
||||
mockedSync.mockResolvedValue({ requestedFromDate: '2026-01-01', historyNarrowed: false, imported: 0, duplicates: 0, errors: 0 })
|
||||
mockGetRevokedConnectionIds.mockResolvedValue(new Set(['conn-REVOKED']))
|
||||
|
||||
const stub: SupabaseStub = {
|
||||
@@ -1283,7 +1301,7 @@ describe('PATCH /accounts (enable-banking)', () => {
|
||||
})
|
||||
|
||||
it('allocates distinct ledgers for legacy accounts with no mapping at all', async () => {
|
||||
mockedSync.mockResolvedValue({ imported: 0, duplicates: 0, errors: 0 })
|
||||
mockedSync.mockResolvedValue({ requestedFromDate: '2026-01-01', historyNarrowed: false, imported: 0, duplicates: 0, errors: 0 })
|
||||
|
||||
const stub: SupabaseStub = {
|
||||
authUser: { id: 'user-1' },
|
||||
|
||||
Reference in New Issue
Block a user