Commit Graph

850 Commits

Author SHA1 Message Date
Simon Michael
74d8570da3 lib: note that depth does not affect transactions reports 2016-06-12 07:40:40 -07:00
Simon Michael
579ab45d0a lib: clarify balance assertion error again
"calculated" is better, "actual" implies the account's actual real-world
balance which might be something else again.
2016-06-07 09:23:54 -07:00
Simon Michael
98cbcced57 lib: account transactions report filters by realness & status
Two fixes for this report when --real/--cleared/real:/status: are in effect,
affecting hledger-ui and possibly hledger-web:

1. exclude transactions which affect the current account via an excluded posting type.
    Eg when --real is in effect, a transaction posting to the current account with only
    virtual postings will not appear in the report.

2. when showing historical balances, don't count excluded posting types in the
    starting balance. Eg with --real, the starting balance will be the sum of only the
    non-virtual prior postings.

This is complicated and there might be some ways to confuse it still, causing
wrongly included/excluded transactions or wrong historical balances/running totals
(transactions with both real and virtual postings to the current account, perhaps ?)
2016-06-03 17:51:10 -07:00
Simon Michael
7c8d7e9820 ui: transaction: ignore real/cleared/empty, always show full txn (#354)
This commit clarifies the account transactions report: as before the included transactions
are the original unfiltered transactions, but now the change and running balance amounts
are calculated from the report-matched postings. This fixed the limitation noted in 509f558,
so that toggling real mode in any screen could work. Then I decided the transaction screen
shouldn't show a partial transaction after all, so real/cleared filtering is no longer allowed or indicated here.
2016-06-02 07:03:00 -07:00
Simon Michael
7f3ae224e2 lib: refactor journal utils 2016-06-01 20:47:27 -07:00
Simon Michael
509f55864d ui: indicate real mode and toggle it with R key (#354)
There is a limitation/bug: disabling real mode in the transaction screen
won't show the non-real postings if it was entered from a real-mode
register screen.
2016-06-01 12:30:39 -07:00
Simon Michael
788021f5a4 ui: make --real/-R affect register/txn screens (#354) 2016-06-01 10:48:57 -07:00
Simon Michael
ad3c5dfb4d lib: fix ghc 8-related date issues (#352)
Our null date is now 0000/01/01 instead of 0000/00/00.
2016-05-27 08:06:53 -07:00
Simon Michael
f3bf98bfae lib: parentheses trying to resolve IDE warning 2016-05-26 15:51:59 -07:00
Simon Michael
90c9735b7a lib: textification: descriptions & codes
Slightly higher (with small files) and lower (with large files) maximum
residency, and slightly quicker for all.

hledger -f data/100x100x10.journal stats
<<ghc: 42858472 bytes, 84 GCs, 193712/269608 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.015 elapsed), 0.016 MUT (0.042 elapsed), 0.011 GC (0.119 elapsed) :ghc>>
<<ghc: 42891776 bytes, 84 GCs, 190816/260920 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.004 elapsed), 0.017 MUT (0.025 elapsed), 0.010 GC (0.015 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 349575240 bytes, 681 GCs, 1396425/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.137 MUT (0.146 elapsed), 0.050 GC (0.057 elapsed) :ghc>>
<<ghc: 349927568 bytes, 681 GCs, 1397825/4097248 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.126 MUT (0.133 elapsed), 0.050 GC (0.057 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3424029496 bytes, 6658 GCs, 11403141/41077288 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.000 elapsed), 1.278 MUT (1.310 elapsed), 0.493 GC (0.546 elapsed) :ghc>>
<<ghc: 3427418064 bytes, 6665 GCs, 11127869/37790168 avg/max bytes residency (11 samples), 109M in use, 0.000 INIT (0.001 elapsed), 1.212 MUT (1.229 elapsed), 0.466 GC (0.519 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 34306546248 bytes, 66727 GCs, 77030638/414617944 avg/max bytes residency (14 samples), 1012M in use, 0.000 INIT (0.000 elapsed), 12.965 MUT (13.164 elapsed), 4.771 GC (5.447 elapsed) :ghc>>
<<ghc: 34340246056 bytes, 66779 GCs, 76983178/416011480 avg/max bytes residency (14 samples), 1011M in use, 0.000 INIT (0.008 elapsed), 12.666 MUT (12.836 elapsed), 4.595 GC (5.175 elapsed) :ghc>>
2016-05-24 19:00:58 -07:00
Simon Michael
a1b68009da lib: fix tests; always try parsing stdin as journal 2016-05-24 19:00:58 -07:00
Simon Michael
770dcee742 lib: textification: comments and tags
No change.

hledger -f data/100x100x10.journal stats
<<ghc: 42859576 bytes, 84 GCs, 193781/269984 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.016 MUT (0.020 elapsed), 0.009 GC (0.011 elapsed) :ghc>>
<<ghc: 42859576 bytes, 84 GCs, 193781/269984 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.015 MUT (0.018 elapsed), 0.009 GC (0.013 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 349576344 bytes, 681 GCs, 1407388/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.124 MUT (0.130 elapsed), 0.047 GC (0.055 elapsed) :ghc>>
<<ghc: 349576280 bytes, 681 GCs, 1407388/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.126 MUT (0.132 elapsed), 0.049 GC (0.058 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3424030664 bytes, 6658 GCs, 11403359/41071624 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.000 elapsed), 1.207 MUT (1.228 elapsed), 0.473 GC (0.528 elapsed) :ghc>>
<<ghc: 3424030760 bytes, 6658 GCs, 11403874/41077288 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.002 elapsed), 1.234 MUT (1.256 elapsed), 0.470 GC (0.520 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 34306547448 bytes, 66727 GCs, 76805504/414629288 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.003 elapsed), 12.615 MUT (12.813 elapsed), 4.656 GC (5.291 elapsed) :ghc>>
<<ghc: 34306547320 bytes, 66727 GCs, 76805504/414629288 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.009 elapsed), 12.802 MUT (13.065 elapsed), 4.774 GC (5.441 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
c89c33b36e lib: textification: parse stream
10% more allocation, but 35% lower maximum residency, and slightly quicker.

hledger -f data/100x100x10.journal stats
<<ghc: 39327768 bytes, 77 GCs, 196834/269496 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.010 elapsed), 0.020 MUT (0.092 elapsed), 0.014 GC (0.119 elapsed) :ghc>>
<<ghc: 42842136 bytes, 84 GCs, 194010/270912 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.009 elapsed), 0.016 MUT (0.029 elapsed), 0.012 GC (0.120 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 314291440 bytes, 612 GCs, 2070776/6628048 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.000 elapsed), 0.128 MUT (0.144 elapsed), 0.059 GC (0.070 elapsed) :ghc>>
<<ghc: 349558872 bytes, 681 GCs, 1397597/4106384 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.004 elapsed), 0.124 MUT (0.133 elapsed), 0.047 GC (0.053 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3070026824 bytes, 5973 GCs, 12698030/62951784 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.002 elapsed), 1.268 MUT (1.354 elapsed), 0.514 GC (0.587 elapsed) :ghc>>
<<ghc: 3424013128 bytes, 6658 GCs, 11405501/41071624 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.001 elapsed), 1.343 MUT (1.406 elapsed), 0.511 GC (0.573 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 30753387392 bytes, 59811 GCs, 117615462/666703600 avg/max bytes residency (14 samples), 1588M in use, 0.000 INIT (0.000 elapsed), 12.068 MUT (12.238 elapsed), 6.015 GC (7.190 elapsed) :ghc>>
<<ghc: 34306530696 bytes, 66727 GCs, 76806196/414629312 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.010 elapsed), 14.357 MUT (16.370 elapsed), 5.298 GC (6.534 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
58c3362908 lib: textification: saved journal source
Slightly worse on small files, better on large ones.

hledger -f data/100x100x10.journal stats
<<ghc: 39305392 bytes, 77 GCs, 196354/268584 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.007 elapsed), 0.014 MUT (0.027 elapsed), 0.011 GC (0.111 elapsed) :ghc>>
<<ghc: 39307728 bytes, 77 GCs, 196909/270248 avg/max bytes residency (3 samples), 2M in use, 0.001 INIT (0.010 elapsed), 0.015 MUT (0.028 elapsed), 0.012 GC (0.116 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 314285912 bytes, 612 GCs, 2064811/6597608 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.002 elapsed), 0.126 MUT (0.134 elapsed), 0.059 GC (0.069 elapsed) :ghc>>
<<ghc: 314271368 bytes, 612 GCs, 2070227/6628024 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.000 elapsed), 0.137 MUT (0.143 elapsed), 0.059 GC (0.068 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3070033264 bytes, 5965 GCs, 12699294/62962464 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.000 elapsed), 1.245 MUT (1.300 elapsed), 0.498 GC (0.558 elapsed) :ghc>>
<<ghc: 3070006752 bytes, 5973 GCs, 12687314/62848920 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.003 elapsed), 1.257 MUT (1.281 elapsed), 0.496 GC (0.554 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 30753465088 bytes, 59763 GCs, 117723618/666643528 avg/max bytes residency (14 samples), 1589M in use, 0.000 INIT (0.002 elapsed), 12.536 MUT (12.793 elapsed), 5.978 GC (7.155 elapsed) :ghc>>
<<ghc: 30753367256 bytes, 59811 GCs, 117723236/666627528 avg/max bytes residency (14 samples), 1590M in use, 0.001 INIT (0.012 elapsed), 12.923 MUT (13.169 elapsed), 5.981 GC (6.860 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
102b76c17f lib: textification: commodity symbols
hledger -f data/100x100x10.journal stats
<<ghc: 39288536 bytes, 77 GCs, 196608/269560 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.016 MUT (0.028 elapsed), 0.009 GC (0.012 elapsed) :ghc>>
<<ghc: 39290808 bytes, 77 GCs, 196608/269560 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.003 elapsed), 0.015 MUT (0.021 elapsed), 0.009 GC (0.011 elapsed) :ghc>>

hledger -f data/1000x100x10.journal stats
<<ghc: 314268960 bytes, 612 GCs, 2143219/6826152 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.009 elapsed), 0.135 MUT (0.151 elapsed), 0.065 GC (0.178 elapsed) :ghc>>
<<ghc: 314254512 bytes, 612 GCs, 2072377/6628024 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.000 elapsed), 0.130 MUT (0.134 elapsed), 0.064 GC (0.075 elapsed) :ghc>>

