Alex Chen
b3a91a49d8
lib: refactor: factor out a TextParser from datep
2018-05-17 18:15:06 -07:00
Alex Chen
09fd8132b7
lib: refactor: weaken types of comment parsers
2018-05-17 18:15:06 -07:00
Alex Chen
31b72f0415
lib: replace notChar for backwards compatibility with megaparsec 5
2018-05-16 22:35:22 -07:00
Alex Chen
99e457f1da
lib: fix performance regression introduced in 30ae9914
2018-05-15 19:29:59 -07:00
Alex Chen
12ddcb1784
lib: extend export list of Read/Common.hs
2018-05-15 11:52:29 -07:00
Alex Chen
17b11aaf1e
lib: refactor parsing of bracketed posting dates
2018-05-15 11:52:29 -07:00
Alex Chen
fcc10f018d
lib: merge parsing of date-tags with that of tags
2018-05-15 11:52:29 -07:00
Alex Chen
ec85271a0b
lib: refactor tags parser: be more efficient, save SourcePos for later
2018-05-15 11:52:29 -07:00
Mykola Orliuk
64c7eb78f4
GHC 8.0 compatibility
2018-05-13 14:41:08 -07:00
Stephen Morgan
5bc5bb5533
Fix doctest error introduced by 49c8c093ac.
2018-05-11 07:25:17 -07:00
Simon Michael
7040289d54
add some exports to fix warnings ( #762 )
2018-05-11 07:17:38 -07:00
Alex Chen
3aa72bdf16
lib: Clean up new code introduced for #655
2018-05-11 06:41:13 -07:00
Alex Chen
30ae991484
lib: Strip comment before parsing tags ( #655 )
2018-05-11 06:41:13 -07:00
Alex Chen
09ec6041bd
lib: Report source positions from internal comment parsers
2018-05-11 06:41:13 -07:00
Alex Chen
b06d22a418
lib: Refactor common comment parsers
2018-05-11 06:41:13 -07:00
Alex Chen
c2199b1125
lib: Add explicit export list to Common.hs
2018-05-11 06:41:13 -07:00
Simon Michael
49c8c093ac
lib: clarify rawnumberp doc
...
[ci skip]
2018-05-09 10:22:39 -07:00
Simon Michael
3f2827424c
refactor: number parsing docs
2018-04-20 21:39:06 -07:00
Dmitry Astapov
ecf49b1e4b
lib: auto postings generated before amount inference and balance checks ( #729 )
2018-04-17 14:33:32 -07:00
Simon Michael
4ff3a749c6
lib: note an oddity with runJournalParser
2018-03-31 02:44:31 +01:00
Mykola Orliuk
b377bff90a
lib: support scientific number notation ( #704 , #706 )
...
closes simonmichael/hledger#704
2018-03-31 01:49:46 +01:00
Moritz Kiefer
d7b68fbd7d
Use skipMany/skipSome for parsing spacenonewline
...
This avoids allocating the list of space characters only to then
discard it.
2018-03-25 22:59:05 +01:00
Simon Michael
84579bb1b4
silence redundant import warnings with ghc 8.4
2018-03-24 22:51:56 +00:00
Simon Michael
d420a8b534
journal: account directive: parse and store a numeric account code also
2018-01-23 11:33:23 -08:00
Mykola Orliuk
47766ea9d4
journal: support space as digits sep
...
Resolves simonmichael/hledger#330
2017-11-29 17:20:18 +01:00
Mykola Orliuk
e58272f28f
journal: use groups sep and prec for decimal hint
...
Use whole AmountStyle in process of resolving decimal/groups separator
ambiguity.
Resolve simonmichael/hledger#399
2017-11-27 15:47:56 -08:00
Mykola Orliuk
7cbdeb40a4
journal: get decimal hint from default commodity
...
If appropriate commodity directive is missing fallback to default
commodity directive to get number representation style.
2017-11-27 15:47:56 -08:00
Mykola Orliuk
b7dbe044b0
journal: use decimal sep hint for amount parser
...
Make use of commodity format directive as a hint for parsing amount.
Kinda resolves simonmichael/hledger#487
2017-11-27 15:47:56 -08:00
Mykola Orliuk
dafdaec1ca
journal: factor out rawnumberp
2017-11-27 15:47:56 -08:00
Mykola Orliuk
bcf7a1add5
journal: make numbers parsing more strict
...
- Hunt down adjacent punctuations with altering char.
- Add some tests dedicated to parsing amounts.
2017-11-27 15:47:56 -08:00
Simon Michael
4ab71f0d0a
journal: clarify that txn/posting comments must start with semicolon
2017-11-01 08:04:25 -07:00
jeevcat
3a9ea65b99
Rewrite of BalanceAssertion type to track its source position.
...
Fixes #481 .
2017-10-16 13:25:03 -07:00
Simon Michael
7edacdf443
cli: import command! hledger import *.csv adds new txns to main file
2017-09-17 18:57:51 -07:00
Simon Michael
669fa706c0
print: --new shows only transactions added since last time
...
First cut, error messages could be refined etc.
2017-09-15 09:55:17 -07:00
Simon Michael
e3c4a76119
add & use simpler readJournalFilesWithOpts/InputOpts api
2017-09-14 17:43:32 -07:00
Simon Michael
d7d5f8a064
add support for megaparsec 6 ( fixes #594 )
...
Older megaparsec is still supported.
Also cleans up our custom parser types,
and some text (un)packing is done in different places
(possible performance impact).
2017-07-27 19:20:46 -07:00
Simon Michael
dcc58d4a2b
lib: rename ClearedStatus type to Status
...
(and fix hard-coded enum count)
2017-06-15 19:16:39 -07:00
Simon Michael
e119941648
rename "uncleared" status to "unmarked" and --uncleared to --unmarked ( #564 )
...
See the issue and linked mail list discussion. Ambiguity between the
uncleared state, and the "not cleared" --uncleared flag causes confusion
and friction. At this point it seems best to break with Ledger and
past hledger, pick a new name and drop --uncleared to put an end to it.
2017-06-15 19:16:39 -07:00
Christian G. Warden
d39040c634
Add Support for Rewriting Multipler Postings Into Different Commodities ( #557 )
...
When generating a new posting as a multiple of an existing posting,
support conversion to a different commodity. For example, postings in
hours can be used to generate postings in USD.
Automatic transactions generated from rewrite rules use the commodity,
amount style, and transaction price if the rewrite defines a commodity.
2017-05-30 07:30:15 -07:00
Mykola Orliuk
7437c96ff6
Make hledger-rewrite tool suitable for re-factoring original journals ( #490 )
...
* cli: fix bug in pivot for postings without tag
Without this fix for postings without tag query checked effective
account which is always empty text ("").
* rewrite: inherit dates, change application order
For budgeting it is important to inherit actual date of posting if it
differs from date of transaction. These dates will be added
as a separate line of comment.
More natural order of rewrites is when result of first defined one is
available for all next rewrites.
* rewrite: factor out Hledger.Data.AutoTransaction
* rewrite: add diff output
With this option you can modify your original files without loosing
inter-transaction comments etc. I.e. you can run:
hledger-rewrite --diff Agency \
--add-posting 'Expenses:Taxes *0.17' \
| patch
As result multiple files should be updated.
Also it is nice to review your changes using colordiff instead of
patch.
* lib: track source lines range for journal
* doc: auto entries and diff output for rewrite
2017-01-20 07:33:24 -08:00
Johannes Gerer
45401e538e
Balance Assignments and accounts resetting ( #438 )
...
* Changed behavior of `readJournalFiles` to be identical to `readJournalFile` for singleton lists
* Balance Assertions have to be simple Amounts
* Add 'isAssignment' and 'assignmentPostings' to Hledger.Data.Posting and Transaction
* Implemented 'balanceTransactionUpdate', a more general version of 'balanceTransaction' that takes an update function
* Fixed test cases.
* Implemented balance assignment ("resetting a balance")
* Add assertions to show function
* updated the comments
* numbering is not needed in journalCheckBalanceAssertions
* remove prices before balance checks
* rename functions
2016-12-10 07:04:48 -08:00
Johannes Gerer
74502f7e50
more general parser types enabling reuse outside of IO ( #439 )
2016-12-09 15:57:17 -08:00
Simon Michael
c8650e0d10
comment
2016-11-12 13:54:48 -08:00
Simon Michael
9396bc6711
lib: fix ghc 8 warnings in Read.Common
2016-09-05 14:31:56 -07:00
Simon Michael
72c39470d6
lib: non-journal formats now produce transaction ids #394
...
Transactions are now numbered consistently during journal finalisation,
rather than just in the journal reader. Also transaction knot-tying has been
moved out of journalBalanceTransactions.
2016-08-14 12:44:19 -07:00
Moritz Kiefer
4141067428
Replace Parsec with Megaparsec (see #289 ) ( #366 )
...
* Replace Parsec with Megaparsec (see #289 )
This builds upon PR #289 by @rasendubi
* Revert renaming of parseWithState to parseWithCtx
* Fix doctests
* Update for Megaparsec 5
* Specialize parser to improve performance
* Pretty print errors
* Swap StateT and ParsecT
This is necessary to get the correct backtracking behavior, i.e. discard
state changes if the parsing fails.
2016-07-29 08:57:10 -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