Commit graph

614 commits

Author SHA1 Message Date
Brett Smith
fff211386f query: Clean unused code.
This moved into _EnvironmentMixin.with_config().
2021-03-15 10:03:06 -04:00
Brett Smith
69f3e4ee6e query: Add a hint for the TypeError unhashable type: 'set'. 2021-03-15 09:56:13 -04:00
Brett Smith
39a9d0d67e query: rt_ticket() supports looking up custom fields. 2021-03-12 17:16:46 -05:00
Brett Smith
5ac2e4a872 query: set() updates from most Iterables, not just Sequences.
This lets it work correctly on set columns.
2021-03-12 16:27:17 -05:00
Brett Smith
2e8e70cff3 query: Add database columns. 2021-03-12 16:11:17 -05:00
Brett Smith
f0a5116429 query: Add ContextMeta function.
Deduplicate metadata lookup code.
2021-03-12 14:58:14 -05:00
Brett Smith
ef03893bfe query: Convert query functions that return List to Set.
Beancount's built-in renderers expect this and are better equipped for it.
2021-03-12 10:56:43 -05:00
Brett Smith
25321a81b0 query: Add rt_ticket() query function. 2021-03-12 10:36:15 -05:00
Brett Smith
7335282e5a rtutil: Add RTDateTime class.
See comments for rationale.
2021-03-11 13:52:31 -05:00
Brett Smith
9e33b2795c config: Add RTCredentials.idstr() method.
Want to reuse this code for a query-report cache key.
2021-03-10 10:37:21 -05:00
Brett Smith
1c71d7c6e1 tests: Add tests for BaseODS.add_annotation(). 2021-03-10 10:25:19 -05:00
Brett Smith
bf09cebf73 query: Add overview docstring. 2021-03-09 16:32:41 -05:00
Brett Smith
c3e0cc869b query: Improve help text in interactive shell. 2021-03-09 16:17:30 -05:00
Brett Smith
741e662894 query: Add original query as a comment to ODS output.
This is generally helpful to keep for future reference, plus this
presentation can support multiple queries and is more discoverable than the
previous file property.
2021-03-09 15:48:30 -05:00
Brett Smith
ea10fb239f query: Add a user hint for query TypeErrors.
The error message that native bean-query provides when this happens
confuses many users. Add a hint to point them in the right direction.
2021-03-09 15:48:30 -05:00
Brett Smith
c5a2c2d39b query: Development cleanup.
Reorder classes for nicer readability. Put shorter classes higher up, keep
related classes together.

Add developer-facing comments.

Remove unused imports.
2021-03-09 15:48:12 -05:00
Brett Smith
5893d6a59a query: Add --calendar-year and --fiscal-year shortcuts. 2021-03-09 10:39:12 -05:00
Brett Smith
6fa1278966 query: Improve formatting of ODS output.
* Provide dedicated formatting for more Beancount types.
* Improve code to determine when we're looking up link metadata
  and should format output as links.
2021-03-09 10:39:12 -05:00
Brett Smith
8af45e5f8a query: Add BQL functions for dealing with link metadata.
query-report was heading to a place where it was going to bifurcate. You
could structure input with its own special input switches, and with ODS
output, it would have its own dedicated grouping logic and use that.

But those things shouldn't be tied together for users. Instead, add
functions to BQL to be able to do the kind of grouping we want. This commit
adds those. Next we'll extend the ODS output to detect and format these
groups correctly.
2021-03-09 10:01:13 -05:00
Brett Smith
0f58960b67 query: Add ODS output format. 2021-03-06 15:45:11 -05:00
Brett Smith
0b3175fe6b query: Add support for --numberify.
bean-query compatibility.
2021-03-06 15:43:04 -05:00
Brett Smith
a5ebc04f5d data: Metadata.human_name() treats _ like -. 2021-03-06 12:11:16 -05:00
Brett Smith
b599ddee5d query: Skip rewrite rule logic when none are loaded.
This saves a few seconds of load time for the user on each run and is easy
to implement, so it's worth it.
2021-03-06 09:33:10 -05:00
Brett Smith
9c943bc8a9 query: Override BQLShell.on_Select.
This is enough to continue passing the existing tests, while giving us a
clear hook to develop ODS output.
2021-03-05 17:36:19 -05:00
Brett Smith
221d42a479 query: Add --select to use with WHERE condition arguments. 2021-03-05 16:45:24 -05:00
Brett Smith
1ca7cccf17 txn_date: Refine the filename regexp. 2021-02-26 17:23:00 -05:00
Brett Smith
9598b29ba7 txn_date: Check more filenames.
This follows up on the recent change to books.Loader.
2021-02-26 17:02:59 -05:00
Brett Smith
ca12496880 typing: Updates to pass type checking under mypy>=0.800.
Most of these account for the fact that mypy now reports that Hashable is
not an allowed return type for sort key functions.

