Commit Graph

445 Commits

Author SHA1 Message Date
Simon Michael
0a3af8d9ee csv: strip outer whitespace when interpolating CSV values (#1051)
This removes a potential snag in amount field assignments, and
hopefully is harmless and acceptable otherwise.
2019-06-14 16:43:12 -07:00
Simon Michael
d2b3185062 csv: don't show invalid inter-field spaces in CSV error messages
Errors involving a record like:

2000-01-01,a,"1"

displayed the record with extra spaces:

the CSV record is:       "2000-01-01", "a", "1"

which was not accurate or valid RFC-4180.
2019-06-14 16:17:40 -07:00
Simon Michael
692620180e ;lib: refactor: change AmountPrice to a Maybe
I've wanted to do this for a long time; now that prices are in flux,
seems a good time.
2019-06-13 15:50:01 -07:00
Simon Michael
adb6ee40eb lib: clarify price types (#131)
dropped journalPrices

renamed Price to AmountPrice,  AKA "transaction price"

renamed MarketPrice to PriceDirective.

added new MarketPrice (more pure form of PriceDirective without the amount style information)

Prices is now a more efficient data structure, but not used yet.
2019-06-13 15:50:01 -07:00
Simon Michael
90af360792 csv: fix parse error printing, broken since 1.11 (#1038) 2019-06-06 23:10:31 -07:00
Simon Michael
61e8ccbf88 csv: accept a balance field assignment instead of an amount (#1000) 2019-04-03 10:46:26 -07:00
Dmitry Astapov
3c3200fa66 lib: csv parser support for 'balance2', 'balance' renamed to 'balance1' 2019-03-15 16:18:43 -07:00
Simon Michael
c5df73910f csv: update some parse errors which weren't in human format
cf
https://www.reddit.com/r/plaintextaccounting/comments/axekse/hledger_how_to_create_curved_brackets_with_rule/
2019-03-05 06:23:11 -08:00
Simon Michael
8789a442a8 lib: inclusive balance assertions (=* and ==*) 2019-02-20 09:14:30 -08:00
Simon Michael
3b47b58aec lib: clarify transaction balancing & balance assertion checking 2019-02-20 09:14:30 -08:00
Simon Michael
d1f122f15e refactor: clarify, note issues (#893) 2019-02-01 15:35:33 -08:00
Simon Michael
d6e075dacd refactor journalModifyTransactions, modifyTransactions
API changes:

Hledger.Data.TransactionModifier
-transactionModifierToFunction
+modifyTransactions

Hledger.Read.Common.applyTransactionModifiers -> Hledger.Data.Journal.journalModifyTransactions
2019-02-01 11:31:04 -08:00
Simon Michael
550e33a558 journal: fix balance assertions/assignments & prices (#824)
Hopefully this is will do it. This restores the past behaviour:

- parsing prices in balance assertions/assignments
- ignoring them in assertions
- using them in assignments
- and printing them

and clarifies tests and docs.
2019-01-25 12:41:10 -08:00
Simon Michael
94d5c6f111 journal: allow prices in balance assertions, but ignore (#824, #958) 2019-01-25 08:59:37 -08:00
Simon Michael
b02f81572c lib: comment
[ci skip]
2019-01-25 08:51:45 -08:00
Simon Michael
a61216ac3c journal: allow account types to be set with a type: tag 2019-01-18 16:40:35 -08:00
Simon Michael
763903ebda journal: save account directives' comments, tags, declaration order 2019-01-18 16:40:35 -08:00
Simon Michael
899946f270 journal: account directive: stop supporting account sort codes
Eg "account   1000". (Introduced in 1.9, deprecated in 1.11, removed in 1.13.)
2019-01-18 16:40:35 -08:00
Dmitry Astapov
faa5b0fba7 lib: fix parsing of status/code/desc/comments in period txn 2019-01-16 17:17:18 -08:00
Simon Michael
c5ae8e6891 comments 2019-01-16 13:58:04 -08:00
Simon Michael
5ee79797e1 better fix for #949, don't reverse same-day assertions with --auto 2019-01-16 09:10:58 -08:00
Simon Michael
274b1c12a1 whitespace 2019-01-15 12:58:05 -08:00
Simon Michael
f1441be404 lib: basic unit test for parseAndFinaliseJournal 2019-01-15 12:57:51 -08:00
Simon Michael
228fc9eb3c preserve correct file order when using --auto (fixes #949)
And clarify parseAndFinaliseJournal a bit.
2019-01-15 06:14:47 -08:00
Simon Michael
e99f80d374 lib: try to clarify periodic transaction double-space error 2019-01-14 15:33:13 -08:00
Simon Michael
86a91c514d lib: disallow prices in balance assertions/assignments (fix #824)
(and in Ledger-style {=FIXEDLOTPRICES} )
2019-01-05 07:35:54 +00:00
Simon Michael
6f36702141 lib: rename, reposition tprecedingcomment field 2019-01-05 07:35:54 +00:00
Simon Michael
5908414d77 lib: amultiplier -> aismultiplier 2019-01-05 07:35:54 +00:00
Simon Michael
3b0cb701ac lib: reorder Amount fields for clearer debug output 2019-01-05 07:35:54 +00:00
Simon Michael
2e525f5600 lib: accountdirectivep: update unit tests 2018-12-02 16:41:16 -08:00
Alex Chen
83a63a4ef5 lib: minor cleanup in 'periodictransactionp' 2018-11-22 14:09:32 -08:00
Alex Chen
519297051d lib: restore previous period expression parser behaviour (PR #807)
- parse a period expression by first extracting words separated by
  single spaces, then by "re-parsing" this text with 'periodexprp'
- this way, the period expression parsers do not need to know about
  the single- or double-space rules
2018-11-22 14:09:32 -08:00
Simon Michael
4b5b9f46db lib: TransactionModifier: clarify 2018-11-13 16:35:46 -08:00
Samuel May
e57ef9e9a9 lib: journal: Add support for exact assertions 2018-10-22 09:55:14 -07:00
Samuel May
cde91fc5f4 lib: Make BalanceAssertion a full datatype
Note: simplifies/moves whitespace parsing out of the balance assertion
parser.
2018-10-22 09:55:14 -07:00
Jesse Rosenthal
a6a73e36e3 Finish removing journalFinalise (#903)
* journal: Get rid of `journalFinalise` and use granular functions

Complete the process started in 53b3e2bd. This gets rid of the
`journalFinalise` function and uses the smaller steps, in order to
have more granular control.

* journal: Change order of operations in finalization

We want to make sure that we add the filepath after the order is
reversed, so the added filepath is on the head and not the tail (as it
would be if it were reversed after it was added).

* journal: Refine granular finalization functions

This commit fixes two of the granular finalization functions:

1. Rename `journalSetTime` to `journalSetLastReadTime` and improve
   documentation.

2. Remove `journalSetFilePath`. It's redundant with `journalAddFile`
   currently in `Hledger.Read.Common`. The only difference between the
   functions is where the file is added (we keep the one in which it
   is added to the tail), so we change the position vis-a-vis
   reversal.
2018-10-16 08:51:51 -07:00
Simon Michael
b72f9697a2 lib: journal: account: allow whitespace or a comment after the account name 2018-10-13 13:09:49 -07:00
Jesse Rosenthal
53b3e2bd94 journal: split up the parts of journalFinalise, and use them as needed.
`journalFinalise` is only used in the `parseAndFinaliseJournal`
functions, but it needs to be run differently at different stages when
transaction modifiers are applied. This change breaks it into smaller
functions, and uses those smaller parts in `parseAndFinaliseJournal`
as needed.
2018-10-12 07:39:53 -07:00
Jesse Rosenthal
20f134c96b read: only run finalise twice if there are modifiers
Previously we ran if `--auto` was set. But this adds a small
performance hit if `--auto` becomes default. Now we only run twice if
there are transactionModifiers AND `--auto` is set. So even if auto is
specified, there will be no penalty if there are no modifiers.
2018-10-12 07:39:53 -07:00
Jesse Rosenthal
5a3462ce48 read: Integrate transaction modifiers with journal finalization
Currently, automated transactions are added before the journal is
finalized. This means that no inferred values will be picked up. We
change the procedure, if `auto_` is set, to

 1. first run `journalFinalise` without assertion checking (assertions
    might be wrong until automated transactions), but with reordering
 2. Insert transaction modifiers
 3. Run `journalFinalise` again, this time with assertion checking as
    set in the options, and without reordering.

If `auto_` is not set, all works as before.

Closes: #893
2018-10-12 07:39:53 -07:00
Simon Michael
c1236fa6e9 journal: account directives can declare account types
Previously you had to use one of the standard english account names
(assets, liabilities..) for top-level accounts, if you wanted to use
the bs/bse/cf/is commands.
Now, account directives can specify which of the big five categories
an account belongs to - asset, liability, equity, revenue or expense -
by writing one of the letters A, L, E, R or X two or more spaces after
the account name (where the numeric account code used to be).

This might change. Some thoughts influencing the current syntax:
- easy to type and read
- does not require multiple lines
- does not depend on any particular account numbering scheme
- allows more types later if needed
- still anglocentric, but only a little
- could be treated as syntactic sugar for account tags later
- seems to be compatible with (ignored by) current Ledger

The current design permits unlimited account type declarations anywhere
in the account tree. So you could declare a liability account somewhere
under assets, and maybe a revenue account under that, and another asset
account even further down. In such cases you start to see oddities like
accounts appearing in multiple places in a tree-mode report. In theory
the reports will still behave reasonably, but this has not been tested
too hard. In any case this is clearly too much freedom. I have left it
this way, for now, in case it helps with:

- modelling contra accounts ?
- multiple files. I suspect the extra expressiveness may come in handy
  when combining multiple files with account type declarations,
  rewriting account names, apply parent accounts etc.
  If we only allowed type declarations on top-level accounts, or
  only allowed a single account of each type, complications seem likely.
2018-10-09 14:24:59 -10:00
Mykola Orliuk
8c6a418325 lib: fix home path expansion in includes
fixes simonmichael/hledger#896
2018-10-09 13:35:40 -10:00
Simon Michael
8c7c59017a lib: fix my wrong merge of #880 more 2018-10-09 15:26:15 -07:00
Simon Michael
f6e095e794 lib: fix my wrong merge of #880 2018-10-09 14:06:22 -07:00
Simon Michael
88887e5458
Merge branch 'master' into ExceptTLayer 2018-10-09 10:31:32 -10:00
Simon Michael
278802e648 journal: Y affects dates in periodic transactions (fix #892) 2018-10-09 11:54:40 -07:00
Alex Chen
2cbc41e088 Merge branch 'master' into ExceptTLayer 2018-10-09 11:19:45 -06:00
Simon Michael
190eee5485 lib: comment
[ci skip]
2018-10-05 11:05:39 -10:00
Alex Chen
3d2584d869 lib: switch to megaparsec 7 2018-09-30 20:15:12 -06:00
Alex Chen
31d4e930e7 lib: Re-implement 'includedirectivep' with the new 'ExceptT' layer
- Parse errors encountered in include files are treated as "final" parse
  errors in the parent file, preventing backtracking and fixing an issue
  in #853
2018-09-29 22:54:49 -06:00