hledger -f data/10000x100x10.journal stats
<<ghc: 3070016592 bytes, 5965 GCs, 13138220/64266016 avg/max bytes residency (10 samples), 128M in use, 0.000 INIT (0.000 elapsed), 1.272 MUT (1.322 elapsed), 0.527 GC (0.595 elapsed) :ghc>>
<<ghc: 3069989896 bytes, 5973 GCs, 12687877/62848920 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.002 elapsed), 1.295 MUT (1.324 elapsed), 0.511 GC (0.570 elapsed) :ghc>>

hledger -f data/100000x100x10.journal stats
<<ghc: 30753448072 bytes, 59763 GCs, 121502982/673169248 avg/max bytes residency (14 samples), 1640M in use, 0.000 INIT (0.007 elapsed), 12.421 MUT (12.672 elapsed), 6.240 GC (7.812 elapsed) :ghc>>
<<ghc: 30753350528 bytes, 59811 GCs, 117616668/666703600 avg/max bytes residency (14 samples), 1588M in use, 0.001 INIT (0.011 elapsed), 13.209 MUT (13.683 elapsed), 6.137 GC (7.117 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
2538d14ea7 lib: textification begins! account names
The first of several conversions from String to (strict) Text, hopefully
reducing space and time usage.

This one shows a small improvement, with GHC 7.10.3 and text-1.2.2.1:

hledger -f data/100x100x10.journal stats
string: <<ghc: 39471064 bytes, 77 GCs, 198421/275048 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.015 MUT (0.020 elapsed), 0.010 GC (0.014 elapsed) :ghc>>
text:   <<ghc: 39268024 bytes, 77 GCs, 197018/270840 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.002 elapsed), 0.016 MUT (0.022 elapsed), 0.009 GC (0.011 elapsed) :ghc>>

hledger -f data/1000x100x10.journal stats
string: <<ghc: 318555920 bytes, 617 GCs, 2178997/7134472 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.001 elapsed), 0.129 MUT (0.136 elapsed), 0.067 GC (0.077 elapsed) :ghc>>
text:   <<ghc: 314248496 bytes, 612 GCs, 2074045/6617960 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.003 elapsed), 0.137 MUT (0.145 elapsed), 0.067 GC (0.079 elapsed) :ghc>>

hledger -f data/10000x100x10.journal stats
string: <<ghc: 3114763608 bytes, 6026 GCs, 18858950/75552024 avg/max bytes residency (11 samples), 201M in use, 0.000 INIT (0.000 elapsed), 1.331 MUT (1.372 elapsed), 0.699 GC (0.812 elapsed) :ghc>>
text:   <<ghc: 3071468920 bytes, 5968 GCs, 14120344/62951360 avg/max bytes residency (9 samples), 124M in use, 0.000 INIT (0.003 elapsed), 1.272 MUT (1.349 elapsed), 0.513 GC (0.578 elapsed) :ghc>>

