diff --git a/conservancy_beancount/plugin/__init__.py b/conservancy_beancount/plugin/__init__.py index 6f1cd8d..3aa9e9c 100644 --- a/conservancy_beancount/plugin/__init__.py +++ b/conservancy_beancount/plugin/__init__.py @@ -55,7 +55,7 @@ class HookRegistry: INCLUDED_HOOKS: Dict[str, Optional[List[str]]] = { '.meta_approval': None, '.meta_entity': None, - '.meta_expense_allocation': None, + '.meta_expense_type': None, '.meta_income_type': None, '.meta_invoice': None, # Enforcing this hook would be premature as of May 2020. --brett diff --git a/conservancy_beancount/plugin/meta_expense_allocation.py b/conservancy_beancount/plugin/meta_expense_type.py similarity index 74% rename from conservancy_beancount/plugin/meta_expense_allocation.py rename to conservancy_beancount/plugin/meta_expense_type.py index dbca29d..ce03a1a 100644 --- a/conservancy_beancount/plugin/meta_expense_allocation.py +++ b/conservancy_beancount/plugin/meta_expense_type.py @@ -1,4 +1,4 @@ -"""meta_expense_allocation - Validate expense-allocation metadata""" +"""meta_expense_type - Validate expense-type metadata""" # Copyright © 2020 Brett Smith # # This program is free software: you can redistribute it and/or modify @@ -21,17 +21,19 @@ from ..beancount_types import ( Transaction, ) -class MetaExpenseAllocation(core._NormalizePostingMetadataHook): - VALUES_ENUM = core.MetadataEnum('expense-allocation', { - 'administration', +class MetaExpenseType(core._NormalizePostingMetadataHook): + VALUES_ENUM = core.MetadataEnum('expense-type', { 'fundraising', + 'management', 'program', }, { - 'admin': 'administration', + 'admin': 'management', + 'administration': 'management', + 'mgmt': 'management', }) DEFAULT_VALUES = { - 'Expenses:Services:Accounting': VALUES_ENUM['administration'], - 'Expenses:Services:Administration': VALUES_ENUM['administration'], + 'Expenses:Services:Accounting': VALUES_ENUM['management'], + 'Expenses:Services:Administration': VALUES_ENUM['management'], 'Expenses:Services:Fundraising': VALUES_ENUM['fundraising'], } diff --git a/conservancy_beancount/reports/ledger.py b/conservancy_beancount/reports/ledger.py index 05df550..e180910 100644 --- a/conservancy_beancount/reports/ledger.py +++ b/conservancy_beancount/reports/ledger.py @@ -100,7 +100,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]): ] ACCOUNT_COLUMNS: Dict[str, Sequence[str]] = collections.OrderedDict([ ('Income', ['project', 'rt-id', 'receipt', 'income-type', 'memo']), - ('Expenses', ['project', 'rt-id', 'receipt', 'approval', 'expense-allocation']), + ('Expenses', ['project', 'rt-id', 'receipt', 'approval', 'expense-type']), ('Equity', ['rt-id']), ('Assets:Receivable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']), ('Liabilities:Payable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']), diff --git a/setup.py b/setup.py index f073853..53730ac 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.6.0', + version='1.6.1', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/test_meta_expense_allocation.py b/tests/test_meta_expense_type.py similarity index 90% rename from tests/test_meta_expense_allocation.py rename to tests/test_meta_expense_type.py index 6f712bb..c8289a8 100644 --- a/tests/test_meta_expense_allocation.py +++ b/tests/test_meta_expense_type.py @@ -1,4 +1,4 @@ -"""Test handling of expense-allocation metadata""" +"""Test handling of expense-type metadata""" # Copyright © 2020 Brett Smith # # This program is free software: you can redistribute it and/or modify @@ -18,29 +18,31 @@ import pytest from . import testutil -from conservancy_beancount.plugin import meta_expense_allocation +from conservancy_beancount.plugin import meta_expense_type VALID_VALUES = { 'program': 'program', - 'administration': 'administration', 'fundraising': 'fundraising', - 'admin': 'administration', + 'management': 'management', + 'admin': 'management', + 'administration': 'management', + 'mgmt': 'management', } INVALID_VALUES = { - 'invalid', 'porgram', - 'adimn', + 'mangement', 'fundrasing', '', + *testutil.NON_STRING_METADATA_VALUES, } -TEST_KEY = 'expense-allocation' +TEST_KEY = 'expense-type' @pytest.fixture(scope='module') def hook(): config = testutil.TestConfig() - return meta_expense_allocation.MetaExpenseAllocation(config) + return meta_expense_type.MetaExpenseType(config) @pytest.mark.parametrize('src_value,set_value', VALID_VALUES.items()) def test_valid_values_on_postings(hook, src_value, set_value): @@ -101,8 +103,8 @@ def test_non_expense_accounts_skipped(hook, account): testutil.check_post_meta(txn, None, meta) @pytest.mark.parametrize('account,set_value', [ - ('Expenses:Services:Accounting', 'administration'), - ('Expenses:Services:Administration', 'administration'), + ('Expenses:Services:Accounting', 'management'), + ('Expenses:Services:Administration', 'management'), ('Expenses:Services:Advocacy', 'program'), ('Expenses:Services:Development', 'program'), ('Expenses:Services:Fundraising', 'fundraising'),