Commit Graph

661 Commits

Author SHA1 Message Date
Simon Michael
c759c9b3de ;lib: fix some more warnings in Transaction 2019-12-09 06:08:03 -08:00
Simon Michael
13e6c7dfdf lib: drop "assertion" alias for nullassertion
Perhaps we'll stick with the null* convention. Fixes a warning in Transaction.hs.
2019-12-09 06:08:03 -08:00
Simon Michael
a0b92e02b9 Revert "remove old fail compatibility imports that are obsolete ?"
They are needed with ghc <8.4, not for fail but for <> I think.
Try cleaning up again another time.
This reverts commit 318ce7eb07.
2019-12-01 11:32:51 -08:00
Simon Michael
318ce7eb07 remove old fail compatibility imports that are obsolete ? 2019-12-01 08:31:50 -08:00
Simon Michael
279e9624ed ;lib: clarify docs for setFullPrecision, setNaturalPrecision 2019-11-30 16:56:45 -08:00
Simon Michael
2b2a0b3cf8 ;tests: use "test" alias for testCase everywhere
Easier to type and read, and a little clearer to my eyes;
"testCase" implies a single case, but it can contain many assertions.
2019-11-28 15:33:33 -08:00
Simon Michael
b36f6df110 tests: port all unit tests to tasty, second pass (#1090)
Hledger.Util.Tests helpers have been cleaned up, and test names are
now shown.

Tests have been cleaned up a bit. Some groups of unnamed tests have
been collapsed into a single named test containing a sequence of
assertions. The test command counts named tests, not assertions, so
the reported unit test count has dropped from 199 to 188.
2019-11-27 13:17:34 -08:00
Simon Michael
13a3542464 tests: port all unit tests to tasty, first cut (#1090)
easytest is not actively maintained and requires an old version of
hedgehog which does not support base-compat 0.11 & ghc 8.8.

This is still using the old easytest helpers, and not displaying test
names properly.
2019-11-27 12:43:43 -08:00
Simon Michael
3f0892556d ;lib: clarify choiceopt doc 2019-11-23 13:03:26 -08:00
Mykola Orliuk
2a36ac0d62 ;lib: fix doctest for RawOptions 2019-11-19 20:43:19 +01:00
Mykola Orliuk
5287fe671b ;all: hide RawOpts internals
This way we can ensure we always use only functions from RawOptions.
2019-11-18 17:38:39 -08:00
Simon Michael
68b1cacf0f lib: refactor, prepare to drop showTransactionUnelided functionality
It seems we don't use it at all, and ony says it's not robust with
prices either.

Merge remote-tracking branch 'ony/chores/drop-elide-in-showTransaction'
2019-11-18 17:27:30 -08:00
Michael Kainer
79ca4a767e cli: Add -% to compound balance commands
This commit introduces the commandline argument -%/--percent to show
percentages of the column's total instead of the absolute amounts for
each account in reports. The signs of the values are preserved.

This option is especially useful for the balance and incomestatement
commands.

If there are multiple commodities involved in a report hledger bails
with an error message. This can be avoided by using --cost. Also note
that if one uses -% with the balance command the chances are high that
all numbers are 0. This is due to the fact that by default balance sums
up to zero. If one wants to use -% in a meaningful way with balance one
has to add a query.

In order to keep the implementation as simple as possible --tree has no
influence over how the percentages are calculated, i.e., the percentages
always represent the fraction of the columns total. If one wants to know
the percentages relative to a parent account, one has to use a query to
narrow down the accounts.
2019-11-18 17:10:59 -08:00
Mykola Orliuk
aca214b0ac lib: drop amount elision in showing last posting
This behavior is highly depends on journal. If we want to re-introduce
it we'd better re-consider how transaction entry can be "simplified".
I.e. besides dropping last amount we may drop prices that can be assumed
implicitly.
Note that there is no need to knit it into showTransaction since it
easily achievable with pre-processing (similar to implicit balances
etc).
2019-11-16 12:53:07 +01: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
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
Dmitry Astapov
568cb32677 lib: more runPeriodicTransaction tests (lifted from #1085 and spanIntervalIntersect) 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
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
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
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
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
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