hledger -f data/100000x100x10.journal stats
string: <<ghc: 31186579432 bytes, 60278 GCs, 135332581/740228992 avg/max bytes residency (13 samples), 1697M in use, 0.000 INIT (0.008 elapsed), 14.677 MUT (15.508 elapsed), 7.081 GC (8.074 elapsed) :ghc>>
text:   <<ghc: 30753427672 bytes, 59763 GCs, 117595958/666457240 avg/max bytes residency (14 samples), 1588M in use, 0.000 INIT (0.008 elapsed), 13.713 MUT (13.966 elapsed), 6.220 GC (7.108 elapsed) :ghc>>
2016-05-24 19:00:49 -07:00
Simon Michael
097c9e09b6 lib: cleanups 2016-05-23 12:51:15 -07:00
Simon Michael
0f5ee154c4 lib: simplify parsers; cleanups (#275)
The journal/timeclock/timedot parsers, instead of constructing (opaque)
journal update functions which are later applied to build the journal,
now construct the journal directly (by modifying the parser state). This
is easier to understand and debug. It also removes any possibility of
the journal updates being a space leak. (They weren't, in fact memory
usage is now slightly higher, but that will be addressed in other ways.)

Also:

Journal data and journal parse info have been merged into one type (for
now), and field names are more consistent.

The ParsedJournal type alias has been added to distinguish being-parsed
and finalised journals.

Journal is now a monoid.

stats: fixed an issue with ordering of include files

journal: fixed an issue with ordering of included same-date transactions

timeclock: sessions can no longer span file boundaries (unclocked-out
sessions will be auto-closed at the end of the file).

expandPath now throws a proper IO error (and requires the IO monad).
2016-05-23 00:44:19 -07:00
Simon Michael
4179a83c1d lib: pprint 2016-05-20 08:31:39 -07:00
Simon Michael
550e99acd3 lib: let dbg*IO work in any MonadIO 2016-05-20 07:51:51 -07:00
Simon Michael
7f5e09096f lib: rename JournalContext to JournalParseState 2016-05-18 20:57:34 -07:00
Simon Michael
ea383d88d6 lib: drop "double" build flag 2016-05-18 20:32:58 -07:00
Simon Michael
ff09d60746 lib: types whitespace 2016-05-18 20:28:37 -07:00
Simon Michael
ae490d738f lib: Hledger.Read notes 2016-05-18 16:42:25 -07:00
Simon Michael
20bfceff2e lib: allow multiple files of different format (#320)
When multiple files are specified with multiple -f options, we now
parse each one individually, rather than just concatenating them, so
they can have different formats.

Directives (like default year or account aliases) no longer carry over
from one file to the next. Limitation or feature ?
2016-05-18 16:41:52 -07:00
Simon Michael
fdd7feefdb lib: make Journal a monoid 2016-05-18 15:08:50 -07:00
Simon Michael
6ed0369cdc lib: note transaction idx only counts journal txns 2016-05-18 15:06:57 -07:00
Simon Michael
7e84b4d643 lib: rename get/setIndex, add increment fn 2016-05-18 15:06:16 -07:00
Simon Michael
84097b75c7 journal: can now include timeclock/timedot files (#320)
journal files can now include journal, timeclock or timedot files (but
not yet CSV files). Also timeclock/timedot files no longer support
default year directives.

The Hledger.Read.* modules have been reorganised for better reuse.
Hledger.Read.Utils has been renamed Hledger.Read.Common and holds
low-level parsers & utilities; high-level read utilities have moved to
Hledger.Read.
2016-05-17 19:46:54 -07:00
Simon Michael
ec507955e1 journal: simplify parse error 2016-05-17 10:06:51 -07:00
Simon Michael
9c130e1850 lib: journal: hlint cleanups!
Hopefully still backward compatible.
2016-05-13 22:09:39 -07:00
Simon Michael
16ee07cc52 remove temp type 2016-05-13 20:44:21 -07:00
Simon Michael
ddefec412f journal: also allow one-line commodity directives 2016-05-08 20:56:34 -07:00
Simon Michael
b583cb327d lib: fix a warning 2016-05-08 20:55:59 -07:00
Simon Michael
9304aa1100 journal: commodity format directive overrides inferred style (#295)
The commodity directive's format subdirective can now be used to
override the inferred style for a commodity, eg to increase or decrease
the precision. This doesn't fix the root cause of #295 but is at least a
good workaround.
2016-05-08 09:07:08 -07:00
Simon Michael
2c0ef877eb journal: parse and store commodity formats 2016-05-08 09:06:54 -07:00
Simon Michael
207922a023 lib: Commodity now has a CommoditySymbol and style 2016-05-08 08:07:27 -07:00
Simon Michael
aac67b3d4d lib: fix parsedate haddock 2016-05-06 19:02:48 -07:00
Simon Michael
ce344f9b96 lib: fix a haddock error 2016-05-06 18:16:12 -07:00
Simon Michael
e9c6c1ef5e lib: convert date hunit tests to doctests 2016-05-06 18:10:49 -07:00
Simon Michael
c9a892eabe lib: remove hopefully superfluous comment 2016-05-06 17:40:33 -07:00
Simon Michael
a52fd599c4 lib: more compact Show instance for datespans 2016-05-06 17:23:24 -07:00
Simon Michael
884c0b8a58 reg: fix sorting regression with --date2 (#326)
And rewrite/clarify postingsReport.
2016-05-06 17:19:43 -07:00
Simon Michael
6cbc0ceb0d lib: note issues 2016-05-06 17:19:23 -07:00
Simon Michael
e7a1eb627f journal: export parsing helpers, fix warning 2016-05-06 16:58:07 -07:00
Simon Michael
525ca6041d lib: tweak balance assertion message 2016-05-04 09:08:53 -07:00
Simon Michael
9a424d77fc lib: more thorough journal reloading
Reloading a journal should now reload all included files as well.
2016-05-02 20:07:53 -07:00
Simon Michael
856c0b3042 lib: fix bracketed posting dates, parser cleanup (#304)
Bracketed posting dates were fragile; they worked only if you wrote full
10-character dates. Also some semantics were a bit unclear. Now they
should be robust, and have been documented more clearly. This is a
legacy undocumented Ledger syntax, but it improves compatibility and
might be preferable to the more verbose "date:" tags if you write
posting dates often (as I do).

Internally, bracketed posting dates are no longer considered to be tags.
Journal comment, tag, and posting date parsers have been reworked, all
with doctests. Also the journal parser types generally have been
tightened up and clarified, making it much easier to know how to combine
and run them. There's now

-- | A parser of strings with generic user state, monad and return type.
type StringParser u m a = ParsecT String u m a

-- | A string parser with journal-parsing state.
type JournalParser m a = StringParser JournalContext m a

-- | A journal parser that runs in IO and can throw an error mid-parse.
type ErroringJournalParser a = JournalParser (ExceptT String IO) a

and corresponding convenience functions (and short aliases) for running them.
2016-04-28 13:34:57 -07:00
Simon Michael
259e7bfbe3 lib: add a doctest suite 2016-04-28 13:34:57 -07:00
Simon Michael
9946e7df88 lib: organise JournalReader a bit 2016-04-28 13:34:57 -07:00
Simon Michael
df4b82740b lib: make the supported format names accessible 2016-04-18 16:43:57 -07:00
Simon Michael
588f36d662 rename timelog format to timeclock 2016-04-12 21:13:19 -07:00
Simon Michael
31a754544a journal: parse account directives
We now parse account directives, like Ledger's. We don't do anything
with them yet. The default parent account feature must now be spelled
"apply account"/"end apply account".
2016-04-04 11:35:39 -07:00
Simon Michael
931a1d5b9e hlint 2016-02-21 02:37:59 -08:00
Simon Michael
a9afd7bcbe lib: slightly better journal/time format detection
The Journal, Timelog and Timedot readers' detectors now check
each line in the sample data, not just the first one. I think
the sample data is only about 30 chars right now, but even so
this fixed a format detection issue I was seeing.
2016-02-19 23:02:10 -08:00
Simon Michael
70863ae40b lib: timedot allow indenting 2016-02-19 22:58:08 -08:00
Simon Michael
4b4a4bacf7 lib: timedot parse order fix 2016-02-19 22:57:43 -08:00
Simon Michael
0adcdf21f8 lib: timedot parsing fix 2016-02-19 22:57:06 -08:00
Simon Michael
b26dd3d9b0 lib: fix timedot comments 2016-02-19 22:55:30 -08:00
Simon Michael
dd77ac4c0a lib: note debugLevel gotcha in GHCI 2016-02-19 22:54:38 -08:00
Simon Michael
c9937db10e lib: show txn's file position in assertion errors 2016-02-19 22:48:59 -08:00
Simon Michael
1cf223a2db lib: finish move of reading utils, useful for 320
It seems this already began in today's timedot commit.
2016-02-19 21:37:12 -08:00
Simon Michael
06b54bf05e lib: timedot format, convenient for time logging
Timedot is a plain text format for logging dated, categorised
quantities (eg time), supported by hledger.  It is convenient for
approximate and retroactive time logging, eg when the real-time
clock-in/out required with a timeclock file is too precise or too
interruptive.  It can be formatted like a bar chart, making clear at a
glance where time was spent.
2016-02-19 17:55:57 -08:00
Simon Michael
5da355c06f lib: more ergonomic balance assertion errors 2016-02-10 07:40:18 -08:00
Simon Michael
a2b989d898 journal: support ledger3-compatible "apply account" 2016-01-29 07:39:26 -08:00
Simon Michael
8f432b651e api: Typeable/Data/Generic instances for Account 2016-01-21 15:16:11 -08:00
Simon Michael
96e1ca7ea1 lib: refactor amount canonicalisation
Amount display style canonicalisation code and terminology has been
clarified a bit. Individual amounts still have styles; from these we
derive the standard "commodity styles". In user docs, we might call
these "commodity formats" since a Ledger-compatible commodity directive
would use the "format" keyword.
2015-11-24 01:40:10 -08:00
Simon Michael
0ee2ff7ab2 lib: fix off-by-one in transaction index 2015-10-30 10:41:42 -07:00
Simon Michael
2feace32dd lib: number transactions as they are read
And allow looking up transactions by their read order (index),
or the previous/next transactions in the sequence.
2015-10-29 20:12:46 -07:00
Simon Michael
11fee9fbe8 ui: txn: show multi-commodity amounts on one line
In the transaction screen, show multi-commodity posting amounts on one
line, consistent with the rest of hledger-ui.
2015-10-29 18:10:06 -07:00
Simon Michael
76ab5df833 lib: credit pandoc for the charWidth function 2015-10-29 09:19:20 -07:00
Simon Michael
d24b1b96f7 lib: parser cleanups 2015-10-17 12:09:03 -07:00
Simon Michael
bc43036117 lib: use consistent p suffix for parsers 2015-10-17 11:51:45 -07:00
Simon Michael
8214a6ccef dangit.. simplify combineJournalUpdates for real 2015-10-13 11:54:15 -07:00
Simon Michael
3be88ad6b5 simplify combineJournalUpdates
I really don't see why that extra x parameter is needed or works..
rewrite it in simpler form.

I also might be introducing breakage for older GHC's by using
unconditionally <$>, but I'm not seeing that for some reason
(tested back to ghc 7.6).
2015-10-13 11:49:51 -07:00
Simon Michael
71921135f6 include P amounts in canonicalisation (fixes #131)
Since market price amounts didn't contribute to the canonical commodity
styles, they were being reset to the null style. And this propagated to
the reported amounts when -V was in effect, causing much confusion.
Now, market prices contribute to canonicalisation and the expected
styles are preserved even with -V.

cf https://github.com/simonmichael/hledger/issues/131#issuecomment-133545140
2015-10-11 16:07:31 -07:00
Simon Michael
eb75946e64 print: always right-align amounts
print now always right-aligns the amounts in an entry, even when they
are wider than 12 characters.

If there is a price, it's considered part of the amount for
right-alignment. Maybe it would be nicer to put amounts and prices in
separate columns ? That will get a little complicated, needs more
discussion/design.

Also some cleanup of postingAsLines.
2015-10-10 15:09:42 -07:00
Simon Michael
155722d7ee make strWidth aware of multi-line strings (#242) 2015-10-10 15:08:28 -07:00
Simon Michael
1d944ac1a9 doc: balance --format does not support - any more 2015-10-10 15:07:49 -07:00
Simon Michael
3b40edba9c print: fix wide char support, add tests (#242)
The print command wasn't lining up amounts with wide chars in account
names, fixed it properly this time. Transaction and Posting's Show instances
should also be wide-char-aware now.
2015-10-10 11:53:28 -07:00
Simon Michael
939f7184c9 journal: make "end comment" optional, like ledger
The "comment" directive longer requires an "end comment", and will
extend to the end of the file(s) without it.
2015-10-07 16:41:49 -07:00
Simon Michael
a2f344f6d9 journal: require dates to begin with a digit 2015-10-04 08:41:01 -10:00
Simon Michael
ef27e5c427 string utils cleanup 2015-09-28 18:47:05 -10:00
Simon Michael
42e2da4bb6 balance, print; more wide char support (#242)
Simple (non-multicolumn) balance reports containing wide characters
should now align correctly (in apps and fonts that show wide chars as
double width). Likewise, the print command.
2015-09-28 18:33:18 -10:00
Simon Michael
5b5e5eeaf4 register: wide-character-aware layout (#242)
Wide characters, eg chinese/japanese/korean characters, are typically
rendered wider than latin characters. In some applications (eg gnome
terminal or osx terminal) and fonts (eg monaco) they are exactly double
width. This is a start at making hledger aware of this. A register
report containing wide characters (in descriptions, account names, or
commodity symbols) should now align its columns correctly, when viewed
with a suitable font and application.
2015-09-28 16:12:20 -10:00
Simon Michael
dafa8efada note possible combineJournalUpdates inefficiency 2015-09-26 16:01:27 -10:00
Simon Michael
5048d3bf06 lib: memoise accountNameApplyAliases too ?
This adds a accountNameApplyAliasesMemo, which memoises the result of
applying a set of aliases (simple and regex) to an account name. In
theory this should reduce more repetitive work, but in practice it
doesn't seem to make a difference, so it's unused for now.
2015-09-26 15:58:12 -10:00
Simon Michael
4326f88c26 lib: memoise aliasReplace for fast regex aliases (#244)
Roughly speaking, the time to apply regular expression account aliases
was O(aliases x transactions), and should now be O(aliases x accounts).
Also, the constant factor was reduced a lot by the recent commit
memoising toRegex. So now, regex aliases should be "free" like simple
aliases - use as many as you want, the slowdown shouldn't be noticeable.
2015-09-26 15:45:44 -10:00
Simon Michael
041541e466 lib: memoised versions of regexReplace[CI] (#244) 2015-09-26 15:45:17 -10:00
Simon Michael
f8f2d457b9 lib: memoize toRegex[CI] (#244)
The regex helpers were converting strings to regex-tdfa regular
expressions on the fly every time, but this appears to be quite
expensive. The simplest memoisation lib seems to solve it nicely.
2015-09-26 15:39:21 -10:00
Simon Michael
591abefe9e clarify modifiedaccountnamep 2015-09-24 14:23:52 -10:00
Simon Michael
f4c963b648 whitespace 2015-09-22 12:59:25 -07:00
Simon Michael
821f1b7120 lib: fix tests for zero amount style (#230, #276) 2015-09-02 16:38:45 -07:00
Simon Michael
b770190942 lib: clarify flattenAccounts 2015-09-02 16:22:08 -07:00
Simon Michael
b8d75b7728 balance, etc: fix amount style loss (fixes #230, #276)
hledger-lib-0.24's "track the commodity of zero amounts when
possible (useful eg for hledger-web's multi-commodity charts)" preserved
the commodity when normalising a zero mixed amount, but not the amount
style. This showed up as occasionally incorrect amount style (commodity
symbol placement, decimal point character, etc.) in balance reports with
certain journals, like this:

  $ hledger bal
              €3000.00  a     <------ not using the canonical € style
              4000,58€    1
             -1000,58€    D
             -3000,00€  e
  --------------------
                     0

I thought this would require a big rewrite of amount arithmetic, but it
seems that just being a little more careful is enough. When normalising
a mixed amount containing multiple zeros in the same commodity, we now
preserve the last zero with its amount style, instead of replacing them
all with a new one.
2015-09-02 16:21:56 -07:00
Simon Michael
92038b7d72 web: fix options breakage, add test code to tags 2015-08-28 15:23:49 -07:00
Simon Michael
74512814ec cli/ui/web: rename X.Options modules to X.XOptions
Make these modules' names more like the heavily-used types they
define (CliOpts, UIOpts, WebOpts). This is consistent with
RawOptions and ReportOptions, and helps with code navigation.
2015-08-28 12:43:51 -07:00
Simon Michael
8673332c8e ui, web: show fewer other accounts in acct register
To reduce noise in the "other accounts" field of hledger-ui's and
hledger-web's account register: if there are both real and virtual
postings to other accounts, show only the accounts posted to by real
postings.

Use case: in many transactions I have extra balanced-virtual postings
which adjust budget envelopes (subaccounts of checking). These clutter
up the register's other accounts field making it useless. Excluding them
(when there are also real postings) makes it more useful for me and
probably others.
2015-08-28 11:58:57 -07:00
Simon Michael
f3dd5eb830 fix options breakage with GHC < 7.10 2015-08-28 11:17:49 -07:00
Simon Michael
0d02262463 validate --depth/depth:'s argument is positive 2015-08-28 09:57:30 -07:00
Simon Michael
4dd1e9c725 clean up options validation a little 2015-08-28 09:57:01 -07:00
Simon Michael
5fa06453f1 lib: note depth's filtering and display control uses 2015-08-28 08:04:54 -07:00
Simon Michael
19c3749b50 balance: move -V helpers to the *Report modules 2015-08-26 10:38:45 -07:00
Simon Michael
d23d9acf33 fix haddock failures (#281) 2015-08-26 10:11:32 -07:00
Simon Michael
3a7a5d6035 lib: 6-tuple accessors 2015-08-24 16:24:11 -07:00
Simon Michael
866414a528 ui: provide a more useful transaction register
The register screen is now like the register view in hledger-web (and
other accounting systems), rather than hledger's register command.
This means:

- it shows transactions affecting a particular current account, rather
  than postings matching a pattern.

- Each line represents a whole transaction.

- The account field shows the *other* account being transacted with.
  When there is more than one, they are all listed, abbreviated and
  marked with "(split)".

- The amount field shows the effect of the transaction on the current
  account; positive for an inflow to this account, negative for an
  outflow.

- The balance field should usually show the current account's historic
  balance as of the transaction date, even when you change the report
  start date. (Not working yet - currently it always shows the running
  total).

- Transactions are listed most recent first, currently.
2015-08-24 16:24:11 -07:00
Simon Michael
cc98ee39f7 balance, lib: --format/StringFormat improvements
The balance command's --format option (in single-column mode) can now
adjust the rendering of multi-line strings, such as amounts with multiple
commodities. To control this, begin the format string with one of:

 %_  - renders on multiple lines, bottom-aligned (the default)
 %^  - renders on multiple lines, top-aligned
 %,  - render on one line, comma-separated

Also the final total (and the line above it) now adapt themselves to a
custom format.
2015-08-19 20:53:51 -07:00
Simon Michael
7aecbac851 lib: split up Utils more 2015-08-19 20:53:50 -07:00
Simon Michael
69c870c6f0 balance, lib: make StringFormat singular; cleanup
Pass around a StringFormat rather than [StringFormat].
Also more balance report item rendering refactoring.
2015-08-19 20:53:50 -07:00
Simon Michael
36dd64cf02 balance, lib: clarify --format implementation
The --format option's OutputFormat type was named confusingly like the
--output-format option.  It has been renamed StringFormat to distinguish
it from StorageFormat (aka the data file format, referenced by
--output-format). Related code and types have been consolidated.
Also the (single-column) balance report's item rendering has had
some cleanup.
2015-08-19 20:53:49 -07:00
Simon Michael
2b339667e2 Merge branch 'perf-polyparse' (early part) 2015-08-13 13:10:10 -07:00
Simon Michael
632a000f08 derive NFData in a way compatible with GHC < 7.10
The DeriveAnyClass extension requires GHC 7.10, so instead do this in a
more verbose backwards-compatible way. Adds a dependency on deepseq.
2015-08-13 12:58:44 -07:00
Simon Michael
790d42bfa4 derive NFData (and Generic) for all types
so we can benchmark things more easily with criterion.

As well as NFData, the Generic instance and a bunch more GHC extensions
seemed necessary. This is a little scary, impact unknown.
2015-08-13 12:58:35 -07:00
Simon Michael
42d452f99c abstract parsec's SourcePos so as to derive NFData
The NFData instance helps us time things with criterion.
2015-08-13 12:56:15 -07:00
Simon Michael
94094252be rename historical prices to market prices
Simpler and clearer. We now have "transaction prices" (recorded as part
of transaction amounts) and "market prices" (recorded with P
directives). Both are matters of historical record, also this avoids
confusion with the balance command's "historical balances".
2015-08-09 16:20:02 -07:00
Simon Michael
49be1f646e balance: add -V/--value to show as market value
Initial support of market value reporting and currency conversion,
similar in spirit to Ledger's.  The balance command now has a -V/--value
flag that converts all the reported amounts using their "default market
price". That is the latest market price (P directive, formerly called
"historical prices") found in the journal for their commodity that is on
or before the report end date.

Unlike Ledger, hledger's -V only uses the market prices recorded with P
directives, ignoring transaction prices recorded as part of posting
amounts (which -B/--cost uses). Using -B and -V together is allowed.
2015-08-09 16:03:16 -07:00
Simon Michael
040d00e8fb also canonicalise historical price amounts
So that when we convert amounts to market value, the result will have
the canonical style of the target commodity.
2015-08-09 15:12:16 -07:00
Simon Michael
73e4ccee80 allow year parser to handle arbitrarily large years 2015-07-12 12:32:53 -07:00
Simon Michael
7a050d65c8 bs/is/cf: recognise "debt..." as a synonym for "liabilities..." 2015-07-12 12:32:53 -07:00
Simon Michael
cddaa2724d rendering a June 30 date span properly (#272)
30 days hath september, april, JUNE and november
2015-07-02 20:44:39 -07:00
Simon Michael
b827f1a146 more balanceTransaction cleanup
Clarify: it's fine to try to infer prices on a transaction that has had
an amount inferred, it just won't have any effect.
2015-07-02 18:06:03 -07:00
Simon Michael
b735107f43 print: show inferred unit prices with at least 2 decimal places
We don't do a good job of calculating good-looking unit prices when the
commodity display precisions are low. Eg when a journal doesn't use any
decimal places, any inferred unit prices are shown by the print command
also with no decimal places, which makes them look wrong.

Now inferred unit prices always have a minimum display precision of 2,
which helps a bit. Could do better.
2015-07-02 17:36:09 -07:00
Simon Michael
5978a19b15 finish refactoring balanceTransaction 2015-07-02 16:59:43 -07:00
Simon Michael
61e4034de5 Journal's Show instance reported one too many accounts 2015-06-28 14:14:56 -07:00
Simon Michael
ba18f4a25a begin refactoring balanceTransaction 2015-06-28 12:03:42 -07:00
Simon Michael
b9883d9eb1 query: make real: equivalent to real:1 2015-06-12 06:23:34 -07:00
Simon Michael
ba6269981b begin reviving journalreader unit tests 2015-06-11 10:16:46 -07:00
Simon Michael
d1769d9d62 journal: allow journal entries with no postings
We now parse, and also print, posting-less journal entries, as I
proposed on the lists.

These are not real General Journal entries/transactions, but here is my
rationale:

- Ledger and beancount parse them
- if we parse them, we should print them
- they provide a natural way to record and report non-transaction events
- most of all, they permit more gradual introduction and learning of the concepts.
  Eg a beginner can keep a simple journal even before learning about accounts and postings.
2015-06-11 10:16:46 -07:00
Imuli
49f1744ae5 read multiple files: internals 2015-05-28 10:40:48 -07:00
Simon Michael
46bbc9e0aa fix simple aliases that match the whole account name 2015-05-28 10:40:48 -07:00
Simon Michael
ef890e1b23 add: quote file name consistently in output
Don't show quotes around the journal file path in the "Creating..."
message since there aren't any in the subsequent "Adding..." message.
2015-05-27 14:41:23 -07:00
Simon Michael
8d75635505 print: limit display precision of generated prices (#262)
When a transaction posts to two commodities without specifying the
conversion price, we generate a price which makes it balance
(cf http://hledger.org/manual.html#prices).

Until now, these generated prices were always shown with full precision
(all available decimal digits) so that a manual calculation with the
displayed numbers would agree.

If there's just one posting in the commodity being priced, we can use an
exact total price and the precision is no problem.

But if there are multiple postings in the commodity being priced, we
must show the averaged unit price. This can be an irrational number,
which with our current Decimal-based implementation would display an
excessive 255 decimal digits. So in this case we now set the price's
display precision to the sum of the (max) display precisions of the
commodities involved. An example:

hledgerdev -f- print
<<<
1/1
    c    C 10.00
    c    C 11.00
    d  D -320.00
>>>
2015/01/01
    c  C 10.00 @ D 15.2381
    c  C 11.00 @ D 15.2381
    d     D -320.00

>>>=0

There might still be cases where this will show more price decimal
places than necessary. For now, YAGNI.
2015-05-27 14:21:19 -07:00
Simon Michael
87d5ddfb71 query: drop the empty: query term
This seems to be equivalent to the --empty option, and overlaps
a bit confusingly with amt:0. I think we can drop it.
2015-05-21 16:44:11 -07:00
Simon Michael
fdc507bd13 match tag names with a regexp, like everything else 2015-05-21 16:25:19 -07:00
Simon Michael
9e2111106b drop regexpr dependency 2015-05-17 08:32:45 -07:00
Simon Michael
68c71de25d tighten up status:X parsing, cleanups 2015-05-16 12:21:50 -07:00
Simon Michael
d1f63334ee handle pending status correctly, add --pending (#250)
A transaction/posting status of ! (pending) was effectively equivalent
to * (cleared). Now it's a separate state, not matched by --cleared.
The new Ledger-compatible --pending flag matches it, and so does
--uncleared. The equivalent search queries are now status:*, status:!
and status: (the old status:1 and status:0 spellings are deprecated).

Since we interpret --uncleared and status: as "any state except cleared",
it's not currently possible to match things which are neither cleared
nor pending.
2015-05-16 11:51:35 -07:00
Simon Michael
077e3c6a02 journal: re-add non-regex aliases, as default (#252)
The regex account aliases added in 0.24 trip up people switching between
hledger and Ledger. (Also they are currently slow).

This change makes the old non-regex aliases the default; they are
unsurprising, useful, and pretty close in functionality to Ledger's.

The new regex aliases are also available; they must be enclosed in
forward slashes. Ledger effectively ignores these, which is ok.

Also clarify docs, refactor, and use the same parser for alias
directives and alias options
2015-05-14 13:01:50 -07:00
Simon Michael
70d87613f2 some cleanup of debug trace helpers 2015-05-14 13:01:49 -07:00
Simon Michael
7c3379db63 journal: allow whitespace following a comment directive 2015-05-09 13:25:31 -07:00
Simon Michael
52ce7c1d93 make recent timelog commit ghc 7.8 compatible 2015-04-29 07:10:13 -07:00
Simon Michael
bb71b077a2 fix runExceptT breakage from recent PR (#248) 2015-04-29 07:08:33 -07:00
Simon Michael
5102eca9c3 timelog: support the description field (fix #247) 2015-04-28 13:54:36 -07:00
Simon Michael
fb37e99bc8 lib: simple dates must start with non-space; docs 2015-04-28 13:50:58 -07:00
Simon Hengel
964a410b24 hledger-lib: Update for base-compat-0.8.0 (see #245) 2015-04-23 15:41:59 +08:00
Simon Michael
ab7ed99cc4 fix broken TimeLocale import for ghc 7.8 (#239) 2015-03-29 16:30:25 -07:00
Simon Michael
f8a24ccead fix parseTime warnings with time 1.5+ (#239) 2015-03-29 16:12:54 -07:00
Simon Michael
e838ed0637 fix a Control.Monad.Error warning (#239) 2015-03-29 16:12:05 -07:00
Simon Michael
e7376e4ea5 unnecessary CPP pragma 2015-03-29 16:10:39 -07:00
Simon Michael
f75849cdd6 fix ghc 7.10 Applicative import warnings (#239)
Still needed CPP, despite using base-compat.
2015-03-29 16:09:41 -07:00
Simon Michael
8e50395b7c ErrorT -> ExceptT, handle mtl <2.2.1 && >=2.2.1 (#239) 2015-03-29 14:16:42 -07:00
Simon Michael
4538745005 adapt to GHC-7.10's foldable/traversable changes (#239) 2015-03-27 15:43:28 -07:00
Simon Michael
e60eb71467 adapt to GHC-7.10's time-1.5 (#239) 2015-03-27 15:42:32 -07:00
Simon Michael
592ae9a28e timelog: show hours with 2 decimal places, not 1 2015-02-27 08:37:16 -08:00
Simon Michael
099a1de3b6 clarify built-in commodities rounding 2015-02-27 08:37:16 -08:00
Simon Michael
d2877a919a add some type signatures in Utils, helps ghci-web 2015-02-09 17:42:51 +00:00
Simon Michael
3d5b269b3d fix rendering of week 52 heading in weekly reports 2015-01-18 09:32:14 -08:00
Julien Moutinho
af56ced3b0 lib: add eof parsing checks 2015-01-11 09:45:55 -08:00
Simon Michael
257ce57383 fix balance accumulation across assertions (#195)
A sequence of balance assertions asserting first one commodity, then
another, then the first again, was not working.
2015-01-10 22:17:19 -08:00
Simon Michael
6da4942633 balance: tweak flags a bit; we now use -N and -T
-N doesn't seem to be used by Ledger currently; we'll
use it as shortcut for --no-total.

-T is used by Ledger to set a custom value expression for the final
total. I'm going to take it as a shortcut for --row-total instead.
2014-12-27 15:34:23 -08:00
Simon Michael
ba0623165f balance: row totals/averages in multicolumn mode 2014-12-27 15:24:45 -08:00
Simon Michael
e794412a8f fix JournalReader ctx warning 2014-12-27 15:24:02 -08:00
Simon Michael
9c68944c79 journal, csv: comment lines can also start with *
As in Ledger. This means you can embed emacs org/outline-mode nodes in
your journal file and manipulate it like an outline.
2014-12-27 14:41:28 -08:00
Simon Michael
62bad65e5b tighten up status: docs and behaviour a bit (fix #227)
A status: query term no longer accepts * as a synonym for 1,
which was a bit confusing since 1 matches both * and !.
For now, it takes a value of 1 (true) or anything else (false).
2014-12-24 23:48:23 -08:00
Simon Michael
c138c35d3b register: support date:/date2:/--date2 better (fix #201, #221, #222) 2014-12-24 16:11:30 -08:00
Simon Michael
d1404adf3f note lack of date2 support in (eg) postingsReport 2014-12-24 14:54:56 -08:00
Simon Michael
6780c63ab3 simplify null Date2 queries too 2014-12-24 14:54:56 -08:00
Simon Michael
77c2c90290 cli: parse date2: correctly (#222) 2014-12-24 14:54:56 -08:00
Julien Moutinho
c65fea2b4b lib: fix combineJournalUpdates folding order
NOTE: this is important to correctly build JournalContext
NOTE: currently a list reverse must done at the end,
      maybe using a Data.Queue would be more efficient.
2014-12-11 04:37:10 +01:00
Simon Michael
855d4e1131 balance: with --tree and --flat, use the last (fix #219) 2014-12-05 12:56:33 -08:00
Simon Michael
d352bbedd2 cli: with a repeated flag, the last takes precedence
This is helpful eg for customising your reporting command aliases on the fly.
2014-12-04 12:41:47 -08:00
Simon Michael
bd39e5df99 showDateSpan: handle boundary-crossing 1-day spans
Eg recognise that 2014/11/30-2014/12/1 can be abbreviated to
2014/11/30d, similarly 2014/12/31-2015/1/1. Doesn't handle feb 29th
correctly, so eg 2000/2/28-2000/3/1 is wrongly abbreviated to
2000/2/28d.
2014-12-03 18:18:05 -08:00
Simon Michael
1708f0b441 csv: try to preserve order of same-day transactions
If the CSV records appear to have been in reverse date order,
we'll now reverse them all before also sorting by transaction date,
so that the original order of same-day transactions is preserved.
We detect this using a simple heuristic: if the first converted
transaction's date is later than the last's.
2014-12-02 11:16:51 -08:00
Simon Michael
733a7b12ef csv: include path is relative to current (close #198) 2014-12-02 10:50:31 -08:00
Julien Moutinho
cf28985cf2 lib: move from Text.ParserCombinators.Parsec to Text.Parsec
NOTE: required to use liftIO in includedirective
SEE: http://www.vex.net/~trebla/haskell/parsec-generally.xhtml#IO
2014-11-20 10:08:30 +01:00
Simon Michael
23fb4ffd84 export failIfInvalidMonth/Day (fixes #216) 2014-10-30 07:58:15 -07:00
Simon Michael
a2612f17c6 tweak wording 2014-10-29 08:27:52 -07:00
Simon Michael
d25fe21834 apply all matching account aliases, not just one directive and one option 2014-10-29 08:20:27 -07:00
Simon Michael
9fa22e0398 account aliases (and regexReplace) now support backreferences 2014-10-29 07:46:49 -07:00
Simon Michael
69636f70fb extract debug helpers into a module 2014-10-28 18:40:22 -07:00
Gergely Risko
6e4a7dff8c Add support for ledger3 style multi-line comments 2014-10-26 19:20:46 +01:00
Simon Michael
e892fdc6d5 parsing: aliases now match by regular expression
alias match patterns (the part left of the =) are now case-insensitive
regular expressions matching anywhere in the account name. The
replacement string (the part right of the =) can replace multiple
matches within the account name. The replacement string does not yet
support any of the usual syntax like backreferences.
2014-10-24 15:05:10 -07:00
Simon Michael
be9b637e0c fix a regexReplaceCI bug 2014-10-24 15:04:21 -07:00
Simon Michael
bfedf367c4 export Regexp types, disambiguate CsvReader's 2014-10-24 14:30:49 -07:00
Simon Michael
f064ecf138 fix a splitAtElement bug with adjacent separators 2014-10-24 14:30:00 -07:00
Simon Michael
b6774f47a3 balance, print: add -o and CSV output here too
Not very elegant yet, but works.
2014-10-21 12:02:23 -07:00
Simon Michael
7f6cf1f849 balance, register, register-csv: depth 0 shows summary items (#206)
Previously, a depth:0 query produced an empty report (since there are no
level zero accounts). Now, it aggregates all data into one summary item
with account name "...".

This makes it easier to see the kind of data Gwern was looking for from
register-csv (net worth over time). Eg this shows one line per month
summarising the total of assets and liabilities:

hledger register-csv -- -MHE ^assets ^liabilities depth:0

Single and multi-column balance reports behave similarly.
2014-10-19 17:53:20 -07:00
Simon Michael
e8a58d9388 cli: add a hidden --version+ flag showing number representation (#118) 2014-10-18 12:35:58 -07:00
Simon Michael
3b70362525 switch to Decimal for representing quantities (closes #118)
hledger has represented quantities with floating point (Double) until
now.  While this has been working fine in practice, the time has come to
upgrade our number representation to something more principled: Decimal,
for now. As a bonus, this brings a ~30% speed boost to most reports.

We'll keep the old representation(s) around for a while, selectable via
hledger-lib cabal flag, for research/testing/benchmarking purposes. To
build with the old Double representation: cabal install -fdouble
hledger-lib hledger hledger-web
2014-10-18 12:33:31 -07:00
Simon Michael
e888be0bf4 clarify similarAmountsOp doc 2014-10-18 10:45:17 -07:00
Simon Michael
2b39f68682 fix a warning in TransactionsReports 2014-10-18 10:32:01 -07:00
gwern
d1618aaca8 strip trailing whitespace from all Haskell files 2014-10-14 18:48:24 -07:00
Simon Michael
22279978af revert an unnecessary "fix" in efe7c7a that broke tests 2014-09-13 21:28:48 -07:00
Simon Michael
efe7c7a029 journal: dates should be followed by whitespace or newline 2014-09-06 09:20:22 -07:00
Simon Michael
aa85e786b9 register: describe datespans briefly, like balance
Eg instead of 2014/01/01 - 2014/01/31, show 2014/01, as in a multicolumn
balance report. The data model is not very elegant, but works for now.
2014-08-08 07:34:11 -07:00
Simon Michael
c485017ca6 journal: require consistent separators in a Y/M/D date
Date separators can be /, - or . but only one kind should be used in
each date. Eg we now reject 2014-8/1.
2014-08-08 07:29:02 -07:00
Simon Michael
3e27f4fb8b journal: add p suffix to date[time] parsers 2014-08-08 07:29:02 -07:00
Simon Michael
a0010a294f cli: smart dates must use a consistent separator
Along with the preceding commits, this means that date:2014-8/1 is now
parsed as 2014/01/01-2014/08/01 as intended, not 2014/08/01.
2014-08-08 07:21:02 -07:00
Simon Michael
632dee668d parse period expressions and date: more strictly
Period expressions and date: query terms must now be parseable all the
way to their end; we won't ignore unparseable trailing bits.
2014-08-08 07:21:02 -07:00
Simon Michael
a675b99870 query: report an error when date:D fails to parse
Previously, a date:D query term was just ignored if D could not be
parsed as a date.
2014-08-08 07:21:02 -07:00
Simon Michael
f631e8e063 register: --average implies --empty
The -A flag now enables -E, so that with a report interval the averages
are always per-period and not per-report-line. (Without a report
interval, -E is already the default).
2014-08-07 14:03:56 -07:00
Simon Michael
d0ad571321 fix manual url in default CSV rules file 2014-08-07 13:15:40 -07:00
Julien Moutinho
a6190420b2 data: add source location to transactions 2014-08-07 16:38:44 +02:00
Simon Michael
3ce34b145c add missing dbgN helpers 2014-07-28 18:57:54 -07:00
Simon Michael
40ab1e17f6 amounts cleanups, and support zeros with commodity 2014-07-28 18:45:13 -07:00
Simon Michael
1333b2650a more showDateSpan cleanup 2014-07-26 17:07:36 -07:00
Simon Michael
a7f7c3181f balance: show compact headings for common intervals
In periodic multicolumn balance reports, column headings now show a more
compact description of common periods (years, half-years, quarters,
months, weeks) for better readability and screen space efficiency.
2014-07-26 16:54:18 -07:00
Simon Michael
f2d9c6e9c1 web: more register chart improvements
- show a background color for future and less-than-zero regions
- show points for transactions, not all line corners
- hovering over point shows balance, date, posted amount and transaction
- clicking a point scrolls towards that date
2014-07-18 16:45:46 -07:00
Simon Michael
4333cae43f web: register chart improvements
- bigger
- plot is horizontal when balance is not changing
- legend for commodities
- some work towards stable commodity colors
2014-07-17 18:56:55 -07:00
Simon Michael
663c68e8e2 web: fix 0s with search by acct within a register 2014-07-17 16:53:36 -07:00
Simon Michael
d3ede5d676 web: remove debug code 2014-07-17 16:29:14 -07:00
Simon Michael
441cae645f web: account transactions report, register clarifications
Clarify the semantics and code of account transactions report a bit.

In the web account register view, emphasise the "historical balance" vs
"running total" distinction; show it as a label for the chart as well,
to reduce confusion.
2014-07-17 16:20:34 -07:00
Simon Michael
b3da48aaa0 identify the commodity in balance assertion errors
Now that balance assertions are checking only a single commodity, it can
be confusing. Eg say all your amounts are in dollars, an assertion like
"= 0" checked the dollar balance in hledger 0.23 but always succeeds in
hledger 0.24. When an assertion fails, we now report which commodity was
checked to help troubleshooting.
2014-07-17 15:23:03 -07:00
Simon Michael
528913d1bd balance: -E adds all starting accounts to multicol rpts
multicolumn balance reports only show accounts with activity (postings)
during the report period, by default. Sometimes you want to show
accounts which have an interesting balance, even if they have no
activity during the period. -E now does this, in addition to showing
leading & trailing empty columns.
2014-07-17 15:18:40 -07:00
Simon Michael
8aec855d04 note dbg0 is like ltrace 2014-07-17 15:06:28 -07:00
Simon Michael
2bfbdd175b queryEndDate 2014-07-15 07:01:01 -07:00
Simon Michael
19d42f8c99 clarify failed balance assertion message 2014-07-15 06:55:46 -07:00
Simon Michael
9f991fa94b tweak Regex haddock 2014-07-08 11:50:19 -07:00
Simon Michael
5bebc2beb0 regex haddock fix 2014-07-06 14:08:45 -07:00
Simon Michael
3a16e6cfc7 mostly replace slow regexpr with regex-tdfa (fixes #189) 2014-07-06 14:03:28 -07:00
Simon Michael
04f6162e19 extract regular expression utils module 2014-07-06 10:11:02 -07:00
Simon Michael
16f8b78305 balance: show multi-commodity amts on one line (fixes #186)
To avoid totally breaking the layout of multicolumn balance reports when
there are multi-commodity balances, these are now rendered on a single
line, comma separated. Simple balance reports still use the old vertical
format for now.
2014-07-03 07:45:55 -07:00
Simon Michael
c31710d942 look harder for decimal point & digit groups (fixes #196)
Amount display styles have been reworked a bit; they are now calculated
after journal parsing, not during it. This allows the fix for #196:
we now search through the amounts until a decimal point is detected,
instead of just looking at the first one; likewise for digit groups.
Digit groups are now implemented with a better type.

Digit group size detection has been improved a little:
1000,000 now gives group sizes [3,4,4,...], not [3,3,...], and
10,000 gives groups sizes [3,3,...] not [3,2,2,..].
(To get [3,2,2,...] you'd use eg 00,00,000.)

There are still some old (or new ?) issues; I don't think we handle
inconsistent decimal points & digit groups too well. But for now all
tests pass.
2014-07-02 23:26:16 -07:00
Simon Michael
647d5833ff clarify dbgAtM issue 2014-07-02 23:24:58 -07:00
Simon Michael
330dfe6891 commodity & amount style parser cleanups, part 2 2014-07-02 17:41:33 -07:00
Simon Michael
9b4b85b4bf commodity & amount style parser cleanups 2014-07-02 11:23:30 -07:00
Simon Michael
8ae303f685 assert only a single commodity, like Ledger (fixes #195)
This change means you can make assertions on a multi-commodity account
balance (asserting one commodity at a time). On the flip side, you can
no longer assert the complete balance of an account (new unexpected
commodities will not be detected.) We might restore that ability later,
using the == syntax.
2014-07-02 07:35:06 -07:00
Simon Michael
0c3148ac7b add an --ignore-assertions flag
Can be helpful when reading Ledger files, where assertions may have
different semantics; or for getting some answers from your journal
to help you fix your assertions.

Could be called --no-assertions, but this might create surprise when it
has an effect contrary to --no-new-accounts.

I had to add another flag throughout the parsers & journal read
functions, ok for now.
2014-07-01 18:26:37 -07:00
Simon Michael
04cfdac0ce query: add >= and <= for amt queries 2014-06-29 11:09:13 -07:00
Simon Michael
5af4ef33ab web: fix a warning 2014-06-13 00:21:26 +01:00
Simon Michael
ec51d28839 web: a bunch of ui cleanup & improvement
- the web UI has been streamlined; edit form, raw & entries views dropped
- we now remember whether sidebar is open or closed
- better help dialog
- keyboard shortcuts are now available
- better add form
- more bootstrap styling
- static file cleanups
- report filtering fixes
- upgrade jquery to 2.1.1, bootstrap to 3.1.1, drop select2, add typeahead, cookie, hotkeys
- clarify debug helpers a little
- refactoring
2014-06-13 00:19:00 +01:00
Simon Michael
b22cb66319 refactor amount filtering helpers 2014-05-23 13:10:36 -07:00
Simon Michael
cf3d21afef csv and general reader fixes, cleanups
- The CSV reader no longer writes a "(stdin).rules" file when reading
  from stdin.

- Selection of reader(s) is now smarter when input is coming from stdin.
  Previously, all readers were considered applicable for stdin.  This
  meant that when reading a CSV file from stdin, the journal and timelog
  readers were always tried first, and if the CSV file was unparseable,
  you'd see the first (journal) reader's error instead of the CSV
  reader's.  Now, the readers do some basic content sniffing when
  reading stdin, so it generally tries only the one right reader and
  we'll see the right errors.

- The read system now has more debug output.
2014-05-09 17:55:32 -07:00
Simon Michael
6871c4cce5 dbgtrace, does a trace if --debug was used 2014-05-09 17:52:23 -07:00
Simon Michael
25ccead21c register: also fix date (or date2) sorting of postings (#184) 2014-05-08 14:20:12 -07:00
Simon Michael
2bd785c3fb aregister: fix date filtering with disordered txns (fixes #184)
Fix a refactoring-related regression that the tests missed: if
transactions were not ordered by date in the journal, register
could include postings before the report start date in the output.
2014-05-07 06:31:34 -07:00
Simon Michael
88f18adbc4 show posting dates in debug output 2014-05-06 21:35:38 -07:00
Simon Michael
4740c7082e csv: allow an empty first name in fields list (fixes #178) 2014-05-03 15:05:35 -07:00
Simon Michael
dedd26bbf5 csv: don't count fields in skipped lines (fixes #177) 2014-05-03 14:54:15 -07:00
Simon Michael
a28d4fd400 register: drop --display, use --historical instead
We provided a very limited implementation of --display only for one use
case: to see an accurate running balance. Now that is achieved more easily
with -H/--historical, similar to the balance command, and --display
can be dropped.
2014-04-30 17:24:41 -07:00
Simon Michael
0132ed7bea balance: a fix for starting balance with --date2 2014-04-30 17:20:02 -07:00
Simon Michael
70ad5b26ff journal: really don't parse + before an amount as part of the commodity (fixes #181 harder) 2014-04-30 11:28:47 -07:00
Simon Michael
8341b4a8d3 journal: don't parse + before an amount as part of the commodity (fixes #181) 2014-04-30 11:21:01 -07:00
Simon Michael
084bf8fea8 queries: treat amt:>0 like amt:>+0
Similar to the special case for amt:<0, for convenience.
To test that the absolute quantity is greater than 0, ie that the
quantity is non-zero, use not:amt:0.
2014-04-27 23:59:11 -07:00
Simon Michael
eeb48c86d1 default report dates come from secondary dates with --date2 2014-04-24 14:44:30 -07:00
Simon Michael
3ed82bd231 default report dates now include postings dated outside the transaction dates span
journalDateSpan now looks at posting dates as well as transaction dates.
2014-04-24 14:28:20 -07:00
Simon Michael
c9d60fab73 balance, register: fix --date2 with report intervals 2014-04-19 15:54:58 -07:00
Simon Michael
4ef33c012a register: report intervals now include all postings in the interval
As with balance. For example, register -p 'weekly in jan' generates
these intervals: 2013/12/30-2014/01/05, 2014/01/06-2014/01/12,
2014/01/13-2014/01/19, 2014/01/20-2014/01/26, 2014/01/27-2014/02/02.
With this change, postings on 2013/12/30-31 and 2014/2/1-2 will be
included in the report, so all period totals are complete and
comparable.
2014-04-19 11:47:05 -07:00
Simon Michael
6af5e6fe06 note potentially useful interval algebra link 2014-04-19 11:45:47 -07:00
Simon Michael
d0461c3ef7 cleanup 2014-04-19 11:26:01 -07:00