Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import can't check account names / account declarations not affecting sibling files #2113

Closed
simonmichael opened this issue Nov 16, 2023 · 3 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. csv The csv file format, csv output format, or generally CSV-related. docs Documentation-related. import journal The journal file format, and its features.

Comments

@simonmichael
Copy link
Owner

Reported in chat: hledger import -s does not seem to see account declarations in the main journal, and will wrongly complain that account names are not declared. Current workaround: don't use -s with import, eg you could do this instead: hledger import ... && hledger check -s

@simonmichael simonmichael added A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. csv The csv file format, csv output format, or generally CSV-related. labels Nov 16, 2023
@simonmichael simonmichael changed the title import does not support --strict properly import --strict does not see account declarations Nov 16, 2023
@simonmichael
Copy link
Owner Author

simonmichael commented Nov 16, 2023

I believe this is related:

commodity ""
account a
account b

2023-01-01
  (a)   1
2023-01-02
  (b)   2
$ hledger -f a.j  -f b.j print -s
hledger: Error: /Users/simon/src/hledger/b.j:2:
  | 2023-01-02
2 |     (b)               2
  |      ^

Strict account checking is enabled, and
account "b" has not been declared.
Consider adding an account directive. Examples:

account b
account b    ; type:A  ; (L,E,R,X,C,V)

Ie, account directives are not affecting a sibling file. This is odd because https://hledger.org/dev/hledger.html#directive-effects says account should affect all files, not just the current one.

@simonmichael simonmichael added the needs:debugging To unblock: needs debugging/investigation label Nov 16, 2023
@simonmichael simonmichael changed the title import --strict does not see account declarations account declarations not affecting sibling files or import with --strict Nov 16, 2023
@simonmichael simonmichael added journal The journal file format, and its features. import docs Documentation-related. labels Nov 16, 2023
@simonmichael
Copy link
Owner Author

And, hledger -f a.b -f b.j check accounts passes, but hledger -f a.b -f b.j check accounts -s does not.

@simonmichael simonmichael changed the title account declarations not affecting sibling files or import with --strict import can't check account names / account declarations not affecting sibling files Nov 16, 2023
@simonmichael
Copy link
Owner Author

simonmichael commented Nov 16, 2023

We'd like to be able to do strict account name checking on the generated transactions before proceeding with an import. Eg because we want to know

  • when categorisation rules are incomplete and transactions involving "expenses:unknown" or "income:unknown" are generated
  • when we accidentally changed the rules so as to generate undeclared account names
  • when we forgot to update csv rules after changing account names and account declarations

simonmichael added a commit that referenced this issue Nov 17, 2023
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.
@simonmichael simonmichael removed the needs:debugging To unblock: needs debugging/investigation label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. csv The csv file format, csv output format, or generally CSV-related. docs Documentation-related. import journal The journal file format, and its features.
Projects
None yet
Development

No branches or pull requests

1 participant