Commit Graph

471 Commits

Author SHA1 Message Date
Simon Michael
e4263e69e1 areg: begin respecting --date2: show txns' date2 (#1731) 2021-10-10 10:34:45 -10:00
Simon Michael
b4c1188c26 ref!: postingDateOrDate2, transactionDateOrDate2, whichDateFromOpts -> whichDate (#1731) 2021-10-10 10:34:35 -10:00
Stephen Morgan
5aadcdea4d ref: Add new helper functions journalValueAndFilterPostings(With)?.
Combining valuation with filtration is subtle and error-prone (see e.g. #1625).
We have to do in in both MultiBalanceReport and PostingsReport, where it
is done in slightly different ways. This refactors this functionality
into separate functions which are called in both reports, for uniform
behaviour.
2021-09-26 08:13:12 -10:00
Stephen Morgan
ce4fcfae84 imp!: value: For register reports with no reporting interval and
--value=end, historical reports should be valued at journal/report end
date.
2021-09-24 11:32:41 -10:00
Simon Michael
72a4c82043 cli: tweak --pretty help 2021-09-21 17:15:39 -10:00
Stephen Morgan
399d28dc05 cln: Display friendly error message if --pretty is given an incorrect
argument.
2021-09-21 15:32:09 -10:00
Stephen Morgan
bf3e82f780 imp: pretty: Replace --pretty-tables argument with --pretty=WHEN
argument, which takes yes or no. Default is no for now.
2021-09-21 14:53:52 -10:00
Stephen Morgan
1e766e481e cln: Flatten dependency tree by removing dependencies of Hledger.Reports
on Hledger.Read.

This is done by using equivalent functions/types defined elsewhere
instead.
2021-09-19 17:10:38 -10:00
Stephen Morgan
a2d7ac5318 ref: balance: Refactor getPostingsByColumn to use groupByDateSpan.
This reduces code duplication, makes the code more idiomatic, and hides
optimisation magic within groupByDateSpan.
2021-09-18 14:40:28 -10:00
Stephen Morgan
35c33f342b cln: Move column grouping functions form Report.PostingsReport to Data.Dates. 2021-09-18 14:40:28 -10:00
Simon Michael
326d6e8dae ref: ReportOptions{infer_value_} renamed to infer_prices_
For more consistency with the flag name (--infer-market-prices).
And BalancingOpts{infer_prices_} is now infer_transaction_prices_.
2021-09-18 12:12:31 -10:00
Simon Michael
daa9fddec9 imp: cli: --infer-market-price renamed to --infer-market-prices
It was too easy to get this wrong, even some of the docs did.
Now either plural or singular spelling works
(since we accept flag prefixes).
2021-09-18 12:12:31 -10:00
Stephen Morgan
62351dd329 fix: bal: Make sure boring parent accounts in compound balance reports
include historical postings when account declarations have undeclared
parents. (#1698)
2021-09-17 15:24:19 -10:00
Stephen Morgan
3b5262e54a fix: performance: Speed up PostingsReport when called with a large number of intervals. (#1683)
It is still very slow for large journals, but at least it doesn't run
any slower for interval reports.
2021-09-16 17:40:24 -10:00
Stephen Morgan
6905e40c4d pkg!: cli: Add --today option to explicitly set the current date. (#1674)
rawOptsTo* in hledger-lib now takes a day as an argument, and does not
live in the IO monad, since it's now pure.

This is so that we can run tests containing future transactions that
won't fail as soon as ‘the future’ actually arrives.
2021-09-09 14:40:39 -10:00
Stephen Morgan
50f73b7434 fix: balance: Show all empty accounts in flat balance reports. (#1688)
Previously we only showed empty leaves.
2021-09-08 18:17:27 -10:00
Stephen Morgan
8274da81fc cln: tests: Remove test and tests, which are just aliases for testCase
and testGroup.

Replacing these removes a layer of indirection, and reduces the need to
depend on Hledger.Utils.Test.
2021-08-30 16:32:19 -10:00
Stephen Morgan
f3eacebc1d dev: lens: Use TemplateHaskell for ReportOpts and ReportSpec.
Also rename overWithReport/setWithReport to overEither/setEither.
2021-08-28 19:12:04 -10:00
Stephen Morgan
13206d0b18 cln: Rename balancingOpts to defbalancingopts, to be consistent with definputopts, defreportopts, etc. 2021-08-28 19:12:04 -10:00
Stephen Morgan
d248aec313 cln: hlint: Remove eta reduce warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
32dad455fd cln: hlint: Clean up section related warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
8bf7c95697 cln: hlint: Clean up Functor related hlint warnings, and NOINLINE warning. 2021-08-27 06:13:56 -10:00
Stephen Morgan
46b0745412 cln: hlint: Remove Either and Bifunctor related warnings. 2021-08-26 21:00:35 -10:00
Stephen Morgan
d13ce0e134 cln: hlint: Remove Unused LANGUAGE pragma ignore. 2021-08-26 07:23:11 -10:00
Stephen Morgan
fed75c58e9 cln: hlint: Clean up hlint warnings not already ignored in hlint.yaml. 2021-08-25 20:44:36 -10:00
Stephen Morgan
06312c353a fix!: register: Tighten up spacing around the date in register reports. (#1655)
As a side effect, this changes the Json representation of the
PostingsReport. The maybe report end date is now replaced with a maybe
period.
2021-08-22 08:15:22 -10:00
Lawrence
710823e5d7 imp: bal: handle commodity-column flag in compound balance reports (#1654) 2021-08-19 17:37:30 -10:00
Lawrence
277227acf8 fix: budget: handle transpose flag with commodity-columns (#1654)
Budget formatting is quite complicated since we must determine widths
for each of the transposed columns
2021-08-19 17:37:29 -10:00
Lawrence
44e1ea10fa fix: bal: correctly handle empty commodity in commodity-column (#1654)
We can't filter out empty commodity strings since that is a legitimate
group. Simultaneously, we should only include the empty commodity if it
is explicitly used (part of a posting) and not generated as part of
`Amounts.amounts`
2021-08-19 17:37:19 -10:00
Stephen Morgan
ddba9f6ce4 imp: lib,cli: Implement gain report for balance reports.
A gain report will report on unrealised gains by looking at the
difference between the valuation of an amount (by default, --value=end),
and the valuation of the cost of the amount.
2021-08-18 21:44:30 -10:00
Lawrence
5989ca0381 fix: skip budget grand total and average if they look zero
Makes them consistent with the remaining cells and fixes awkward
alignment issue in commodity-column mode where we don't display
anything
2021-08-08 09:19:25 -10:00
Lawrence
198d2211fc budget: option to view one commodity per row
Extension of commodity-column to budget reporting.
2021-08-08 09:19:25 -10:00
Lawrence Wu
f3c07144a8 bal: option to view one commodity per row
This adds the `--commodity-column` option that displays each commodity
on a separate line and the commodities themselves as a separate column.
The initial design considerations are at
simonmichael.hledger.issues.1559

The single-period balance report with `--commodity-column` does not
interoperate with custom formats.
2021-08-08 09:19:25 -10:00
Stephen Morgan
918c243fa9 fix: forecast: Generate forecast transactions at journal finalisation,
rather than as a postprocessing step. (#1638)

This allows us to have a uniform procedure for balancing transactions,
whether they are normal transactions or forecast transactions, including
dealing with balance assignments, balance assertions, and auto postings.
2021-08-05 21:10:47 -10:00
Stephen Morgan
c404800fbf ref!: forecast: Move forecast_ from ReportOpts to InputOpts. 2021-08-05 21:10:47 -10:00
Stephen Morgan
5cca04cdc9 imp: areg: aregister no longer excludes future/forecast transactions by default.
To get the previous behaviour, you can call with the additional query "not📅tomorrow-".

This is because we are preparing to move forecast_ to InputOpts, where
it is not accessible to AccountTransactionsReport.
2021-08-05 21:10:47 -10:00
Stephen Morgan
23b0cad6ef fix: areg: Make sure aregister sorts first by transaction register date,
then by parse order to break any ties. (#1642)
2021-08-05 20:49:25 -10:00
Stephen Morgan
ae3c7e8756 fix: areg: Make sure the true original transaction is made available in
AccountTransactionsReport.

Only a limited number of journal transformations are allowed in
accountTransactionReports due to the need to include the original
transaction. Document these.

Make sure to remove currency and amount queries from the reportq, so
they do not cause problems after valuation.

Avoid confusion by calculating transaction date at one point, and
passing that down with the transaction.
2021-08-02 22:47:50 -10:00
Stephen Morgan
b7e40a9e63 ref: areg: Avoid reversing transactions list by making sure we sort them
in the correct order to start with.
2021-08-02 22:47:50 -10:00
Stephen Morgan
4e0dcec096 fix: areg: Explicitly avoid filtering by depth queries, perform
valuation after all reportq filtering is done (in both the historical
and recent postings), and make sure filtering is done at the correct
point based on whether --txn-dates is set. (#1634)
2021-08-02 22:47:50 -10:00
Stephen Morgan
c537f9426b dev: lens: Use lenses for updateReportSpec(With). 2021-07-30 09:27:39 -10:00
Stephen Morgan
4e9db4e377 dev: lens: Introduce lenses for ReportOpts and ReportSpec. 2021-07-30 09:27:39 -10:00
Simon Michael
2f819725e5 ;lib: accountTransactionsReport: clarify 2021-07-30 09:09:49 -10:00
Stephen Morgan
9df574b3c0 fix: reg: register --related should not create duplicate postings when
more than one posting in a transaction matches. (#1629)
2021-07-30 09:06:27 -10:00
Stephen Morgan
6528f25593 fix: lib: Filter postings before performing valuation and costing in
MultiBalanceReport, PostingsReport, EntriesReport, and
AccountTransactionsReport. (#1625, #1630)
2021-07-30 09:06:27 -10:00
Simon Michael
d2b799a717 feat: bal: select budget( transaction)s by name (#1612)
This makes it possible to keep multiple named budgets in one journal,
and select the one you want with --budget's argument.

More precisely, you can select the subset of periodic transactions
rules which contain a certain fixed, case-insensitive substring.

Only one such --budget argument is supported, the last one on the
command line takes precedence.
2021-07-23 10:38:20 -10:00
Stephen Morgan
b0aa70b27a lib!: Rename the fields of ReportSpec.
This is done to be more consistent with future field naming conventions,
and to make automatic generation of lenses simpler. See discussion in
\#1545.

rsOpts -> _rsReportOpts
rsToday -> _rsDay
rsQuery -> _rsQuery
rsQueryOpts -> _rsQueryOpts
2021-07-23 10:37:08 -10:00
Stephen Morgan
7ed2a0aa9b lib!: lib: Remove aismultiplier from Amount.
In Amount, aismultiplier is a boolean flag that will always be False,
except for in TMPostingRules, where it indicates whether the posting
rule is a multiplier. It is therefore unnecessary in the vast majority
of cases. This posting pulls this flag out of Amount and puts it into
TMPostingRule, so it is only kept around when necessary.

This changes the parsing of journals somewhat. Previously you could
include an * before an amount anywhere in a Journal, and it would
happily parse and set the aismultiplier flag true. This will now fail
with a parse error: * is now only acceptable before an amount within an
auto posting rule.

Any usage of the library in which the aismultiplier field is read or set
should be removed. If you truly need its functionality, you should
switch to using TMPostingRule.

This changes the JSON output of Amount, as it will no longer include
aismultiplier.
2021-07-22 19:06:33 -10:00
Stephen Morgan
3969eb2679 lib!: lib,cli,ui,web: For accountTransactionsReport, generate the overall
reportq from the ReportSpec, rather than being supplied as a separate
option.

This is the same approach used by the other reports, e.g. EntryReport,
PostingReport, MultiBalanceReport. This reduces code duplication, as
previously the reportq had to be separately tweaked in each of 5
different places.

If you call accountTransactionreport, there is no need to separately
derive the report query.
2021-07-22 19:00:37 -10:00
Stephen Morgan
f673e7c2eb lib!: lib,web: Remove unused TransactionReport. Move the useful utility
functions to AccountTransactionsReport.

If you use transactionsReport, you should either use entryReport if you
don't require a running total, or using accountTransactionsReport with
thisacctq as Any or None (depending on what you want included in the
running total).
2021-07-22 19:00:37 -10:00