Repository navigation
Require account class and normal side in account editor dialog - #134
Merged
Merged
Conversation
Konton utan klassificering (account_class/normal_balance_side = null) visades som Tillgång/Debet i Redigera konto eftersom indexOf(null) gav -1 som Math.max(0, ...) gjorde om till index 0. Att bara trycka OK sparade då tyst kontot som ASSET/DEBIT. Dialogen får nu ett '(ej angiven)'-alternativ i båda kombinationsrutorna som väljs när värdet saknas, och OK meddelar och stänger inte dialogen om klass eller normalsida lämnats ospecificerade. Fixes #121
Den första rättelsen behöll Math.max(0, ...) som klämde indexOf(null) = -1 till 0, vilket med den nya platshållaren på index 0 fortfarande blev ASSET/DEBIT. indexOf(value) + 1 mappar nu null och okända värden till '(ej angiven)'. - Extraherade package-scope-hjälparna initialIndex, selectedAccountClass och selectedNormalBalanceSide samt EditorForm, med enhetstester som täcker mappningen i båda riktningarna. - Granska-kryssrutan rensas nu automatiskt när ett tidigare oklassat konto klassificeras, i linje med updateAccountClassification (MCP). - Lade till skärmdump av dialogen för konto 8990 med platshållaren vald.
- Granska-kryssrutan rensas nu när kontot blir fullt klassificerat (klass OCH sida valda), högst en gång, baserat på initialt oklassificerat tillstånd så att även okända lagrade värden täcks. Användaren kan kryssa i flaggan igen utan att dialogen åsidosätter. - Tester för flaggrensning: en gång, inte för redan klassificerade. - java.awt.headless satt globalt på test-tasken i build.gradle i stället för i en statisk block per testklass. - VatCodeChoice är nu package-scope så EditorForms fälttyp kan namnges. - Skärmdump flyttad ut ur repot (läggs till som bilaga i PR-beskrivningen).
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.
Problem
Fixes #121.
Opening Redigera konto for an account with
account_class = null/normal_balance_side = null(e.g. SIE-imported accounts flagged for review, such as 8990 "Resultat") showed Klass = Tillgång and Normal = Debet. Those values are not stored; pressing OK silently saved the account as ASSET/DEBIT, moving a result account into the balance sheet as an asset and changing the year's result without any warning.Cause:
indexOf(null)returns -1, whichMath.max(0, …)turned into index 0 (ASSET / DEBIT).Review follow-up (commit 2): the first fix kept the
Math.max(0, …)clamp, which — with the new placeholder at index 0 — still mapped null to ASSET/DEBIT (index 1). The selection now usesinitialIndex(values, value) = indexOf(value) + 1, so null and unknown stored values map to the "(not specified)" placeholder.Fix
In
AccountEditorDialog:AccountService.updateAccount.updateAccountClassification(the MCP path). The user can re-tick it afterwards without the dialog overriding them. Accounts that were already classified keep the flag untouched when their class changes.The index mapping lives in small package-scope helpers (
initialIndex,selectedAccountClass,selectedNormalBalanceSide) alongside an extractedEditorForm, covered byAccountEditorDialogTest.New i18n keys in
messages.propertiesandmessages_sv.properties.Behaviour change worth noting
An unclassified account can no longer be saved from this dialog until it has a class and normal side — so toggling only Aktiv/Granskning or setting SRU codes on an unclassified account now requires classifying it first. This is consistent with the service layer, which has always rejected null class/side.
Verification
app/src/test/groovy/unit/se/alipsa/accounting/ui/AccountEditorDialogTest.groovycover the index mapping (null/unknown → placeholder, known → own entry, placeholder → null), end-to-endEditorFormconstruction for unclassified and classified accounts, and the review-flag auto-clear (including the not-twice and classified-account cases)../gradlew spotlessApply,./gradlew codenarcMain,./gradlew codenarcTest, and full./gradlew build(compilation, all tests, Spotless, CodeNarc) pass.UnusedPrivateMethodRuleexception for the pre-existingBackgroundTaskRunner.groovy; it does not fail the task and is unrelated to this change.Review follow-up
isComplete(EditorForm)helper, with tests for missing class, missing normal side, and a complete classification. VAT preservation and incompatibility are also covered by unit tests.Screenshots
Sample account 8990 (“Resultat”) with a stored
OUTPUT_25VAT code, shown before and after choosing Income/Credit in the dialog:Test suite setting
app/build.gradlesetssystemProperty 'java.awt.headless', 'true'for the whole test task. This lets Swing component tests run in headless CI; they useSwingUtilities.invokeAndWaitand do not open dialogs.