Commit Graph

277 Commits

Author SHA1 Message Date
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