mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
fix: bin: Get scripts compiling with current hledger-lib.
This commit is contained in:
parent
db45b13249
commit
8fcdc22a45
@ -43,4 +43,4 @@ main = do
|
||||
opts@CliOpts{reportspec_=rspec} <- getHledgerCliOpts' cmdmode args
|
||||
d <- getCurrentDay
|
||||
(report,j) <- withJournalDo opts $ \j -> return (multiBalanceReport rspec j, j)
|
||||
return (rsOpts rspec,j,report)
|
||||
return (_rsReportOpts rspec,j,report)
|
||||
|
@ -116,6 +116,7 @@ import qualified Hledger.Data as H
|
||||
import qualified Hledger.Query as H
|
||||
import qualified Hledger.Read as H
|
||||
import qualified Hledger.Utils.Parse as H
|
||||
import Lens.Micro (set)
|
||||
import Options.Applicative
|
||||
import "base-compat" Prelude.Compat ((<>))
|
||||
import System.Exit (exitFailure)
|
||||
@ -127,7 +128,7 @@ main :: IO ()
|
||||
main = do
|
||||
opts <- execParser args
|
||||
journalFile <- maybe H.defaultJournalPath pure (file opts)
|
||||
ejournal <- H.readJournalFile H.definputopts{H.ignore_assertions_=ignoreAssertions opts} journalFile
|
||||
ejournal <- H.readJournalFile (set H.ignore_assertions (ignoreAssertions opts) H.definputopts) journalFile
|
||||
case ejournal of
|
||||
Right j -> do
|
||||
(journal, starting) <- fixupJournal opts j
|
||||
@ -219,14 +220,14 @@ checkAssertion accounts = checkAssertion'
|
||||
evaluate (Account account) =
|
||||
fromMaybe H.nullmixedamt $ lookup account accounts
|
||||
evaluate (AccountNested account) =
|
||||
maSum [m | (a,m) <- accounts, account == a || (a <> pack ":") `isPrefixOf` account]
|
||||
H.maSum [m | (a,m) <- accounts, account == a || (a <> pack ":") `isPrefixOf` account]
|
||||
evaluate (Amount amount) = H.mixed [amount]
|
||||
|
||||
-- Add missing amounts (with 0 value), normalise, throw away style
|
||||
-- information, and sort by commodity name.
|
||||
fixup m1 m2 =
|
||||
let m = H.mixed $ amounts m1 ++ [m_ { H.aquantity = 0 } | m_ <- amounts m2]
|
||||
as = amounts m
|
||||
let m = H.mixed $ H.amounts m1 ++ [m_ { H.aquantity = 0 } | m_ <- H.amounts m2]
|
||||
as = H.amounts m
|
||||
in H.mixed $ sortOn H.acommodity . map (\a -> a { H.astyle = H.amountstyle }) $ as
|
||||
|
||||
-- | Check if an account name is mentioned in an assertion.
|
||||
@ -280,7 +281,7 @@ closingBalances' postings =
|
||||
|
||||
-- | Add balances in matching accounts.
|
||||
addAccounts :: [(H.AccountName, H.MixedAmount)] -> [(H.AccountName, H.MixedAmount)] -> [(H.AccountName, H.MixedAmount)]
|
||||
addAccounts as1 as2 = [ (a, a1 `maPlus` a2)
|
||||
addAccounts as1 as2 = [ (a, a1 `H.maPlus` a2)
|
||||
| a <- nub (map fst as1 ++ map fst as2)
|
||||
, let a1 = fromMaybe H.nullmixedamt $ lookup a as1
|
||||
, let a2 = fromMaybe H.nullmixedamt $ lookup a as2
|
||||
|
@ -65,7 +65,7 @@ main = do
|
||||
(_,report1) <- mbReport report1args
|
||||
(rspec2,report2) <- mbReport report2args
|
||||
let merged = appendReports report1 report2
|
||||
TL.putStrLn $ multiBalanceReportAsText (rsOpts rspec2) merged
|
||||
TL.putStrLn $ multiBalanceReportAsText (_rsReportOpts rspec2) merged
|
||||
where
|
||||
mbReport args = do
|
||||
opts@CliOpts{reportspec_=rspec} <- getHledgerCliOpts' cmdmode args
|
||||
|
@ -57,21 +57,21 @@ _FLAGS
|
||||
main :: IO ()
|
||||
main = do
|
||||
copts@CliOpts{reportspec_=rspec, rawopts_} <- getHledgerCliOpts cmdmode
|
||||
let ropts = rsOpts rspec
|
||||
let ropts = _rsReportOpts rspec
|
||||
copts' = copts{
|
||||
-- One of our postings will probably have a missing amount; this ensures it's
|
||||
-- explicit on all the others.
|
||||
rawopts_ = setboolopt "explicit" rawopts_
|
||||
-- Don't let our ACCT argument be interpreted as a query by print
|
||||
,reportspec_ = rspec{rsOpts=ropts{querystring_=[]}}
|
||||
,reportspec_ = rspec{_rsReportOpts=ropts{querystring_=[]}}
|
||||
}
|
||||
withJournalDo copts' $ \j -> do
|
||||
today <- getCurrentDay
|
||||
let
|
||||
menddate = reportPeriodLastDay rspec
|
||||
q = rsQuery rspec
|
||||
q = _rsQuery rspec
|
||||
acct = headDef (error' "Please provide an account name argument") $ querystring_ ropts
|
||||
pr = postingsReport rspec{rsQuery = And [Acct $ accountNameToAccountRegexCI acct, q]} j
|
||||
pr = postingsReport rspec{_rsQuery = And [Acct $ accountNameToAccountRegexCI acct, q]} j
|
||||
|
||||
-- dates of postings to acct (in report)
|
||||
pdates = map (postingDate . fourth5) pr
|
||||
|
@ -33,7 +33,7 @@ main = do
|
||||
\j -> do
|
||||
d <- getCurrentDay
|
||||
let
|
||||
q = rsQuery rspec
|
||||
q = _rsQuery rspec
|
||||
ts = filter (q `matchesTransaction`) $ jtxns $ journalApplyValuationFromOpts rspec j
|
||||
ts' = map transactionSwapDates ts
|
||||
mapM_ (T.putStrLn . showTransaction) ts'
|
||||
|
Loading…
Reference in New Issue
Block a user