Commit Graph

520 Commits

Author SHA1 Message Date
Simon Michael
568a442307 budget: tweak hiding/grouping of unbudgeted accounts
It now works slightly differently. Eg:

- <unbudgeted>'s subaccounts are hidden by default
- --show-unbudgeted shows all unbudgeted accounts, including subaccounts of budgeted parents
- --show-unbudgeted doesn't affect the grouping under <unbudgeted>

IMHO it's a nice simplification and increase in consistency, while still meeting the original intent.
2018-04-24 13:42:12 -07:00
Simon Michael
8759f12b63 budget: more consistent display of percentage 2018-04-23 18:52:28 -07:00
Simon Michael
0c140d7238 budget: allow multi-interval budgets again
Budgets were restricted to a single interval in 1.9, but this was
a mistake. This restores the 1.5 behaviour, where a budget can be built
up from multiple periodic transactions with different intervals.
2018-04-23 18:52:28 -07:00
Simon Michael
43287a3e26 budget: use a new first-class BudgetReport for --budget 2018-04-23 18:52:28 -07:00
Simon Michael
0b380971f7 journal: require a decimal point in commodity/format/D directives
A commodity directive that doesn't specify the decimal point character
increases ambiguity and the chance of misparsing numbers, especially
as it overrides all style information inferred from the journal amounts.
In some cases it caused amounts with a decimal point to be parsed as if
with a digit group separator so 1.234 became 1234.

We could augment it with extra info from the journal amounts, when available,
but it would still be possible to be ambiguous, and that won't be obvious.

A commodity directive is what we recommend to nail down the style.
It seems the simple and really only way to do this reliably is to require
an explicit decimal point character. Most folks probably do this already.

