Skip to content

Commit 812fccb

Browse files
committed
fix: add: don't restart from posting 1 when the final balance check fails
When the user finishes entering postings, if the resulting transaction fails to balance or satisfy balance assertions, we now just re-prompt for another posting, rather than discarding the postings entered so far and starting again at posting 1. This is most visible when entering balance assignments.
1 parent f6a9b7d commit 812fccb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

  • hledger/Hledger/Cli/Commands

hledger/Hledger/Cli/Commands/Add.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,8 @@ transactionWizard previnput state@AddState{..} stack@(currentStage : _) = case c
227227
transactionWizard previnput state (Confirm t' : stack)
228228
Left err -> do
229229
liftIO (hPutStrLn stderr $ "\n" ++ (capitalize err) ++ ", please re-enter.")
230-
let notFirstEnterPost stage = case stage of
231-
GetPosting _ Nothing -> False
232-
_ -> True
233-
transactionWizard previnput state{asPostings=[], asInferredAmounts=[]} (dropWhile notFirstEnterPost stack)
230+
-- Back up one step: re-prompt for the next account, keeping postings entered so far.
231+
transactionWizard previnput state (GetAccount txndata : drop 1 stack)
234232

235233
GetAccount txndata -> accountWizard previnput state >>= \case
236234
Just account

0 commit comments

Comments
 (0)