That, plus the new ignore for the regression in config.py.
2021-02-26 16:13:02 -05:00
Brett Smith
6752a40206 books: Let files under books/ include any Beancount files they want.
This provides more flexibility in repository setup while remaining backwards
compatible.

The changes to test_reports_query are just to accommodate the new
transaction in 2020-expenses.beancount.
2021-02-26 14:45:55 -05:00
Brett Smith
96b39a8778 beancount_types: OptionsMap is a dict.
While mutating it is *probably* not a good idea, I've gotten to a point
where I need to do that (to update a value), so just admit the truth here.
2021-02-26 14:43:22 -05:00
Brett Smith
95f7524b00 cliutil: Add ExtendAction.
This is a user affordance we've wanted for a while, and
query-report *really* wants it.
2021-02-24 15:31:23 -05:00
Brett Smith
6c89febb90 fund: Clean up accidental carry-overs from ledger-report docstring. 2021-02-24 15:27:12 -05:00
Brett Smith
ccbc447a35 query: Start new reporting tool.
Ultimately this is going to be a tool that can generate nicely-formatted
spreadsheets from arbitrary bean-queries. This initial version doesn't
generate spreadsheets yet, but it does integrate our usual books-loading
tools and rewrite rules into existing bean-query functionality, so it's a
start. It also has some of the query building and parsing that higher-level
spreadsheets will need.
2021-02-24 13:15:33 -05:00
Brett Smith
5231a1784f cliutil: EnumArgument matches user arguments against aliases. 2021-02-24 13:15:33 -05:00
Brett Smith
ee2bd6c096 books: All tools use books.Loader.dispatch() and LoadResult.
This is significant code deduplication, as seen in the diffstat.
2021-02-24 13:15:33 -05:00
Brett Smith
3721226d17 books: Add Loader.dispatch() classmethod. 2021-02-24 13:15:33 -05:00
Brett Smith
f3c3ebcf59 books: Add LoadResult NamedTuple.
This refactors out some common functionality from our CLI tools.
2021-02-24 13:15:33 -05:00
Brett Smith
0a34ed6798 cliutil: ExceptHook catches RewriteRuleError.
Now that we have richer exceptions, this is the easiest way to refactor out
rewrite rule error handling from the various main functions where it
currenly lives.
2021-02-24 13:15:33 -05:00
Brett Smith
f508df06c1 rewrite: Richer exceptions for error reporting. 2021-02-19 18:54:36 -05:00
Brett Smith
4de5df9035 typing: Upgrade more Posting Iterables to Iterators. 2021-02-19 18:54:36 -05:00
Brett Smith
b142b3e521 accrual: Use EnumArgument for ReportType. 2021-02-18 15:05:56 -05:00
Brett Smith
bd1a5fc9de ledger: Add program metadata column to all reports. 2021-02-17 14:21:45 -05:00
Brett Smith
55b347271c ledger: Add fund ledger report type.
See the FundLedgerODS docstring for details.
2021-02-17 14:20:58 -05:00
Brett Smith
4188dc6a64 cliutil: Add EnumArgument.
This functionality already existed in the code three times, and it's about
to get more important for the ledger report, so now was the time to abstract
it.
2021-02-17 14:00:06 -05:00
Brett Smith
fe3560b748 meta_tax_reporting: New plugin validation. 2021-02-11 13:38:11 -05:00
Brett Smith
328f59231c meta_tax_implication: Accept titlecased values. 2021-02-11 11:17:24 -05:00
Brett Smith
b5a22a963f statement: Accept search terms.
This is the most consistent way to be able to reconcile specific kinds of
payroll taxes.
2021-02-01 10:11:12 -05:00
Brett Smith
32eaf08552 statement: Fix typo in --output-file help. 2021-02-01 09:38:22 -05:00
Brett Smith
f23e0431e2 reconcile: New statement reconciler.
For now, this is basically just a specialized ledger report. It highlights
rows that already appear reconciled, and reports different balances, with
appropriate formulas to assist interactive reconciliation.

In the future I hope we can extend this to read various CSV statements and
then highlight rows different based on discrepancies between the statement
and the books, sort of like the PayPal reconciler does now.
2021-01-31 17:06:40 -05:00
Brett Smith
ca38e45178 reports: Add BaseODS.row_count() method. 2021-01-29 14:26:54 -05:00