hledger icon indicating copy to clipboard operation
hledger copied to clipboard

check accounts warns about --infer-equity's accounts, check tags warns about _price-matched

Open PainFile opened this issue 1 year ago • 16 comments

Hello everyone, I currently use hledger to track my finances, I normally do Strick checks to my files once every month to make sure that everything is ok. With the release of 1.40 I notice that check accounts and check tags send some errors with my information (not present on 1.34 or lower).

This is the MRE I can come up with:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of Minimal, Reproducible Example (MRE).

; Commodities
commodity "CD200130"
  format 1,000.00000000 "CD200130"

commodity MXN
  format 1,000.00 MXN

; Accounts
account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes
account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction
    Assets:Investing:Bonds:CetesDirecto:Invested:Cetes     100 "CD200130" @ 9.94392220 MXN
    Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I run on Windows 11. Under hledger 1.34-g7a83578ec-20240601, windows-x86_64 if I go with ".\bin\hledger.exe -f test.journal check -s" nothing comes out, i. e. everyting is OK.

If I change to hledger 1.40-g0f31974c5-20240909, windows-x86_64 still under Windows 11 and I run the same command I got the following error:

hledger.exe: Error: C:\Temp\test.journal:17: 17 | 2024-01-01 * Test transaction | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN | Assets:Investing:Bonds:CetesDirecto:Wallet -994.39222000 MXN

Strict account checking is enabled, and account "equity:conversion:CD200130-MXN:CD200130" has not been declared. Consider adding an account directive. Examples:

account equity:conversion:CD200130-MXN:CD200130 account equity:conversion:CD200130-MXN:CD200130 ; type:A ; (L,E,R,X,C,V)

When trying to troubleshoot, going by each strick test I see that .\bin\hledger.exe -f test.journal check accounts is sending that error.

Also, if I try .\bin\hledger.exe -f test.journal check tags I have another error:

hledger.exe: Error: C:\Temp\test.journal:17: 17 | 2024-01-01 * Test transaction | Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN | equity:conversion:CD200130-MXN:CD200130 -100 "CD200130" | equity:conversion:CD200130-MXN:MXN 994.39222000 MXN | Assets:Investing:Bonds:CetesDirecto:Wallet -994.39222000 MXN

Strict tag checking is enabled, and tag "_price-matched" has not been declared. Consider adding a tag directive. Examples:

tag _price-matched

I hope this information is enough for you to replicate the behavior, if not please let me know. Keep up with this great project!

PainFile avatar Sep 30 '24 22:09 PainFile

Hi, thanks for the MRE.

I see you're using an unreleased developer build, but that should be fine.

I tested with that exact version and the file you gave, but can't reproduce the problems; both checks seem to be working normally here.

simonmichael avatar Oct 01 '24 02:10 simonmichael

(on mac.)

Maybe there's another windows user who could try it.

Maybe also you are able to try it on a non-windows computer ? Perhaps with the 1.40 release ?

On Mon, Sep 30, 2024, at 16:19, Simon Michael wrote:

Hi, thanks for the MRE.

I see you're using an unreleased developer build, but that should be fine.

I tested with that exact version and the file you gave, but can't reproduce the problems; both checks seem to be working normally here.

On Mon, Sep 30, 2024, at 12:37, PainFile wrote:

Hello everyone, I currently use hledger to track my finances, I normally do Strick checks to my files once every month to make sure that everything is ok. With the release of 1.40 I notice that check accounts and check tags send some errors with my information (not present on 1.34 or lower).

This is the MRE I can come up with:

`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Start of Minimal, Reproducible Example (MRE).

; Commodities commodity "CD200130" format 1,000.00000000 "CD200130"

commodity MXN format 1,000.00 MXN

; Accounts account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ` I run on Windows 11. Under hledger 1.34-g7a83578ec-20240601, windows-x86_64 if I go with ".\bin\hledger.exe -f test.journal check -s" nothing comes out, i. e. everyting is OK.

If I change to hledger 1.40-g0f31974c5-20240909, windows-x86_64 still under Windows 11 and I run the same command I got the following error:

hledger.exe: Error: C:\Temp\test.journal:17: 17 | 2024-01-01 * Test transaction | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN | Assets:Investing:Bonds:CetesDirecto:Wallet -994.39222000 MXN

Strict account checking is enabled, and account "equity:conversion:CD200130-MXN:CD200130" has not been declared. Consider adding an account directive. Examples:

