Changeset - 123508ef8882
[Not reviewed]
2 3 2
Brett Smith - 4 years ago 2020-07-28 15:46:00
brettcsmith@brettcsmith.org
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.
5 files changed with 24 insertions and 20 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/__init__.py
Show inline comments
...
 
@@ -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
conservancy_beancount/plugin/meta_expense_type.py
Show inline comments
 
file renamed from conservancy_beancount/plugin/meta_expense_allocation.py to conservancy_beancount/plugin/meta_expense_type.py
 
"""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'],
 
    }
 

	
conservancy_beancount/reports/ledger.py
Show inline comments
...
 
@@ -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']),
setup.py
Show inline comments
...
 
@@ -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+',
tests/test_meta_expense_type.py
Show inline comments
 
file renamed from tests/test_meta_expense_allocation.py to tests/test_meta_expense_type.py
 
"""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'),
0 comments (0 inline, 0 general)