Commit Graph

12022 Commits

Author SHA1 Message Date
Simon Michael
606d99834a fix: -o/--outputfile with a .json or .sql extension now selects those formats 2023-11-22 19:25:37 -10:00
Simon Michael
f2026aec5a ;doc:commodity directive: edits 2023-11-22 16:27:26 -10:00
Simon Michael
e623df23a3 ;doc:commodity directive: explain why decimal mark is required 2023-11-22 16:23:16 -10:00
Simon Michael
443336033e ;doc: amount formatting: correction, csv does not force . (#2115) 2023-11-22 16:06:33 -10:00
Simon Michael
5cda7c582a ;doc: amount formatting: edits (#2115) 2023-11-22 15:27:41 -10:00
Simon Michael
edf6738109 ;doc: amount formatting: edits (#2115) 2023-11-22 14:49:59 -10:00
Simon Michael
b5fd3c767c ;doc: amount formatting: edits (#2115) 2023-11-22 14:46:50 -10:00
Simon Michael
1744021986 fix: non-print-like reports no longer add trailing decimal marks (fix #2115)
That 1.31 change was advertised as being for the print command only,
but it affected all commands. Now it affects only print and other
"print-like" commands (ie all commands that show whole journal entries
that we might want to re-parse).

Also three classes of hledger output, and how they modify the
commodity display styles' digit group marks and decimal marks
to suit different consumers, have been identified and documented
(under REPORTING CONCEPTS).
2023-11-22 14:22:51 -10:00
Simon Michael
ef2f3e1607 ;doc:csv:if table: clarify, explain why backslash won't work (#2107) 2023-11-21 12:01:28 -10:00
Simon Michael
32d9deb3e1 ;bin:bar: cleanup 2023-11-21 09:27:26 -10:00
Simon Michael
2b18715885 fix:csv: fix tag: queries on CSV data (#2114) 2023-11-20 21:55:11 -10:00
Simon Michael
4febb74d1e ;doc:journal: decimal marks, commodity directives: rewrites 2023-11-20 10:45:37 -10:00
Simon Michael
d717732928 ;doc: Hledger.Read: cleanups (#2113) 2023-11-16 23:37:20 -10:00
Simon Michael
037613abab ;doc: Hledger.Read: cleanups (#2113) 2023-11-16 23:28:14 -10:00
Simon Michael
fba297f705 imp:import: support -s/--strict properly (fix #2113)
hledger import -s now runs strict checks on an in-memory copy of the
updated journal, before updating the journal file; if strict checks
fail, nothing is written to disk.

And hledger import now does not update any .latest files until it has
run without error (no failing strict checks, no failure while writing
the journal file). This makes it more idempotent, so you can run it
again after fixing problems.
2023-11-16 22:21:05 -10:00
Simon Michael
e92ab28cce imp:reading: better timing of strict checks and .latest writing (#2113)
Strict checks now run only once, at end of the high level read operation,
and not for each individual file; this fixes some spurious --strict failures,
like account declarations not affecting a sibling file as they should.

And .latest file writing now happens as the last step, after passing
strict checks. This is mainly for the import command, but it also
means that hledger print --new now does not update .latest files
if strict checks are failing.

The file reading API has been improved and documented in more detail.
2023-11-16 21:48:43 -10:00
Simon Michael
5ee2139f18 imp: web: round amounts to display precision as before (precisiongeddon) 2023-11-14 13:26:06 -08:00
Simon Michael
6bd862efbf imp: ui: round amounts to display precision as before (precisiongeddon) 2023-11-14 13:23:40 -08:00
Simon Michael
96db4a1b97 ;tools:bake lastweek: time percentage report 2023-11-10 16:30:30 -08:00
Simon Michael
fa40077ebf ;doc: regular expressions: add examples (hledger_site#224) 2023-11-09 12:04:33 -08:00
Simon Michael
c8484b5792 ;doc: More valuation examples: drop obsolete explanation (precisiongeddon) 2023-11-09 06:19:57 -08:00
Simon Michael
f4de65ab48 doc:code: add Jargon section; describe styling/precision in detail (precisiongeddon) 2023-11-08 13:59:18 -08:00
Simon Michael
f2320bf57c ;doc: move Hledger.hs haddock to a named chunk below code 2023-11-08 13:59:18 -08:00
Simon Michael
8a2a9643de ;tools: bake jargon - extract Hledger.hs haddock examples to a test journal 2023-11-08 13:59:18 -08:00
Simon Michael
96f52ee00c ;tools: make haddock-watch etc.: new fast version, cleanups 2023-11-08 13:59:18 -08:00
Simon Michael
1ae59ad0af dev: Amount: cleanups 2023-11-08 13:59:18 -08:00
Simon Michael
e035730afb imp: roi: limit large decimals to 8 digits by default (precisiongeddon)
With valuation now preserving more decimal digits, roi could show
excessively precise decimals if there was no known display precision
for the valuation commodity. Now in that situation it limits the
precision to a maximum of 8 digits.
2023-11-08 13:59:18 -08:00
Simon Michael
f8ffd9cdda imp: more precision handling fixes, debug output, test updates (precisiongeddon)
This and the preceding commits were "work in progress" that got out of control.
There's more to do, but this one brings these precision-related improvements
(at least):

When "infinite decimals" arise, they are now generally shown with
8 decimal digits rather than 255.

print and prices no longer add trailing decimal zeros unnecessarily.

Some code has been refactored or given more debug output.

All tests have been updated to match the recent changes.
2023-11-08 13:59:18 -08:00
Simon Michael
c51d883162 imp: prices: clarify, fixes, improve semantics (precisiongeddon)
- The prices comand now more accurately lists the prices that hledger
  uses when calculating value reports (similar to what you'd see with
  eg `hledger bal -V --debug=2`).

- The prices command's --infer-reverse-prices flag was confusing since
  we always infer and use reverse prices; it has been renamed to --show-reverse.

- --infer-market-prices and --show-reverse combine properly.

- --show-reverse now ignores all zero prices rather than giving an error.

- Reverse prices (which can be infinite decimals) are now displayed
  with at most 8 decimal digits (rather than the internal precision of
  255 digits).

- Filtering prices by cur: or amt: now works properly.

- Price amounts are styled, but all decimal digits are shown.
2023-11-08 13:59:18 -08:00
Simon Michael
50dc7bebb1 imp: set display style, natural precision on valued amounts (fix #2105, precisiongeddon)
Cost/value conversion now applies the standard display style, and
sets the display precision equal to the internal decimal precision
(or 8 if the decimal appears to be infinite).
This means value reports and especially `print -V` now show amounts
with more accurate and standard style and precision.

New tests have been added describing and explaining various
style/precision behaviours in print cost/value reports.
2023-11-08 13:59:18 -08:00
Simon Michael
64ffdd7c9c dev: clarify some amount operations 2023-11-08 13:59:18 -08:00
Simon Michael
d435557979 lib: Hledger.Utils.Debug: lbl_ helper, cleanups, notes 2023-11-08 13:50:33 -08:00
Simon Michael
b1dc550c35 ;tools:bake dbgstrs 2023-11-08 13:50:33 -08:00
Simon Michael
6e54de12b2 ;tools:ghci :rmain 2023-11-08 13:50:33 -08:00
Simon Michael
a4d3573d29 ;dev: valuation.test: cleanup 2023-11-08 13:50:33 -08:00
Jonathan Dowland
d424966706 ;doc: import: document Match Groups
Add a description of Match Groups to the manual; Section "Matchers".
Include two examples.

Clarify a description of regular expression features with respect
to match groups.

Expand the description of field assignments to cover match group
interpolation, cross-referencing to Section "Matchers" for the full
description.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-11-08 13:49:39 -08:00
Jonathan Dowland
aaf50c165c test: import: functional tests for match group interpolation
Add functional tests for matching substrings in field matchers and
interpolating them into the corresponding field assignments. Check
the following properties and use-cases:

 * Use-case 1: matching a portion of a date in a known format
   (YYY-MM-DD) and writing a comment-command to warp a posting date.
   Useful for credit cards.
 * Use-case 2: match a portion of a CSV field and use it as an
   account assignment. Useful for my byzantine setup with two
   separate ledgers cross-importing to each other.
 * Ensure bracketed portions of field matchers are captured.
 * Ensure bracketed portions of record matchers are captured.
 * Check match token numerical offset is relative to match group,
   not the whole rules file.
 * Check nested matches work.
 * Ensure match group token expansion works with or without
   surrounding text.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-11-08 13:49:39 -08:00
Jonathan Dowland
8bfa382c68 feat: import: interpolate regex matches in field templates (#2009)
Replace occurrences of '\N' (where N is a positive number) in field
templates with the corresponding regular expression match group, if it
exists.

E.g. Warp the date to the first of the month for the second posting

    if %date (....-..)-..
        comment2 date:\1-01

E.g. Strip a prefix from an imported account name

    if %account1 liabilities:jon:(.*)
        account1 \1

Fixes #2009.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-11-08 13:49:39 -08:00
Jonathan Dowland
549c47bca8 ;dev: add Utils.Regex.regexMatchTextGroups
A matcher function which returns the list of match-groups, which may
be empty.

Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-11-08 13:49:39 -08:00
Jonathan Dowland
c619e387ea ;fix: import: minor typo 2023-11-08 13:49:39 -08:00
Simon Michael
23c961f4bb ;doc: Setting LEDGER_FILE: fix a quote (hledger_site#93) 2023-11-07 16:19:21 -08:00
Simon Michael
250d98df29 cabal: update cabal files 2023-11-07 09:25:29 -08:00
Simon Michael
fef3413c51 pkg:web: clean up some apparently redundant declarations and deps 2023-11-07 09:06:58 -08:00
Simon Michael
4813e3fc5f pkg:ui: fix wasteful double-building of hledger-ui modules 2023-11-07 09:06:56 -08:00
Simon Michael
96117ae514 ci: do haddock testing less often, in the mac binaries workflow
It costs 1m+, doesn't fail that often, and is not hard to fix even if
detected late.
2023-11-07 05:27:18 -08:00
Simon Michael
617e35ec57 ci: really fix some redundant building of hledger-lib and hledger 2023-11-07 04:59:53 -08:00
Simon Michael
1eee7f0208 ci: fix some redundant building of hledger-lib and hledger 2023-11-07 04:47:04 -08:00
Simon Michael
54b4c2ed22 fix: auto postings: detect redundant costs properly (fix #2110) 2023-11-07 04:38:39 -08:00
Peter Sagerson
efcea0600a feat: cli: Add tsv output (#869)
All commands that suport csv output now also support tsv output. The
data is identical, but the fields are separated by tab characters and
there is no quoting or escaping. Tab, carriage return, and newline
characters in data are converted to spaces (this should rarely if ever
happen in practice).
2023-11-06 16:46:04 -08:00
Simon Michael
dae7b352dd ;ci: disable weekly scheduled builds
They also run in forks, which I don't want.
2023-11-06 10:13:57 -08:00