account equity:conversion:CD200130-MXN:CD200130 account equity:conversion:CD200130-MXN:CD200130 ; type:A ; (L,E,R,X,C,V)

When trying to troubleshoot, going by each strick test I see that .\bin\hledger.exe -f test.journal check accounts is sending that error.

Also, if I try .\bin\hledger.exe -f test.journal check tags I have another error:

hledger.exe: Error: C:\Temp\test.journal:17: 17 | 2024-01-01 * Test transaction | Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN | equity:conversion:CD200130-MXN:CD200130 -100 "CD200130" | equity:conversion:CD200130-MXN:MXN 994.39222000 MXN | Assets:Investing:Bonds:CetesDirecto:Wallet -994.39222000 MXN

Strict tag checking is enabled, and tag "_price-matched" has not been declared. Consider adding a tag directive. Examples:

tag _price-matched

I hope this information is enough for you to replicate the behavior, if not please let me know. Keep up with this great project!

— Reply to this email directly, view it on GitHub https://github.com/simonmichael/hledger/issues/2247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACPIEUGR7FWD4NIP6HFN3ZZHHAZAVCNFSM6AAAAABPEKU6T2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TONZWG42DSOA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/simonmichael/hledger/issues/2247#issuecomment-2384648611, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACPIHRRNV3ICBZNLHOLLLZZIBB7AVCNFSM6AAAAABPEKU6T2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBUGY2DQNRRGE. You are receiving this because you are subscribed to this thread.Message ID: @.***>

simonmichael avatar Oct 01 '24 02:10 simonmichael

I see you're using an unreleased developer build, but that should be fine.

