Commit Graph

1000 Commits

Author SHA1 Message Date
Simon Michael
321635274c lib: move assertParseEqual' (#812) 2018-08-14 16:05:06 +01:00
Simon Michael
b03584dbce lib: parse helper haddocks 2018-08-14 16:05:06 +01:00
Simon Michael
cfaa0501e6 lib: update some journal parser tests (#812) 2018-08-14 16:05:06 +01:00
Jakub Zárybnický
c67404c73d lib: Fix compile errors in tests 2018-08-14 16:05:06 +01:00
Simon Michael
e88a9c4a5f lib: followingcomment: parse no comment as "", not "\n"
Same-line & next-line comments of transactions, postings, etc.
are now parsed a bit more precisely. Previously parsing no comment
gave the same result as an empty comment (a single newline); now
it gives an empty string.

Also, and perhaps as a consequence of the above, when there's no
same-line comment but there is a next-line comment, we'll insert an
empty first line, otherwise next-line comments would get moved up to
the same line when rendered.

Some doctests have been added.
2018-08-03 19:38:55 +01:00
Simon Michael
df430e5eb0 lib: AccountName: set OverloadedStrings for doctests 2018-08-03 19:05:14 +01:00
Joseph Weston
40d70ad10b lib: fail when file to include is in stack of 'include' files 2018-08-02 18:43:00 +01:00
Joseph Weston
1d91ea43a5 lib: add whitespace around '$' operator 2018-08-02 18:43:00 +01:00
Simon Michael
d685d1aa9b lib,rewrite: simplify transactionModifierToFunction
This removes transactionModifierToFunction's extra query parameter;
the rewrite command sets it in the TransactionModifier instead, which
I think is equivalent. I had to change one functional test, but it
seems correct now, so perhaps it wasn't working right before ?
2018-08-02 08:25:49 +01:00
Simon Michael
1e0a7ec8f1 remove some unneeded CPP pragmas 2018-08-02 08:25:49 +01:00
Simon Michael
eae9d78bb1 lib: generateAutomaticPostings -> applyTransactionModifiers 2018-08-02 08:25:49 +01:00
Simon Michael
bb36693155 lib: refactor, txnTieKnot automatically 2018-08-02 08:25:49 +01:00
Simon Michael
572f5a4b31 lib: drop parseAndFinaliseJournal', seems unused (api change) 2018-08-02 08:25:49 +01:00
Simon Michael
a49b1cd3bb lib: AutoTransaction.hs -> TransactionModifier.hs, PeriodicTransaction.hs 2018-07-30 20:22:39 +01:00
Simon Michael
efc54c4c25 lib: ModifierTransaction -> TransactionModifier; try to clarify a bit 2018-07-30 19:38:21 +01:00
Simon Michael
007b9f8caa lib: capitalised month names broke some period expressions (fix #852)
This was a regression in hledger 1.10.
mon[th]Index are now case insensitive.
2018-07-30 11:08:23 +01:00
Simon Michael
daa37a9993 lib: nthdayof(month|year)containing now validate input a bit (#852) 2018-07-30 11:08:14 +01:00
Simon Michael
0f3a030a40 lib: whitespace 2018-07-30 11:05:02 +01:00
Simon Michael
eb6baac6e7 lib: make applyN more robust (#852) 2018-07-30 11:04:33 +01:00
Simon Michael
d9d94e2cf6 journal: fix breakage in auto posting rule parser (#745)
I was negligent and did not test enough. This should ignore
transaction comments in auto posting rules more safely.
It also adds support for trailing comments on the first line of auto
posting rules, which previously were misparsed as part of the query.
2018-07-26 15:54:21 +01:00
Simon Michael
e2f5e98926 lib: clarify account name parsing rules 2018-07-26 08:30:32 +01:00
Simon Michael
41c985b5fb journal: ignore transaction comments in auto posting rules (#745)
Previously they were misparsed as account names.
2018-07-26 08:29:02 +01:00
Joseph Weston
f2c1586238 lib: sort the matched include files lexicographically
Now the files are included in the same order as they would be
listed by 'ls'.
2018-07-26 06:12:31 +01:00
Joseph Weston
1ec16c2dc0 lib: explicitly specify that the 'Glob' package should be used
Without this there are conflicts with the 'filemanip' package,
which itself exports a module 'System.FilePath.Glob'.
2018-07-26 06:12:31 +01:00
Joseph Weston
c69b16d826 lib: prefer use of 'parseErrorAt' to generic 'fail'
'fail' will just terminate the current parse branch, whereas here
we have encountered a definite error. Also bring the code to
get the current working directory inside 'getFilePaths', as it
logically belongs there.
2018-07-26 06:12:31 +01:00
Joseph Weston
5077443a84 lib: add tests and code for nonexistant files and malformed globs 2018-07-26 06:12:31 +01:00
Joseph Weston
2c4d0c0acd lib: factor out logic for obtaining a list of files to include 2018-07-26 06:12:31 +01:00
Joseph Weston
0ade323d2a lib: use glob matching if filename in 'include' directive is a glob pattern 2018-07-26 06:12:31 +01:00
Joseph Weston
96f7a03487 lib: factor out parsing child journal into separate function 2018-07-26 06:12:31 +01:00
Joseph Weston
52da073828 lib: expand current directory separately from filepath
We will need the current directory as an absolute path when
adding glob patterns in a few commits time.
2018-07-26 06:12:31 +01:00
Joseph Weston
9e56ad24e2 lib: reorder code for reading include files
This should be before all journal and parser state manipulations,
so that those can be readily factored in a few commits time.
2018-07-26 06:12:31 +01:00
Simon Michael
aab7d2d964 lib: fix error triggered by upper-case day in period expression (#847) 2018-07-24 14:36:45 +01:00
Simon Michael
da8047d286 lib: type signatures 2018-07-24 14:24:45 +01:00
Simon Michael
fe73f2a6b5 csv: interpolated field names in values are now case insensitive
Field names are supposed to be case insensitive, but a field assignment like

fields  ...,Transaction_Date,...
date %Transaction_Date

was failing, because of the capitalised letters. Fixed now.
2018-07-22 22:26:24 +01:00
Simon Michael
aebd6c50d6 smooth: smoothes out irregular transactions (experimental addon) 2018-07-16 23:36:06 +01:00
Simon Michael
d5430e7ddf clean up debug helpers (api change) 2018-07-16 15:28:58 +01:00
Simon Michael
9d2e80aa2c lib: Debug: simplify pprint, export ppShow as pshow (api change) 2018-07-16 12:51:50 +01:00
Simon Michael
92404bb847 prices: allow filtering by query, clarify docs
Query arguments are allowed, prices can be filtered by date, and
postings providing transaction prices can be filtered by anything.
2018-07-15 09:21:10 +01:00
Simon Michael
91e5baf617 lib: clean up queryDateSpan, queryDateSpan' (api change)
These now intersect date AND'ed date spans, instead of unioning them,
and docs are clearer.
2018-07-15 08:35:39 +01:00
Simon Michael
6924e8390c lib: journal: let alias/apply account affect account directives (#825) 2018-06-27 11:33:12 +01:00
Alex Chen
e82b01bcf8 lib: refine parse errors and parser labels 2018-06-20 23:24:39 -06:00
Alex Chen
9674f2a8cc lib: tweak whitespace parsing for better parse errors
- expands the set of expected tokens when e.g. parsing the invalid
  posting `account  $1 a`
- whitespace can affect parse errors because of the longest match rule
  where errors that occur later take precedence over those that occur
  earlier
2018-06-20 23:24:39 -06:00
Alex Chen
ed0106b209 lib: reduce backtracking of various parsers 2018-06-20 23:24:39 -06:00
Alex Chen
e3a755b5b1 lib: refactor amount parsers to minimize backtracking
- inline `spaceamountormissingp` into `postingp`
- combine `rightsymbolamountp` and `nosymbolamountp`
- the multiplier symbol '*' for an amount must now always preceed a sign '-'
  [breaking change]
- make amount parser labels more generic to simplify error messages
2018-06-20 23:24:39 -06:00
Alex Chen
89b1fd7de3 lib: refactor date-time parser, add error messages
- also removed commented-out time-zone code
2018-06-20 23:24:39 -06:00
Simon Michael
816ba0f89d consistent comment wording 2018-06-18 17:54:25 -07:00
Simon Michael
c4d45cffc4 lib: journal: require a space between period expr. and other fields 2018-06-12 16:41:36 -07:00
Simon Michael
eb23504906 lib: periodexprp: don't consume trailing whitespace 2018-06-12 16:41:36 -07:00
Alex Chen
c6bfd92dd3 removing "re-parsing" for pull 807
For Data/Dates.hs in particular:
- Changed `SimpleTextParser` to `TextParser m` for all parsers
- Changed `string` to the case-insensitive `string'` to match the
  behaviour of `T.toLower` found in `parsePeriodExpr`
- export `periodexprp` for "direct" use
2018-06-12 16:41:36 -07:00
Simon Michael
e3507ad944 lib: journal: allow descriptions/comments in periodic transactions
Also period expressions relative to today's date can now be used,
for what it's worth.
2018-06-12 16:41:36 -07:00