Commit Graph

297 Commits

Author SHA1 Message Date
Simon Michael
87f575e643 ref: bal: rename some report types to clarify/sync with docs
ReportType -> BalanceCalculation
 ChangeReport -> CalcChange
 BudgetReport -> CalcBudget
 ValueChangeReport -> CalcValueChange

BalanceType -> BalanceAccumulation
 PeriodChange -> PerPeriod
 CumulativeChange -> Cumulative
 HistoricalBalance -> Historical

ReportOpts:
 reporttype_ -> balancecalc_
 balancetype_ -> balanceaccum_

CompoundBalanceCommandSpec:
 cbctype -> cbcaccum

Hledger.Reports.ReportOptions:
 balanceTypeOverride -> balanceAccumulationOverride
2021-07-15 14:22:20 -10:00
Stephen Morgan
3380190d9a fix: web: register chart with multiple commodities/prices, broken in 1.22 (#1597)
Make sure to strip prices from amounts before generating JSON data for
the register chart.
2021-07-12 19:02:38 -10:00
Simon Michael
665fec83cd
Merge pull request #1560 from Xitian9/rationalisevaluation
Clean up valuation functions, and make clear which to use where.
2021-06-07 19:02:44 -10:00
Stephen Morgan
0f1837816d lib,cli,ui,web: Add check balancednoautoconversion command, which checks that
transactions are balanced possibly using explicit prices, but without
inferring any prices. This is included in --strict mode.

Renames check autobalanced to check balancedwithautoconversion.
2021-06-07 18:58:58 -10:00
Stephen Morgan
0a019e2167 lib,cli,web,bin: Replace journalSelectingAmountFromOpts with journalApplyValuationFromOpts.
This also has the effect of allowing valuation in more reports, for
example the transactionReport.
2021-06-08 14:55:05 +10:00
Stephen Morgan
68e975adf1 lib,cli,ui,web: Remove unused LANGUAGE pragmas. 2021-06-07 17:33:54 -10:00
Stephen Morgan
55308e1ca8 lib,cli,ui,web: Remove unnecessary CPP when dropping support for GHC 8.2. 2021-06-07 17:33:54 -10:00
Stephen Morgan
bf063e4538 cli,ui,web: Display full git description in --version report if able.
Remove unused prognameanddetailedversion code branches.
2021-06-02 19:46:18 -10:00
Stephen Morgan
5e7b69356f lib: Change internal representation of MixedAmount to use a strict Map
instead of a list of Amounts. No longer export Mixed constructor, to
keep API clean (if you really need it, you can import it directly from
Hledger.Data.Types). We also ensure the JSON representation of
MixedAmount doesn't change: it is stored as a normalised list of
Amounts.

This commit improves performance. Here are some indicative results.

hledger reg -f examples/10000x1000x10.journal
- Maximum residency decreases from 65MB to 60MB (8% decrease)
- Total memory in use decreases from 178MiB to 157MiB (12% decrease)

hledger reg -f examples/10000x10000x10.journal
- Maximum residency decreases from 69MB to 60MB (13% decrease)
- Total memory in use decreases from 198MiB to 153MiB (23% decrease)

hledger bal -f examples/10000x1000x10.journal
- Total heap usage decreases from 6.4GB to 6.0GB (6% decrease)
- Total memory in use decreases from 178MiB to 153MiB (14% decrease)

hledger bal -f examples/10000x10000x10.journal
- Total heap usage decreases from 7.3GB to 6.9GB (5% decrease)
- Total memory in use decreases from 196MiB to 185MiB (5% decrease)

hledger bal -M -f examples/10000x1000x10.journal
- Total heap usage decreases from 16.8GB to 10.6GB (47% decrease)
- Total time decreases from 14.3s to 12.0s (16% decrease)

hledger bal -M -f examples/10000x10000x10.journal
- Total heap usage decreases from 108GB to 48GB (56% decrease)
- Total time decreases from 62s to 41s (33% decrease)

If you never directly use the constructor Mixed or pattern match against
it then you don't need to make any changes. If you do, then do the
following:

- If you really care about the individual Amounts and never normalise
  your MixedAmount (for example, just storing `Mixed amts` and then
  extracting `amts` as a pattern match, then use should switch to using
  [Amount]. This should just involve removing the `Mixed` constructor.
- If you ever call `mixed`, `normaliseMixedAmount`, or do any sort of
  amount arithmetic (+), (-), then you should replace the constructor
  `Mixed` with the function `mixed`. To extract the list of Amounts, use
  the function `amounts`.
- If you ever call `normaliseMixedAmountSquashPricesForDisplay`, you can
  replace that with `mixedAmountStripPrices`. (N.B. this does something
  slightly different from `normaliseMixedAmountSquashPricesForDisplay`,
  but I don't think there's any use case for squashing prices and then
  keeping the first of the squashed prices around. If you disagree let
  me know.)
- Any remaining calls to `normaliseMixedAmount` can be removed, as that
  is now the identity function.
2021-05-01 09:45:29 -10: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
Simon Michael
ffb985f1a2 ui, web: make --man and --info work, similar to hledger
(cf #1410)
2021-03-03 05:57:31 -08:00
Arnout Engelen
fe6e9a79fe Allow selecting the date range from the chart
By dragging a region with the mouse
2021-02-17 09:05:13 -08:00
Simon Michael
3f095fb472 web: add form: in description field also offer declared/used payees 2021-01-17 16:37:38 -08:00
Simon Michael
90e82b6624 ;web: sketch of a test for #1409 2021-01-13 10:38:13 -08:00
Stephen Morgan
7e44b89bb4 lib: Remove unused label on TranspactionReport and AccountTransactionsReport. 2021-01-02 15:08:09 +11:00
Simon Michael
69edf9003e web: don't hang when reloading the file, eg after adding a transaction (#1409)
This was caused by an circular reference in an untested code path
in getViewData, added some months ago (lines 211-212 in 260283e2:
"lib,cli,ui,web: Introduce ReportSpec, which holds ReportOpts, the day of the report, and the parsed Query.").

This kind of bug unfortunately seems to be easy to create in Haskell,
and sometimes quite tedious to track down.

For this particular case, we should add a suitable test to the hledger-web
test suite, and/or set up a pre-release human test script, like hledger-ui's.
The bug was very obvious to the first downloader of hledger-web 1.20,
but it seems over the last three months nobody used a hledger-web built
from master. Providing and encouraging use of nightly builds could also help.
2020-12-06 17:49:19 -08:00
Simon Michael
a3dc78f3ff web: --test: don't require ./config/settings.yml 2020-11-16 15:36:17 -08:00
Simon Michael
59f1817bbf ;web: --test: show correct program name 2020-11-16 15:13:43 -08:00
Simon Michael
ee73a6aabf web: --test [-- HSPECARGS] runs the test suite 2020-11-16 14:02:16 -08:00
Simon Michael
3651a5f5f4 ;web: tests: refactor, add a test for --forecast (#1390) 2020-11-13 16:40:33 -08:00
Simon Michael
b76a88aa81 web: fix --forecast breakage since 1.18 (fix #1390)
Replaces the partial HashMap.! with List.elemIndex.
(Although the HashMap is more algorithmically efficient,
its API changed recently, possibly complicating building,
and efficiency is just not going to be an issue here.)
2020-11-12 17:03:39 -08:00
Stephen Morgan
260283e2f1 lib,cli,ui,web: Introduce ReportSpec, which holds ReportOpts, the day of
the report, and the parsed Query.
2020-10-23 14:14:11 -07:00
Stephen Morgan
19ab222599 lib,cli: Remove old impure ReportOpts date functions. 2020-10-23 14:14:11 -07:00
Stephen Morgan
fcbe511d42 ui,web: Adopt new ReportOptions interface, store literal query string in UIOpts. 2020-10-23 14:14:11 -07:00
Simon Michael
80146f6143 ;web: fix yet another typo (#1362) 2020-09-30 15:55:09 -07:00
Simon Michael
0cb4bbf105
;web: fix typo (#1362) 2020-09-30 14:02:05 -07:00
Simon Michael
e66a862681 ;web: /version: use hledger-web's version, not hledger's (#1152) 2020-09-29 17:56:00 -07:00
Simon Michael
fd200a85af web: /version provides hledger version string as JSON (#1152) 2020-09-29 17:28:03 -07:00
legrostdg
1dfc7e1116
web: Put session file in $XDG_DATA_DIR. (#1344)
* web: Put session file in $XDG_DATA_DIR.

* web: Use $XDG_CACHE_HOME instead of $XDG_DATA_HOME.

* web: Force minimum version of directory (needed for xdg utilities).

* web: Cancel changes to hledger-web.cabal

Co-authored-by: Félix Sipma <felix.sipma@no-log.org>
2020-09-10 08:37:33 -07:00
Stephen Morgan
8dfffb1e61 lib,web: Replace regex functions with simple text replacement. 2020-08-31 20:45:28 +10:00
Stephen Morgan
e5371d5a6a lib,cli,ui,web: Make Regexp a wrapper for Regex. 2020-08-31 12:04:45 +10:00
Simon Michael
3f55c23603 ;review, tag all error calls with an easier to find PARTIAL: comment (#1312) 2020-08-05 16:08:33 -07:00
Simon Michael
c60ad79727 web: update for new parseQuery (#1312)
Query parsing is slightly more robust ("date:" no longer gives an
internal server error, but other things still do).
2020-08-05 14:25:08 -07:00
Simon Michael
7df9a40750 ;web: ensure sidebar accounts are in tree mode, fixing a regression 2020-07-31 18:02:38 -07:00
Simon Michael
44c3eb1904 add a color argument to most amount show helpers, drop cshow variants
This is an API change, but it seems better than having additional
colour-supporting variants and trying to avoid duplicated code.
I stopped short of changing showAmount, so cshowAmount still exists.
2020-07-05 06:59:16 -07:00
Stephen Morgan
c811ea4c7b lib, cli, ui, web: intopt and friends now make sure their arguments fit
inside bounds.
2020-07-03 12:35:51 -07:00
Henning Thielemann
ebe021b0c8 ;web: maintain queries in all other links, too 2020-05-27 04:59:55 -07:00
Henning Thielemann
ec27eb6b17 ;web: maintain query when choosing a different 'inacct' account on the sidebar 2020-05-27 04:59:55 -07:00
Henning Thielemann
c35d0a8b44 ;web: transaction fragments: use numeric identifiers for journal files
This saves us from any escaping issues.
2020-05-25 10:02:39 -07:00
Henning Thielemann
e9792bfd42 ;web: links from register to journal now contain journal filename
in order to distinguish transactions from multiple journal files (#1041)
2020-05-25 10:02:39 -07:00
Stephen Morgan
e0dde6fe57 lib: Remove non-law-abiding Monoid instance for Journal. 2020-03-02 12:45:30 -08:00
Simon Michael
7ec25da13a web: edit/upload: normalise line endings, avoiding parse errors (#1194)
Renamed: writeValidJournal -> writeJournalTextIfValidAndChanged

Added comments clarifying line ending behaviour of:
add, import, appendToJournalFileOrStdout, readFilePortably,
writeFileWithBackupIfChanged, writeJournalTextIfValidAndChanged

Summary of current behaviour:

- hledger add and import commands will append with (at least some)
  unix line endings, possibly causing the file to have mixed line
  endings

- hledger-web edit and upload forms will write the file with
  the current system's native line endings, ie changing all
  line endings if the file previously used foreign line endings.
2020-02-24 14:04:44 -08:00
Amarandus
76ffaca466 web: Add IPv6 and hostname support
This commit introduces IPv6 support (and thus closes #1145).
It also allows using local hostnames as a parameter for --host.
For this, multiple things needed to be changed:

 - checkWebOpts is dropped, as the supplied parameter is checked later
 by Network.Socket.getAddrInfo
 - defbaseurl needs to check if : is used in the host, as this indicates
 the usage of an IPv6 address. In this case, the host needs to be
 wrapped in [] for the base URL
 - To allow opening such a modified base URL, runHostPortFullUrl is used
 instead of runhostPortUrl, as it allows opening arbitrary URLs instead
 of a path prefixed with http://127.0.0.1

As checking the host for validity is postponed until the webserver tries
to start, an invalid hostname leads to an exception caused by
Network.Socket.getAddrInfo.
This is still fine, as hledger-web won't start in an undefined state, but
will terminate with a nonzero exit code.
2020-01-17 13:18:51 -08:00
Carl Richard Theodor Schneider
72acd7c22a web: Add option --socket to use UNIX socket file
This commit adds the --socket option to use hledger-web over an AF_UNIX socket
file.
It allows running multiple instances of hledger-web on the same system without
having to manually choose a port for each instance, which is helpful for running
individual instances for multiple users. In this scenario, the socket path is
predictable, as it can be derived from the username.

It also introduces the following dependencies:

 - network
   - Used to create the unix domain socket
 - unix-compat
   - Used to identify if the socket file is still a socket, to reduce the risk
     of deleting a file when cleaning up the socket
2020-01-12 16:15:37 -08:00
Stephen Morgan
74778efcf5 Use nubSort instead of nub . sort. 2020-01-04 08:31:10 -08:00
Simon Michael
aa47d8ddc9 web: fix add form completions (fixes #1156)
It seems like show (toJSON "a") used to give "\"a\"" instead of
"String \"a\"". I haven't found the root cause, it's possible
that this fix won't work if built with older libs.
2019-12-27 17:21:50 -08:00
Simon Michael
46d516e7a3 move JSON instances from hledger-web to hledger-lib 2019-12-16 17:17:00 -08:00
Simon Michael
b7bea5698e web: drop old dependency on json (#1190) 2019-12-03 08:41:44 -08:00
Simon Michael
ac5652b7cc ;web: fix redundant import warnings with ghc 8.8 2019-11-29 07:02:52 -08: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
Mykola Orliuk
8991419c68 ;all: drop dummy decodeRawOpts 2019-11-18 17:38:39 -08:00
Alejandro García Montoro
4efd0242da web: Modify the --cors option to require a specific origin
- Modified the cors option to require a String
- Moved the logic to build the cors policy to WebOptions.hs
- Specify the --cors "*" example in the cors option help
- Added utf8-string dependency to convert a String into a ByteString
2019-10-07 14:54:18 -10:00
Alejandro García Montoro
e96dfe832f web: Allow CORS to be enabled in hledger-web
Add a --cors option to the CLI to enable simple cross-origin requests
2019-10-07 14:54:18 -10:00
Simon Michael
4db14ef70f ;api: another round of hledger-api purging; fix the build 2019-09-11 14:49:22 -07:00
Simon Michael
e70c7123b7 web: ?sidebar= hides the sidebar, like ?sidebar=0 2019-08-17 17:17:30 +01:00
Simon Michael
ef1bd24edc web: don't disable /add PUT with --serve-api, that's considered API 2019-08-17 17:17:30 +01:00
Simon Michael
a154ea72c0 web: with --serve-api, also disable the header/sidebar HTML 2019-08-17 17:17:30 +01:00
Simon Michael
c3da82043b web: --serve-api disables server-side UI; startup logging cleanups 2019-08-16 23:55:56 -07:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Simon Michael
6a62bd6437 web, api: update for MarketPrice/PriceDirective change 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
Henning Thielemann
1fa4419cd1 web: register page: clip linked accounts to 40 characters
This was the behaviour before adding the links.
2019-06-13 10:12:44 -07:00
Henning Thielemann
adbdbf002c web: avoid spaces before commas in register account links 2019-06-13 10:12:44 -07:00
Henning Thielemann
ac96bcfdf0 web: add links to accounts in register transactions 2019-06-13 10:12:44 -07:00
Simon Michael
faf85d91e3 cli: restore --aux-date and --effective as --date2 aliases (#1034)
These Ledger-ish spellings were dropped over the years, to improve
--help's layout. Now they work again, but are considered hidden flags
so --help doesn't show them automatically (but I decided to mention
them manually in --date2's description).
2019-06-02 08:48:41 -07:00
Simon Michael
7ef3ddd1e6 web: fix build breakage 2019-05-23 22:25:28 -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
54c1529638 lib: drop TransactionsReport, BalanceHistoryReport
They seem unused.
2019-05-23 21:55:19 -07:00
Simon Michael
7c14e10858 web: /accounts: return all accounts, not just top-level ones (#985)
Accounts are returned as a flat list, in tree order, with asubs fields
empty.
2019-03-09 15:47:06 -08:00
Simon Michael
92fb24b1af web: note some Account JSON issues (#985)
[ci skip]
2019-03-09 15:28:30 -08:00
Simon Michael
16157bc711 lib, web: tweaks to keep building with GHC 7 2019-03-01 15:07:17 -08:00
Jakub Zárybnický
6becbc78f3 cli, web, ui: Replace withJournalDo* variants 2019-03-01 05:42:30 -08:00
Simon Michael
8cf39e55e0 web: more Decimal FromJSON notes
[ci skip]
2019-02-21 17:13:47 -08:00
Simon Michael
115643a024 web: silence one more pesky warning 2019-02-20 20:45:09 -08:00
Simon Michael
0bc16d4af6 lib, cli, web: rename porigin -> poriginal 2019-02-20 20:23:54 -08:00
Simon Michael
2dc716cdb4 web: support adding new transactions via JSON PUT (#316)
A single transaction can be added by PUT to /add.
(I read that PUT, not POST, should be used to create;
perhaps the web add form should also use PUT ?)

As with the web form, the `add` capability is required (and enabled by
default).

Here's how to test with curl:

$ curl -s http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @in.json; echo

New readJsonFile/writeJsonFile helpers in Hledger.Web.Json
are handy for generating test data. Eg:

>>> writeJsonFile "in.json" (head $ jtxns samplejournal)
2019-02-20 20:23:51 -08:00
Simon Michael
b46212ae50 web: better ToJSON instances, new FromJSON instances, utilities (#316) 2019-02-20 20:23:45 -08:00
Jakub Zárybnický
861baadb2b web: Re-add 'balanced transaction' validation to add form 2019-02-20 14:57:04 -08:00
Simon Michael
7e0b74d431 web: fix warnings 2019-02-19 07:29:08 -08:00
Simon Michael
afd7931ca0 web: add the same 6 JSON routes as in hledger-api (#316) 2019-02-18 23:57:58 -08:00
Simon Michael
34c43489f8 web: document --capabilities/--capabilities-header, editing
[ci skip]
2019-02-18 14:40:14 -08:00
Simon Michael
10b45c75aa web: fix tooltips showing transactions (fixes #927) 2019-02-18 07:55:29 -08:00
Alex Chen
3d2584d869 lib: switch to megaparsec 7 2018-09-30 20:15:12 -06:00
Simon Michael
0f83fb91c1 ui, web: fix build after tests cleanup 2018-09-03 08:43:57 -07:00
Simon Michael
cd67f8ea68 tests: clear out old boilerplate 2018-08-31 18:12:17 -07:00
Simon Michael
d778a92561 tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers 2018-08-18 15:19:59 +01:00
Simon Michael
1e0a7ec8f1 remove some unneeded CPP pragmas 2018-08-02 08:25:49 +01:00
Jakub Zárybnický
466558968b web: Fix compilation errors for all 'stack.yaml's 2018-06-25 12:00:18 +02:00
Jakub Zárybnický
8d1ee38627 web: Add missing capability guards to /manage and /download 2018-06-24 23:17:56 +02:00
Jakub Zárybnický
483283ec43 web: Add capabilities guards and conditional widget rendering 2018-06-24 16:25:22 +02:00
Jakub Zárybnický
e8668e2a5c web: Conform layout to the rest of hledger-* packages 2018-06-24 14:18:06 +02:00
Jakub Zárybnický
9beec88727 web: Move sources to src/ subdirectory 2018-06-24 14:13:04 +02:00
Jakub Zárybnický
50e97e05fd web: Clean up imports 2018-06-24 14:13:03 +02:00
Simon Michael
6a96683691 web: make --auto and multiple -f options work again
I think we lost one or both of these at the time of ecf49b1e.
2018-06-20 00:26:37 -07:00
Simon Michael
061aad0431 remove some CPP that's obsolete since we require base 4.8+ 2018-06-04 17:33:21 -07:00
Dmitry Astapov
d82370d10b lib, app, web: remove differences between command line and journal file aliases 2018-04-17 16:09:11 -07:00
Dmitry Astapov
f6ec26e321 lib, app, web, ui: rename readJournalFile[s]WithOpts to readJournalFile, same for tryReader[s]WithOpts 2018-04-17 15:25:02 -07:00
Dmitry Astapov
37607beaea lib, app, web: use readJournalFileWithOpts instead of readJournalFile whenever possible 2018-04-17 14:33:32 -07:00
Dmitry Astapov
ecf49b1e4b lib: auto postings generated before amount inference and balance checks (#729) 2018-04-17 14:33:32 -07:00
Simon Michael
f8e781462d ui, web: use/support new -V, --forecast, --auto 2017-12-29 16:53:37 -08:00