From 307f723b0a4ab48beb9730949e35c5e9fcc51463 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 9 May 2022 08:12:45 -1000 Subject: [PATCH] lib: simpler, more consistent names for check functions API changes: journalCheckAccountsDeclared journalCheckCommoditiesDeclared journalCheckPayeesDeclared -> journalCheckAccounts journalCheckCommodities journalCheckPayees --- hledger-lib/Hledger/Read/Checks.hs | 20 ++++++++++---------- hledger-lib/Hledger/Read/Common.hs | 6 +++--- hledger/Hledger/Cli/Commands/Check.hs | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hledger-lib/Hledger/Read/Checks.hs b/hledger-lib/Hledger/Read/Checks.hs index 986781910..7cd2c123d 100644 --- a/hledger-lib/Hledger/Read/Checks.hs +++ b/hledger-lib/Hledger/Read/Checks.hs @@ -8,9 +8,9 @@ others can be called only via the check command. {-# LANGUAGE NamedFieldPuns #-} module Hledger.Read.Checks ( - journalCheckAccountsDeclared, - journalCheckCommoditiesDeclared, - journalCheckPayeesDeclared, + journalCheckAccounts, + journalCheckCommodities, + journalCheckPayees, module Hledger.Read.Checks.Ordereddates, module Hledger.Read.Checks.Uniqueleafnames, ) @@ -29,10 +29,10 @@ import Hledger.Read.Checks.Ordereddates import Hledger.Read.Checks.Uniqueleafnames import Hledger.Read.Error --- | Check that all the journal's postings are to accounts declared with +-- | Check that all the journal's postings are to accounts with -- account directives, returning an error message otherwise. -journalCheckAccountsDeclared :: Journal -> Either String () -journalCheckAccountsDeclared j = mapM_ checkacct (journalPostings j) +journalCheckAccounts :: Journal -> Either String () +journalCheckAccounts j = mapM_ checkacct (journalPostings j) where checkacct p@Posting{paccount=a} | a `elem` journalAccountNamesDeclared j = Right () @@ -49,8 +49,8 @@ journalCheckAccountsDeclared j = mapM_ checkacct (journalPostings j) -- | Check that all the commodities used in this journal's postings have been declared -- by commodity directives, returning an error message otherwise. -journalCheckCommoditiesDeclared :: Journal -> Either String () -journalCheckCommoditiesDeclared j = mapM_ checkcommodities (journalPostings j) +journalCheckCommodities :: Journal -> Either String () +journalCheckCommodities j = mapM_ checkcommodities (journalPostings j) where checkcommodities p = case findundeclaredcomm p of @@ -109,8 +109,8 @@ journalCheckCommoditiesDeclared j = mapM_ checkcommodities (journalPostings j) -- | Check that all the journal's transactions have payees declared with -- payee directives, returning an error message otherwise. -journalCheckPayeesDeclared :: Journal -> Either String () -journalCheckPayeesDeclared j = mapM_ checkpayee (jtxns j) +journalCheckPayees :: Journal -> Either String () +journalCheckPayees j = mapM_ checkpayee (jtxns j) where checkpayee t | payee `elem` journalPayeesDeclared j = Right () diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 0f423a1a4..f14fdb3a1 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -148,7 +148,7 @@ import Hledger.Query (Query(..), filterQuery, parseQueryTerm, queryEndDate, quer import Hledger.Reports.ReportOptions (ReportOpts(..), queryFromFlags, rawOptsToReportOpts) import Hledger.Utils import Hledger.Read.InputOptions -import Hledger.Read.Checks (journalCheckAccountsDeclared, journalCheckCommoditiesDeclared) +import Hledger.Read.Checks (journalCheckAccounts, journalCheckCommodities) --- ** doctest setup -- $setup @@ -324,8 +324,8 @@ journalFinalise iopts@InputOpts{auto_,infer_equity_,balancingopts_,strict_,_ioDa <&> (if infer_equity_ then journalAddInferredEquityPostings else id) -- Add inferred equity postings, after balancing transactions and generating auto postings <&> journalInferMarketPricesFromTransactions -- infer market prices from commodity-exchanging transactions when strict_ $ do - journalCheckAccountsDeclared j -- If in strict mode, check all postings are to declared accounts - journalCheckCommoditiesDeclared j -- and using declared commodities + journalCheckAccounts j -- If in strict mode, check all postings are to declared accounts + journalCheckCommodities j -- and using declared commodities return j -- | Apply any auto posting rules to generate extra postings on this journal's transactions. diff --git a/hledger/Hledger/Cli/Commands/Check.hs b/hledger/Hledger/Cli/Commands/Check.hs index 666705166..fb67fd5c9 100644 --- a/hledger/Hledger/Cli/Commands/Check.hs +++ b/hledger/Hledger/Cli/Commands/Check.hs @@ -98,10 +98,10 @@ runCheck :: CliOpts -> Journal -> (Check,[String]) -> IO () runCheck CliOpts{reportspec_=ReportSpec{_rsReportOpts=ropts}} j (check,_) = do let results = case check of - Accounts -> journalCheckAccountsDeclared j - Commodities -> journalCheckCommoditiesDeclared j + Accounts -> journalCheckAccounts j + Commodities -> journalCheckCommodities j Ordereddates -> journalCheckOrdereddates (whichDate ropts) j - Payees -> journalCheckPayeesDeclared j + Payees -> journalCheckPayees j Uniqueleafnames -> journalCheckUniqueleafnames j -- the other checks have been done earlier during withJournalDo _ -> Right ()