Unfortunately, it makes another potential incompatiblity with ledger and
beancount journals. But the error message will be clear and easy to
work around.
2018-04-20 21:56:06 -07:00
Simon Michael
3f2827424c refactor: number parsing docs 2018-04-20 21:39:06 -07:00
Simon Michael
3d4f5600ae journal: infer and balance amounts with standard amount styles (fix #737)
Inferred amounts now have the appropriate standard amount style applied.
And when checking for balanced transactions, amount styles declared with
commodity directives are also used (previously only inferred amount styles were).
2018-04-20 13:40:05 -07:00
Dmitry Astapov
0c835acd18 lib, app: better descriptions for forecast transactions 2018-04-18 16:05:08 -07:00
Dmitry Astapov
d82370d10b lib, app, web: remove differences between command line and journal file aliases 2018-04-17 16:09:11 -07:00
Dmitry Astapov
93814652f8 lib: auto postings are generated right after posting that triggered them (#729) 2018-04-17 14:33:32 -07:00
Simon Michael
a5d70debbb cli: disable failing test (#727) 2018-04-08 18:38:54 -07:00
Simon Michael
cc1db7be98 bal: failing test for account code sorting (#727)
[ci skip]
2018-04-06 05:42:00 -07:00
Simon Michael
4822b53f69 scientific notation test notes (#704, #706) 2018-03-31 02:42:37 +01:00
Simon Michael
c95982381b remove test unrelated to scientific notation (#704, #706) 2018-03-31 01:50:06 +01:00
Mykola Orliuk
b377bff90a lib: support scientific number notation (#704, #706)
closes simonmichael/hledger#704
2018-03-31 01:49:46 +01:00
Simon Michael
2a87ea56ff budget: refactor; show budget goals even with no or zero actual
This makes budget reports more intuitive. It is a temporary hack which
can misorder columns in some cases (if actual and budget activity
occur in a different range of columns). We should redo this in a more
principled way.
2018-03-30 03:26:32 +01:00
Simon Michael
fc3a71bc46 budget: more tests 2018-03-29 16:36:31 +01:00
Simon Michael
38289686b7 budget: convert tests to format 3 2018-03-29 15:56:09 +01:00
Simon Michael
6f8714cdbd update budget func. tests 2018-03-29 15:49:31 +01:00
Simon Michael
10a4392b24 update functional tests for new monthly headings 2018-03-29 14:54:36 +01:00
Simon Michael
fb5c0dba22 bin: delete hledger-budget func. tests 2018-03-21 12:36:26 +00:00
Simon Michael
7550a1dcb8 convert register tests to new format, test stderr, reveal travis issue 2018-02-16 01:22:08 -08:00
Simon Michael
e491f513a1 cli: tabular reports no longer have a trailing blank line added
Tabular reports from bal, bs etc. have until now been rendered on
the terminal with one final blank line, for readability.
This change drops the blank line.

This is consistent with the non-tabular balance and register output
(not print, which is a special case), and with most unix commands.
The real reason for it, which I admit is flimsy, is that I can now omit
the final delimiter (>=0) when using shelltestrunner 1.9's new format,
making functional tests easier to maintain and more readable.
If there's opposition, this could be reverted.
2018-01-23 12:47:56 -08:00
Simon Michael
e43c430a61 bal: clarify some todo tests, use shelltestrunner's format 3 2018-01-23 12:17:14 -08:00
Simon Michael
6c60e4a97b bs/cf/is: always show a tabular report, even with no report interval
Previously, if you specified no report interval, the text output of
these commands was a simple report like the original balance command,
with amounts on the left and account names on the right. Also,
balances used arithmetic sign like the balance command.
Now it always draws a table, with account names in the left
column, and shows balances with normal-positive sign, consistent with
the multicolumn reports. Less code, fewer bugs.
2018-01-23 11:05:01 -08:00
Simon Michael
c4b778bfb9 update report titles in func. tests 2018-01-22 07:58:01 -08:00
Simon Michael
6b349e3123 bs/bse/cf/is: show all balances as normally-positive (experimental)
Income, liability and equity balances, which until now we have
always displayed as negative numbers, are now shown as normally positive
by these reports.
Negative numbers now indicate a contra-balance (eg an overdrawn
checking account), a net loss, a negative net worth, etc.
This makes these reports more like conventional financial statements,
and easier to read and share with normal people.
2018-01-18 11:01:07 -08:00
Simon Michael
1234671c69 equity: rename to close 2018-01-03 17:02:35 -08:00
Simon Michael
31effcd731 equity: ignore any begin date; closed balances are historical 2018-01-03 13:50:16 -08:00
Simon Michael
2d66f8cf04 fix some 2017-isms in func. tests 2018-01-01 15:47:31 -08:00
Simon Michael
ecdbc05703 Merge branch 'feature/space-as-digits-sep' of https://github.com/ony/hledger into ony-feature/space-as-digits-sep 2017-12-30 09:29:22 -08:00
Simon Michael
8f55b6137d uses today's prices, not those of last txn date, for -V (fix #683,#648) 2017-12-29 21:42:59 -08:00
Dmitry Astapov
58c755df86 lib: fix budget display to always show %% consumed and handle costs
For multi-column balance report, if there are no transactions in the
given period for budgeted account, display [0% of <budget>] for
consistency.

If balance is a mix of commodities, convert to cost basis for the
purposes of computing percent of balance spent.
2017-12-01 15:52:29 -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
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
Mykola Orliuk
53ad035b24 journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves simonmichael/hledger#402
2017-11-27 14:32:48 -08:00
Dmitry Astapov
8cd58b71ab bal: show percentage of budget spent 2017-11-26 14:57:41 +00:00
Dmitry Astapov
6ea5da2d9d bal: --budget shows budget performance
Budget goals specified with periodic transactions (as with
hledger-budget) can now be displayed in balance report (but not in bs/is/cf).

--budget shows the target amount and percentage alongside the actual
amount, per account and period.

Unbudgeted accounts will be hidden, unless --show-unbudgeted is used.

Budgeted accounts are displayed folded (depth-clipped) at a depth
matching the budget specification. Unbudgeted accounts, if shown, are
displayed at their usual depth (in full detail, or according to --depth).
2017-11-26 14:57:41 +00:00
Dmitry Astapov
23f3da4e92 cli: --auto adds automated postings to reports
Ledger-style automated postings, previously supported only by
hledger-budget, have landed as a first-class feature.  The --auto
flag activates them, so that any postings they generate are
included in reports.
2017-11-26 14:57:41 +00:00
Dmitry Astapov
f101d5b515 cli: --forecast adds periodic transactions to reports
Ledger-style periodic transactions, previously supported only by
hledger-budget, have landed as a first-class feature.  The --forecast
flag activates them, so that any transactions they generate are
included in reports.
2017-11-26 14:57:41 +00:00
Simon Michael
4ab71f0d0a journal: clarify that txn/posting comments must start with semicolon 2017-11-01 08:04:25 -07:00
Mykola Orliuk
39d13d68ef test: equity/prices/rewrite now builtin
Fix shell-tests for add-ons that became built-in commands.
2017-10-28 07:14:48 -07:00
jeevcat
3a9ea65b99 Rewrite of BalanceAssertion type to track its source position.
Fixes #481.
2017-10-16 13:25:03 -07:00
Sam Jeeves
b7f8ca2cda Modified test to check for single line number of posting. 2017-10-14 15:11:19 -07:00
Simon Michael
80fefe9c43 cli: fix functional tests 2017-09-14 06:14:26 -07:00
Christian G. Warden
deaf9cfbef Exclude Fixed Assets from Cashflow Report
Add "fixed" to the regex used to exclude asset accounts from cashflow
reports.  Assumes accounts are set up something like:
assets:fixed assets:equipment
assets:fixed assets:vehicles
assets:fixed assets:buildings
2017-08-27 04:41:05 -07:00
Simon Michael
ce5724fee1 csv: switch the order of generated postings, so account1 is first
This is subjective, but simplifies things as we'll be adding more than
two postings. Free-form entry templates will allow custom orderings
in future.
2017-08-15 08:16:49 -07:00
Simon Michael
ea0aced89c lib: add test for an amount parsing issue
[ci skip]
2017-08-03 16:58:54 -07:00
Simon Michael
e53c3e6d8a bin: budget: update func tests 2017-07-31 08:15:29 -07:00
Simon Michael
b9571bd088 bal/bs/cf/is: consistently separate columns with a double space
Previously, amounts wider than the column headings would be separated
by only a single space. Also there was an extra space before the first
column.
2017-07-27 09:09:03 -07:00
Simon Michael
a25a8f868c bs/is: fix tests 2017-07-25 13:23:16 -07:00
Simon Michael
9d4d6ebc4d bs/cf/is: show one trailing blank line, not two 2017-07-25 12:43:56 -07:00
Simon Michael
11202c897a bs: merge pretty.test 2017-07-25 09:33:43 -07:00
Simon Michael
c89bec0e17 bs/is: don't let an empty subreport disable the grand totals (fixes #588) 2017-07-25 09:21:09 -07:00
Simon Michael
6e00247df3 rewrite: make test use compiled version like the others
That's the current most robust way. Otherwise, it can fail due to
stack's progress output as it reinstalls hledger libs, and that
reinstallation also forces all the addons to be relinked.
2017-07-07 02:14:29 +01:00
Simon Michael
38752565a9 csv: test stderr output more accurately 2017-07-06 14:10:54 +01:00
Simon Michael
28e8c76a8e csv: rename csv-read.test for easy file finding 2017-07-05 14:49:48 +01:00
Mykola Orliuk
15c86e1f79 prices: add inverted-costs support and sort output 2017-06-16 11:28:15 -07:00
Nikolay Orlyuk
8966e765c8 prices: improve precision 2017-06-16 11:28:15 -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
Simon Michael
5d28120f6d lib: multiple status: query terms are OR'd (#564)
Like desc: and acct:. I think this is more intuitive and useful,
so now eg "status: status:!" works (equivalent to -UP or "not:status:*").
2017-06-15 19:16:39 -07:00
Simon Michael
7fc921db86 lib, cli: -U/-P/-C flags can be combined (#564) 2017-06-15 19:16:39 -07:00
Simon Michael
8b073014e4 lib, cli: -U/--uncleared no longer matches pending things (#564)
Also begin using "marked"/"unmarked" terminology where it's helpful.
2017-06-15 19:16:39 -07:00
Simon Michael
c5d63f03ce lib: clean up status functional tests, document ClearedStatus (#564) 2017-06-15 19:16:39 -07:00
Simon Michael
a14317db3c tests: csv: cleanup #573 2017-06-14 08:54:32 -07:00
Simon Michael
9d33fbee17 tests: csv: fix wrong use of echo #573
echo doesn't normally render \n as a newline. It was working on
some machines and not others, possibly due to a shelltestrunner
quoting bug,
2017-06-14 08:50:12 -07:00
Simon Michael
6de874c544 tests: csv: note some issues #573 2017-06-14 08:50:08 -07:00
Simon Michael
a104aee3a0 tests: csv: fix confusingly wrong numbering 2017-06-13 10:01:22 -07:00
Simon Michael
30a018337c bs: test for #552 2017-06-07 07:02:58 -07:00
Simon Michael
c0e1dc6676 bs: test for #565 2017-06-07 07:00:26 -07:00
Simon Michael
5c09553481 lib: keep amounts aligned when rendering a transaction with posting flags
Related to #563, when rendering a transaction, we reserve two more chars
of width so that amounts remain aligned when there are posting flags.
Affects hledger-ui's transaction screen, print, hledger-rewrite etc.
2017-06-04 21:26:18 -07:00
Simon Michael
1adc636554 lib: show pending posting flags when rendering a transaction (fix #563)
This affects hledger-ui's transaction screen, print, hledger-rewrite etc.
A pending flag on postings is now displayed, just like a cleared flag.
Also there will now be a space between flag and account name.
And it's slightly better at aligning amounts, due to now considering
virtual posting parentheses/brackets or something.
2017-06-04 17:54:57 -07:00
Simon Michael
cd70bb1a86 disable not-yet-implemented test that was breaking travis (#551) 2017-06-04 14:51:25 -07:00
Simon Michael
4f712754e4 lib: test for #551 2017-05-30 13:57:52 -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
Simon Michael
a6c2f0697d tests: make cashflow.test compatible with released shelltestrunner 2017-05-24 15:46:00 -07:00
Nicolas Wavrant
309d1ccd59 CsvReader: simplify '-' signs if there exist more than one (#548)
It prevents hledger to crash later, as it fails to read
amount strings containing more than one '-'

Fix #524
2017-05-14 09:34:33 +09:00
Simon Michael
02eb809348 timeclock: comment out unfinished tests 2017-04-25 18:56:38 -07:00
Simon Michael
1af0f66e73 lib: timeclock test notes 2017-04-25 12:04:39 -07:00
Dmitry Astapov
c4c4be5fad Fix parsing of blank/empty balances + testcases (#539) 2017-04-18 09:07:30 -07:00
Dmitry Astapov
451f9d7307 "balance" parser for csv reader (#537)
* "balance" parser for csv reader

* Some docs for
2017-04-14 14:52:03 -07:00
Simon Michael
e50dede708 cashflow: make totals row and -N more like balance/bs/is (#518) 2017-03-31 16:39:47 -07:00
Simon Michael
b82e800ae6 bs/cf/is: fix subtitle appearing above total (and put on one line) (#527) 2017-03-30 17:18:30 -07:00
Justin Le
ac68ae1349 simple functional tests for multicolumn modes for is/bs/cf 2017-03-30 15:35:04 -07:00
Moritz Kiefer
f4b3f1c094 Add an option to use unicode in balance tables (#528)
* Add an option to use unicode in balance tables

fixes #522

* Add a test for unicode tables

* Document --pretty-tables

* Support --pretty-tables in BalanceView
2017-03-29 11:12:01 -07:00
Simon Michael
7d0734f1ed update addons tests, note a todo 2017-03-29 08:21:30 -07:00
Simon Michael
5d2f9d742a test: cli: test stderr for more verbose failures 2017-03-29 06:40:39 -07:00
Simon Michael
895a66eb06 cli: first of several cleanups; separate commands list & usage (#297) 2017-03-28 18:44:34 -07:00
Simon Michael
5a7f74c6ff tests: use compiled addons in func tests, much quicker 2017-03-28 18:43:14 -07:00
Simon Michael
863989e0e7 print: bring back the short -x form of --explicit (#442) 2017-03-27 05:17:35 -07:00
Joshua Kehn
4f00925ad5 [TEST] Add balance/cashflow/incomestatement shelltest
These pass the current version of hledger available on homebrew and
cover the bug reported in #514 and fixed in #515.
2017-03-20 10:04:28 -04:00
Mykola Orliuk
0a8212bda3 equity: generate assertions 2017-01-25 14:45:54 -08:00
Mykola Orliuk
f3cb32a56f prices: new addon (#486) 2017-01-25 11:50:54 -08:00
Mykola Orliuk
d5c2ed4fa7 budget: bucketing 2017-01-20 13:42:17 -08:00
Mykola Orliuk
3a632acea0 budget: periodic transactions support 2017-01-20 13:42:17 -08:00
Mykola Orliuk
2d9259ab3a budget: new addon 2017-01-20 13:42:17 -08: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
Mykola Orliuk
295af41f38 cli: fix bug in pivot for postings without tag (#491)
Without this fix for postings without tag query checked effective
account which is always empty text ("").
2017-01-19 07:53:00 -08:00
Simon Michael
39662260cd cli: use a blank acct name for postings without the specified pivot tag
Eg. if you --pivot code, postings from transactions with no code value
were formerly displayed with the unpivoted account name, so you'd see
a mixture of account names and codes. Now we always pivot the account name,
to blank if nothing else. This probably makes reports pretty ugly, it's just another
step towards making --pivot's behaviour clearer.
2017-01-13 14:06:23 -08:00
Mykola Orliuk
8954944ee6 Apply ModifierTransaction's from journal during hledger-rewrite. (#477)
* rewrite: rewrite every posting

Also start using ModifierTransaction

* rewrite: use journal parser for postings

* rewrite: use ModifierTransactions from Journal

See simonmichael/hledger#99
2017-01-13 12:41:16 -08:00
Mykola Orliuk
fabd6b450a Update tests to match current pivot effect (#476) 2017-01-13 11:53:06 -08:00
Mykola Orliuk
76867c98a3 Feature/pivot implicit tags (#460)
* Add implicit tags code/desc/payee for --pivot

Additionally allow using of transaction inherited tags.

* Use original posting in query by account name

To be able to query on individual postings and by account name it is
useful to have access to original account name (before pivot).
Especially this is useful when all postings within transaction gets
the same pivot name due.
As a side effect we'll match by alias.

Note: to query on amt it usually expected to see matches with inferred
amounts.
2017-01-13 08:02:11 -08:00
Mykola Orliuk
015b764d00 Preserve implicit amounts and prices the way user wrote them in output of print command (#471)
* Remember original postings during infer and pivot

This includes such functions like:
- inferFromAssignment
- inferBalancingAmount
- inferBalancingPrices
- pivotPosting

* Use original postings for hledger print

- Introduce "--explicit" option for "print" command which brings back
  old behavior when every inferred number being printed.
- Make "print" by default print original postings without inferred
  amounts. But use effective account name to have effect from aliases.
- Instruct shell tests with an new expected output or to use
  --explicit option when inferred amounts are checked.

Resolves simonmichael/hledger#442
2017-01-13 07:25:44 -08:00
Nikolay Orlyuk
c0d12f5d1c Normalize amount in infereBalancingAmount (#469)
This fixes issue exposed by a fix for simonmichael/hledger#465
2017-01-11 12:09:07 -08:00
Nikolay Orlyuk
ea7a7d78aa Strip prices for equity report (#468)
Fixes simonmichael/hledger#467
2017-01-11 07:53:01 -08:00
Nikolay Orlyuk
32d9365fc2 Ensure showTransaction produce a valid journal (#466)
- Make output of print to be a valid journal
- Partially reverts 419f5f2a2

Fixes simonmichael/hledger#465
2017-01-10 20:44:10 -08:00
Simon Michael
34ec7406a1 move add-ons and scripts to bin/ 2017-01-08 07:28:23 -08:00
Simon Michael
3ae8712bbc rename data/ to examples/ 2017-01-08 07:26:13 -08:00
Mykola Orliuk
44538cce57 extra: tests for equity and rewrite 2017-01-05 16:06:21 -08:00
Simon Michael
a5992c38a8 update market price tests #403 #453 2016-12-30 14:36:27 -08:00
Simon Michael
fe58ef7946 lib: fix typo breaking tests (#438) 2016-12-10 07:13:17 -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
97ef9d621c disable failing test #415 2016-10-21 17:50:47 -07:00
Simon Michael
cf71a803f9 csv: add a failing test for #415 2016-10-08 15:20:26 -10:00
Simon Michael
18bed45e1a bal: draft some tests for #373 2016-09-21 09:34:01 -07:00
Simon Michael
5ea088d1ca bs,is,cf: add functional tests, fix bs infinite loop #393 2016-08-13 07:47:43 -07:00
Simon Michael
c1ddbfc08a drop unusual "d" suffix when showing a day period 2016-08-11 11:23:05 -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
6ec4426edd journal: fix balance assertion test 2016-07-06 15:22:29 -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
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
80e8caebe7 func. test for 320 2016-05-18 13:10:41 -07:00
Simon Michael
975e3274ea stats: fix func test 2016-05-17 19:52:19 -07:00
Simon Michael
695d96231c test numbering 2016-05-13 22:10:23 -07:00
Simon Michael
ddefec412f journal: also allow one-line commodity directives 2016-05-08 20:56:34 -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
8312573fed tests for #295 2016-05-07 18:34:24 -07:00
Malte Brandy
913b8e4c19 Add --pivot option with tests and docs (#323) 2016-05-06 18:27:35 -07:00
Simon Michael
e2ce7c4802 doc, tests: clarify what --date2 does 2016-05-06 16:57:24 -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
b0f40bd7c8 tools: fix make functest in a fresh copy 2016-04-21 08:37:37 -07:00
Simon Michael
1fc34d76f8 cli: adapt func tests pass to new --help 2016-04-19 10:44:43 -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
25cd65442a cli: fix opts parsing regressions from feb
Since commit 7aab544, "-f -" before the command broke command
detection, causing spurious "no such option" errors (and breaking
about 70 functional tests which neither I nor travis noticed).
2016-04-04 11:35:39 -07:00
Simon Michael
0a7fb17635 fix two failing tests 2016-02-19 21:45:39 -08:00
Simon Michael
36970f7b19 lib: fix balance assertion test 2016-02-19 17:52:40 -08:00
Simon Michael
a2b989d898 journal: support ledger3-compatible "apply account" 2016-01-29 07:39:26 -08:00
Simon Michael
8c6d53f912 consolidate some journal format-specific tests 2015-11-22 08:55:29 -08:00
Simon Michael
0a7a6c87f8 clean up price tests 2015-11-22 08:37:02 -08:00
Simon Michael
56a79c479f cleanup 2015-10-12 07:02:36 -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
cbbe07e3c4 tests/nonascii -> tests/i18n 2015-10-10 13:11:31 -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
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
821f1b7120 lib: fix tests for zero amount style (#230, #276) 2015-09-02 16:38:45 -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
21d9945ba9 tests: make functional tests use "hledger" again
Using "hledgerdev" was a hack to help ensure that tests used a fresh
developer build by default. Now they specify "hledger" again, which fits
better with stack. It's up to the tester to make sure the desired
executable is first in PATH or specified with -w. (Note a couple of
tests currently don't obey -w and will always run "hledger", see addons.test).
2015-07-12 12:29:53 -07:00
Simon Michael
25d41acadf update a functional test
the parse error has changed
2015-07-12 12:26:21 -07:00
Simon Michael
745f2dd788 cli: a cabal bench test that works 2015-06-18 09:49:51 -07:00
Imuli
67432f1220 read multiple files: tests 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
c138852dab maybe stop numbering functional tests 2015-05-28 10:40:48 -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
64bc422b85 forgot to commit status tests 2015-05-16 13:04:22 -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
5102eca9c3 timelog: support the description field (fix #247) 2015-04-28 13:54:36 -07:00
Simon Michael
6bad57a4d8 tools: bench test update 2015-03-15 18:51:14 -07:00
Simon Michael
592ae9a28e timelog: show hours with 2 decimal places, not 1 2015-02-27 08:37:16 -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
95ced2da80 balance: fix partially-visible totals row
With --no-total in a periodic (non-cumulative, non-historical) balance
report, hide the totals row completely, as in the other modes.
2014-12-27 16:46:37 -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
663e1f5ba9 tests for --date2, date2: (#201) 2014-12-23 06:23:23 -08:00
Simon Michael
20cace6948 tools: some bench tests cleanup or other 2014-12-10 23:13:34 -08:00
Simon Michael
855d4e1131 balance: with --tree and --flat, use the last (fix #219) 2014-12-05 12:56:33 -08: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
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
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
a65116ae5e fix func. test numbering 2014-09-13 21:28:07 -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
7fb154f820 balance: include report span in title 2014-07-26 17:29:20 -07:00
Simon Michael
ca43eab47a balance: simplify multicolumn report titles slightly 2014-07-26 17:09:29 -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
b499ea85eb register: optimise postingsReportItemAsText a bit
Avoid concatTopPadded when rendering register output, making that
command faster when there's a lot of output.
2014-07-07 08:37:27 -07:00
Simon Michael
e13dd554a1 tools: benchmarking updates 2014-07-06 10:19:34 -07:00
Simon Michael
3669422bbf make --width and --debug require an argument (fixes #149)
This is a workaround for a cmdargs limitation. Having "--debug 2"
or "--width 100" produce no output (because the number is parsed
as a separate argument) is too annoying.
2014-07-03 07:31:52 -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
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
18716f2908 some missing functional test files 2014-05-09 17:48:51 -07:00
Simon Michael
d1a3516c70 reorganise functional tests by command/topic 2014-05-06 21:02:58 -07:00
Simon Michael
dd736a871c add: drop an obsolete functional test 2014-05-06 20:04:28 -07:00
Simon Michael
d0d2edb42f cli: drop a --display functional test 2014-05-01 07:33:24 -07:00
Simon Michael
31aac193fa make addon functional tests pass 2014-04-30 16:33:10 -07:00
Simon Michael
cfc1db1725 cli: more tests for add-on options pass-through 2014-04-27 23:33:30 -07:00
Simon Michael
dbd35fbe3e cli: clarify spec 2014-04-27 23:33:13 -07:00
Simon Michael
4381022e25 addons: move test addons under tests/ 2014-04-27 18:45:22 -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
6743f8c2a1 balance: multicolumn now includes all postings in the displayed periods 2014-04-19 08:45:46 -07:00
Simon Michael
a761ae5b86 balance: support --date2 in multicolumn reports (cf #174) 2014-04-13 15:14:07 -07:00
Simon Michael
d4993092fb register: test for #174 2014-04-13 15:12:30 -07:00
Simon Michael
2af04ec2fc balance: merge/improve multicol report implementations
Periodic, cumulative and historical multicolumn balance reports are now
generated by one code path, which helps with consistency and reducing
the bug/test surface. --tree now also works with --cumulative or
--historical.
2014-04-13 12:49:05 -07:00
Simon Michael
6a928a03a8 overhaul single- and multi-column balance reports
Changes include:

- flat mode now shows exclusive (subaccount-excluding) balances.
  This is a deviation from ledger, but seems simpler and clearer
  for users and implementors across the various modes.

- in flat mode, --depth now aggregates deeper accounts at the
  depth limit, rather than just excluding them from the report.
  This is more useful.

- in flat mode, --empty no longer shows parent accounts with
  no postings.

- more tests, more debug output, clearer code
2014-04-03 18:49:57 -07:00
Simon Michael
4dc61e76bf test and fix display of zero-balance leaves (fixes #170) 2014-04-03 18:49:57 -07:00