Commit Graph

1243 Commits

Author SHA1 Message Date
Stephen Morgan
4e9fa1615c dev!: lib: Refactor splitSpan to return Maybe DayPartition.
This eliminates all error calls from the chain calculating report
periods.
2025-10-09 15:31:28 -10:00
Stephen Morgan
b9caa4d948 dev!: balance: Use DayPartition for multibalance reports.
This allows us to guarantee that the report periods are well-formed and
don't contain errors (e.g. empty spans, spans not contiguous, spans not
a partition).

Note the underlying representation is now for disjoint spans, whereas
previously the end date of a span was equal to the start date of the
next span, and then was adjusted backwards one day when needed.
2025-10-09 15:31:28 -10:00
Simon Michael
215ef5e12d fix:check accounts: don't garble non-ascii account names in errors [#2469]
This regressed in 1.27 or so.
2025-10-01 14:40:08 -10:00
Simon Michael
061d105fed dev:Hledger.Data.Journal: fix a recent ghc 9.6 / old base breakage 2025-09-29 19:31:49 -10:00
Simon Michael
2f007c93d2 dev: switch all qualifed imports to ImportQualifiedPost style 2025-09-29 19:28:59 -10:00
Simon Michael
e414446076 imp: pivoting on the type tag normalises type values to their short spelling. 2025-09-25 01:11:03 -10:00
Stephen Morgan
aad61e465d fix: balance: Correctly handle empty journals (#2452)
Eliminate several partial functions.
2025-09-11 07:29:27 +01:00
Simon Michael
bc55e1c58f dev: fix liftA2, Foldable1 build errors with ghc <9.6 [#2395] 2025-09-03 20:02:12 +01:00
Simon Michael
91d785aee8 dev:fix: use compatible code rather than new T.show added yesterday 2025-09-01 20:08:17 +01:00
Simon Michael
65eb0b1f78 fix:timeclock: change misleadding error message in --old-timeclock mode 2025-09-01 08:49:11 +01:00
Simon Michael
9849f196cb fix:timeclock: process in parse order; fully support overlapping sessions [#2417]
We no longer attempt to process timeclock entries in time order - that
was a wrong requirement, probably given by me, that can't work.  Now
we just process them in parse order. This plus a little tweaking of
error checking fixes several ordering bugs with overlapping sessions
and also allows same-named overlapping sessions.

More cleanup will follow. More testing might show that --old-timeclock
is no longer needed.
2025-09-01 08:27:08 +01:00
Simon Michael
7ac0fa1aaa dev:TimeclockReader, Timeclock: refactor/reindent [#2417] 2025-09-01 08:27:01 +01:00
Simon Michael
a2710a5c2b dev:timeclock: make --old-timeclock parser call itself, not new parser [#2417]
There was no known visible bug, but this seems more correct.
2025-09-01 08:26:44 +01:00
Simon Michael
8bd9d92981 imp:timeclock: improve overlapping sessions error [#2417] 2025-09-01 06:03:26 +01:00
Simon Michael
04e6c140c0 imp:timeclock: more informative error output for clashing sessions [#2417] 2025-08-31 17:35:13 +01:00
Simon Michael
539a876e7a ;dev:Timeclock: indentation 2025-08-31 16:20:58 +01:00
Simon Michael
e6dbe5d231 fix:timeclock: sessions can begin at a same-named session's end time
Now we process entries in a more careful order: time, then parse
order, like journal format. This fixes the original issue and another
one mentioned at #2417.
2025-08-31 12:01:04 +01:00
Simon Michael
5a3e34cc55 imp:timeclock: syntax is more robust and featureful
The default timeclock parser (ie when not using --old-timeclock) has
the following changes, related to issues such as
[#2141], [#2365], [#2400], [#2417]:

- semicolon now always starts a comment; timeclock account names can't include semicolons
  (though journal account names still can)
- clock-in and clock-out entries now have different syntax
- clock-ins now require an account name
- clock-outs now can have a comment and tags
- the doc has been rewritten, and now mentions the --old-timeclock flag

- lib: accountnamep and modifiedaccountnamep now take a flag to allow semicolons or not
2025-08-31 10:58:37 +01:00
Simon Michael
4e52c7bd76 ;lib:spanExtend: improve doc 2025-08-28 17:26:42 +01:00
Simon Michael
f604b7a416 fix: accounts: a tag: query only matches account tags, not posting tags
Eg, `hledger accounts tag:t` lists only account a from this journal:

    account a  ; t:

    2025-01-01
        a          1
        b         -1  ; t:
2025-08-03 05:38:33 +01:00
Simon Michael
c48c41bcd2 dev:timeclock: cleanups 2025-07-18 07:17:45 -07:00
Simon Michael
1046f652b1 dev: PrefixedFilePath cleanups
And some helpers that weren't needed after all, but maybe in future
2025-07-16 06:52:19 -07:00
Simon Michael
08017366b5 imp: file reading: demote some debug=6 output to level 7 2025-07-11 13:48:58 -07:00
Stephen Morgan
8ab2fb6b77 feat: lib: Allow special string %account in auto-posting rules (#1975)
This allows using the special string `%account` in auto posting rules.
When run, this will be substituted with the account name of the matched
posting.
2025-06-24 10:12:57 -07:00
Simon Michael
714b346fdd imp: fully support quarter syntax in smart dates and period expressions 2025-06-23 18:37:08 -07:00
Simon Michael
afd18a10bf fix: show historical balances even if report period is empty [#2403]
This adds a safer version of spanDefaultsFrom that won't create spans
that end before they start, and updates all reports to use it.

The only related change noticed so far is that close now gives an
error instead of a malformed entry, when there's no data to close.
[#2409]
2025-06-15 22:42:58 -10:00
Simon Michael
4a5775da71 imp: commodities/payees/tags: used/declared flags, like accounts
And general cleanup of options and help across
the accounts, commodities, payees, tags commands.
2025-06-15 07:32:40 -10:00
Simon Michael
bd2d8728d1 fix: txn balancing: fix logic for the 1.50 message [#2402]
and add more tests.
2025-06-13 09:10:46 -10:00
Simon Michael
cda62d9a59 ;dev: change "1.44" to "1.50" in docs and error messages 2025-06-12 17:55:13 -10:00
Simon Michael
0d388a6f93 ;imp: show a more helpful error for transactions unbalanced by upgrade [#2402]
(and drop the last sentence from the single-commodity unbalanced
transaction error)
2025-06-12 17:55:13 -10:00
Simon Michael
de4d637def dev: transaction balancing: cleanup [#2402] 2025-06-12 17:55:13 -10:00
Simon Michael
bf90b20f2c imp: --txn-balancing flag to select transaction balancing precision [#2402] 2025-06-12 17:55:13 -10:00
Simon Michael
a9408b8cd5 imp:journal: balance transactions with local precisions [#2402] 2025-06-12 17:55:13 -10:00
Simon Michael
82ba831822 dev: move commodityStylesFromAmounts to Hledger.Data.Amount
Also drop canonicalStyleFrom, seems unused.
2025-06-12 17:55:13 -10:00
Simon Michael
41e62885c4 dev: avoid a strange vscode/Haskell highlighting bug 2025-06-07 15:28:41 -10:00
Stephen Morgan
80cf1d1995 !dev: lib: Allow Account to store date-indexed balances.
This upgrades Account to enable it to store a multiperiod balance, with
a separate balance for each date period. This enables it do the hard
work in MultiBalanceReport.

Some new types are created to enable convenient operation of accounts.
- `BalanceData` is a type which stores an exclusive balance, inclusive
  balance, and number of postings. This was previously directly stored
  in Account, but is now factored into a separate data type.
- `PeriodData` is a container which stores date-indexed data, as well as
  pre-period data. In post cases, this represents the report spans,
  along with the historical data.
- Account becomes polymorphic, allowing customisation of the type of
  data it stores. This will usually be `BalanceData`, but in
  `BudgetReport` it can use `These BalanceData BalanceData` to store
  both actuals and budgets in the same structure. The data structure
  changes to contain a `PeriodData`, allowing multiperiod accounts.

Some minor changes are made to behaviour for consistency:
- --declared treats parent accounts consistently.
- --flat --empty ensures that implied accounts with no postings are not displayed, but
  accounts with zero balance and actual postings are.
2025-06-04 23:10:00 -10:00
Simon Michael
2a4718d40a fix: make a few more error messages consistent, hiding call stack [#2367] 2025-06-03 10:10:04 -10:00
Michael Rees
0c3e7bc395 Always check added transaction, even if no immediate assertion 2025-05-31 23:19:47 -10:00
Michael Rees
b042115692 Ignore assertions during add with -I 2025-05-31 23:19:47 -10:00
Michael Rees
5a4aa87df8 Clarify some code after review 2025-05-31 23:19:47 -10:00
Michael Rees
17f914e571 imp: add: Verify balance assertions on each posting (#2355) 2025-05-31 23:19:47 -10:00
Simon Michael
820a44eb07 imp:lib:Hledger.Utils.Debug: simpler, more consistent dbg* names 2025-05-21 22:54:00 -10:00
Stephen Morgan
eda4c8dd62 dev: lib: Add NFData instances for Journal and subcomponents. 2025-05-02 08:30:38 -10:00
Stephen Morgan
468a3da1b7 dev: lib: Use strict data in Hledger.Data.Types.
This reduces memory usage and results in speedups in some commands.
2025-05-02 08:30:17 -10:00
Simon Michael
330f3fccaa ;dev: rename assertions.test 2025-04-27 08:30:18 -10:00
Simon Michael
4788bd9e41 lib: journalCommoditiesUsed 2025-04-23 21:43:30 -10:00
Simon Michael
a13b7d2a82 lib: Hledger.Data.Dates.parsedate: also accept YYYYMMDD format; document
- Added support for unseparated dates, for convenience in ghci and for parseHledgerVersion
- Noted two user-facing uses: --value's argument, and import's .latest files.
  YYYYMMDD dates will now also work there. Left this undocumented.
- Noted this is now more permissive, parsing many integers successfully; not expecting problems.
2025-04-22 16:59:57 -10:00
Simon Michael
b7509030c5 lib: Hledger.Data.Dates: parsedateM -> parsedate
M makes me think of monad and is awkward to type for this common helper; Maybe is expected for a parser.
2025-04-22 10:40:41 -10:00
Michael Rees
62071bc4c2 feat: timeclock: Add support for multiple clocked in sessions (#2141)
We now support having multiple sessions clocked in. These are paired by
account name if given on the out entry, and otherwise an out closes the
most recent in entry.

Note that this breaks some backwards compatibility, in that we
previously ignored the description on the clock out entry. To mitigate
this, a new hidden flag --timeclock-old has been added, which reverts to
the old behavior.
2025-04-03 11:19:18 -10:00
Thomas Miedema
e7cc2f1066 ;dev: lib: drop base-compat dependency 2025-03-31 16:21:38 -10:00