Commit Graph

135 Commits

Author SHA1 Message Date
Stephen Morgan
dcb884c5ff lib: Align postings to unnormalised amount widths. 2020-11-04 14:25:20 +11:00
Stephen Morgan
9de238757b lib,cli,ui: Introduce showMixed*Unnormalised, eliminate most direct calls of strWidth.
This introduces some new helper functions which are exactly the same
as what we had before, but do not call
normaliseMixedAmountSquashPricesForDisplay, so that we can use the new
functions for displaying Transaction and Posting. It also goes through
and gets rid of most uses of the old showMixed* functions which would
benefit from using the new interface.
2020-11-04 14:25:20 +11:00
Stephen Morgan
f6fa76bba7 lib,cli: Get rid of magic values for asprecision, use a sum type instead. 2020-08-30 23:00:35 +10:00
Stephen Morgan
371b349b2e lib,cli: Replace parsedate and mkdatespan with direct applications of fromGregorian, transaction now takes Day instead of a date string. 2020-08-29 15:08:28 -07:00
Stephen Morgan
dc076b0d5b lib: Use text library functions for stripping. 2020-07-16 10:03:25 -07:00
Stephen Morgan
ed99aea7d5 lib: Introduce takeEnd to get rid of some reverse . take n . reverse. 2020-07-16 10:03:25 -07:00
Simon Michael
97f2235bca ;lib: refactor amount cost functions
Rename costOfAmount -> amountCost, costOfMixedAmount -> mixedAmountCost,
drop amountToCost, mixedAmountToCost.
2020-05-31 15:48:08 -07:00
Simon Michael
660ba7e1d9 lib: clarify zero-checking function names
isZeroAmount                -> amountLooksZero
isReallyZeroAmount          -> amountIsZero
isZeroMixedAmount           -> mixedAmountLooksZero
isReallyZeroMixedAmount     -> mixedAmountIsZero
isReallyZeroMixedAmountCost dropped
2020-05-29 18:57:22 -07:00
Simon Michael
1087e790cf ;lib: refactor transactionCheckBalanced 2020-05-29 17:57:10 -07:00
Simon Michael
7bcc205622 lib: drop transactionPostingBalances 2020-05-29 17:33:53 -07:00
Simon Michael
0a5fa33f9d split more long transaction balancing errors into lines; refactor 2020-05-29 16:31:15 -07:00
Simon Michael
924ec1c98d journal: clearer transaction balancing errors; refactor
As mentioned by netvor on IRC, the unbalanced transaction error was
not too clear when postings all have the same sign.

Some other wording has been clarified, and the main error message is
now shown on multiple lines for readability (at the cost of
predictability/grepability..)

There's also a probably unnoticeable change: selecting which parts of
the error to show is now based on display precisions (reusing the
balanced check logic), rather than original precisions.
2020-05-29 16:07:58 -07:00
Simon Michael
e6f9f09b41 ;lib: refactor, consolidate, add transactionCheckBalanced 2020-05-29 11:57:48 -07:00
Jakob Schöttl
50acfc9119 Fix documentation, make ISO date format standard in some places 2020-02-09 07:26:54 -08:00
Brian Wignall
00eb0b3c8f Make "stack test" pass again 2020-01-07 15:58:22 -08:00
Simon Michael
c759c9b3de ;lib: fix some more warnings in Transaction 2019-12-09 06:08:03 -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
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
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
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
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
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
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
bc7a1476ed refactor: lib: hlint cleanups 2019-02-14 05:15:49 -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
6f36702141 lib: rename, reposition tprecedingcomment field 2019-01-05 07:35:54 +00: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
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
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
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
91b111b60d rename easytests_* to tests_* 2018-09-06 13:13:26 -07:00
Simon Michael
4003264129 lib: drop HUnit helpers, rename expectEqPP 2018-09-04 13:52:36 -07:00
Simon Michael
3b63c2ff2f tests: Transaction, Data -> easytest 2018-09-04 11:54:15 -07: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