Ignore assertions during add with -I

This commit is contained in:
Michael Rees 2025-05-29 10:28:36 -05:00 committed by Simon Michael
parent 636860363f
commit b042115692
3 changed files with 16 additions and 3 deletions

View File

@ -155,7 +155,7 @@ transactionCheckAssertions bopts j t =
if (ignore_assertions_ bopts) || noassertions t then Right t else do
j' <- journalStyleAmounts j
let newtxns = sortOn tdate (jtxns j' ++ [ t ])
case journalBalanceTransactions defbalancingopts j'{jtxns = newtxns} of
case journalBalanceTransactions bopts j'{jtxns = newtxns} of
Right _ -> Right t
Left e -> Left e
where

View File

@ -248,7 +248,8 @@ confirmedTransactionWizard prevInput es@EntryState{..} stack@(currentStage : _)
dummytxn = nulltransaction{tpostings = esPostings ++ [p, post "" missingamt]
,tdate = txnDate txnParams
,tdescription = txnDesc txnParams }
validated = balanceTransaction defbalancingopts dummytxn >>= transactionCheckAssertions defbalancingopts esJournal
bopts = balancingopts_ (inputopts_ esOpts)
validated = balanceTransaction bopts dummytxn >>= transactionCheckAssertions bopts esJournal
case validated of
Left err -> do
liftIO (hPutStrLn stderr err)

View File

@ -220,8 +220,20 @@ $ rm -f nosuch.journal; hledger -f nosuch.journal add; rm -f nosuch.journal
> /\(a\)[[:space:]]+3 = 3 ; date:2025-05-01/
>2 //
## 16. Verify that -I skips assertions
<
2025-05-10
x
a
10 USD = 20 USD
b
-10 USD
.
$ rm -f nosuch.journal; hledger -f nosuch.journal -I add; rm -f nosuch.journal
> /Save this transaction to the journal/
>2 //
## 16. shouldn't add decimals if there aren't any
## 17. shouldn't add decimals if there aren't any
## printf '\n\na\n1\nb\n' | hledger -f /dev/null add
# <
#