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
f8a24ccead
fix parseTime warnings with time 1.5+ ( #239 )
2015-03-29 16:12:54 -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
e60eb71467
adapt to GHC-7.10's time-1.5 ( #239 )
2015-03-27 15:42:32 -07:00
Julien Moutinho
af56ced3b0
lib: add eof parsing checks
2015-01-11 09:45:55 -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
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
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
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
bfedf367c4
export Regexp types, disambiguate CsvReader's
2014-10-24 14:30:49 -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
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
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
40ab1e17f6
amounts cleanups, and support zeros with commodity
2014-07-28 18:45:13 -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
3a16e6cfc7
mostly replace slow regexpr with regex-tdfa ( fixes #189 )
2014-07-06 14:03:28 -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
9b4b85b4bf
commodity & amount style parser cleanups
2014-07-02 11:23:30 -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
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
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
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
da0ce23144
don't let default commodity limit the max precision ( fixes #169 )
2014-03-26 17:25:59 -07:00
Simon Michael
4b4715ab76
parsing: don't accept . as a valid amount
2014-03-01 10:26:20 -08:00
Simon Michael
762a1b4d74
parsing: comments can also start with # in col 0
2014-02-27 11:47:36 -08:00
Simon Michael
d158d401d9
fix some breakages found by Hydra
2014-02-05 19:30:01 -08:00
Simon Michael
5223bc5c41
lib: rename and expose more journal file parsers
2014-02-05 18:55:38 -08:00
Simon Michael
dc8b687056
extra: hledger-rewrite script
2014-02-05 13:03:06 -08:00
Simon Michael
3cf53661f3
new debug helpers; --debug=N sets debugLevel
...
The debug level set by `--debug[=N]` is now available to pure and
startup code as debugLevel, using unsafePerformIO.
`dbg LABEL ...` is now the go-to helper for tracing values on the
console; it produces output when the debug level is non-zero. `dbgExit`
is similar but exits immediately, avoiding further output. The
`dbgshow`, `dbgppshow` and `dbgpprint` variants allow control over the
pretty-printing method and required debug level, allowing more control
over what is displayed when.
Other cleanups: lstrace -> ltrace, pdbgAt -> pdbg, tracewith -> traceWith.
2013-12-06 13:35:50 -08:00
Simon Michael
f9656a21af
print: comment positions (same line or next line) are now preserved
2013-09-10 10:32:49 -07:00
Simon Michael
eff1d3f1a5
csv reader: add the include directive, useful for factoring out common rules used with multiple CSV files
2013-08-03 20:53:41 -07:00
Dmitry Astapov
ed58d815d6
Fix for multiple field assignments in CSV parsing
2013-06-19 08:30:33 +01:00
Simon Michael
080eb866ec
web: clean up language extensions a bit, make autoweb works again
2013-06-04 18:23:55 -07:00
Simon Michael
44545d6ec7
parsing: update a csv reader error message
2013-06-01 12:38:58 -07:00
Simon Michael
a26ab926d8
parsing: don't fail when a csv amount has trailing whitespace ( fixes #113 )
2013-06-01 12:38:13 -07:00
Simon Michael
56a37aabcf
small cleanup
2013-05-30 15:17:21 -07:00
Simon Michael
0be986fcb9
parsing: actually parse balance assertions
...
Parser unit test is commented out until HTF tests are fixed.
2013-05-28 16:22:30 -07:00
Simon Michael
78837c66a6
parsing: fix test breakage due to new csv rules format ( fixes #102 )
2013-04-12 14:59:28 -07:00
Simon Michael
616a25979a
CSV reader version 2 with new rules syntax
...
At long last. The main change is a new rules file format that aims to
be more powerful and more intuitive than v1 (hledger 0.19.x and older).
Existing rules files will need to be adapted manually to the new format.
2013-03-29 22:56:55 +00:00
Simon Michael
af5c0e80e0
parsing: read files in universal newline mode
...
Line endings other than the unix style, are now accepted in journal and rules files.
2013-03-29 18:46:10 +00:00
Simon Michael
7b6a59123d
eolof parser matches end of line or end of file
2013-03-29 18:42:00 +00:00
Simon Michael
69f2491224
export journal file code parser
2013-02-24 21:07:54 +00:00
Simon Michael
621a91807e
rename actual/effective dates to primary/secondary
...
The command-line flag is now --date2. Alternate spellings --effective and --aux-date
are accepted for compatibility.
2012-12-06 04:43:41 +00:00
Simon Michael
869ff2528a
accept normal simple date syntax in posting dates, give an error on bad date syntax here
2012-12-06 03:23:56 +00:00
Simon Michael
20e68f23a8
support effective dates on postings as well
...
We now preserve all dates while reporting, instead of overwriting one with the other.
2012-12-06 02:41:37 +00:00
Simon Michael
e75abc4625
parse posting dates, better comment/tag handling, begin using HTF for unit testing
2012-12-06 00:28:23 +00:00
Simon Michael
4aafeb32e6
refactor: clean up Posting construction
2012-12-06 00:03:07 +00:00
Joachim Breitner
f0372bdd93
Also parse ! as a modifier, like *
2012-12-03 21:38:05 +00:00
Simon Michael
6eda8c4bbf
csv reader: append ".rules" to the original file name instead of replacing its extension
2012-11-26 01:56:39 +00:00
Simon Michael
afb4fb0356
csv reader: parse parenthesised amounts as negative
2012-11-26 01:56:01 +00:00
Simon Michael
8b4a99c4d5
79: convert: add a skip-lines directive (Magnus Henoch)
2012-11-18 18:21:52 +00:00
Simon Michael
1c6a7d8a6f
rename the commodityless amount constructor to num
2012-11-20 02:22:20 +00:00
Simon Michael
45d4a38cc7
refactor: setAmountPrecision -> withPrecision
2012-11-19 23:24:04 +00:00
Simon Michael
64180b18ef
refactor: clarify that price amounts have only a single commodity
2012-11-19 23:17:55 +00:00
Simon Michael
8c06553e3b
refactor: make amount price a non-maybe, reducing noise
2012-11-19 22:39:08 +00:00
Simon Michael
4567e91409
refactor: move amount display settings out of commodity, simplify amount construction
2012-11-19 21:20:10 +00:00
Simon Michael
1c1058be4e
70: ignore ledger's fixed lot price declarations
2012-11-17 02:40:27 +00:00
Simon Michael
28baf926f7
parsing: ignore ledger-style balance assertions ("= BAL" after a posting's amount)
2012-11-02 16:50:36 +00:00
Simon Michael
5b9c5459be
web: make hledger[-lib] compatible with all of yesod's language extensions
...
Useful when building all of hledger-web at once.
2012-11-14 17:25:02 +00:00
Simon Michael
2a4d89bb27
expose more utilities from CsvReader
2012-05-29 21:00:49 +00:00
Simon Michael
0b96a767b4
support tilde (~) in journal and rules file paths
2012-05-30 08:36:01 +00:00
Simon Michael
776ad2a098
remove ensureRulesFile debug trace
2012-05-30 08:36:34 +00:00
Simon Michael
34318906d8
register, print: fix reverse ordering of same-day transactions
2012-06-29 18:06:58 +00:00
Simon Michael
33b7c91e20
combine journal updates with foldl' instead of foldr
...
on general principles, even though it makes no measurable difference
2012-05-30 10:19:08 +00:00
Simon Michael
9a239789fa
apply journal updates in the order they were parsed, not the reverse (!)
...
Fixes the order of include files in stats command.
2012-05-30 10:16:37 +00:00
Simon Michael
50068221c3
fix build warnings in all GHC versions
2012-03-29 21:19:35 +00:00
Simon Michael
b77ba66fb1
haddock fix
2012-05-15 01:51:14 +00:00
Simon Michael
9524e6d927
more metadata -> tag renaming in the parser
2012-05-28 00:24:49 +00:00
Simon Michael
1062e2f9a4
clean up reader selection, don't write a csv rules file on journal parse error
2012-05-28 18:40:36 +00:00
Simon Michael
cb905a741c
new query by tag implementation
2012-05-28 00:27:55 +00:00
Simon Michael
2fb2aea056
rename metadata fields to tags
2012-05-27 22:59:06 +00:00
Simon Michael
3ee6a351f3
big query/tests/show refactoring
...
- use new query system for command line too, filterspec is no more
- move unit tests near the code they test, run them in bottom up order, add more
- more precise Show instances, used for debugging not ui
2012-05-27 18:14:20 +00:00
Simon Michael
56cf9b21cb
fix txn & posting comment parsing & printing; better unit tests
2012-05-15 01:49:05 +00:00
Simon Michael
a58a5f96ad
more robust comments & metadata, on postings too, and document as "tags"
2012-05-14 18:52:22 +00:00
Simon Michael
88212f26e8
simplify journal parser names
2012-05-09 15:34:05 +00:00
xiaoruoruo
ce83876700
metadata parse and show for transaction
2012-04-08 19:13:56 +00:00
Simon Michael
8492f6cae4
fix unicode handling on GHC >= 7.2, unify utf8 IO compatibility layer
...
tests pass again from GHC 6.12.3 to 7.4.1
2012-03-29 19:06:31 +00:00
Simon Michael
d4451ce5e3
read system cleanup, require conversion rules from a file to simplify API
2012-03-24 18:08:11 +00:00
Simon Michael
e396c0dc8d
push csv rule and format string types down
2012-03-24 01:58:34 +00:00
Simon Michael
6eb7ad28e1
refactor/beef up readJournal/readJournalFile
2012-03-23 16:21:41 +00:00
Simon Michael
4d7a809c4a
cleanups and early code for csv reader based on convert
2012-03-10 21:55:48 +00:00
Simon Michael
381ebea35c
show correct line number for posting parse errors ( #67 )
2011-10-04 23:39:53 +00:00
Simon Michael
8d62452260
parsing: historical price directives may contain a numeric time zone, like ledger; note that the time is ignored
2011-06-01 01:50:04 +00:00
Simon Michael
946e5ffcbc
parsing: parse time of day more carefully
2011-05-31 22:45:54 +00:00
Simon Michael
1f24e025da
parsing: make bad date parse error more reliable
2011-05-31 19:49:37 +00:00
Simon Michael
a44aa8d7d2
refactor: remove unnecessary LANGUAGE CPP pragmas
2011-07-17 23:29:57 +00:00
Simon Michael
1273f02a9a
more balance/amount clarifications and a test
2011-08-30 11:37:36 +00:00
Simon Michael
957c349780
--alias command-line option
2011-08-05 00:05:39 +00:00
Simon Michael
30b7448f45
parsing: alias/end aliases directives, like ledger's but a bit more powerful
2011-08-04 08:45:18 +00:00
Simon Michael
4015e02097
account directive should preserve virtual/balanced virtual posting type
2011-08-02 23:29:13 +00:00
Simon Michael
345c2343b6
refactor ledgerDirective
2011-08-04 07:49:10 +00:00
Johann Klähn
8e7d20e4d5
parsing: support pop as well as end tag
2011-05-31 17:41:12 +00:00
Simon Michael
75f0886ad4
parsing: make the leading ! in directives optional, like ledger
2011-08-02 23:28:53 +00:00
Simon Michael
5084280879
imports, api cleanup
2011-05-28 04:11:44 +00:00
Simon Michael
8980dd9336
parser cleanup
2011-01-19 23:27:44 +00:00
Simon Michael
6a845eb5e4
i18n: always read and write UTF-8, ignoring current locale ( #34 )
...
Also remove a bunch of CPP conditions.
Uses the GHC-version-independent UTF-8 layer from pandoc.
2011-01-21 01:24:51 +00:00
Simon Michael
5f1ebc694a
parsing: assume current year when transaction dates have no year and there is no default year
2011-03-11 18:45:57 +00:00
Simon Michael
1c7ad7f421
parsing: more careful validation of eg leap years in transaction dates (only)
2011-04-22 13:55:42 +00:00
Simon Michael
d3663b818e
parsing: better international number format support ( #32 )
...
This allows period and comma to be used for decimal point and digit group
separator or vice versa, and also flexible digit groups. See
http://en.wikipedia.org/wiki/Decimal_separator . Digit group separators
are possibly not worth the trouble and might not stay.
2011-01-19 12:32:18 +00:00
Simon Michael
dd9e78a67a
reorganize tests
2010-12-27 20:26:22 +00:00
Simon Michael
e03ada3bd3
parsing: support @@ syntax specifying total price
2011-01-15 02:04:53 +00:00
Simon Michael
631215d5d7
parsing: accept (but ignore) c++ ledger's C commodity conversion directive
2010-11-12 23:55:40 +00:00
Simon Michael
d7617fe154
parsing: ignore cleared flags at the start of postings, parse account name correctly
2010-11-13 20:20:04 +00:00
Simon Michael
811e71aba7
price precisions don't influence display precision; balancing is based on display precision ( #23 )
...
Like ledger, price amounts are now "unobserved", ie their precision does
not affect the canonical display precisions used when displaying amounts,
and transaction balancing is done based on display precision, ie amounts
are considered to balance if their sum appears to be zero when using the
canonical display precision.
2010-11-14 22:44:37 +00:00
Simon Michael
77519e2c1d
remove debug code breaking reports
2010-11-14 18:10:48 +00:00
Simon Michael
e707f97847
parsing: parse transaction and posting metadata, though we don't use it yet
2010-11-13 22:17:32 +00:00
Simon Michael
17d5acf64b
refactor: more reader cleanups
2010-11-15 07:18:35 +00:00
Simon Michael
a3a7a346ac
uniquify reader module names
2010-11-15 07:01:46 +00:00
Simon Michael
d6c2cf6a90
parsing: save final parse context with journal
2010-11-13 15:03:40 +00:00
Simon Michael
7714bab58d
web: offer a choice of files to edit when there are multiple (included) files
2010-09-24 01:56:11 +00:00
Simon Michael
78db98366f
parsing: support D default commodity directive
2010-11-12 23:54:21 +00:00
Simon Michael
8429df0f32
remember all included file paths, if any
2010-09-22 23:02:19 +00:00
Simon Michael
96036e56a0
docs: comments
2010-09-22 21:51:25 +00:00
Simon Michael
d132f5e45a
ledgerInclude cleanup
2010-09-22 21:52:04 +00:00
Ben Boeckel
5e576e9ff0
fix-recursive-includes
...
Fix recursive includes beyond depth 3. Also add a test case for the bug.
2010-09-02 00:30:57 +00:00
Simon Michael
d29b393ca2
fix a failing test, handle unicode better in errors
2010-09-05 18:18:50 +00:00
Simon Michael
ce7e155934
parsing: fix obscured date parse errors with parsec 3; require split
...
With parsec 3, invalid date errors were not being reported properly.
This should be more robust.
2010-09-03 23:22:58 +00:00
Simon Michael
63de5e0127
parsing: fix wrong parse error locations within postings
2010-07-08 02:51:17 +00:00
Simon Michael
3e9ad0ae13
parsing: don't let trailing whitespace in a timelog description mess up layout
2010-07-08 03:08:28 +00:00
Simon Michael
7d7159609b
refactor: much renaming of ledger -> journal, hopefully the right amount
2010-07-13 06:30:06 +00:00
Simon Michael
8a64792ba7
smarter file reading: detect (or specify) intended data format and show appropriate error messages
...
New data reader modules need to provide just reader :: Reader, which is
the format name, a detector predicate, and a parser.
2010-06-25 14:56:48 +00:00
Simon Michael
1ec1f7c4ea
more file reading cleanup, try each known format in turn
...
Currently this is just the journal and timelog file formats. This is more
scalable, but when things go wrong there is no longer just a single parse
error. For now we'll just show the first error, the one from the journal
file parser.
2010-05-31 01:15:18 +00:00
Simon Michael
a848a835a2
clean up and combine I/O and parsing under Hledger.Read.*
...
This facilitates adding readers for new data formats. Timelog parsing is temporarily broken.
2010-05-30 19:11:58 +00:00