-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
File-specific rules #102
Comments
Could this case be covered by naming the file in question using the They are described here: |
Actually, no. The format of these files is still the same and all generic rules still apply. It's just a way to isolate hyperspecific transaction allocation rules that only apply once. E.g., in your All generic rules are in
but rules that only have to be applied to one file are in a specific rules file:
As you can see in the example, "ATM Cash Withdrawals" are by default categorized as Because this rule is only useful for this specific transaction, it is much clearer in my opinion to have in a specific rules file. This keeps the main rules file readable and sensible, reduces the number of rules performed over all files, and avoids the risk of having a hyperspecific rule actually be applied out of its intended scope. |
I agree that file specific rules might be useful in my situation as well. Creating rules override in every case seems too much manual toil. |
@sbibauw I think this can be done with following patch
This replaces rules override logic with statement specific rules at |
@sbibauw Are you still looking for this feature? There is a pull request with this change that you can test. Please take a look and let me know if anything works differently than you would expect. |
On this page, @josephmturner and @adept have proposed to use file-specific rules, i.e. hyperspecific rules that would only apply to one specific imported file, typically because they only target one transaction or transactions from this specific timeframe. The main reason for this is to avoid cluttering the main rules file while still being able to correctly allocate specific transactions, even by overriding general rules in some cases. The second advantage is in terms of performance optimization, as these rules won't be unnecessarily evaluated on every single file.
I think it would make sense for
hledger-flow
to allow similar file-specific rules and to enforce a way to implement them. In your example directory, I'd see it as:Process
Now, as I don't think
hledger
allows to specify using multiple rules files, we'd have to include the general rules in the specific rules. I'd see the process as following (but maybe there's a better way to do it):On
hledger-flow import
, check if file-specific rules exist and create them if they don't (don't overwrite) for all detected CSVs. Write the following in each new file:Then, to import, use the file-specific rules only (as they contain all generic rules).
Potential issues
hledger
will complain on an empty rules file. But I suppose that an error message indicating that it cannot import without a rules file would make sense then.hledger-flow
users know better ;-)The text was updated successfully, but these errors were encountered: