Commit Graph

1633 Commits

Author SHA1 Message Date
Simon Michael
c4d7cc198a csv: finalise and check journals generated from CSV (#1000)
Invalid transactions generated from CSV will now be rejected.
I updated some csv tests to avoid this, except for 21, which
probably needs more cleanup.
2019-11-07 18:58:12 -08:00
Simon Michael
5264a7ebc1 ;lib: refactor, split out finaliseJournal 2019-11-07 18:08:41 -08:00
Dmitry Astapov
fc001da1ef lib: expenses:unknown is a much better default account name 2019-11-05 21:16:42 +00:00
Dmitry Astapov
c66ccc5cee lib: do not try to balance transaction in csv reader 2019-11-05 21:16:42 +00:00
Dmitry Astapov
95ec5715cc lib: better compatibility code in csv reader 2019-11-05 21:16:42 +00:00
Dmitry Astapov
d62f84bec2 lib: csv reader does not generate postings if account="" 2019-11-05 21:16:42 +00:00
Dmitry Astapov
8d24a40150 lib: csv parser fills out amounts on all postings, if possible 2019-11-05 21:16:42 +00:00
Dmitry Astapov
637741a755 lib: amount1 is no longer magical 2019-11-05 21:16:42 +00:00
Dmitry Astapov
977592e49c lib: typo fix, "expense:unknown" -> "expenses:unknown" 2019-11-05 21:16:42 +00:00
Dmitry Astapov
3c7d5d466d lib, doc, test: csv parser gains "end" command for "if" block 2019-11-05 21:16:42 +00:00
Dmitry Astapov
f92590f92c lib: allow zero postings in csv reader 2019-11-05 21:16:42 +00:00
Dmitry Astapov
1ab8631264 lib: change default rules file text to mention "amount1" 2019-11-05 21:16:42 +00:00
Dmitry Astapov
32cbe4c7b3 lib: better inference for unknown account names in csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
b5d4918c16 lib: allow recursive interpolation of fields with underscores in names 2019-11-05 21:16:42 +00:00
Dmitry Astapov
38db7eb24d lib: implement skip end in csv reader 2019-11-05 21:16:42 +00:00
Dmitry Astapov
b2ba1086b6 lib: fixed validation rules for minimul viable csv rules to include account1 etc 2019-11-05 21:16:42 +00:00
Dmitry Astapov
f1ab107400 lib, doc: extended "skip" in "if" body to "skip N" 2019-11-05 21:16:42 +00:00
Dmitry Astapov
f108b52171 lib: fix for #1001 - empty field assignment consumes next line 2019-11-05 21:16:42 +00:00
Dmitry Astapov
5dac141a7e lib: implement conditional line skips in csv (fixes #1076) 2019-11-05 21:16:42 +00:00
Dmitry Astapov
f74df08e98 lib: fix accidental switch of income:unknown and expence:unknown in csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
77fa81ea4d lib: fix error message formatting (header displayed twice) 2019-11-05 21:16:42 +00:00
Dmitry Astapov
825b9ce5b3 lib: fixed amount vs amount1 conflict detection in csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
24bba96ea2 lib: more robust multi-line joining in csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
881422cd0f lib: fix recursive interpolation in CSV parser for fields with dashes 2019-11-05 21:16:42 +00:00
Dmitry Astapov
e4476dd2f1 lib: more robust "unknown" account assignment in csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
28ca65b99a lib: more explicit conditions for using legacy csv parser 2019-11-05 21:16:42 +00:00
Dmitry Astapov
e4add6df83 lib: fix for multiline descriptions in csv (fixes #841, #416) 2019-11-05 21:16:42 +00:00
Dmitry Astapov
9aab476d53 lib: csv parser supports up to 9 postings. Fixes #570, #627 2019-11-05 21:16:42 +00:00
Simon Michael
312e772468 prices: style price amounts; always show full precision 2019-10-20 07:09:34 -07:00
Simon Michael
b598f30a8a ;lib: styleAmountExceptPrecision 2019-10-20 07:08:45 -07:00
Simon Michael
2e3b51c03f ;lib: journalConvertAmountsToCost -> journalToCost 2019-10-19 19:58:27 -07:00
Simon Michael
54e1caebf1 ;lib: refactor journalConvertAmountsToCost 2019-10-19 19:53:05 -07:00
Simon Michael
905149df86 ;lib: transaction valuation helpers 2019-10-19 19:41:21 -07:00
Simon Michael
de0a6b1e62 ;lib: Transaction: as Map -> as M 2019-10-19 19:17:35 -07:00
Mykola Orliuk
78146978f4 ;lib: store raw opts unquoted
It looks like we only need quote when we build query and in some
messages.

Fixes simonmichael/hledger#1079
2019-10-19 14:44:08 -07:00
Simon Michael
eff1b31c86 csv: allow csv records with varying lengths, padding with empties
Sometimes trailing empty fields are omitted entirely (including the
commas) in CSV records. (I see this in exported Google spreadsheets.)
Now we don't raise an error in this case, instead we automatically pad
any "short" records with empty fields. Not yet well tested.
2019-10-07 14:54:36 -10:00
Simon Michael
6dcddadd9f ;journal: in generated-transaction:/posting: tags, add a space before the value 2019-10-07 14:54:36 -10:00
Simon Michael
16973ce296 ;lib: fix journalInferCommodityStyles debug message 2019-09-27 18:51:37 -07:00
Simon Michael
58a313165c ;journal: infer amount styles more carefully, fix wrong output (#1091)
Certain journal entries could trigger a bug where we displayed amounts
with the same character for digit group mark and decimal mark. Now if
a comma or period digit group mark is detected, that forces the
decimal mark to be the other character.
2019-09-27 15:40:36 -10:00
Simon Michael
9967ead4c5 ;lib: let commodityStylesFromAmounts & co. return an error (#793, #1091)
And if they did, the stats command would now throw an error.

Changed:
journalApplyCommodityStyles
journalInferCommodityStyles
commodityStylesFromAmounts
2019-09-27 15:09:39 -10:00
Simon Michael
64f49a8c02 ;doc: journal: rewrite Amounts; switch to "digit group mark" term (#1091) 2019-09-27 14:25:32 -10:00
Simon Michael
b754abc36b ;lib: commodityStylesFromAmounts: simplify, disable #1091 test 2019-09-26 18:06:22 -10:00
Simon Michael
4884213a3e ;lib: commodityStylesFromAmounts: a failing unit test for #1091 2019-09-25 23:08:00 -10:00
Simon Michael
7ffe38677a ;lib: parseAndFinaliseJournal: note txns order issue (#1091) 2019-09-25 23:07:22 -10:00
Simon Michael
6037d701b6 ;lib: document RawNumber, AmbiguousNumber, DigitGrp (#1091) 2019-09-25 21:26:06 -10:00
Simon Michael
180f4baedb ;lib: csv: note cause of #1087
[ci skip]
2019-09-14 03:45:37 -07:00
Simon Michael
f92b2fe6ef ;lib: csv: refactor: clarify, get rid of some IO/ExceptT
Rule parsing doesn't need IO (since we are doing expandIncludes as a
pre-parsing step).
2019-09-14 03:45:37 -07:00
Simon Michael
3c05662ce2 ;lib: csv: clarify confusing imports 2019-09-13 18:11:40 -07:00
Simon Michael
46caa1d4ef ;lib: csv: rename error-prone default rules 2019-09-13 17:51:14 -07:00
Dmitry Astapov
568cb32677 lib: more runPeriodicTransaction tests (lifted from #1085 and spanIntervalIntersect) 2019-09-11 16:09:28 -07:00
Dmitry Astapov
e9d300bef3 lib: dont raise when there is neither budget nor transactions in the report period 2019-09-11 16:09:28 -07:00
Dmitry Astapov
cf74972148 bin: improve debug output for budger report (show budget txns) 2019-09-11 16:09:28 -07:00
Dmitry Astapov
cf4029a5ed lib: fix generation of periodic transactions with days/months/... repeat 2019-09-11 16:09:28 -07:00
Simon Michael
499e20c0b2 lib, cli, ui: start using Control.Monad.Fail, allow base-compat 0.11
fail is moving out of Monad and into it's own MonadFail class.
This will be enforced in GHC 8.8 (I think).

base-compat/base-compat-batteries 0.11.0 have adapted to this,
and are approaching stackage nightly
(https://github.com/commercialhaskell/stackage/issues/4802).

hledger is now ready to build with base-compat-batteries 0.11.0, once
all of our deps do (eg aeson). We are still compatible with the older
0.10.x and GHC 7.10.3 as well.

For now we are using both fails:

- new fail (from Control.Monad.Fail), used in our parsers, imported
  via base-compat-batteries Control.Monad.Fail.Compat to work with
  older GHC versions.

- old fail (from GHC.Base, exported by Prelude, Control.Monad,
  Control.Monad.State.Strict, Prelude.Compat, ...), used in easytest's
  Test, since I couldn't find their existing fail implementation to update.

To reduce (my) confusion, these are imported carefully, consistently,
and qualified everywhere as Fail.fail and Prelude.fail, with clashing
re-exports suppressed, like so:

import Prelude hiding (fail)
import qualified Prelude (fail)
import Control.Monad.State.Strict hiding (fail)
import "base-compat-batteries" Prelude.Compat hiding (fail)
import qualified "base-compat-batteries" Control.Monad.Fail.Compat as Fail
2019-09-08 17:13:47 -07:00
Simon Michael
c7746131fc ;lib: clarify parser monad transformers a little
[ci skip]
2019-09-08 10:40:47 -07:00
Simon Michael
a7f172b085 valuation: -V/-X respects report end date, code/doc cleanups (#1083)
-V (and -X) now respects a report end date set with -e/-p/date: when
choosing the valuation date, similar to hledger 1.14 and Ledger.

This means that -V/-X aren't exactly like either --value=end or
--value=now. The "Effect of --value on reports" doc has been extended
accordingly, and much of it has been reworded and made more accurate.
2019-09-05 13:41:36 -07:00
Simon Michael
095badd7f9 ;fix doctests 2019-08-31 17:15:48 -07:00
Simon Michael
5925808108 lib, web: unhide exports, fix build 2019-08-19 12:30:54 +01:00
Simon Michael
11519744d8 ;lib: Valuation: hide some exports 2019-08-19 11:59:32 +01:00
Simon Michael
62e96b1b20 ;lib: move PriceGraph, PriceOracle, ValuationType to Valuation.hs 2019-08-19 02:21:30 +01:00
Simon Michael
1cbbe8f43d memoise market valuation, making it fast (#999) 2019-08-19 02:16:39 +01:00
Simon Michael
4beb416070 lib: currying helpers 2019-08-19 02:09:27 +01:00
Simon Michael
7177f533b2 ;lib: pricesAtDate: refactor 2019-08-01 18:31:39 +02:00
Simon Michael
70986769ef ;lib: derive NFData for MultiBalanceReport, PriceGraph for criterion
Allow these to be timed with criterion at ghci prompt.
2019-08-01 18:31:39 +02:00
Simon Michael
d193d757ea ;lib: multiBalanceReport: fix error message typo 2019-08-01 18:22:14 +02:00
Simon Michael
02ed4f5d04 ;lib: intervalFromRawOpts: replace undefined with an error message 2019-07-25 10:46:45 +01:00
Simon Michael
35799142dd
Merge pull request #914 from simonmichael/rule-tags
tags for matching rule-generated txns and postings
2019-07-17 18:38:14 +01:00
Simon Michael
6e3a264f17 lib: export aliasnamep for hledger-check (#1072) 2019-07-16 23:30:15 +01:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Simon Michael
6b61d1e0f1 ;lib: move transactionNote/Payee to Transaction.hs 2019-07-15 08:22:16 +01:00
Simon Michael
6f2f8d7638 ;deps: a better fix for nubSortBy with ghc 7.10, 8.0
nubSortBy and nub . sortBy are not equivalent, it seems.
I didn't notice the failing valuation func tests.
2019-07-13 00:13:33 -07:00
Simon Michael
ec310aea73 ;lib: avoid nubSortBy which breaks ghc 7, 8.0 builds 2019-07-12 15:21:57 -07:00
Simon Michael
5c3e4de647 ;lib: periodFromRawOpts: clarify doc (#1011)
[ci skip]
2019-07-01 18:33:18 +01:00
Jakob Schöttl
e483faf7f0 Bugfix for #1011: begin/end date options 2019-06-30 10:38:06 +02:00
Simon Michael
014db152d9 add, web: disallow unsafe trailing dot paths on windows (fix #1056)
On Windows, ensureJournalFileExists now rejects file paths
containing any problematic trailing dots, to prevent data loss.
This affects the add command and hledger-web's add form.
2019-06-26 18:19:53 +01:00
Simon Michael
33d03284c3 ;valuation: more tests; document default amount style issue
[ci skip]
2019-06-17 08:19:23 -07:00
Simon Michael
2da50875ee lib: setNaturalPrecisionUpTo 2019-06-14 19:04:09 -07:00
Simon Michael
5cb334514c ;lib: rename setMinimalPrecision -> setNaturalPrecision 2019-06-14 19:04:09 -07:00
Simon Michael
69defd497f ;lib: refactor: Data.Prices -> Data.Valuation 2019-06-14 19:04:09 -07:00
Simon Michael
83030a09de ;lib: Prices: refactor 2019-06-14 19:04:09 -07:00
Simon Michael
7dd0c5783a ;lib: multibalancereport: refactor 2019-06-14 19:04:09 -07:00
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
baa15d9bea ;lib: rename MultiBalanceReports.hs -> MultiBalanceReport.hs 2019-06-14 11:45:25 -07:00
Simon Michael
e664fab956 lib: try to simplify, use just one price graph (#131) 2019-06-13 15:50:01 -07:00
Simon Michael
dd5afbb6fe ;doc, debug output tweaks (#131) 2019-06-13 15:50:01 -07:00
Simon Michael
6a62bd6437 web, api: update for MarketPrice/PriceDirective change 2019-06-13 15:50:01 -07:00
Simon Michael
ce0354ddbe lib: -X/--exchange now supports indirect price chains (#131)
Adds fgl as a dependency.
2019-06-13 15:50:01 -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
e24c6292d0 lib: support -X/--exchange (direct/reverse prices only) (#131) 2019-06-13 15:50:01 -07:00
Simon Michael
50a52dd467 lib: --value can select commodity (via direct/reverse prices) (#131) 2019-06-13 15:50:01 -07:00
Simon Michael
6b6c3385c9 lib: parse optional ,COMM suffix in --value (#131) 2019-06-13 15:50:01 -07:00
Caleb Maclennan
18e19b9ad2 ;tests: normalize tests, examples, and docs using 2spcs before comments 2019-06-13 12:12:21 -07:00
Caleb Maclennan
8f3e5f9d3b ;print: differentiate posting indent (4spc) and pre-comment space (2spc)
Co-authored-by: Simon Michael <simon@joyful.com>
2019-06-13 12:12:21 -07:00
Henning Thielemann
4962b2696a lib: accountTransactionsReportItems: rewrite using catMaybes and mapAccumL
I find the report function less convolved without the integrated recursion.
2019-06-09 18:45:58 -07:00
Simon Michael
88f3f6fc41 print: also canonicalise balance assertions' amount style (fix #1042) 2019-06-09 17:39:46 -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
45198d3faa lib: debug helpers: add ptraceAtWith, dbgNWith 2019-06-02 08:48:41 -07:00
Simon Michael
42ce95aaef ; refactor: centralise valuation logic #131 2019-05-31 15:29:09 -07:00
Simon Michael
ad83919c6a ; lib: drop the Maybe from SummaryPosting 2019-05-31 15:29:09 -07:00
Simon Michael
69d72e8c48 ;refactor amountValue 2019-05-25 05:34:29 -07:00
Simon Michael
34a0ad00b1 ;lib: encapsulate Prices db 2019-05-25 05:29:34 -07:00
Simon Michael
aa99743096 make -V do --value=end in multiperiod reports (#329) 2019-05-24 10:30:35 -07:00
Simon Michael
ea5050963f web: try to fix RegisterR warning 2019-05-23 22:34:31 -07:00
Simon Michael
20bc386b80 restore TransactionsReport
hledger-web's register chart uses it, I didn't see it
because it's called from a hamlet template.
2019-05-23 22:15:40 -07:00
Simon Michael
7212b92079 cleanups (#329) 2019-05-23 22:07:50 -07:00
Simon Michael
54c1529638 lib: drop TransactionsReport, BalanceHistoryReport
They seem unused.
2019-05-23 21:55:19 -07:00
Simon Michael
04a30fa084 lib: TransactionsReport/AccountTransactionsReport cleanup
Split them into separate files, rename journalTransactionsReport to
transactionsReport.
2019-05-23 21:55:19 -07:00
Simon Michael
9977739c76 bal etc.: replace --value=transaction with --value=cost (#329) 2019-05-23 21:55:18 -07:00
Simon Michael
adbce22152 bal: --budget: don't always convert to cost
And don't show a percentage when budgeted and actual amounts are in
different commodities.
2019-05-23 21:55:18 -07:00
Simon Michael
2355da0f93 reg: replace --value=transaction with --value=cost 2019-05-23 21:55:18 -07:00
Simon Michael
ace215f5f3 print: replace --value=transaction with --value=cost 2019-05-23 21:55:18 -07:00
Simon Michael
37c0edb1f9 lib: drop postingValueAtDate 2019-05-23 21:55:18 -07:00
Simon Michael
4a75971c6d lib: postingTransformAmount, postingToCost, postingValue 2019-05-23 21:55:17 -07:00
Simon Michael
e5cb082fb5 lib: amountToCost, mixedAmountToCost 2019-05-23 13:11:34 -07:00
Simon Michael
f999bf78e6 opts: new -B/--cost, -V/--market, --value flags (#329) 2019-05-23 13:11:20 -07:00
Simon Michael
e21afc466a bal/bs/bse: -H or --cumulative now disables -T (#329)
To reduce confusion, multiperiod balance reports using -H/--historical
or --cumulative, which show end balances, no longer show a Totals
column since summing end balances generally doesn't make sense.
Also the underlying MultiBalanceReport now returns zero for those
totals when in cumulative or historical mode.
2019-05-11 20:43:28 -07:00
Simon Michael
76342a3fd0 bal/bs/cf/is: mention valuation type in report title 2019-05-09 15:39:43 -07:00
Simon Michael
e5339218f7 lib: valueTypeFromOpts helper 2019-05-09 15:36:26 -07:00
Simon Michael
d15869f855 ;doc: typo
[ci skip]
2019-05-09 12:22:48 -07:00
Simon Michael
d77fd5743d bal/bs/cf/is: support --value-at with -H; fix row/col/grand totals
This also includes a big cleanup of multiBalanceReport, which got
accidentally mingled.
2019-05-09 07:58:45 -07:00
Simon Michael
2ffe7914be ;improve valuation code docs 2019-05-07 16:19:49 -07:00
Simon Michael
74e653bfbc ;lib: declare Period exports 2019-05-06 11:52:10 -07:00
Simon Michael
72214a5747 reg: fix --value-at=transaction with -M (#329) 2019-05-06 08:07:16 -07:00
Simon Michael
ad00da244b reg: support --value-at with -H (#329) 2019-05-05 17:47:38 -07:00
Simon Michael
2ba0281335 bal: fix --value-at for old-style single period balance reports (#329) 2019-05-05 10:51:07 -07:00
Simon Michael
629b590de1 ;lib: cleanup 2019-05-05 10:38:13 -07:00
Simon Michael
76542458e6 lib: mapJournalTransactions, mapJournalPostings, mapTransactionPostings 2019-05-05 10:35:49 -07:00
Simon Michael
5a13bc632d ;clarify ledgerFromJournal doc 2019-05-05 10:09:40 -07:00
Simon Michael
1ad82d5b77 ;lib: balanceReport cleanup 2019-05-05 09:57:03 -07:00
Simon Michael
f4b0381043 ;lib: more docs for balanceReport 2019-05-05 09:50:29 -07:00
Simon Michael
8d7eacd73f bal: support --value-at=p/t with multiperiod reports (#329) 2019-05-05 09:30:01 -07:00
Simon Michael
74c381cc88 ;lib: more docs for multiBalanceReport 2019-05-04 17:46:52 -07:00
Simon Michael
66b1599058 ;lib: postingsReport cleanup 2019-05-04 17:09:16 -07:00
Simon Michael
cc05f48697 ;lib: multiBalanceReport cleanup 2019-05-04 12:34:59 -07:00
Simon Michael
12c0bfb39b ;lib: brValue cleanup 2019-05-04 12:22:00 -07:00
Simon Michael
ec1b98434c reg: support --value-at=period with periodic reports (#329) 2019-05-04 12:22:00 -07:00
Simon Michael
dd8c403c81 ;cli: option help tweaks 2019-05-04 12:22:00 -07:00
Simon Michael
ebf5ed93f2 valuation: more thorough --value-at; document status (#329, #999)
This feature turns out to be quite involved, as valuation interacts
with the many report variations. Various bugs/specs have been
fixed/clarified relating to register's running total, balance totals
etc. Eg register's total should now be the sum of the posting amount
values, not the values of the original sums. Current level of support
has been documented.

When valuing at transaction date, we once again do early valuation of
all posting amounts, to get more correct results. variants. This means
--value-at=t can be slower than other valuation modes when there are
many transactions and many prices. This could be revisited for
optimisation when things are more settled.
2019-05-03 12:24:02 -07:00
Simon Michael
696e3098c8 reg: support --value-at in register reports; cleanups, tests 2019-04-26 12:08:46 -07:00
Simon Michael
7306e61646 bal: support --value-at in single column balance reports 2019-04-26 12:08:32 -07:00
Simon Michael
00975fb226 bal*: support --value-at in multicolumn balance reports 2019-04-26 12:08:31 -07:00
Simon Michael
65934958f9 rename --value-date -> --value-at; --value-at implies -V 2019-04-26 12:08:31 -07:00
Simon Michael
6626778012 lib: amountValue, commodityValue doc cleanups 2019-04-26 12:08:31 -07:00
Simon Michael
9adae02973 print: add --value-date general option; implement for print -V 2019-04-26 12:08:31 -07:00
Simon Michael
9d3eb8c069 bal, reg, print: -V prefers non-future valuation dates again (#999) 2019-04-24 08:31:21 -07:00
Simon Michael
ef9c4a29c4 lib: save the current date in ReportOpts
We need this for choosing a valuation date, otherwise, report
functions would have to be in IO or we'd have to pass in yet another
argument.

It's optional because it's useful to be able to create report opts
purely (I think ?) This is not ideal but maybe not a problem.
2019-04-24 08:25:55 -07:00
Simon Michael
c23fc8b671 speed up -V/--value by converting reports, not the journal (#999)
Instead of converting all journal amounts to value early on, we now
convert just the report amounts to value, before rendering.

This was basically how it originally worked (for the balance command),
but now it's built in to the four basic reports used by print,
register, balance and their variants - Entries, Postings, Balance,
MultiBalance - each of which now has its own xxValue helper.

This should mostly fix -V's performance when there are many
transactions and prices (the price lookups could still be optimised),
and allow more flexibility for report-specific value calculations.

+------------------------------------------++-----------------+-------------------+--------------------------+
|                                          || hledger.999.pre | hledger.999.1sort | hledger.999.after-report |
+==========================================++=================+===================+==========================+
| -f examples/1000x1000x10.journal bal -V  ||            1.08 |              0.96 |                     0.76 |
| -f examples/2000x1000x10.journal bal -V  ||            1.65 |              1.05 |                     0.73 |
| -f examples/3000x1000x10.journal bal -V  ||            2.43 |              1.58 |                     0.84 |
| -f examples/4000x1000x10.journal bal -V  ||            4.39 |              1.96 |                     0.93 |
| -f examples/5000x1000x10.journal bal -V  ||            7.75 |              2.99 |                     1.07 |
| -f examples/6000x1000x10.journal bal -V  ||           11.21 |              3.72 |                     1.16 |
| -f examples/7000x1000x10.journal bal -V  ||           16.91 |              4.72 |                     1.19 |
| -f examples/8000x1000x10.journal bal -V  ||           27.10 |              9.83 |                     1.40 |
| -f examples/9000x1000x10.journal bal -V  ||           39.73 |             15.00 |                     1.51 |
| -f examples/10000x1000x10.journal bal -V ||           50.72 |             25.61 |                     2.15 |
+------------------------------------------++-----------------+-------------------+--------------------------+

There's one new limitation, not yet resolved: -V once again can pick a
valuation date in the future, if no report end date is specified and
the journal has future-dated transactions. We prefer to avoid that,
but reports currently are pure and don't have access to today's date.
2019-04-23 17:39:01 -07:00
Simon Michael
9ac1d7869b lib: journalStartDate, journalEndDate 2019-04-23 13:58:32 -07:00
Simon Michael
168edb910e lib: try a single filter again to speed up -V; simplify a bit (#999)
There was no speedup, in fact.
2019-04-22 16:38:42 -07:00
Simon Michael
028303acd7 lib: speed up -V by sorting market prices just once (#999)
-V is still quite a bit slower than no -V, but not as much as before:

+===========================================================++=======+
| hledger.999.pre -f examples/10000x10000x10.journal bal    ||  5.20 |
| hledger.999.pre -f examples/10000x10000x10.journal bal -V || 57.20 |
| hledger.999 -f examples/10000x10000x10.journal bal        ||  5.34 |
| hledger.999 -f examples/10000x10000x10.journal bal -V     || 17.50 |
+-----------------------------------------------------------++-------+
2019-04-20 13:12:53 -07:00
Jakob Schöttl
4444b8bc8f Change unused argument to undefined to make possible bugs more obvious 2019-04-18 22:38:41 +02:00
Jakob Schöttl
593ee39284 Fix behavior of options like -Mp2019
This fixes the issue #1008
2019-04-18 22:38:41 +02:00
Simon Michael
13dc1096a5 reg: test and fix for --average, broken since 1.12 (#1003) 2019-04-06 11:00:38 -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
16157bc711 lib, web: tweaks to keep building with GHC 7 2019-03-01 15:07:17 -08:00
Simon Michael
420eef4a40 lib: fix some transaction balancing cases
I needed to be more careful about ordering, as johannesgerer's original
code was, and the tests missed it. I think I have it now.
Found the PR whose code I have been reworking, it was #438.
2019-02-21 16:50:32 -08:00
Simon Michael
ca565795ad lib: transaction, [v]post*, balassert* constructors, for tests etc. 2019-02-21 16:20:04 -08:00
Simon Michael
0bc16d4af6 lib, cli, web: rename porigin -> poriginal 2019-02-20 20:23:54 -08:00
Simon Michael
ba850f3871 lib: more transaction balancing/assertions/assignments cleanup 2019-02-20 09:14:30 -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
b34b262c76 lib: document mapM'
[ci skip]
2019-02-17 08:36:59 -08:00
Simon Michael
bc7a1476ed refactor: lib: hlint cleanups 2019-02-14 05:15:49 -08:00
Simon Michael
03877057fb refactor: cli: commands: hlint clean 2019-02-14 05:15:49 -08:00
Simon Michael
226add41d3 lib: slight cleanup (spelling, hlint)
[ci skip]
2019-02-14 05:15:49 -08:00
Simon Michael
9e3cdef1e9 lib: balance assertion docs (#290)
[ci skip]
2019-02-13 15:52:07 -08:00
Jakob Schöttl
161ca660dc Support register --invert option to negate amounts 2019-02-09 15:55:41 -08:00
Simon Michael
86d5652e53 stop depending on here due to slow haskell-src-meta/stackage issues
Using file-embed or ordinary literals instead, for now.
2019-02-02 16:34:10 -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
550aa408eb lib: refactor, add embedFileRelative 2019-01-26 15:52:58 -08:00
Dmitry Astapov
f2aaaf3310 lib, cli: merge --show-unbudgeted into --empty 2019-01-25 12:53:09 -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
Dmitry Astapov
5711cdf9ba cli: added --transpose to "balance" command 2019-01-24 15:06:35 -08:00
Dmitry Astapov
f3366c7256 lib: fix behavior of nested budgets and --show-unbudgeted 2019-01-24 14:56:22 -08:00
Dmitry Astapov
92e7370f1f lib: fix alignment in budget report 2019-01-24 14:56:22 -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
573a13fc27 lib: expectParseStateOn helper 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
90bf354566 lib: allow more account directive info in Account records 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
9e4b302af7 lib: setFullPrecision, setMinimalPrecision (#941) 2019-01-16 14:45:50 -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
944554557a tweak readJournalFiles type signature 2019-01-15 06:18:56 -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
70b11ed0a4 journal: make balance assertions exact again (#941)
Going with option 1b from the issue: calculated and asserted amounts
are compared exactly, disregarding display precision.
But now balance assertion failure messages show those exact amounts at
full precision, avoiding confusion.
2019-01-08 16:51:11 +00:00
Simon Michael
c331be7f23 journal: clarify balance assertion/display precision more (#941) 2019-01-06 22:17:20 +00:00
Simon Michael
187fcf75ed journal: clarify balance assertion/display precision interaction
Surprisingly, balance assertions were checking to maximum precision,
which meant it was possible, with a display-precision-limiting
commodity directive, to have a failing assertion with the error
message showing asserted and actual amounts that looked the same.

Now we round the calculated account balance (but not the asserted
balance) to display precision before comparing. This should ensure
assertions always behave as you would expect from visual inspection.
2019-01-06 08:30:54 +00:00
Simon Michael
72eb48bb29 lib: clarify checkBalanceAssertion etc. 2019-01-06 08:24:07 +00: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
cd1455e9ea lib: note aquantity zero with AUTO amounts 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
Jesse Rosenthal
11a5809c5c journal: improve unassignable error. 2018-12-02 13:29:00 -08:00
Jesse Rosenthal
07d0a003a3 journal: fill unassignable list from account names. 2018-12-02 13:29:00 -08:00
Jesse Rosenthal
597b1b8ccd journal: check assignments against unassignable list 2018-12-02 13:29:00 -08:00
Jesse Rosenthal
ff455689a3 journal: add new state field for unassignable accounts
This should eventually include accountnames from transaction
modifiers (if `--auto` is enabled), or periodic transactions (if
`--forecast` is enabled).
2018-12-02 13:29:00 -08:00
Simon Michael
df775326d9 lib: add disabled test for proposed #931 solution 2018-11-29 13:44:38 -08:00
Simon Michael
6d0ee6a590 lib: clarify what postingsAsLines does (#931) 2018-11-29 13:32:59 -08:00
Simon Michael
e06e300446 lib: try to pin down what isTransactionBalanced does (#931) 2018-11-29 13:14:49 -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
b00aa32d7b journal: txn modifier multipliers multiply total-priced amounts (#928)
A different approach: instead of converting to unit prices and fiddling
with the display precision, just multiply the total prices by the same
multiplier (and keep them positive).

This seems a little more natural. I'm not sure if one of these will be
more robust than the other.
2018-11-13 17:50:30 -08:00
Simon Michael
d7919003ae lib: (divide|multiply)[Mixed]AmountAndPrice (#928)
Divide/multiply amounts *and* their total price, if they have one.
Helpful for keeping transactions balanced when transaction modifiers are
multiplying amounts.
2018-11-13 17:43:15 -08:00
Simon Michael
b053942e9b lib: flip the arguments of (divide|multiply)[Mixed]Amount (api change)
Also, start using a mapMixedAmount helper.
2018-11-13 17:28:24 -08:00
Simon Michael
9e8b1612b0 journal: fix txn modifier multipliers with total-priced amounts (#928)
Transaction modifier multipliers have never multiplied total-priced amounts
correctly (and prior to hledger 1.10, this could generate unbalanced
transactions).

Now, the generated postings in this situation will have unit prices,
and an extra digit of display precision. This helps ensure that
the modified transaction will remain balanced. I'm not sure yet if
it's guaranteed.
2018-11-13 16:35:46 -08:00
Simon Michael
4b5b9f46db lib: TransactionModifier: clarify 2018-11-13 16:35:46 -08:00
Simon Michael
80b34ea48d lib: TransactionModifier: cleanup 2018-11-13 11:25:36 -08:00
Mykola Orliuk
99bfebd1a1 ui: support all results of showGenericSourcePos
Resolves simonmichael/hledger#904
2018-10-26 16:32:16 -07:00
Mykola Orliuk
1aac38d3d3 lib: include source info in txn balance errors
Partially address simonmichael/hledger#904
2018-10-23 15:54:38 -07:00
Simon Michael
3f6922b51f lib: showTransaction: comment
[ci skip]
2018-10-22 14:28:18 -07:00
Samuel May
e57ef9e9a9 lib: journal: Add support for exact assertions 2018-10-22 09:55:14 -07:00
Samuel May
6c31393dd3 lib: Groundwork allowing multi-commodity 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
Simon Michael
0d531bb24f lib: showTransaction: fix a case showing multiple missing amounts
Noticed by peti: showTransaction could sometimes hide the last posting's
amount even if one of the other posting amounts was already implcit,
producing invalid transaction output.
2018-10-22 07:23:40 -07:00
Simon Michael
b5a90432ff lib: document and test showTransaction*, posting*AsLines 2018-10-22 06:46:31 -07:00
Simon Michael
20f006f7f6 lib: transaction: drop commented code 2018-10-22 04:03:29 -07:00
Simon Michael
b5df5fb5f0 lib: comment 2018-10-18 14:43:00 -07:00
Simon Michael
74611a7be1 ui: accounts: fix balances when there's only periodic txns
And clarify multiBalanceReport.
2018-10-18 14:43:00 -07:00
Simon Michael
2c2d10f9c2 lib: plog, plogAt: add missing newline, note issue 2018-10-18 14:43:00 -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
4a399e50cb acc: don't require an explicit --flat to make --drop work 2018-10-13 13:22:11 -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
Jesse Rosenthal
b346d7f701 Journal: make reordering optional in journalFinalise
Currently `journalFinalise` always reverses the order of
entries. However, if there are automated transactions, we might need
to run it twice. This adds a boolean flag to make reordering
optional. This will be used in the `parseAndFinaliseJournal`
functions.
2018-10-12 07:39:53 -07:00
Simon Michael
605a082d77 bs/bse/cf/is: use account type declarations if any
These commands now detect the account types declared by account directives.
Whenever such declarations are not present, built-in regular expressions
are used, as before.
2018-10-09 14:24:59 -10: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
6c57629b8c lib: fix posting-date-and-balance-assignment error properly (#894) 2018-10-09 16:08:47 -07:00
Simon Michael
8c7c59017a lib: fix my wrong merge of #880 more 2018-10-09 15:26:15 -07:00
Simon Michael
36fdeceb6c lib: tweak posting-date-no-amount-balance-assertion error (#894) 2018-10-09 14:15:52 -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
Simon Michael
ab26220b23 lib: document SmartDate
[ci skip]
2018-10-09 10:43:03 -07:00
Alex Chen
2cbc41e088 Merge branch 'master' into ExceptTLayer 2018-10-09 11:19:45 -06:00
Simon Michael
2ba135e402 lib: journal: fix wrong txn rendering in balance assertion errors 2018-10-06 09:31:22 -10: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
Alex Chen
3e54fc77a4 lib: make 'includedirectivep' an 'ErroringJournalParser'
- Update tests as well, requiring test utilities in Utils/Test.hs
  analogous to the those for 'JournalParser' but instead for
  'ErroringJournalParser'
2018-09-29 22:34:52 -06:00
Alex Chen
855a8f1985 lib: Re-implement the 'ExceptT' layer of the parser
We previously had another parser type, 'type ErroringJournalParser =
ExceptT String ...' for throwing parse errors without the possibility of
backtracking. This parser type was removed under the assumption that it
would be possible to write our parser without this capability. However,
after a hairy backtracking bug, we would now prefer to have the option
to prevent backtracking.

- Define a 'FinalParseError' type specifically for the 'ExceptT' layer
- Any parse error can be raised as a "final" parse error
- Tracks the stack of include files for parser errors, anticipating the
  removal of the tracking of stacks of include files in megaparsec 7
  - Although a stack of include files is also tracked in the 'StateT
    Journal' layer of the parser, it seems easier to guarantee correct
    error messages in the 'ExceptT FinalParserError' layer
  - This does not make the 'StateT Journal' stack redundant because the
    'ExceptT FinalParseError' stack cannot be used to detect cycles of
    include files
2018-09-29 22:33:34 -06:00
Alex Chen
2b3c97e1af lib: tweak custom parse errors
- Don't immediately throw custom parse errors into 'ParsecT'; rather,
  just construct and return them
- This anticipates the re-implementation of an 'ExceptT' layer of the
  parser, which should be able throw custom parse errors
2018-09-29 22:32:34 -06:00
Alex Chen
5e1f0ba6f7 lib: add a field to 'Journal' for a stack of include files
- In anticipation of megaparsec 7, which removes support for stacks of
  include files (as far as I can tell)
- Intended for the 'StateT Journal' layer of the parser
  - A stack of include files would be better in a 'ReaderT' layer, but I
    don't want to add another layer to the parser
- Intended for detecting cycles of include files
  - Potential issue: for proper error messages for include file cycles,
    we must remember to provide the filepath of the root journal file via
    the initial journal state passed to a 'JournalParser'; I imagine
    that we may forget to do so because in all other cases it is okay
    not to do so.
2018-09-29 22:32:27 -06:00
Simon Michael
2960c9209f lib: whitespace 2018-09-27 10:51:36 -10:00
Simon Michael
f42b140d53 lib: note about strict Map 2018-09-27 10:51:36 -10:00
Simon Michael
855bd54d19 budget: declaration and (actual) amount sorting for bal --budget
Account declaration-aware sorting is the default throughout hledger now.
2018-09-24 08:31:19 -10:00
Dmitry Astapov
8c79d6529d lib: fix balance --budget in the presence of --value 2018-09-23 07:45:34 -10:00
Simon Michael
3de8c11de1 journal: a new account sorting mechanism, and a bunch of sorting fixes
A bunch of account sorting changes that got intermingled.

First, account codes have been dropped. They can still be parsed and
will be ignored, for now. I don't know if anyone used them.
Instead, account display order is now controlled by the order of account
directives, if any. From the mail list:

  I'd like to drop account codes, introduced in hledger 1.9 to control
  the display order of accounts. In my experience,

  - they are tedious to maintain
  - they duplicate/compete with the natural tendency to arrange account
    directives to match your mental chart of accounts
  - they duplicate/compete with the tree structure created by account
    names

  and it gets worse if you think about using them more extensively,
  eg to classify accounts by type.

  Instead, I plan to just let the position (parse order) of account
  directives determine the display order of those declared accounts.
  Undeclared accounts will be displayed after declared accounts,
  sorted alphabetically as usual.

Second, the various account sorting modes have been implemented more
widely and more correctly. All sorting modes (alphabetically, by account
declaration, by amount) should now work correctly in almost all commands
and modes (non-tabular and tabular balance reports, tree and flat modes,
the accounts command). Sorting bugs have been fixed, eg #875.
Only the budget report (balance --budget) does not yet support sorting.

Comprehensive functional tests for sorting in the accounts and balance
commands have been added. If you are confused by some sorting behaviour,
studying these tests is recommended, as sorting gets tricky.
2018-09-22 21:45:07 -10:00
Simon Michael
598129ad6a lib: pushAccount -> pushDeclaredAccount 2018-09-22 21:06:29 -10:00
Simon Michael
059ad9eb76 refactor: jaccounts -> jdeclaredaccounts 2018-09-17 05:52:13 -07:00
Simon Michael
8d3cddc907 drop another old csv import 2018-09-07 12:51:10 -07:00
Simon Michael
23bdac41d9 csv: merge lucamolteni's cassava/custom separators (squashed) (#829)
commit 5ba464de76
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Sep 7 17:54:12 2018 +0200

    Fix CI 2

commit f060ae9449
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Sep 7 17:30:08 2018 +0200

    Fix CI build

commit af0719a33b
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Sep 7 17:19:01 2018 +0200

    Fix rebase

commit 1a24ddfa54
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Aug 10 16:25:24 2018 +0200

    Fixed some GHC warnings

commit 1ac43398a3
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Aug 10 16:14:49 2018 +0200

    Fix .cabal

commit 422456b925
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jul 1 22:56:20 2018 +0200

    Removed to-do list

commit 1118b762e4
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jul 1 22:53:28 2018 +0200

    Better test

commit 1146ed0941
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jul 1 15:32:28 2018 +0200

    Fix parsing

commit 4fc2374b2b
Author: Luca Molteni <volothamp@gmail.com>
Date:   Thu Jun 21 22:11:11 2018 +0200

    Parsing of separator

commit f7a61737f1
Author: Luca Molteni <volothamp@gmail.com>
Date:   Thu Jun 21 14:29:23 2018 +0200

    Almost separator in options

commit ac8841cf3b
Author: Luca Molteni <volothamp@gmail.com>
Date:   Thu Jun 21 14:16:59 2018 +0200

    Separator in parseCSV

commit 92a8b9f6ba
Author: Luca Molteni <volothamp@gmail.com>
Date:   Thu Jun 21 13:30:41 2018 +0200

    separator option

commit ec417a81ae
Author: Luca Molteni <volothamp@gmail.com>
Date:   Thu Jun 21 10:45:26 2018 +0200

    Removed one qualified import

commit 8b2f386c2f
Author: Luca Molteni <volothamp@gmail.com>
Date:   Wed Jun 20 14:01:12 2018 +0200

    Removed string conversions

commit a14d0e099e
Author: Luca Molteni <volothamp@gmail.com>
Date:   Wed Jun 20 10:23:20 2018 +0200

    custom delimiter in cassava

commit 694d48e2bc
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jun 10 17:51:54 2018 +0200

    Use Text.getContents - remove UTF-8 compatibility library

commit a7ada2cc60
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jun 10 17:49:34 2018 +0200

    todo list

commit 58ec47d398
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jun 10 17:45:22 2018 +0200

    CSV test now has unicode characters

commit b7851e94c3
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jun 10 16:59:39 2018 +0200

    Use decode from Text

commit 79f59fd28c
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sun Jun 10 13:28:57 2018 +0200

    Use Text and Lazy Bytestring

commit 470c9bcb8d
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 15:30:22 2018 +0200

    Use megaparsec error

commit f978848ba2
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 15:22:07 2018 +0200

    Renamed qualify and remove Parsec

commit 152587fde2
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 15:12:36 2018 +0200

    Use cassava mega parsec

commit cf281577a3
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 14:01:47 2018 +0200

    Removed Data.Vector

commit 1272e8e758
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 12:16:18 2018 +0200

    Removed Parsec ParseError

commit ae07f04313
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 12:06:14 2018 +0200

    Type sinonim for ParsecError

commit 8e15b253c1
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 11:16:08 2018 +0200

    Replaced with typeclasses

commit 1ed46f9c17
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 11:01:33 2018 +0200

    Replaced Text/CSV with Cassava

commit 362f4111b5
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 10:34:37 2018 +0200

    Use cassava parsin instead of Text/CSV

commit 83e678e371
Author: Luca Molteni <volothamp@gmail.com>
Date:   Sat Jun 9 08:22:51 2018 +0200

    Text CSV error messages

commit f922df71d2
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Jun 8 21:45:20 2018 +0200

    Better types

commit edd130781c
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Jun 8 21:34:59 2018 +0200

    Conversion to Text CSV type

commit 0799383214
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Jun 8 16:06:21 2018 +0200

    First function with cassava

commit e92aeb151f
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Jun 8 13:47:34 2018 +0200

    Added cassava as dependency

commit 5ea005c558
Author: Luca Molteni <volothamp@gmail.com>
Date:   Fri Jun 8 13:18:47 2018 +0200

    Better .gitignore for multi idea modules
2018-09-07 12:34:51 -07:00
Simon Michael
91b111b60d rename easytests_* to tests_* 2018-09-06 13:13:26 -07:00
Simon Michael
ce96001cfc lib: keep Tests building with ghc 7.10
The doctests test suite fails to bulid with ghc 7.10, not fixed.
2018-09-04 14:27:10 -07:00
Simon Michael
d14d6e2b68 tests: update doctests after Transaction Show change 2018-09-04 14:02:04 -07:00
Simon Michael
4003264129 lib: drop HUnit helpers, rename expectEqPP 2018-09-04 13:52:36 -07:00
Simon Michael
54db19e857 tests: convert & re-enable StringFormat tests 2018-09-04 13:51:08 -07:00
Simon Michael
51618adc37 tests: use is in a few more places 2018-09-04 13:39:21 -07:00
Simon Michael
09d9fbf487 tests: Reports -> easytest 2018-09-04 12:23:07 -07:00
Simon Michael
241d0dbebd tests: ReportOptions -> easytest 2018-09-04 11:54:40 -07:00
Simon Michael
3b63c2ff2f tests: Transaction, Data -> easytest 2018-09-04 11:54:15 -07:00
Simon Michael
a8175d8b14 tests: Timeclock -> easytest 2018-09-04 11:30:48 -07:00
Simon Michael
8d1506a4a4 tests: Posting -> easytest 2018-09-04 10:26:22 -07:00
Simon Michael
c5cd0dc648 tests: Ledger -> easytest 2018-09-04 10:24:07 -07:00
Simon Michael
d5c756e6c8 tests: Journal -> easytest 2018-09-04 10:10:10 -07:00
Simon Michael
0499b3f7e5 tests: Amount -> easytest 2018-09-04 10:01:26 -07:00
Simon Michael
dcc44d10a5 lib: export HasCallStack from Hledger.Utils.Test 2018-09-04 09:59:48 -07:00
Simon Michael
c3755f9a52 tests: AccountName -> easytest 2018-09-04 07:40:27 -07:00
Simon Michael
5de679ce62 tests: Query -> easytest 2018-09-04 07:29:48 -07:00
Simon Michael
bbecb28cae tests: Utils -> easytest 2018-09-03 15:54:53 -07:00
Simon Michael
f713a413ff clarify expectEq' arguments 2018-09-03 15:54:13 -07:00
Simon Michael
f3709f241d tests: port Read tests to easytest 2018-09-03 15:42:24 -07:00
Simon Michael
d1cff46ba7 tests: port CsvReader tests to easytest 2018-09-03 15:30:52 -07:00
Simon Michael
1fced57c81 lib: export expectEq' helper 2018-09-03 15:30:27 -07:00
Simon Michael
cd67f8ea68 tests: clear out old boilerplate 2018-08-31 18:12:17 -07:00
Simon Michael
d1a7cc1c09 port remaining Read.Common tests 2018-08-31 18:12:17 -07:00
Simon Michael
f124007acf tests: dehyphenate test names 2018-08-31 18:12:17 -07:00
Simon Michael
be7866da59 tests: parsedate -> fromGregorian 2018-08-31 18:12:17 -07:00
Simon Michael
f108b56e61 uniquify modules' easytests, simplify imports 2018-08-20 14:31:31 +01:00
Simon Michael
6568784bf6 port remaining JournalReader tests 2018-08-20 14:31:31 +01:00
Simon Michael
9733e0378e journal: restore/port more old unit tests 2018-08-20 10:38:51 +01:00
Simon Michael
776d575610 test helpers: more line breaks, clarify monadic behaviour 2018-08-20 10:38:02 +01:00
Simon Michael
d6fb96cb4c tests: expectParse, expectParseError helpers; parse to end of input 2018-08-20 08:59:06 +01:00
Simon Michael
5d9d9a8edb tests: drop obsolete helpers 2018-08-20 08:25:03 +01:00
Simon Michael
9c0483fef2 tests: port another to easytest 2018-08-20 08:22:31 +01:00
Simon Michael
1a38beaad1 drop old transactionp hunit tests 2018-08-19 19:12:26 +01:00
Simon Michael
7706f8498e tests: comment 2018-08-19 19:05:59 +01:00
Simon Michael
89357bb7b6 another parse test helper, use the IO variant always, port more tests 2018-08-19 19:02:59 +01:00
Simon Michael
3e6159e632 replace a bunch of custom Show instances for easier troubleshooting
Custom Show instances were obscuring important details in test failure
output again. The best policy seems to be: stick with default derived
Show instances as far as possible, but when necessary customize them
to conform to haskell syntax so pretty-show can do its thing (eg when
they contain Day values, cf https://github.com/haskell/time/issues/101).
2018-08-19 18:17:49 +01:00
Simon Michael
2778f6cf8f lib: restore some old unit tests
Also change nullsourcepos, tests prefer JournalSourcePos for some reason.
2018-08-19 18:13:01 +01:00
Simon Michael
150b40e465 tests: remove empty scope 2018-08-19 18:07:33 +01:00
Simon Michael
bdcfba4eaa whitespace 2018-08-18 20:31:47 +01:00
Simon Michael
fc11b5130f journal: another failing test from #807 2018-08-18 19:50:15 +01:00
Simon Michael
7ab8bc2685 tests: import cleanups 2018-08-18 19:47:52 +01:00
Simon Michael
a8031de729 tests: fix build error with GHC < 8.4 2018-08-18 19:26:07 +01:00
Simon Michael
d778a92561 tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers 2018-08-18 15:19:59 +01:00
Simon Michael
4d578c008f typo 2018-08-18 13:40:01 +01:00
Simon Michael
e0e21a2c6c lib: note 2018-08-18 07:30:23 +01:00
Simon Michael
9c3a57f615 lib: some test fixes (#823) 2018-08-17 14:18:24 +01:00
Simon Michael
b4c336c874 test/_test/it/_it helpers; refactor easytests
This makes skipping/unskipping tests easier, and improves readability
a bit.

Note it's also possible to just write the test name with no preceding
function, when the type is constrained (see Journal.hs).
2018-08-17 13:40:37 +01:00
Simon Michael
626247bacd journal: unit tests (2 skipped) for periodtransactionp (#823) 2018-08-17 12:42:43 +01:00
Simon Michael
b1bbbf0d93 lib: expectParseEqIO helper 2018-08-17 12:42:05 +01:00
Simon Michael
43d973e8ab lib: more verbose show instance for PeriodicTransaction 2018-08-17 12:41:45 +01:00
Simon Michael
1d775a7a9c lib: D should not affect automated posting multiplier amounts (fix #860) 2018-08-17 07:39:17 +01:00
Simon Michael
13436637c6 lib: "decimal point" -> "decimal separator" in error message 2018-08-17 07:37:26 +01:00
Simon Michael
e35dd19cc8 lib: refactor: tighten up amountwithoutpricep 2018-08-17 06:51:07 +01:00
Simon Michael
e9c5d13ac1 lib: update old failing amountp/postingp tests, at last (#812) 2018-08-16 06:42:52 +01:00
Simon Michael
dab75d98c8 lib: expectEq', expectParseEq: pretty-print compared values (#812) 2018-08-16 06:31:37 +01:00
Simon Michael
536eadb809 lib: improve expectParseEq (#812)
Show a pretty parse error, and avoid sequenced scopes
which are confusing (you can't run only the second).
2018-08-16 06:03:44 +01:00
Simon Michael
09d8e302db lib: use unspaced scopes to simplify command lines (#812) 2018-08-16 05:58:17 +01:00
Simon Michael
50d666d5a0 test: refactor, document, organise easytests, port amountp tests (#812) 2018-08-15 19:58:07 +01:00
Simon Michael
69325da110 comment out failing tests to fix CI (#812) 2018-08-15 11:30:53 +01:00
Simon Michael
ab7dc3294e lib: more informative failure output for amount tests (#812) 2018-08-15 11:24:52 +01:00
Simon Michael
e6181efe95 lib: more compact show instance for Amounts (#812)
Amount's default show instance hid important details, making eg test
failures hard to understand. Showing full detail required increasing
the debug level which was inconvenient.

Now it has a single show instance which shows more information, is
fairly compact, and is pretty-printable with pretty-show.
Ellipses (..) in the output indicate where fields are
- not shown in full detail, and/or
- shown in pseudo syntax (double quoted) to work with pretty-show.

ghci> usd 1
OLD:
Amount {acommodity="$", aquantity=1.00, ..}
NEW:
Amount {acommodity = "$", aquantity = 1.00, aprice = NoPrice, astyle = AmountStyle "L False 2 Just '.' Nothing..", amultiplier = False}

MixedAmount's show instance is unchanged, but showMixedAmountDebug
is affected by this change:

ghci> putStrLn $ showMixedAmountDebug $ Mixed [usd 1]
OLD:
Mixed [Amount {acommodity="$", aquantity=1.00, aprice=, astyle=AmountStyle {ascommodityside = L, ascommodityspaced = False, asprecision = 2, asdecimalpoint = Just '.', asdigitgroups = Nothing}}]
NEW:
Mixed [Amount {acommodity="$", aquantity=1.00, aprice=, astyle=AmountStyle "L False 2 Just '.' Nothing.."}]
2018-08-15 11:18:55 +01:00
Simon Michael
27d464f344 lib: some helpers for setting Amount internals (#812) 2018-08-14 16:05:06 +01:00
Simon Michael
efae8f8f2a lib: comment 2018-08-14 16:05:06 +01:00
Simon Michael
e077aeff5f lib: more informative test failure message (#812) 2018-08-14 16:05:06 +01:00
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