expense_type: Revamp expense-allocation metadata.
* Change the name for symmetry with income-type. * Standardize on "management" value because that's what it's called in the 990.
This commit is contained in:
parent
a27d68beab
commit
123508ef88
5 changed files with 24 additions and 20 deletions
|
@ -55,7 +55,7 @@ class HookRegistry:
|
||||||
INCLUDED_HOOKS: Dict[str, Optional[List[str]]] = {
|
INCLUDED_HOOKS: Dict[str, Optional[List[str]]] = {
|
||||||
'.meta_approval': None,
|
'.meta_approval': None,
|
||||||
'.meta_entity': None,
|
'.meta_entity': None,
|
||||||
'.meta_expense_allocation': None,
|
'.meta_expense_type': None,
|
||||||
'.meta_income_type': None,
|
'.meta_income_type': None,
|
||||||
'.meta_invoice': None,
|
'.meta_invoice': None,
|
||||||
# Enforcing this hook would be premature as of May 2020. --brett
|
# Enforcing this hook would be premature as of May 2020. --brett
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""meta_expense_allocation - Validate expense-allocation metadata"""
|
"""meta_expense_type - Validate expense-type metadata"""
|
||||||
# Copyright © 2020 Brett Smith
|
# Copyright © 2020 Brett Smith
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -21,17 +21,19 @@ from ..beancount_types import (
|
||||||
Transaction,
|
Transaction,
|
||||||
)
|
)
|
||||||
|
|
||||||
class MetaExpenseAllocation(core._NormalizePostingMetadataHook):
|
class MetaExpenseType(core._NormalizePostingMetadataHook):
|
||||||
VALUES_ENUM = core.MetadataEnum('expense-allocation', {
|
VALUES_ENUM = core.MetadataEnum('expense-type', {
|
||||||
'administration',
|
|
||||||
'fundraising',
|
'fundraising',
|
||||||
|
'management',
|
||||||
'program',
|
'program',
|
||||||
}, {
|
}, {
|
||||||
'admin': 'administration',
|
'admin': 'management',
|
||||||
|
'administration': 'management',
|
||||||
|
'mgmt': 'management',
|
||||||
})
|
})
|
||||||
DEFAULT_VALUES = {
|
DEFAULT_VALUES = {
|
||||||
'Expenses:Services:Accounting': VALUES_ENUM['administration'],
|
'Expenses:Services:Accounting': VALUES_ENUM['management'],
|
||||||
'Expenses:Services:Administration': VALUES_ENUM['administration'],
|
'Expenses:Services:Administration': VALUES_ENUM['management'],
|
||||||
'Expenses:Services:Fundraising': VALUES_ENUM['fundraising'],
|
'Expenses:Services:Fundraising': VALUES_ENUM['fundraising'],
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
|
||||||
]
|
]
|
||||||
ACCOUNT_COLUMNS: Dict[str, Sequence[str]] = collections.OrderedDict([
|
ACCOUNT_COLUMNS: Dict[str, Sequence[str]] = collections.OrderedDict([
|
||||||
('Income', ['project', 'rt-id', 'receipt', 'income-type', 'memo']),
|
('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']),
|
('Equity', ['rt-id']),
|
||||||
('Assets:Receivable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
|
('Assets:Receivable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
|
||||||
('Liabilities:Payable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
|
('Liabilities:Payable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.6.0',
|
version='1.6.1',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Test handling of expense-allocation metadata"""
|
"""Test handling of expense-type metadata"""
|
||||||
# Copyright © 2020 Brett Smith
|
# Copyright © 2020 Brett Smith
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -18,29 +18,31 @@ import pytest
|
||||||
|
|
||||||
from . import testutil
|
from . import testutil
|
||||||
|
|
||||||
from conservancy_beancount.plugin import meta_expense_allocation
|
from conservancy_beancount.plugin import meta_expense_type
|
||||||
|
|
||||||
VALID_VALUES = {
|
VALID_VALUES = {
|
||||||
'program': 'program',
|
'program': 'program',
|
||||||
'administration': 'administration',
|
|
||||||
'fundraising': 'fundraising',
|
'fundraising': 'fundraising',
|
||||||
'admin': 'administration',
|
'management': 'management',
|
||||||
|
'admin': 'management',
|
||||||
|
'administration': 'management',
|
||||||
|
'mgmt': 'management',
|
||||||
}
|
}
|
||||||
|
|
||||||
INVALID_VALUES = {
|
INVALID_VALUES = {
|
||||||
'invalid',
|
|
||||||
'porgram',
|
'porgram',
|
||||||
'adimn',
|
'mangement',
|
||||||
'fundrasing',
|
'fundrasing',
|
||||||
'',
|
'',
|
||||||
|
*testutil.NON_STRING_METADATA_VALUES,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_KEY = 'expense-allocation'
|
TEST_KEY = 'expense-type'
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
def hook():
|
def hook():
|
||||||
config = testutil.TestConfig()
|
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())
|
@pytest.mark.parametrize('src_value,set_value', VALID_VALUES.items())
|
||||||
def test_valid_values_on_postings(hook, src_value, set_value):
|
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)
|
testutil.check_post_meta(txn, None, meta)
|
||||||
|
|
||||||
@pytest.mark.parametrize('account,set_value', [
|
@pytest.mark.parametrize('account,set_value', [
|
||||||
('Expenses:Services:Accounting', 'administration'),
|
('Expenses:Services:Accounting', 'management'),
|
||||||
('Expenses:Services:Administration', 'administration'),
|
('Expenses:Services:Administration', 'management'),
|
||||||
('Expenses:Services:Advocacy', 'program'),
|
('Expenses:Services:Advocacy', 'program'),
|
||||||
('Expenses:Services:Development', 'program'),
|
('Expenses:Services:Development', 'program'),
|
||||||
('Expenses:Services:Fundraising', 'fundraising'),
|
('Expenses:Services:Fundraising', 'fundraising'),
|
Loading…
Reference in a new issue