Changeset - 27acf1f0c106
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-09-03 15:55:59
brettcsmith@brettcsmith.org
meta_expense_type: Default management for payroll expenses.

It's a little abstract since we usually rewrite these but this is a
safer default.
2 files changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/meta_expense_type.py
Show inline comments
 
"""meta_expense_type - Validate expense-type metadata"""
 
# Copyright © 2020  Brett Smith
 
#
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU Affero General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU Affero General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

	
 
from . import core
 
from .. import data
 
from ..beancount_types import (
 
    MetaValueEnum,
 
    Transaction,
 
)
 

	
 
FUND_KEY = 'project'
 
UNRESTRICTED_FUND = 'Conservancy'
 

	
 
class MetaExpenseType(core._NormalizePostingMetadataHook):
 
    VALUES_ENUM = core.MetadataEnum('expense-type', {
 
        'fundraising',
 
        'management',
 
        'program',
 
    }, {
 
        'admin': 'management',
 
        'administration': 'management',
 
        'mgmt': 'management',
 
    })
 
    DEFAULT_VALUES = {
 
        'Expenses:Accounting': ('management', 'management'),
 
        'Expenses:BadDebt': ('management', 'program'),
 
        'Expenses:BankingFees': ('management', 'management'),
 
        'Expenses:ComputerEquipment': ('management', 'program'),
 
        'Expenses:Fines': ('management', 'program'),
 
        'Expenses:FilingFees': ('management', 'program'),
 
        'Expenses:Hosting': ('management', 'program'),
 
        'Expenses:Insurance': ('management', 'management'),
 
        'Expenses:Office': ('management', 'program'),
 
        'Expenses:Other': ('management', 'program'),
 
        'Expenses:Payroll': ('management', 'management'),
 
        'Expenses:Phones': ('management', 'program'),
 
        'Expenses:Postage': ('management', 'program'),
 
        'Expenses:ProfessionalMemberships': ('management', 'program'),
 
        'Expenses:Services:Accounting': ('management', 'management'),
 
        'Expenses:Services:Administration': ('management', 'management'),
 
        'Expenses:Services:Fundraising': ('fundraising', 'fundraising'),
 
        'Expenses:Travel': ('management', 'management'),
 
    }
 

	
 
    def _run_on_post(self, txn: Transaction, post: data.Posting) -> bool:
 
        return post.account.is_under('Expenses') is not None
 

	
 
    def _default_value(self, txn: Transaction, post: data.Posting) -> MetaValueEnum:
 
        key = post.account.is_under(*self.DEFAULT_VALUES)
 
        if key is None:
 
            return 'program'
 
        else:
 
            unrestricted, restricted = self.DEFAULT_VALUES[key]
 
            if post.meta.get(FUND_KEY) == UNRESTRICTED_FUND:
 
                return unrestricted
 
            else:
 
                return restricted
setup.py
Show inline comments
 
#!/usr/bin/env python3
 

	
 
from setuptools import setup
 

	
 
setup(
 
    name='conservancy_beancount',
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.9.3',
 
    version='1.9.4',
 
    author='Software Freedom Conservancy',
 
    author_email='info@sfconservancy.org',
 
    license='GNU AGPLv3+',
 

	
 
    install_requires=[
 
        'babel>=2.6',  # Debian:python3-babel
 
        'beancount>=2.2',  # Debian:beancount
 
        'GitPython>=2.0',  # Debian:python3-git
 
        # 1.4.1 crashes when trying to save some documents.
 
        'odfpy>=1.4.0,!=1.4.1',  # Debian:python3-odf
 
        'PyYAML>=3.0',  # Debian:python3-yaml
 
        'regex',  # Debian:python3-regex
 
        'rt>=2.0',
 
    ],
 
    setup_requires=[
 
        'pytest-mypy',
 
        'pytest-runner',  # Debian:python3-pytest-runner
 
    ],
 
    tests_require=[
 
        'mypy>=0.770',  # Debian:python3-mypy
 
        'pytest',  # Debian:python3-pytest
 
    ],
 

	
 
    packages=[
 
        'conservancy_beancount',
 
        'conservancy_beancount.plugin',
 
        'conservancy_beancount.reports',
 
        'conservancy_beancount.tools',
 
    ],
 
    entry_points={
 
        'console_scripts': [
 
            'accrual-report = conservancy_beancount.reports.accrual:entry_point',
 
            'assemble-audit-reports = conservancy_beancount.tools.audit_report:entry_point',
 
            'balance-sheet-report = conservancy_beancount.reports.balance_sheet:entry_point',
 
            'extract-odf-links = conservancy_beancount.tools.extract_odf_links:entry_point',
 
            'fund-report = conservancy_beancount.reports.fund:entry_point',
 
            'ledger-report = conservancy_beancount.reports.ledger:entry_point',
 
            'opening-balances = conservancy_beancount.tools.opening_balances:entry_point',
 
        ],
 
    },
 
)
0 comments (0 inline, 0 general)