Commit Graph

141 Commits

Author SHA1 Message Date
Stephen Morgan
df71d2ddd5 dev: Move journal and text parsing utilities into more appropriate places, to reduce reliance on Hledger.Read.Common. 2021-09-19 17:10:38 -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
21e62ffcbd cln: hlint: Remove unless and $> warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
22db5c4a3f cln: hlint: Remove warnings to use library list functions. 2021-08-27 06:13:56 -10:00
Stephen Morgan
c07ad29a87 imp!: forecast: Implements more intuitive logic for the forecast interval. (#1648)
The forecast period begins on:
- the start date supplied to the `--forecast` argument, if present
- otherwise, the later of
  - the report start date if specified with -b/-p/date:
  - the day after the latest normal (non-periodic) transaction in the journal, if any
- otherwise today.
It ends on:
- the end date supplied to the `--forecast` argument, if present
- otherwise the report end date if specified with -e/-p/date:
- otherwise 180 days (6 months) from today.

Note that the previous behaviour did not quite match the documentation,
so this also acts as a bug fix for #1665.
2021-08-26 20:32:30 -10:00
Arjen Langebaerd
3426030a91 feat: added commodity style commandline option 2021-08-17 22:05:29 -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
2df8ad781e
imp: cli: Don't show extra double quotes in missing journal file error. (#1601) 2021-07-13 10:41:51 -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
e63138ef7d lib,cli: Assorted fixes for older GHC. 2021-01-02 15:08:09 +11:00
Stephen Morgan
e3ec01c3c6 lib,cli,ui: Use Text for showDate and related. 2021-01-02 15:08:09 +11:00
Simon Michael
94b3f090be csv, timedot, timeclock: respect --alias options (fix #859)
Command-line account aliases now also affect transactions read
from these formats (not just journal format).

lib: journalApplyAliases, transactionApplyAliases, postingApplyAliases
helpers have been added.
2020-11-24 09:17:01 -08: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
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
765fb732c9 debug: move command parsing debug output down to level 8 2020-07-03 11:37:01 -07:00
Simon Michael
684cb45e1a tweak debug levels, document some guidelines
Beginnings of a project-wide policy for what output to show at
each debug level, for now. Later we'll want more flexibility,
eg filtering by topic.
2020-06-14 17:17:09 -07:00
Simon Michael
9868d7f20d ;lib: update emacs code-folding config
orgstruct-mode was dropped from org 9.2, and I shouldn't have been
forcing it on anyway.

The new config allows its "replacement", outshine-mode, to do similar
code folding when you press tab on any of the lines matching
outline-regexp. But only if you patch it as mentioned at
https://github.com/alphapapa/outshine/issues/77.
Enable it by, eg: (add-hook 'haskell-mode-hook 'outshine-mode)
2020-03-28 17:09:47 -07:00
Stephen Morgan
e0dde6fe57 lib: Remove non-law-abiding Monoid instance for Journal. 2020-03-02 12:45:30 -08:00
Stephen Morgan
702c958487 lib: Replace some utility functions with library functions. 2020-03-02 12:45:30 -08:00
Simon Michael
374be00223 ;lib: fix org headings and doctest setup that were breaking haddock
(and in some cases, installation).
[ci skip]
2020-03-01 22:00:39 -08:00
Simon Michael
b9954bff60 journal, lib: the include directive no longer guesses the format
The include directive now tries just one reader, based on the file
extension and defaulting to journal, like the rest of hledger.
(It doesn't yet handle a reader prefix.)

Reader-finding utilities have moved from Hledger.Read to
Hledger.Read.JournalReader so the include directive can use them.

Reader changes:
- rExperimental flag removed
- old rParser renamed to rReadFn
- new rParser field provides the actual parser.
  This seems to require making Reader a higher-kinded type, unfortunately.
2020-03-01 14:06:29 -08:00
Simon Michael
b1f3880c3d lib: drop the file format auto-detection feature
For a long time hledger has auto-detected the file format when it's
not known, eg when reading from a file with unusual extension (like
.dat or .txt), or from standard input (-f-), or when using the include
directive (which currently ignores file extensions).

Auto-detecting has been done by trying all readers until one succeeds.
This could guess wrong in some cases, but it was so rare that it has
been working fine.

Recently, more conveniences have been added to timedot format,
increasing its overlap with journal format, which makes this kind of
auto-detection unreliable.

Auto-detection and auto-detection failures are (probably) still pretty
rare in practice. But when it does happen it's confusing, giving
misleading errors or false successes (eg printing timedot entries
instead of a journal error).

For predictability and to minimise confusion, hledger no longer tries
to guess; when there's no file extension or reader prefix, it assumes
journal format. To specify one of the other formats, you must use a
standard file extension (.timeclock, .timedot, .csv, .ssv, .tsv), or a
reader prefix (-f csv:foo.txt, -f timedot:-).

For now, the include directive still tries to autodetect
(journal/timeclock/timedot), and this can't be overridden; it will be
fixed later.

Experimental; testing and feedback welcome.
2020-03-01 14:06:29 -08:00
Simon Michael
8ad2ea2fb4 lib: Hledger.Read cleanup 2020-02-27 23:51:54 -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
Simon Michael
62a9e1aa62 ;lib: clarify Hledger.Read imports a little 2019-12-02 08:21:06 -08:00
Simon Michael
180f4baedb ;lib: csv: note cause of #1087
[ci skip]
2019-09-14 03:45:37 -07:00
Simon Michael
6e3a264f17 lib: export aliasnamep for hledger-check (#1072) 2019-07-16 23:30:15 +01:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Simon Michael
014db152d9 add, web: disallow unsafe trailing dot paths on windows (fix #1056)
On Windows, ensureJournalFileExists now rejects file paths
containing any problematic trailing dots, to prevent data loss.
This affects the add command and hledger-web's add form.
2019-06-26 18:19:53 +01:00
Simon Michael
944554557a tweak readJournalFiles type signature 2019-01-15 06:18:56 -08:00
Simon Michael
91b111b60d rename easytests_* to tests_* 2018-09-06 13:13:26 -07:00
Simon Michael
f3709f241d tests: port Read tests to easytest 2018-09-03 15:42:24 -07:00
Simon Michael
d1cff46ba7 tests: port CsvReader tests to easytest 2018-09-03 15:30:52 -07:00
Simon Michael
cd67f8ea68 tests: clear out old boilerplate 2018-08-31 18:12:17 -07:00
Simon Michael
d1a7cc1c09 port remaining Read.Common tests 2018-08-31 18:12:17 -07:00
Simon Michael
f108b56e61 uniquify modules' easytests, simplify imports 2018-08-20 14:31:31 +01:00
Simon Michael
6568784bf6 port remaining JournalReader tests 2018-08-20 14:31:31 +01:00
Simon Michael
d778a92561 tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers 2018-08-18 15:19:59 +01:00
Simon Michael
b4c336c874 test/_test/it/_it helpers; refactor easytests
This makes skipping/unskipping tests easier, and improves readability
a bit.

Note it's also possible to just write the test name with no preceding
function, when the type is constrained (see Journal.hs).
2018-08-17 13:40:37 +01:00
Simon Michael
626247bacd journal: unit tests (2 skipped) for periodtransactionp (#823) 2018-08-17 12:42:43 +01:00
Simon Michael
50d666d5a0 test: refactor, document, organise easytests, port amountp tests (#812) 2018-08-15 19:58:07 +01:00
Jakub Zárybnický
c67404c73d lib: Fix compile errors in tests 2018-08-14 16:05:06 +01: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
Simon Michael
ae8046d47b lib: restore/update haddocks on readJournalFile[s]WithOpts
[ci skip]
2018-04-17 14:34:43 -07:00
Dmitry Astapov
5579af9a04 lib: remove readJournalFile(s) - supeceded by readJournalFile(s)WithOpts 2018-04-17 14:33:32 -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
81e964502b lib: refactor low-level text file reading 2018-01-04 16:17:25 -08:00
Simon Michael
5de51c9bad fix warnings/errors found by make stacktest 2017-09-30 13:00:22 -10:00