Commit graph

118 commits

Author SHA1 Message Date
Brett Smith
e7720b8fb8 tests: Add check_post_meta.
This makes it simple to conveniently check all posting metadata in tests.
2020-03-16 10:15:31 -04:00
Brett Smith
3fbc14d377 Improve organization between modules.
* Rename _typing to beancount_types to better reflect what it is.
* LessComparable isn't a Beancount type, so move that to
  plugin.core with its dependent helper classes.
* Errors are a core Beancount concept, so move that module to the
  top level and have it include appropriate type definitions.
2020-03-15 16:03:57 -04:00
Brett Smith
a41feb94b3 plugin: Transform posting hooks into transaction hooks.
I feel like posting hooks a case of premature optimization in early
development. This approach reduces the number of special cases in
the code and allows us to more strongly reason about hooks in the
type system.
2020-03-15 15:50:14 -04:00
Brett Smith
c9ff4ab746 plugin: Settle on words-with-dashes metadata keys. 2020-03-15 10:36:49 -04:00
Brett Smith
547ae65780 plugin.core: _meta_set properly handles when post.meta is None.
post is a NamedTuple, so attribute assignment is not allowed.
Instead we have to construct a whole new Posting.
2020-03-08 11:32:03 -04:00
Brett Smith
d34db71542 plugin: Introduce HookRegistry.
This is the layer that keeps track of the different groups of hooks and
can filter them before runtime. The idea here is that you'll be able
to do things like skip hooks that require network access when you don't
have it, or skip CPU-intensive hooks when you don't need them, etc.
2020-03-06 09:22:55 -05:00
Brett Smith
d145e22734 test_plugin_run: Simplify testing strategy.
Avoid keeping state in the hook classes/instances.
2020-03-05 19:31:07 -05:00
Brett Smith
e9e2bb9b00 plugin: Rename the main method of hooks from check to run.
This will be more appropriate when we have hooks that do more than
check metadata.
2020-03-05 17:48:59 -05:00
Brett Smith
53329c7a23 plugin: Start entry point.
This doesn't integrate with existing hooks but at least sketches out the
main loop.
2020-03-05 17:41:58 -05:00
Brett Smith
dbe9362987 meta_tax_implication: Initial module and tests. 2020-03-05 15:48:10 -05:00
Brett Smith
16c47c64b2 expenseAllocation: Date-limit the transactions we work on.
This prevents the plugin from giving meaning to postings that
might not really be there.
2020-03-05 14:37:47 -05:00
Brett Smith
34090df23f expenseAllocation: Set default values by account. 2020-03-05 13:44:36 -05:00
Brett Smith
a1ec25a33d expenseAllocation: Test typos as invalid values. 2020-03-05 12:23:52 -05:00
Brett Smith
99f97d3f58 expenseAllocation: Accept 'admin' shorthand for 'administration'. 2020-03-05 12:23:03 -05:00
Brett Smith
2ac434b616 expenseAllocation: Test setting at transaction level. 2020-03-05 12:21:20 -05:00
Brett Smith
d436a388f7 expenseAllocation: Only check Expenses postings. 2020-03-05 12:10:05 -05:00
Brett Smith
7862919022 expenseAllocation: Start checker.
This is the simplest version of a common validation we're going to do:
make sure that a particular piece of metadata has one of a set of
values.

This checker needs some bounds checking but I wanted to err on the
side of committing this early because it introduces so much base
infrastructure.
2020-03-05 12:05:13 -05:00
Brett Smith
c5dd7984bc Initial commit: license, setup.py, gitignore, skeleton structure. 2020-03-05 09:33:23 -05:00