Added deterministic preprocessor functionality #243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed solution for issue #241 allowing user-defined, deterministic preprocessing of imported sources.
Rather than having the pre-processing logic hard-coded within the reconcile.py, I settled on a minimal approach where reconcile.py is just very slightly modified with a hook to pass the LoadedReconciler instance to a user-defined preprocessor function.
That user-defined preprocessor function can be any user-supplied function. It has full access to the LoadedReconciler state, so it can directly modify the list of pending_entries, and also has access to the JournalEditor class for writing entries to the appropriate ledger. So it hopefully allows for many use-cases.
For simple use cases, I also created a separate BasePreprocessor class and a TransactionRuleMixin. User-defined preprocessors that subclass from these can specify pre-processing rules in a dictionary-like fashion
E.g.
And this can be passed to the webserver like so:
Let me know your thoughts on this approach.
If I had React experience + time it would be nice to also allow creating PreprocessingRules based on the selected pending entry directly within the web-ui, but that's unfortunately beyond what i can handle at the moment.