I just downloaded the 1.40 version again from the Official release binaries for Linux, Mac, Windows. (https://github.com/simonmichael/hledger/releases/tag/1.40) and it is the same version. It still throws the same error.

Maybe also you are able to try it on a non-windows computer ? Perhaps with the 1.40 release ? I don't have any other OS handy, will try to mount a VM on the weekend with Linux to try it.

PainFile avatar Oct 02 '24 19:10 PainFile

On Wed, Oct 2, 2024, at 09:47, PainFile wrote:

I just downloaded the 1.40 version again from the Official release binaries for Linux, Mac, Windows. (https://github.com/simonmichael/hledger/releases/tag/1.40) and it is the same version.

My apologies you're right, that is the 1.40 release. The version string looked odd to me.

I can't reproduce in a Windows 11 VM, either:

PS C:\Users\Simon Michael> type a.j ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Start of Minimal, Reproducible Example (MRE).

; Commodities commodity "CD200130" format 1,000.00000000 "CD200130"

commodity MXN format 1,000.00 MXN

; Accounts account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction Assets:Investing:Bonds:CetesDirecto:Invested:Cetes 100 "CD200130" @ 9.94392220 MXN Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PS C:\Users\Simon Michael> hledger -f a.j check -s PS C:\Users\Simon Michael> hledger -f a.j check accounts commodities PS C:\Users\Simon Michael> hledger --version hledger 1.40-g0f31974c5-20240909, windows-x86_64

simonmichael avatar Oct 02 '24 20:10 simonmichael

Also the error message and the example file you've shown do not correspond to one another. Double check ?

simonmichael avatar Oct 02 '24 20:10 simonmichael

Thank you for bearing with me, I did more troubleshooting, and the error persist but I just found out it's only present when I use a config file (I missed to comment that I am using a hledger.conf since the beginning, my apologies):

PS C:\Temp> type .\mre.journal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of Minimal, Reproducible Example (MRE).

; Commodities
commodity "CD200130"
  format 1,000.00000000 "CD200130"

commodity MXN
  format 1,000.00 MXN

; Accounts
account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes
account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction
    Assets:Investing:Bonds:CetesDirecto:Invested:Cetes     100 "CD200130" @ 9.94392220 MXN
    Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS C:\Temp> .\hledger.exe -f .\mre.journal check -s
hledger.exe: Error: C:\Temp\.\mre.journal:15:
15 | 2024-01-01 * Test transaction
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     Assets:Investing:Bonds:CetesDirecto:Invested:Cetes    100 "CD200130" @ 9.94392220 MXN
   |     Assets:Investing:Bonds:CetesDirecto:Wallet                          -994.39222000 MXN

Strict account checking is enabled, and
account "equity:conversion:CD200130-MXN:CD200130" has not been declared.
Consider adding an account directive. Examples:

account equity:conversion:CD200130-MXN:CD200130
account equity:conversion:CD200130-MXN:CD200130    ; type:A  ; (L,E,R,X,C,V)

PS C:\Temp> type .\mre.journal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of Minimal, Reproducible Example (MRE).

; Commodities
commodity "CD200130"
  format 1,000.00000000 "CD200130"

commodity MXN
  format 1,000.00 MXN

; Accounts
account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes
account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction
    Assets:Investing:Bonds:CetesDirecto:Invested:Cetes     100 "CD200130" @ 9.94392220 MXN
    Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS C:\Temp> .\hledger.exe --version
hledger 1.40-g0f31974c5-20240909, windows-x86_64
PS C:\Temp> .\hledger.exe -f .\mre.journal check tags
hledger.exe: Error: C:\Temp\.\mre.journal:15:
15 | 2024-01-01 * Test transaction
   |     Assets:Investing:Bonds:CetesDirecto:Invested:Cetes    100 "CD200130" @ 9.94392220 MXN
   |     equity:conversion:CD200130-MXN:CD200130                               -100 "CD200130"
   |     equity:conversion:CD200130-MXN:MXN                                   994.39222000 MXN
   |     Assets:Investing:Bonds:CetesDirecto:Wallet                          -994.39222000 MXN

Strict tag checking is enabled, and
tag "_price-matched" has not been declared.
Consider adding a tag directive. Examples:

tag _price-matched

This is the config file that I am using (mostly a copy of your example file):

PS C:\Temp> type .\hledger.conf
# An example hledger config file for you to customise.
# This declares extra options/arguments to be added to your hledger commands.
# Save as ~/.hledger.conf, or ~/.config/hledger/hledger.conf, or hledger.conf
# in or above your current directory, and hledger will use it automatically.
# Or you can choose a config file with --conf.
# Or you can turn a config file like this one into a script, by adding
# a shebang line like `#!/usr/bin/env -S hledger --conf` at the top.
#
# Automatic config files are convenient, but have a cost: it's easy to confuse
# yourself, disrupt reports, or break scripts/applications which use hledger.
# If you choose to use one, be careful about what you put in it.
# If a command is not working as expected, run it with `--debug` to troubleshoot.
# To avoid using a config file, run with `-n` (short for `--no-conf`).

# 1. General options. These will be used with all commands which support them.

# Show prettier tables in reports.
# Recommended unless your font doesn't support box drawing characters.
--pretty

# Postpone balance assertions until you use -s or `hledger check assertions`.
# This means there's less need to add -I while piping or fixing problems.
#--ignore-assertions

# Always infer these things ? Why not.
--infer-costs
--infer-market-prices
--infer-equity

# 2. Command-specific options.

[print]
--explicit     # show inferred amounts
--show-costs   # show inferred costs

[help]
#--man          # if you prefer man over info

# Set your preferred options for the balance commands.
# You can override these by adding more options on the command line.
# [balance]            --tree --depth 3 --layout=bare
[balancesheet]                --depth 5 --layout=bare
# [balancesheetequity] --tree --depth 3 --layout=bare
# [cashflow]           --tree --depth 3 --layout=bare
# [incomestatement]    --tree --depth 3 --layout=bare

# You can also set options for add-on commands (run by `hledger ADDONCMD`).
# The -- argument needed at command line is not needed here.

# Some defaults for hledger-ui: start in the Cash accounts screen,
# watch for file changes, set a depth limit, hide zeros and equity accounts.
[ui] --cash --watch -3 -E not:type:e
# need to repeat this here
--ignore-assertions

[web] --port 5050 --allow edit
# and here
--ignore-assertions

[iadd] --date-format %Y-%m-%d

#[interest]
# --annual 0.05
# --30-360
# --source SRCACCT
# --target DSTACCT
# ACCT

I'm going to dowload some Linux ISO and will try to reproduce later.

PainFile avatar Oct 03 '24 15:10 PainFile

On Thu, Oct 3, 2024, at 05:11, PainFile wrote:

Thank you for bearing with me, I did more troubleshooting, and the error persist but I just found out it's only present when I use a config file (I missed to comment that I am using a hledger.conf since the beginning, my apologies):

Ahh. And I forgot to suggest to try running with -n to disable any possible config file. This is the new reality for troubleshooting since hledger 1.40. :-(

So the problem is that when you use --infer-equity, it creates postings to and from accounts with specific names, based on the commodities involved: see https://hledger.org/1.40/hledger.html#inferring-equity-conversion-postings .

So in that case to satisfy check accounts, you'd need to add declarations like these:

account Equity:Conversion:CD200130-MXN:CD200130 account Equity:Conversion:CD200130-MXN:MXN

Let's think about how to make this more intuitive.

simonmichael avatar Oct 03 '24 15:10 simonmichael

Ahh. And I forgot to suggest to try running with -n to disable any possible config file. This is the new reality for troubleshooting since hledger 1.40. :-(

So the problem is that when you use --infer-equity, it creates postings to and from accounts with specific names, based on the commodities involved: see https://hledger.org/1.40/hledger.html#inferring-equity-conversion-postings .

So in that case to satisfy check accounts, you'd need to add declarations like these:

account Equity:Conversion:CD200130-MXN:CD200130 account Equity:Conversion:CD200130-MXN:MXN

Let's think about how to make this more intuitive.

I have added a note to the manual from 1.40 on, and to the sample config file, to start with.

Or possibly these accounts used by --infer-equity accounts should be exempt from strict account checking ? I'm not sure.

simonmichael avatar Oct 03 '24 15:10 simonmichael

Ok, with -n both issues are gone. The check tags error with --infer-equity is also expected?

PainFile avatar Oct 06 '24 13:10 PainFile

Currently yes it’s expected, and you have to declare those accounts to fix it.

simonmichael avatar Oct 06 '24 23:10 simonmichael

Simon, I understand the accounts. I am asking about the tags error:

PS C:\Temp> type .\mre.journal
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of Minimal, Reproducible Example (MRE).

; Commodities
commodity "CD200130"
  format 1,000.00000000 "CD200130"

commodity MXN
  format 1,000.00 MXN

; Accounts
account Assets:Investing:Bonds:CetesDirecto:Invested:Cetes
account Assets:Investing:Bonds:CetesDirecto:Wallet

2024/01/01 * Test transaction
    Assets:Investing:Bonds:CetesDirecto:Invested:Cetes     100 "CD200130" @ 9.94392220 MXN
    Assets:Investing:Bonds:CetesDirecto:Wallet

; End of MRE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS C:\Temp> .\hledger.exe --version
hledger 1.40-g0f31974c5-20240909, windows-x86_64
PS C:\Temp> .\hledger.exe -f .\mre.journal check tags
hledger.exe: Error: C:\Temp\.\mre.journal:15:
15 | 2024-01-01 * Test transaction
   |     Assets:Investing:Bonds:CetesDirecto:Invested:Cetes    100 "CD200130" @ 9.94392220 MXN
   |     equity:conversion:CD200130-MXN:CD200130                               -100 "CD200130"
   |     equity:conversion:CD200130-MXN:MXN                                   994.39222000 MXN
   |     Assets:Investing:Bonds:CetesDirecto:Wallet                          -994.39222000 MXN

Strict tag checking is enabled, and
tag "_price-matched" has not been declared.
Consider adding a tag directive. Examples:

tag _price-matched

Is this also expected?

PainFile avatar Oct 07 '24 01:10 PainFile

Oh sorry. That’s something I should fix, thanks. These are special tags used internally and we shouldn’t be warning about them.

simonmichael avatar Oct 07 '24 04:10 simonmichael

I have renamed the _price-matched tag to _cost-matched and added it to the allowlist so check tags no longer complains about it.

simonmichael avatar Oct 15 '24 01:10 simonmichael

And https://github.com/simonmichael/hledger/pull/2262 proposes to simplify --infer-equity's accounts (and allowlists the default one, equity:conversion) to solve the other problem reported above.

simonmichael avatar Oct 15 '24 03:10 simonmichael

It looks like #2262 won't happen, so check accounts still needs to allow or be better documented regarding commodity conversion accounts.

simonmichael avatar Oct 17 '24 07:10 simonmichael

The proposed #2267 exempts all conversion accounts from check accounts.

This may or may not be the best move; let's discuss over there.

simonmichael avatar Oct 17 '24 23:10 simonmichael

@PainFile: FYI #2267 resolved into deciding not to do anything special for this case - when doing strict account checking with --infer-equity, you need to ensure those equity account names are declared; but it is now documented better. Thanks for the report.

simonmichael avatar Dec 04 '24 18:12 simonmichael