Commit Graph

9662 Commits

Author SHA1 Message Date
Simon Michael
0f4e462ae7 add a Show instance for AmountDisplayOpts, WideBuilder
For debug logging.
2021-04-13 17:19:22 -10:00
Stephen Morgan
28fd7c65f2 lib: When displaying amounts on a single line, always display at least one amount, even if that would exceed the requested maximum width. Addresses #1526. 2021-04-13 15:29:58 -10:00
Simon Michael
f5121129ec timeclock: print shows timeclock amounts with just 2 decimals, like pre-1.21 (#1527) 2021-04-12 18:40:33 -10:00
Simon Michael
25322e489e ui: add tests for query filtering (#1523) 2021-04-12 12:58:51 -10:00
Simon Michael
bd41d1bd11 ui: tests: clean up, update for #1468 2021-04-12 12:47:50 -10:00
Simon Michael
dbe7ef0157 ui: setFilter: note error-ignoring behaviour 2021-04-12 12:06:11 -10:00
Simon Michael
b13df845c0 ui: register: fix queries, broken in 1.21 (#1523) 2021-04-12 12:05:35 -10:00
Stephen Morgan
493ed14629 lib,test: Make sure historical postings have prices stripped if necessary in PostingsReport (see issue #1522). 2021-04-11 18:31:30 -10:00
Stephen Morgan
f6feef7f80 lib,cli: Strip prices in MultiBalanceReport and PostingsReport whenever
we know we won't need them.

Knowing whether we need them is accomplished by pulling the "show-costs"
option used by the Close command up into ReportOpts.
2021-04-11 18:31:30 -10:00
Stephen Morgan
b7a2479186 lib: Use uniform naming for stripping prices.
Creates a new function amountStripPrices, and renames removePrices to
postingStripPrices.
2021-04-11 18:31:30 -10:00
Stephen Morgan
42d7009fef test: Alter valuation tests to better distinguish between costing and
valuation. Replaces a redundant test with one which tests both costing
and valuation simultaneously.
2021-04-11 18:06:04 -10:00
Stephen Morgan
278153effa lib: Add more efficient toEncoding for custom ToJSON declarations. 2021-04-10 17:52:33 -10:00
Stephen Morgan
a529207ae7 lib: Do not round Decimal before applying JSON representation if
existing representation is small enough.

Previously the JSON representation of Decimal was rounded to 10 points
of precision before serialising. This sometimes results in an
unnecessary increase of precision.
2021-04-10 17:52:33 -10:00
Simon Michael
55772cbd9b stack config for testing with GHC 9.0, WIP (#1503) 2021-04-06 07:59:11 -10:00
Simon Michael
4578d5d329 ui: work around ghc 9.0 build failure (#1503)
Also remove obsolete shebang line.
2021-04-06 07:45:49 -10:00
Simon Michael
eb2da22f63 ;update cabal files 2021-04-04 08:03:57 -10:00
Simon Michael
ba1e91c302 drop support for GHC 8.0
Prior to this commit,
- hledger still builds with GHC 8.0
- hledger-ui does if you use the build plan specified by stack8.0.yaml,
  but you are likely to hit problems if you let cabal pick one
  (https://github.com/jtdaugherty/vty/issues/198 and others)
- hledger-web might, if you could find the right build plan

The hassles are enough and GHC 8.0 is old enough (first released in
2016) that I'm letting it go; 8.2 is the new minimum version for all
hledger packages.

This allows a bunch of cleanups to conditional imports, which I leave
for later.

Also, updated the tested-with minor versions.
2021-04-04 07:54:22 -10:00
Simon Michael
8d7fef4f6b stack: fix stack8.0.yaml (#1514) 2021-04-03 21:10:57 -07:00
Stephen Morgan
edbb713cf8 lib,cli: Fix ledgerDateSpan, so that in takes transaction dates into account. 2021-04-03 13:54:23 -10:00
Stephen Morgan
5fbb67b893 lib,cli: Move reportPeriodName to Hledger.Reports.ReportOptions, use it
for HTML and CSV output for compound balance reports.
2021-04-03 13:43:37 -10:00
Simon Michael
d0940bf8ce ;update cabal files 2021-03-29 08:19:54 -07:00
Simon Michael
4e644840bc lib, etc: add now-required lower bound on containers (#1514) 2021-03-29 08:19:28 -07:00
Simon Michael
5db75c39df bal: keep csv column and row labels consistently lower case
It was reported on #hledger that bal -O csv capitalises "account"
differently for single and multi-period reports. All lower case seems
to be the most common, so I have dropped the capitalisation. Also
the trailing colon from --transpose's "total:".
2021-03-29 07:50:43 -07:00
Eric Mertens
03f06128dc Add a whitespace csv test 2021-03-26 16:39:24 -07:00
Eric Mertens
48d558fc7a Tolerate spaces in amount fields in CSV files 2021-03-26 16:39:24 -07:00
Stephen Morgan
b6e20dea13 lib,test: Simplify the JSON representation of AmountPrecision.
It now uses the same JSON representation as Maybe Word8. This means that
the JSON serialisation is now broadly compatible with that used before the
commit f6fa76bba7, differing only in
how it handles numbers outside Word8 and that it can now produce null
for NaturalPrecision.
2021-03-25 15:47:34 -07:00
Simon Michael
eab66de2ca ;cli: doc: commodity, D directive updates 2021-03-25 15:26:28 -07:00
Stephen Morgan
4cb9dfb5b8 lib: Properly escape quotes in csv output. 2021-03-25 09:41:42 -07:00
Stephen Morgan
4609e79f2c lib,cli,ui,web: A number of AccountName and Journal functions which are
supposed to produce unique sorted use Sets internally to be slightly
more efficient. There is also a new function journalCommodities.
2021-03-23 11:26:30 -07:00
Stephen Morgan
7fe58f1346 lib: More efficiently check whether Amounts are or look zero.
Comparing two Quantity (either with (==) or compare) does a lot of
normalisation (calling roundMax) which is unnecessary if we're comparing
to zero. Do things more directly to save work.

For reg -f examples/10000x10000x10.journal, this results in
- A 12% reduction in heap allocations, from 70GB to 62GB
- A 14% reduction in (profiled) time, from 79s to 70s
Results for bal -f examples/10000x10000x10.journal are of the same order
of magnitude.
2021-03-23 11:26:30 -07:00
Stephen Morgan
522c8a6ad3 lib: In sorting account names, perform lookups on HashSets and HashMaps,
rather than lists. This is probably not an enormous performance sink in real
situations, but it takes a huge amount of time and memory in our
benchmarks (specifically 10000x10000x10.journal).

For bal -f examples/10000x10000x10.journal, this results in
- A 23% reduction in heap allocation, from 27GiB to 21GiB
- A 33% reduction in (profiled) time running, from 26.5s to 17.9s
2021-03-23 11:26:30 -07:00
Stephen Morgan
13589aca2e doc: Remove incorrect haddock comment. 2021-03-23 11:26:30 -07:00
Stephen Morgan
f3c9bce02c lib: Minor refactor, using foldMap instead of asum . map . toList. 2021-03-23 11:26:30 -07:00
Simon Michael
d87751ef2e ;doc: ui, web: make image paths absolute 2021-03-21 09:10:50 -07:00
Simon Michael
076da7dd18 ;shake webmanuals: update toc/versions placeholders 2021-03-21 09:01:33 -07:00
Simon Michael
d5a227f18c ;doc: ui, web, contributing: fix image urls 2021-03-21 07:45:37 -07:00
Stephen Morgan
7488140608 lib: Do not call showAmount twice for every posting.
For print -f examples/10000x10000x10.journal, this results in
- A 7.7% reduction in heap allocations, from 7.6GB to 7.1GB.
2021-03-21 07:10:27 -07:00
Stephen Morgan
7aa3d3e760 lib,cli: Some efficiency improvements in register reports.
Strip prices after valuing postings in PostingsReport.
Use renderRow interface for Register report.

For reg -f examples/10000x10000x10.journal, this results in:
- Heap allocations decreasing by 55%, from 68.6GB to 31.2GB
- Resident memory decreasing by 75%, from 254GB to 65GB
- Total (profiled) time decreasing by 55%, from 37s to 20s
2021-03-21 07:10:27 -07:00
Stephen Morgan
d54e276658 lib: Split showMixedAmountB into showMixedAmountB and showAmountsB, the
former being a simple wrapper around the latter.

This removes the need for the showNormalised option, as showMixedAmountB
will always showNormalised and showAmountsB will never do so.

We also strip prices from MixedAmount before displaying if not displaying prices.
2021-03-21 07:10:27 -07:00
Simon Michael
16f8ed3d0f shake webmanuals: include the TOC comment 2021-03-19 08:21:28 -07:00
Simon Michael
7fad876014 ;update manuals 2021-03-18 07:22:42 -07:00
Simon Michael
0c56d3ffa3 shake mandates: update .date.m4 source files to current month/year 2021-03-18 07:21:51 -07:00
Simon Michael
941574423a ;shake: drop ".webmanuals" from website markdown filenames 2021-03-18 06:48:07 -07:00
Simon Michael
5ff6e0b618 ;make copy-bins-to-X: use period instead of hyphen 2021-03-17 18:15:09 -07:00
Simon Michael
cef9aede93 new API for MixedAmount arithmetic (#1491)
Previously we relied on MixedAmount being a Num, which allows +, -,
sum, negate, fromInteger etc. to be used with MixedAmounts. While
convenient, this Num instance is not (and can't be) fully implemented
or law abiding, so it's possible to misuse it, potentially leading to
bugs.

Now, MixedAmount is a lawful Monoid (and a Semigroup), so you can
combine (add) MixedAmounts with <> or mconcat and represent zero with
mempty.

However, we recommend using the following more abstract API, which
will insulate you from future implementation changes:

maPlus       (instead of +)
maMinus      (instead of -)
maNegate     (instead of negate)
maSum        (instead of sum/sumStrict)
nullmixedamt (instead of 0)

And when constructing MixedAmounts, avoid the Mixed constructor,
instead use:

mixed        :: [Amount] -> MixedAmount
mixedAmount  :: Amount -> MixedAmount
maAddAmount  :: MixedAmount -> Amount -> MixedAmount
maAddAmounts :: MixedAmount -> [Amount] -> MixedAmount

For now the Num instance remains, as a convenience for scripters and
for backward compatibility, but for production code you should
probably consider it deprecated.
2021-03-17 17:36:23 -07:00
Stephen Morgan
d6a4310d8f lib,cli,ui,bin: Eliminate all uses of Mixed outside of Hledger.Data.Amount.
Exceptions are for dealing with the pamount field, which is really just
dealing with an unnormalised list of amounts.

This creates an API for dealing with MixedAmount, so we never have to
access the internals outside of Hledger.Data.Amount.

Also remove a comment, since it looks like #1207 has been resolved.
2021-03-18 09:47:59 +11:00
Stephen Morgan
dabb3ef82e lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should
supplant the old interface, which relied on the Num typeclass.

MixedAmount did not have a very good Num instance. The only functions
which were defined were fromInteger, (+), and negate. Furthermore, it
was not law-abiding, as 0 + a /= a in general. Replacements for used
functions are:
0 -> nullmixedamt / mempty
(+) -> maPlus / (<>)
(-) -> maMinus
negate -> maNegate
sum -> maSum
sumStrict -> maSum

Also creates some new constructors for MixedAmount:
mixedAmount :: Amount -> MixedAmount
maAddAmount :: MixedAmount -> Amount -> MixedAmount
maAddAmounts :: MixedAmount -> [Amount] -> MixedAmount

Add Semigroup and Monoid instances for MixedAmount.
Ideally we would remove the Num instance entirely.

The only change needed have nullmixedamt/mempty substitute for
0 without problems was to not squash prices in
mixedAmount(Looks|Is)Zero. This is correct behaviour in any case.
2021-03-18 09:47:21 +11:00
Simon Michael
4b2c943867 ;bin: hledger-combine-balances: fix haddock error 2021-03-16 07:20:01 -07:00
Simon Michael
cca765de72 install: hledger-iadd 1.3.14 2021-03-14 10:16:09 -07:00
Simon Michael
f54f2b3b72 ;doc: also update manual source files (#1504) 2021-03-13 07:28:14 -08:00