64991eb3c9
* feat(salary): add remove-employee button to draft salary runs
The DELETE /api/salary/runs/{id}/employees/{employeeId} endpoint already
existed (draft-only, cascades to the employee's line items) but had no UI
trigger, so a mistakenly added employee could only be cleared by deleting
the whole draft. Add a trash-icon action column to the "Anställda" table,
gated on draft status + write permission to match the endpoint's guard,
with a confirm prompt and success/error toast.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(settings): prevent horizontal overflow on mobile
The company settings invite form was a non-wrapping fixed-width flex row that overflowed narrow viewports, forcing the full-screen settings modal to scroll on the x-axis. Stack the form vertically on mobile (sm:flex-row at and above the sm breakpoint) and add the missing min-w-0 guard to the modal content pane.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(bookkeeping): move journal entry filters into a filter dialog
The ledger toolbar showed every filter inline (fiscal year, sort, series,
date range, missing-documents toggle), which felt cluttered. Keep only the
search field visible and move the rest into a "Filtrera" dialog with an
active-filter count badge.
- JournalEntryList now owns the fiscal-year scope, restored from the same
localStorage key FiscalYearSelector writes, so the page no longer renders
the selector separately.
- Filters apply live and the dialog stays open; "Rensa alla filter" clears them.
- Export STORAGE_KEY_PREFIX / ALL_YEARS_VALUE from FiscalYearSelector so the
list reuses the persisted selection without duplicating the key.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(transactions): implement imported transaction guard for deletion
- Added a guard to prevent deletion of transactions that are imported via bank sync or file uploads.
- Introduced `isImportedTransaction` utility to determine if a transaction is user-created or imported.
- Updated DELETE endpoint to return a 409 status for attempts to delete imported transactions.
- Enhanced transaction history and inbox components to reflect the new deletion rules.
- Added tests for transaction origin determination and deletion behavior.
- Updated UI components to include a confirmation dialog for clearing journal entry forms.
- Localized new strings for clearing form functionality in English and Swedish.
* feat(transactions): enhance transaction deletion guard and improve fiscal year visibility
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { isImportedTransaction } from '@/lib/transactions/origin'
|
|
|
|
describe('isImportedTransaction', () => {
|
|
describe('imported (ignore-only, never deletable)', () => {
|
|
it('treats a row with a live bank connection as imported', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: 'bc-1', import_source: null })).toBe(true)
|
|
})
|
|
|
|
it('treats a row with a bank connection as imported even if import_source looks in-app', () => {
|
|
// The bank link wins — a PSD2 row is imported regardless of the source tag.
|
|
expect(isImportedTransaction({ bank_connection_id: 'bc-1', import_source: 'manual' })).toBe(true)
|
|
})
|
|
|
|
it('treats Enable Banking sync rows as imported', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: 'enable_banking' })).toBe(true)
|
|
})
|
|
|
|
it('treats CAMT053 bank-file imports as imported', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: 'camt053' })).toBe(true)
|
|
})
|
|
|
|
it.each(['csv_nordea', 'csv_lunar', 'csv_seb'])(
|
|
'treats CSV bank-file import %s as imported',
|
|
(source) => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: source })).toBe(true)
|
|
},
|
|
)
|
|
|
|
it('treats an unknown future import source as imported (safe default)', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: 'some_new_feed' })).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('user-created (deletable when unbooked)', () => {
|
|
it('treats a null source with no bank link as user-created (manual add)', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: null })).toBe(false)
|
|
})
|
|
|
|
it('treats create-from-document (manual) as user-created', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: 'manual' })).toBe(false)
|
|
})
|
|
|
|
it('treats MCP/agent-created rows as user-created', () => {
|
|
expect(isImportedTransaction({ bank_connection_id: null, import_source: 'mcp' })).toBe(false)
|
|
})
|
|
|
|
it('tolerates omitted (undefined) origin fields', () => {
|
|
expect(isImportedTransaction({})).toBe(false)
|
|
})
|
|
})
|
|
})
|