Merge branch 'master' into installer
This commit is contained in:
commit
efc75db8d8
@ -19,6 +19,7 @@ module Hledger.Query (
|
||||
-- * accessors
|
||||
queryIsNull,
|
||||
queryIsAcct,
|
||||
queryIsAmt,
|
||||
queryIsDepth,
|
||||
queryIsDate,
|
||||
queryIsDate2,
|
||||
@ -41,6 +42,8 @@ module Hledger.Query (
|
||||
matchesAccount,
|
||||
matchesMixedAmount,
|
||||
matchesAmount,
|
||||
matchesCommodity,
|
||||
matchesMarketPrice,
|
||||
words'',
|
||||
-- * tests
|
||||
tests_Hledger_Query
|
||||
@ -481,6 +484,10 @@ queryIsAcct :: Query -> Bool
|
||||
queryIsAcct (Acct _) = True
|
||||
queryIsAcct _ = False
|
||||
|
||||
queryIsAmt :: Query -> Bool
|
||||
queryIsAmt (Amt _ _) = True
|
||||
queryIsAmt _ = False
|
||||
|
||||
queryIsSym :: Query -> Bool
|
||||
queryIsSym (Sym _) = True
|
||||
queryIsSym _ = False
|
||||
@ -530,33 +537,27 @@ queryEndDate _ _ = Nothing
|
||||
queryTermDateSpan (Date span) = Just span
|
||||
queryTermDateSpan _ = Nothing
|
||||
|
||||
-- | What date span (or secondary date span) does this query specify ?
|
||||
-- For OR expressions, use the widest possible span. NOT is ignored.
|
||||
-- | What date span (or with a true argument, what secondary date span) does this query specify ?
|
||||
-- OR clauses specifying multiple spans return their union (the span enclosing all of them).
|
||||
-- AND clauses specifying multiple spans return their intersection.
|
||||
-- NOT clauses are ignored.
|
||||
queryDateSpan :: Bool -> Query -> DateSpan
|
||||
queryDateSpan secondary q = spansUnion $ queryDateSpans secondary q
|
||||
queryDateSpan secondary (Or qs) = spansUnion $ map (queryDateSpan secondary) qs
|
||||
queryDateSpan secondary (And qs) = spansIntersect $ map (queryDateSpan secondary) qs
|
||||
queryDateSpan False (Date span) = span
|
||||
queryDateSpan True (Date2 span) = span
|
||||
queryDateSpan _ _ = nulldatespan
|
||||
|
||||
-- | Extract all date (or secondary date) spans specified in this query.
|
||||
-- NOT is ignored.
|
||||
queryDateSpans :: Bool -> Query -> [DateSpan]
|
||||
queryDateSpans secondary (Or qs) = concatMap (queryDateSpans secondary) qs
|
||||
queryDateSpans secondary (And qs) = concatMap (queryDateSpans secondary) qs
|
||||
queryDateSpans False (Date span) = [span]
|
||||
queryDateSpans True (Date2 span) = [span]
|
||||
queryDateSpans _ _ = []
|
||||
|
||||
-- | What date span (or secondary date span) does this query specify ?
|
||||
-- For OR expressions, use the widest possible span. NOT is ignored.
|
||||
-- | What date span does this query specify, treating primary and secondary dates as equivalent ?
|
||||
-- OR clauses specifying multiple spans return their union (the span enclosing all of them).
|
||||
-- AND clauses specifying multiple spans return their intersection.
|
||||
-- NOT clauses are ignored.
|
||||
queryDateSpan' :: Query -> DateSpan
|
||||
queryDateSpan' q = spansUnion $ queryDateSpans' q
|
||||
|
||||
-- | Extract all date (or secondary date) spans specified in this query.
|
||||
-- NOT is ignored.
|
||||
queryDateSpans' :: Query -> [DateSpan]
|
||||
queryDateSpans' (Or qs) = concatMap queryDateSpans' qs
|
||||
queryDateSpans' (And qs) = concatMap queryDateSpans' qs
|
||||
queryDateSpans' (Date span) = [span]
|
||||
queryDateSpans' (Date2 span) = [span]
|
||||
queryDateSpans' _ = []
|
||||
queryDateSpan' (Or qs) = spansUnion $ map queryDateSpan' qs
|
||||
queryDateSpan' (And qs) = spansIntersect $ map queryDateSpan' qs
|
||||
queryDateSpan' (Date span) = span
|
||||
queryDateSpan' (Date2 span) = span
|
||||
queryDateSpan' _ = nulldatespan
|
||||
|
||||
-- | What is the earliest of these dates, where Nothing is latest ?
|
||||
earliestMaybeDate :: [Maybe Day] -> Maybe Day
|
||||
@ -641,6 +642,10 @@ matchesMixedAmount :: Query -> MixedAmount -> Bool
|
||||
matchesMixedAmount q (Mixed []) = q `matchesAmount` nullamt
|
||||
matchesMixedAmount q (Mixed as) = any (q `matchesAmount`) as
|
||||
|
||||
matchesCommodity :: Query -> CommoditySymbol -> Bool
|
||||
matchesCommodity (Sym r) s = regexMatchesCI ("^" ++ r ++ "$") (T.unpack s)
|
||||
matchesCommodity _ _ = True
|
||||
|
||||
-- | Does the match expression match this (simple) amount ?
|
||||
matchesAmount :: Query -> Amount -> Bool
|
||||
matchesAmount (Not q) a = not $ q `matchesAmount` a
|
||||
@ -650,7 +655,7 @@ matchesAmount (Or qs) a = any (`matchesAmount` a) qs
|
||||
matchesAmount (And qs) a = all (`matchesAmount` a) qs
|
||||
--
|
||||
matchesAmount (Amt ord n) a = compareAmount ord n a
|
||||
matchesAmount (Sym r) a = regexMatchesCI ("^" ++ r ++ "$") $ T.unpack $ acommodity a
|
||||
matchesAmount (Sym r) a = matchesCommodity (Sym r) (acommodity a)
|
||||
--
|
||||
matchesAmount _ _ = True
|
||||
|
||||
@ -694,7 +699,7 @@ matchesPosting q@(Amt _ _) Posting{pamount=amt} = q `matchesMixedAmount` amt
|
||||
-- matchesPosting (Empty False) Posting{pamount=a} = True
|
||||
-- matchesPosting (Empty True) Posting{pamount=a} = isZeroMixedAmount a
|
||||
matchesPosting (Empty _) _ = True
|
||||
matchesPosting (Sym r) Posting{pamount=Mixed as} = any (regexMatchesCI $ "^" ++ r ++ "$") $ map (T.unpack . acommodity) as
|
||||
matchesPosting (Sym r) Posting{pamount=Mixed as} = any (matchesCommodity (Sym r)) $ map acommodity as
|
||||
matchesPosting (Tag n v) p = case (n, v) of
|
||||
("payee", Just v) -> maybe False (regexMatchesCI v . T.unpack . transactionPayee) $ ptransaction p
|
||||
("note", Just v) -> maybe False (regexMatchesCI v . T.unpack . transactionNote) $ ptransaction p
|
||||
@ -777,6 +782,18 @@ matchesTags namepat valuepat = not . null . filter (match namepat valuepat)
|
||||
match npat Nothing (n,_) = regexMatchesCI npat (T.unpack n) -- XXX
|
||||
match npat (Just vpat) (n,v) = regexMatchesCI npat (T.unpack n) && regexMatchesCI vpat (T.unpack v)
|
||||
|
||||
-- | Does the query match this market price ?
|
||||
matchesMarketPrice :: Query -> MarketPrice -> Bool
|
||||
matchesMarketPrice (None) _ = False
|
||||
matchesMarketPrice (Not q) p = not $ matchesMarketPrice q p
|
||||
matchesMarketPrice (Or qs) p = any (`matchesMarketPrice` p) qs
|
||||
matchesMarketPrice (And qs) p = all (`matchesMarketPrice` p) qs
|
||||
matchesMarketPrice q@(Amt _ _) p = matchesAmount q (mpamount p)
|
||||
matchesMarketPrice q@(Sym _) p = matchesCommodity q (mpcommodity p)
|
||||
matchesMarketPrice (Date span) p = spanContainsDate span (mpdate p)
|
||||
matchesMarketPrice _ _ = True
|
||||
|
||||
|
||||
-- tests
|
||||
|
||||
tests_Hledger_Query :: Test
|
||||
|
||||
@ -17,28 +17,34 @@ import System.Console.CmdArgs.Explicit
|
||||
|
||||
pricesmode = hledgerCommandMode
|
||||
[here| prices
|
||||
Print all market prices from the journal.
|
||||
Print market price directives from the journal.
|
||||
With --costs, also print synthetic market prices based on transaction prices.
|
||||
With --inverted-costs, also print inverse prices based on transaction prices.
|
||||
Prices (and postings providing prices) can be filtered by a query.
|
||||
|]
|
||||
[flagNone ["costs"] (setboolopt "costs") "print transaction prices from postings"
|
||||
,flagNone ["inverted-costs"] (setboolopt "inverted-costs") "print transaction inverted prices from postings also"]
|
||||
[generalflagsgroup1]
|
||||
[]
|
||||
([], Nothing)
|
||||
([], Just $ argsFlag "[QUERY]")
|
||||
|
||||
-- XXX the original hledger-prices script always ignored assertions
|
||||
prices opts j = do
|
||||
-- XXX the original hledger-prices script always ignored assertions
|
||||
let cprices = concatMap postingCosts . allPostings $ j
|
||||
icprices = concatMap postingCosts . mapAmount invertPrice . allPostings $ j
|
||||
printPrices = mapM_ (putStrLn . showPrice)
|
||||
forBoolOpt opt | boolopt opt $ rawopts_ opts = id
|
||||
| otherwise = const []
|
||||
allPrices = sortOn mpdate . concat $
|
||||
[ jmarketprices j
|
||||
, forBoolOpt "costs" cprices
|
||||
, forBoolOpt "inverted-costs" icprices
|
||||
]
|
||||
|
||||
printPrices allPrices
|
||||
d <- getCurrentDay
|
||||
let
|
||||
q = queryFromOpts d (reportopts_ opts)
|
||||
ps = filter (matchesPosting q) $ allPostings j
|
||||
mprices = jmarketprices j
|
||||
cprices = concatMap postingCosts ps
|
||||
icprices = concatMap postingCosts . mapAmount invertPrice $ ps
|
||||
allprices = mprices ++ ifBoolOpt "costs" cprices ++ ifBoolOpt "inverted-costs" icprices
|
||||
mapM_ (putStrLn . showPrice) $
|
||||
sortOn mpdate $
|
||||
filter (matchesMarketPrice q) $
|
||||
allprices
|
||||
where
|
||||
ifBoolOpt opt | boolopt opt $ rawopts_ opts = id
|
||||
| otherwise = const []
|
||||
|
||||
showPrice :: MarketPrice -> String
|
||||
showPrice mp = unwords ["P", show $ mpdate mp, T.unpack . quoteCommoditySymbolIfNeeded $ mpcommodity mp, showAmountWithZeroCommodity $ mpamount mp]
|
||||
|
||||
@ -2426,7 +2426,12 @@ This command also supports output destination and output format
|
||||
selection.
|
||||
.SS prices
|
||||
.PP
|
||||
Print all market prices from the journal.
|
||||
Print market price directives from the journal.
|
||||
With \[en]costs, also print synthetic market prices based on transaction
|
||||
prices.
|
||||
With \[en]inverted\-costs, also print inverse prices based on
|
||||
transaction prices.
|
||||
Prices (and postings providing prices) can be filtered by a query.
|
||||
.SS print
|
||||
.PP
|
||||
Show transactions from the journal.
|
||||
|
||||
@ -1921,7 +1921,10 @@ File: hledger.info, Node: prices, Next: print, Prev: incomestatement, Up: CO
|
||||
4.14 prices
|
||||
===========
|
||||
|
||||
Print all market prices from the journal.
|
||||
Print market price directives from the journal. With -costs, also print
|
||||
synthetic market prices based on transaction prices. With
|
||||
-inverted-costs, also print inverse prices based on transaction prices.
|
||||
Prices (and postings providing prices) can be filtered by a query.
|
||||
|
||||
|
||||
File: hledger.info, Node: print, Next: print-unique, Prev: prices, Up: COMMANDS
|
||||
@ -2520,51 +2523,51 @@ Node: incomestatement61310
|
||||
Ref: #incomestatement61444
|
||||
Node: prices63848
|
||||
Ref: #prices63963
|
||||
Node: print64006
|
||||
Ref: #print64116
|
||||
Node: print-unique69010
|
||||
Ref: #print-unique69136
|
||||
Node: register69204
|
||||
Ref: #register69331
|
||||
Node: Custom register output73832
|
||||
Ref: #custom-register-output73961
|
||||
Node: register-match75191
|
||||
Ref: #register-match75325
|
||||
Node: rewrite75508
|
||||
Ref: #rewrite75625
|
||||
Node: stats75694
|
||||
Ref: #stats75797
|
||||
Node: tags76667
|
||||
Ref: #tags76765
|
||||
Node: test77001
|
||||
Ref: #test77085
|
||||
Node: ADD-ON COMMANDS77453
|
||||
Ref: #add-on-commands77563
|
||||
Node: Official add-ons78850
|
||||
Ref: #official-add-ons78990
|
||||
Node: api79077
|
||||
Ref: #api79166
|
||||
Node: ui79218
|
||||
Ref: #ui79317
|
||||
Node: web79375
|
||||
Ref: #web79464
|
||||
Node: Third party add-ons79510
|
||||
Ref: #third-party-add-ons79685
|
||||
Node: diff79820
|
||||
Ref: #diff79917
|
||||
Node: iadd80016
|
||||
Ref: #iadd80130
|
||||
Node: interest80213
|
||||
Ref: #interest80334
|
||||
Node: irr80429
|
||||
Ref: #irr80527
|
||||
Node: Experimental add-ons80605
|
||||
Ref: #experimental-add-ons80757
|
||||
Node: autosync81037
|
||||
Ref: #autosync81148
|
||||
Node: chart81387
|
||||
Ref: #chart81506
|
||||
Node: check81577
|
||||
Ref: #check81679
|
||||
Node: print64235
|
||||
Ref: #print64345
|
||||
Node: print-unique69239
|
||||
Ref: #print-unique69365
|
||||
Node: register69433
|
||||
Ref: #register69560
|
||||
Node: Custom register output74061
|
||||
Ref: #custom-register-output74190
|
||||
Node: register-match75420
|
||||
Ref: #register-match75554
|
||||
Node: rewrite75737
|
||||
Ref: #rewrite75854
|
||||
Node: stats75923
|
||||
Ref: #stats76026
|
||||
Node: tags76896
|
||||
Ref: #tags76994
|
||||
Node: test77230
|
||||
Ref: #test77314
|
||||
Node: ADD-ON COMMANDS77682
|
||||
Ref: #add-on-commands77792
|
||||
Node: Official add-ons79079
|
||||
Ref: #official-add-ons79219
|
||||
Node: api79306
|
||||
Ref: #api79395
|
||||
Node: ui79447
|
||||
Ref: #ui79546
|
||||
Node: web79604
|
||||
Ref: #web79693
|
||||
Node: Third party add-ons79739
|
||||
Ref: #third-party-add-ons79914
|
||||
Node: diff80049
|
||||
Ref: #diff80146
|
||||
Node: iadd80245
|
||||
Ref: #iadd80359
|
||||
Node: interest80442
|
||||
Ref: #interest80563
|
||||
Node: irr80658
|
||||
Ref: #irr80756
|
||||
Node: Experimental add-ons80834
|
||||
Ref: #experimental-add-ons80986
|
||||
Node: autosync81266
|
||||
Ref: #autosync81377
|
||||
Node: chart81616
|
||||
Ref: #chart81735
|
||||
Node: check81806
|
||||
Ref: #check81908
|
||||
|
||||
End Tag Table
|
||||
|
||||
@ -1727,13 +1727,16 @@ COMMANDS
|
||||
tion.
|
||||
|
||||
prices
|
||||
Print all market prices from the journal.
|
||||
Print market price directives from the journal. With -costs, also
|
||||
print synthetic market prices based on transaction prices. With
|
||||
-inverted-costs, also print inverse prices based on transaction prices.
|
||||
Prices (and postings providing prices) can be filtered by a query.
|
||||
|
||||
print
|
||||
Show transactions from the journal. Aliases: p, txns.
|
||||
|
||||
-m STR --match=STR
|
||||
show the transaction whose description is most similar to STR,
|
||||
show the transaction whose description is most similar to STR,
|
||||
and is most recent
|
||||
|
||||
--new show only newer-dated transactions added in each file since last
|
||||
@ -1746,7 +1749,7 @@ COMMANDS
|
||||
select the output format. Supported formats: txt, csv.
|
||||
|
||||
-o FILE --output-file=FILE
|
||||
write output to FILE. A file extension matching one of the
|
||||
write output to FILE. A file extension matching one of the
|
||||
above formats selects that format.
|
||||
|
||||
$ hledger print
|
||||
@ -1777,39 +1780,39 @@ COMMANDS
|
||||
it does not preserve directives or inter-transaction comments
|
||||
|
||||
Normally, the journal entry's explicit or implicit amount style is pre-
|
||||
served. Ie when an amount is omitted in the journal, it will be omit-
|
||||
ted in the output. You can use the -x/--explicit flag to make all
|
||||
served. Ie when an amount is omitted in the journal, it will be omit-
|
||||
ted in the output. You can use the -x/--explicit flag to make all
|
||||
amounts explicit, which can be useful for troubleshooting or for making
|
||||
your journal more readable and robust against data entry errors. Note,
|
||||
-x will cause postings with a multi-commodity amount (these can arise
|
||||
when a multi-commodity transaction has an implicit amount) will be
|
||||
split into multiple single-commodity postings, for valid journal out-
|
||||
-x will cause postings with a multi-commodity amount (these can arise
|
||||
when a multi-commodity transaction has an implicit amount) will be
|
||||
split into multiple single-commodity postings, for valid journal out-
|
||||
put.
|
||||
|
||||
With -B/--cost, amounts with transaction prices are converted to cost
|
||||
With -B/--cost, amounts with transaction prices are converted to cost
|
||||
using that price. This can be used for troubleshooting.
|
||||
|
||||
With -m/--match and a STR argument, print will show at most one trans-
|
||||
action: the one one whose description is most similar to STR, and is
|
||||
most recent. STR should contain at least two characters. If there is
|
||||
With -m/--match and a STR argument, print will show at most one trans-
|
||||
action: the one one whose description is most similar to STR, and is
|
||||
most recent. STR should contain at least two characters. If there is
|
||||
no similar-enough match, no transaction will be shown.
|
||||
|
||||
With --new, for each FILE being read, hledger reads (and writes) a spe-
|
||||
cial state file (.latest.FILE in the same directory), containing the
|
||||
latest transaction date(s) that were seen last time FILE was read.
|
||||
When this file is found, only transactions with newer dates (and new
|
||||
transactions on the latest date) are printed. This is useful for
|
||||
ignoring already-seen entries in import data, such as downloaded CSV
|
||||
cial state file (.latest.FILE in the same directory), containing the
|
||||
latest transaction date(s) that were seen last time FILE was read.
|
||||
When this file is found, only transactions with newer dates (and new
|
||||
transactions on the latest date) are printed. This is useful for
|
||||
ignoring already-seen entries in import data, such as downloaded CSV
|
||||
files. Eg:
|
||||
|
||||
$ hledger -f bank1.csv print --new
|
||||
# shows transactions added since last print --new on this file
|
||||
|
||||
This assumes that transactions added to FILE always have same or
|
||||
increasing dates, and that transactions on the same day do not get
|
||||
This assumes that transactions added to FILE always have same or
|
||||
increasing dates, and that transactions on the same day do not get
|
||||
reordered. See also the import command.
|
||||
|
||||
This command also supports output destination and output format selec-
|
||||
This command also supports output destination and output format selec-
|
||||
tion. Here's an example of print's CSV output:
|
||||
|
||||
$ hledger print -Ocsv
|
||||
@ -1826,20 +1829,20 @@ COMMANDS
|
||||
"5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""
|
||||
"5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","",""
|
||||
|
||||
o There is one CSV record per posting, with the parent transaction's
|
||||
o There is one CSV record per posting, with the parent transaction's
|
||||
fields repeated.
|
||||
|
||||
o The "txnidx" (transaction index) field shows which postings belong to
|
||||
the same transaction. (This number might change if transactions are
|
||||
reordered within the file, files are parsed/included in a different
|
||||
the same transaction. (This number might change if transactions are
|
||||
reordered within the file, files are parsed/included in a different
|
||||
order, etc.)
|
||||
|
||||
o The amount is separated into "commodity" (the symbol) and "amount"
|
||||
o The amount is separated into "commodity" (the symbol) and "amount"
|
||||
(numeric quantity) fields.
|
||||
|
||||
o The numeric amount is repeated in either the "credit" or "debit" col-
|
||||
umn, for convenience. (Those names are not accurate in the account-
|
||||
ing sense; it just puts negative amounts under credit and zero or
|
||||
umn, for convenience. (Those names are not accurate in the account-
|
||||
ing sense; it just puts negative amounts under credit and zero or
|
||||
greater amounts under debit.)
|
||||
|
||||
print-unique
|
||||
@ -1852,7 +1855,7 @@ COMMANDS
|
||||
show running total from report start date (default)
|
||||
|
||||
-H --historical
|
||||
show historical running total/balance (includes postings before
|
||||
show historical running total/balance (includes postings before
|
||||
report start date)
|
||||
|
||||
-A --average
|
||||
@ -1863,18 +1866,18 @@ COMMANDS
|
||||
show postings' siblings instead
|
||||
|
||||
-w N --width=N
|
||||
set output width (default: terminal width or COLUMNS. -wN,M
|
||||
set output width (default: terminal width or COLUMNS. -wN,M
|
||||
sets description width as well)
|
||||
|
||||
-O FMT --output-format=FMT
|
||||
select the output format. Supported formats: txt, csv.
|
||||
|
||||
-o FILE --output-file=FILE
|
||||
write output to FILE. A file extension matching one of the
|
||||
write output to FILE. A file extension matching one of the
|
||||
above formats selects that format.
|
||||
|
||||
The register command displays postings, one per line, and their running
|
||||
total. This is typically used with a query selecting a particular
|
||||
total. This is typically used with a query selecting a particular
|
||||
account, to see that account's activity:
|
||||
|
||||
$ hledger register checking
|
||||
@ -1883,8 +1886,8 @@ COMMANDS
|
||||
2008/06/02 save assets:bank:checking $-1 $1
|
||||
2008/12/31 pay off assets:bank:checking $-1 0
|
||||
|
||||
The --historical/-H flag adds the balance from any undisplayed prior
|
||||
postings to the running total. This is useful when you want to see
|
||||
The --historical/-H flag adds the balance from any undisplayed prior
|
||||
postings to the running total. This is useful when you want to see
|
||||
only recent activity, with a historically accurate running balance:
|
||||
|
||||
$ hledger register checking -b 2008/6 --historical
|
||||
@ -1894,23 +1897,23 @@ COMMANDS
|
||||
|
||||
The --depth option limits the amount of sub-account detail displayed.
|
||||
|
||||
The --average/-A flag shows the running average posting amount instead
|
||||
The --average/-A flag shows the running average posting amount instead
|
||||
of the running total (so, the final number displayed is the average for
|
||||
the whole report period). This flag implies --empty (see below). It
|
||||
is affected by --historical. It works best when showing just one
|
||||
the whole report period). This flag implies --empty (see below). It
|
||||
is affected by --historical. It works best when showing just one
|
||||
account and one commodity.
|
||||
|
||||
The --related/-r flag shows the other postings in the transactions of
|
||||
The --related/-r flag shows the other postings in the transactions of
|
||||
the postings which would normally be shown.
|
||||
|
||||
With a reporting interval, register shows summary postings, one per
|
||||
With a reporting interval, register shows summary postings, one per
|
||||
interval, aggregating the postings to each account:
|
||||
|
||||
$ hledger register --monthly income
|
||||
2008/01 income:salary $-1 $-1
|
||||
2008/06 income:gifts $-1 $-2
|
||||
|
||||
Periods with no activity, and summary postings with a zero amount, are
|
||||
Periods with no activity, and summary postings with a zero amount, are
|
||||
not shown by default; use the --empty/-E flag to see them:
|
||||
|
||||
$ hledger register --monthly income -E
|
||||
@ -1927,7 +1930,7 @@ COMMANDS
|
||||
2008/11 0 $-2
|
||||
2008/12 0 $-2
|
||||
|
||||
Often, you'll want to see just one line per interval. The --depth
|
||||
Often, you'll want to see just one line per interval. The --depth
|
||||
option helps with this, causing subaccounts to be aggregated:
|
||||
|
||||
$ hledger register --monthly assets --depth 1h
|
||||
@ -1935,18 +1938,18 @@ COMMANDS
|
||||
2008/06 assets $-1 0
|
||||
2008/12 assets $-1 $-1
|
||||
|
||||
Note when using report intervals, if you specify start/end dates these
|
||||
will be adjusted outward if necessary to contain a whole number of
|
||||
intervals. This ensures that the first and last intervals are full
|
||||
Note when using report intervals, if you specify start/end dates these
|
||||
will be adjusted outward if necessary to contain a whole number of
|
||||
intervals. This ensures that the first and last intervals are full
|
||||
length and comparable to the others in the report.
|
||||
|
||||
Custom register output
|
||||
register uses the full terminal width by default, except on windows.
|
||||
You can override this by setting the COLUMNS environment variable (not
|
||||
register uses the full terminal width by default, except on windows.
|
||||
You can override this by setting the COLUMNS environment variable (not
|
||||
a bash shell variable) or by using the --width/-w option.
|
||||
|
||||
The description and account columns normally share the space equally
|
||||
(about half of (width - 40) each). You can adjust this by adding a
|
||||
The description and account columns normally share the space equally
|
||||
(about half of (width - 40) each). You can adjust this by adding a
|
||||
description width as part of -width's argument, comma-separated:
|
||||
--width W,D . Here's a diagram:
|
||||
|
||||
@ -1963,12 +1966,12 @@ COMMANDS
|
||||
$ hledger reg -w 100,40 # set overall width 100, description width 40
|
||||
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
|
||||
|
||||
This command also supports output destination and output format selec-
|
||||
This command also supports output destination and output format selec-
|
||||
tion.
|
||||
|
||||
register-match
|
||||
Print the one posting whose transaction description is closest to DESC,
|
||||
in the style of the register command. Helps ledger-autosync detect
|
||||
in the style of the register command. Helps ledger-autosync detect
|
||||
already-seen transactions when importing.
|
||||
|
||||
rewrite
|
||||
@ -1978,7 +1981,7 @@ COMMANDS
|
||||
Show some journal statistics.
|
||||
|
||||
-o FILE --output-file=FILE
|
||||
write output to FILE. A file extension matching one of the
|
||||
write output to FILE. A file extension matching one of the
|
||||
above formats selects that format.
|
||||
|
||||
$ hledger stats
|
||||
@ -1993,16 +1996,16 @@ COMMANDS
|
||||
Accounts : 8 (depth 3)
|
||||
Commodities : 1 ($)
|
||||
|
||||
The stats command displays summary information for the whole journal,
|
||||
or a matched part of it. With a reporting interval, it shows a report
|
||||
The stats command displays summary information for the whole journal,
|
||||
or a matched part of it. With a reporting interval, it shows a report
|
||||
for each report period.
|
||||
|
||||
This command also supports output destination and output format selec-
|
||||
This command also supports output destination and output format selec-
|
||||
tion.
|
||||
|
||||
tags
|
||||
List all the tag names used in the journal. With a TAGREGEX argument,
|
||||
only tag names matching the regular expression (case insensitive) are
|
||||
List all the tag names used in the journal. With a TAGREGEX argument,
|
||||
only tag names matching the regular expression (case insensitive) are
|
||||
shown. With additional QUERY arguments, only transactions matching the
|
||||
query are considered.
|
||||
|
||||
@ -2012,34 +2015,34 @@ COMMANDS
|
||||
$ hledger test
|
||||
Cases: 74 Tried: 74 Errors: 0 Failures: 0
|
||||
|
||||
This command runs hledger's built-in unit tests and displays a quick
|
||||
This command runs hledger's built-in unit tests and displays a quick
|
||||
report. With a regular expression argument, it selects only tests with
|
||||
matching names. It's mainly used in development, but it's also nice to
|
||||
be able to check your hledger executable for smoke at any time.
|
||||
|
||||
ADD-ON COMMANDS
|
||||
hledger also searches for external add-on commands, and will include
|
||||
hledger also searches for external add-on commands, and will include
|
||||
these in the commands list. These are programs or scripts in your PATH
|
||||
whose name starts with hledger- and ends with a recognised file exten-
|
||||
whose name starts with hledger- and ends with a recognised file exten-
|
||||
sion (currently: no extension, bat,com,exe, hs,lhs,pl,py,rb,rkt,sh).
|
||||
|
||||
Add-ons can be invoked like any hledger command, but there are a few
|
||||
Add-ons can be invoked like any hledger command, but there are a few
|
||||
things to be aware of. Eg if the hledger-web add-on is installed,
|
||||
|
||||
o hledger -h web shows hledger's help, while hledger web -h shows
|
||||
hledger-web's help.
|
||||
|
||||
o Flags specific to the add-on must have a preceding -- to hide them
|
||||
from hledger. So hledger web --serve --port 9000 will be rejected;
|
||||
o Flags specific to the add-on must have a preceding -- to hide them
|
||||
from hledger. So hledger web --serve --port 9000 will be rejected;
|
||||
you must use hledger web -- --serve --port 9000.
|
||||
|
||||
o You can always run add-ons directly if preferred:
|
||||
o You can always run add-ons directly if preferred:
|
||||
hledger-web --serve --port 9000.
|
||||
|
||||
Add-ons are a relatively easy way to add local features or experiment
|
||||
with new ideas. They can be written in any language, but haskell
|
||||
scripts have a big advantage: they can use the same hledger (and
|
||||
haskell) library functions that built-in commands do, for command-line
|
||||
Add-ons are a relatively easy way to add local features or experiment
|
||||
with new ideas. They can be written in any language, but haskell
|
||||
scripts have a big advantage: they can use the same hledger (and
|
||||
haskell) library functions that built-in commands do, for command-line
|
||||
options, journal parsing, reporting, etc.
|
||||
|
||||
Here are some hledger add-ons available:
|
||||
@ -2057,7 +2060,7 @@ ADD-ON COMMANDS
|
||||
hledger-web provides a simple web interface.
|
||||
|
||||
Third party add-ons
|
||||
These are maintained separately, and usually updated shortly after a
|
||||
These are maintained separately, and usually updated shortly after a
|
||||
hledger release.
|
||||
|
||||
diff
|
||||
@ -2065,7 +2068,7 @@ ADD-ON COMMANDS
|
||||
journal file and another.
|
||||
|
||||
iadd
|
||||
hledger-iadd is a curses-style, more interactive replacement for the
|
||||
hledger-iadd is a curses-style, more interactive replacement for the
|
||||
add command.
|
||||
|
||||
interest
|
||||
@ -2073,19 +2076,19 @@ ADD-ON COMMANDS
|
||||
ing to various schemes.
|
||||
|
||||
irr
|
||||
hledger-irr calculates the internal rate of return of an investment
|
||||
hledger-irr calculates the internal rate of return of an investment
|
||||
account.
|
||||
|
||||
Experimental add-ons
|
||||
These are available in source form in the hledger repo's bin/ direc-
|
||||
These are available in source form in the hledger repo's bin/ direc-
|
||||
tory; installing them is pretty easy. They may be less mature and doc-
|
||||
umented than built-in commands. Reading and tweaking these is a good
|
||||
umented than built-in commands. Reading and tweaking these is a good
|
||||
way to start making your own!
|
||||
|
||||
autosync
|
||||
hledger-autosync is a symbolic link for easily running ledger-autosync,
|
||||
if installed. ledger-autosync does deduplicating conversion of OFX
|
||||
data and some CSV formats, and can also download the data if your bank
|
||||
if installed. ledger-autosync does deduplicating conversion of OFX
|
||||
data and some CSV formats, and can also download the data if your bank
|
||||
offers OFX Direct Connect.
|
||||
|
||||
chart
|
||||
@ -2095,21 +2098,21 @@ ADD-ON COMMANDS
|
||||
hledger-check.hs checks more powerful account balance assertions.
|
||||
|
||||
ENVIRONMENT
|
||||
COLUMNS The screen width used by the register command. Default: the
|
||||
COLUMNS The screen width used by the register command. Default: the
|
||||
full terminal width.
|
||||
|
||||
LEDGER_FILE The journal file path when not specified with -f. Default:
|
||||
~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour-
|
||||
~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour-
|
||||
nal).
|
||||
|
||||
FILES
|
||||
Reads data from one or more files in hledger journal, timeclock, time-
|
||||
dot, or CSV format specified with -f, or $LEDGER_FILE, or
|
||||
$HOME/.hledger.journal (on windows, perhaps
|
||||
Reads data from one or more files in hledger journal, timeclock, time-
|
||||
dot, or CSV format specified with -f, or $LEDGER_FILE, or
|
||||
$HOME/.hledger.journal (on windows, perhaps
|
||||
C:/Users/USER/.hledger.journal).
|
||||
|
||||
BUGS
|
||||
The need to precede addon command options with -- when invoked from
|
||||
The need to precede addon command options with -- when invoked from
|
||||
hledger is awkward.
|
||||
|
||||
When input data contains non-ascii characters, a suitable system locale
|
||||
@ -2122,33 +2125,33 @@ BUGS
|
||||
In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger
|
||||
add.
|
||||
|
||||
Not all of Ledger's journal file syntax is supported. See file format
|
||||
Not all of Ledger's journal file syntax is supported. See file format
|
||||
differences.
|
||||
|
||||
On large data files, hledger is slower and uses more memory than
|
||||
On large data files, hledger is slower and uses more memory than
|
||||
Ledger.
|
||||
|
||||
TROUBLESHOOTING
|
||||
Here are some issues you might encounter when you run hledger (and
|
||||
remember you can also seek help from the IRC channel, mail list or bug
|
||||
Here are some issues you might encounter when you run hledger (and
|
||||
remember you can also seek help from the IRC channel, mail list or bug
|
||||
tracker):
|
||||
|
||||
Successfully installed, but "No command `hledger' found"
|
||||
stack and cabal install binaries into a special directory, which should
|
||||
be added to your PATH environment variable. Eg on unix-like systems,
|
||||
be added to your PATH environment variable. Eg on unix-like systems,
|
||||
that is ~/.local/bin and ~/.cabal/bin respectively.
|
||||
|
||||
I set a custom LEDGER_FILE, but hledger is still using the default file
|
||||
LEDGER_FILE should be a real environment variable, not just a shell
|
||||
variable. The command env | grep LEDGER_FILE should show it. You may
|
||||
LEDGER_FILE should be a real environment variable, not just a shell
|
||||
variable. The command env | grep LEDGER_FILE should show it. You may
|
||||
need to use export. Here's an explanation.
|
||||
|
||||
"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
|
||||
"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
|
||||
character" errors
|
||||
In order to handle non-ascii letters and symbols (like ), hledger needs
|
||||
an appropriate locale. This is usually configured system-wide; you can
|
||||
also configure it temporarily. The locale may need to be one that sup-
|
||||
ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
|
||||
ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
|
||||
I'm not sure yet).
|
||||
|
||||
Here's an example of setting the locale temporarily, on ubuntu
|
||||
@ -2167,7 +2170,7 @@ TROUBLESHOOTING
|
||||
$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
|
||||
$ bash --login
|
||||
|
||||
If we preferred to use eg fr_FR.utf8, we might have to install that
|
||||
If we preferred to use eg fr_FR.utf8, we might have to install that
|
||||
first:
|
||||
|
||||
$ apt-get install language-pack-fr
|
||||
@ -2188,7 +2191,7 @@ TROUBLESHOOTING
|
||||
|
||||
|
||||
REPORTING BUGS
|
||||
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
|
||||
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
|
||||
or hledger mail list)
|
||||
|
||||
|
||||
@ -2202,7 +2205,7 @@ COPYRIGHT
|
||||
|
||||
|
||||
SEE ALSO
|
||||
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
|
||||
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
|
||||
hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
|
||||
dot(5), ledger(1)
|
||||
|
||||
|
||||
@ -506,7 +506,10 @@ you can alter the report mode with `--change`/`--cumulative`/`--historical`.
|
||||
This command also supports [output destination](/manual.html#output-destination) and [output format](/manual.html#output-format) selection.
|
||||
|
||||
## prices
|
||||
Print all [market prices](/manual#market-prices) from the journal.
|
||||
Print [market price directives](/manual#market-prices) from the journal.
|
||||
With --costs, also print synthetic market prices based on [transaction prices](/manual#transaction-prices).
|
||||
With --inverted-costs, also print inverse prices based on transaction prices.
|
||||
Prices (and postings providing prices) can be filtered by a query.
|
||||
|
||||
## print
|
||||
Show transactions from the journal. Aliases: p, txns.
|
||||
|
||||
@ -148,15 +148,13 @@ If you prefer more control or if hledger-install failed, here's how to use stack
|
||||
|
||||
On Windows, the 64-bit version of stack is [preferred](https://github.com/simonmichael/hledger/issues/275#issuecomment-123834252).
|
||||
|
||||
2. **`stack install --resolver=nightly-2018-06-02 hledger-lib-1.10 hledger-1.10 hledger-ui-1.10 fsnotify-0.3.0.1 hledger-web-1.10.1 hledger-api-1.10`**\
|
||||
2. **`stack install --resolver=lts-12 hledger-lib-1.10 hledger-1.10 hledger-ui-1.10.1 hledger-web-1.10 hledger-api-1.10`**\
|
||||
This installs the main hledger packages (and dependencies) from [Stackage](https://www.stackage.org) and/or [Hackage](http://hackage.haskell.org).
|
||||
You can save some time by omitting hledger-* packages you don't want.\
|
||||
<span class=warnings>([windows: hledger-ui is not available](https://github.com/jtdaugherty/vty/pull/1#issuecomment-297143444))</span>
|
||||
|
||||
The command above uses stackage's nightly snapshot.
|
||||
You might be able to reduce build time by specifying an older snapshot that you've used before (eg: `--resolver=lts-10.8`), or by omitting the --resolver option.
|
||||
To estimate the build time, add `--dry-run`.
|
||||
You can kill and restart this without losing progress.
|
||||
To estimate the build time, add `--dry-run`.
|
||||
|
||||
If you see "was generated with a newer version of hpack, please upgrade and try again" errors, you can ignore them.
|
||||
(Upgrade to the latest stack release to stop them.)
|
||||
@ -179,9 +177,7 @@ If you prefer more control or if hledger-install failed, here's how to use stack
|
||||
[hledger-iadd](http://hackage.haskell.org/package/hledger-iadd),
|
||||
[hledger-interest](http://hackage.haskell.org/package/hledger-interest),
|
||||
and [hledger-irr](http://hackage.haskell.org/package/hledger-irr)
|
||||
can be installed similarly to the above. Eg:
|
||||
|
||||
**`stack install --resolver=nightly-2018-06-02 hledger-lib-1.10 hledger-1.10 hledger-iadd-1.3.5`**
|
||||
can be installed similarly to the above.
|
||||
|
||||
6. **[Test](#test)**
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user