Changeset - e06b400998a9
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-12-23 23:31:32
brettcsmith@brettcsmith.org
meta_payroll_type: Prefer :Tax: over :Taxes: in metadata values.

This is something we're doing generally, e.g., in our chart of accounts.
Do it here too for consistency. Accept the :Taxes: versions as synonyms.
2 files changed with 21 insertions and 14 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/meta_payroll_type.py
Show inline comments
 
"""meta_payroll_type - Validate payroll-type metadata"""
 
# Copyright © 2020  Bradley M. Kuhn, 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/>.
 

	
 
import datetime
 

	
 
from . import core
 
from .. import ranges
 
from .. import data
 
from .. import errors as errormod
 

	
 
from ..beancount_types import (
 
    Transaction,
 
)
 

	
 
METADATA_KEY = 'payroll-type'
 

	
 
class _PayrollTypeHook(core._NormalizePostingMetadataHook):
 
    ACCOUNT: str
 
    VALUES_ENUM = core.MetadataEnum(METADATA_KEY, [])
 
    TXN_DATE_RANGE = ranges.DateRange(
 
        datetime.date(2020, 3, 1),
 
        core.DEFAULT_STOP_DATE,
 
    )
 

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

	
 

	
 
class HealthInsuranceHook(_PayrollTypeHook):
 
    ACCOUNT = 'Expenses:Payroll:Benefits:HealthInsurance'
 
    VALUES_ENUM = core.MetadataEnum(METADATA_KEY, [
 
        'US:HRA:Fees',
 
        'US:HRA:Usage',
 
        'US:Premium:DentalVision',
 
        'US:Premium:Main',
 
    ])
 

	
 

	
 
class OtherBenefitsHook(_PayrollTypeHook):
 
    ACCOUNT = 'Expenses:Payroll:Benefits:Other'
 
    VALUES_ENUM = core.MetadataEnum(METADATA_KEY, [
 
        'US:403b:Fees',
 
    ])
 

	
 

	
 
class SalaryHook(_PayrollTypeHook):
 
    ACCOUNT = 'Expenses:Payroll:Salary'
 
    _tax_values = [
 
        'CA:Tax:EI',
 
        'CA:Tax:Income',
 
        'CA:Tax:PP',
 
        'US:IL:Tax:Income',
 
        'US:MA:Tax:Income',
 
        'US:NY:Tax:Income',
 
        'US:NY:Tax:NYC',
 
        'US:OR:Tax:Income',
 
        'US:OR:Tax:STT',
 
        'US:Tax:Income',
 
        'US:Tax:Medicare',
 
        'US:Tax:SocialSecurity',
 
    ]
 
    VALUES_ENUM = core.MetadataEnum(METADATA_KEY, [
 
        'CA:General',
 
        'CA:PTO',
 
        'CA:Taxes:EI',
 
        'CA:Taxes:Income',
 
        'CA:Taxes:PP',
 
        'US:403b:Employee',
 
        'US:403b:Match',
 
        'US:General',
 
        'US:IL:Taxes:Income',
 
        'US:MA:Disability:PFL',
 
        'US:MA:Disability:PML',
 
        'US:MA:Taxes:Income',
 
        'US:NY:Disability',
 
        'US:NY:Disability:PFL',
 
        'US:NY:Taxes:Income',
 
        'US:NY:Taxes:NYC',
 
        'US:OR:Taxes:Income',
 
        'US:OR:Taxes:STT',
 
        'US:PTO',
 
        'US:Taxes:Income',
 
        'US:Taxes:Medicare',
 
        'US:Taxes:SocialSecurity',
 
    ])
 
        *_tax_values,
 
    ], {
 
        value.replace(':Tax:', ':Taxes:', 1): value
 
        for value in _tax_values
 
    })
 
    del _tax_values
 

	
 

	
 
class TaxHook(_PayrollTypeHook):
 
    ACCOUNT = 'Expenses:Payroll:Taxes'
 
    VALUES_ENUM = core.MetadataEnum(METADATA_KEY, [
 
        'CA:EI',
 
        'CA:PP',
 
        'US:IL:Unemployment',
 
        'US:MA:Health',
 
        'US:MA:Unemployment',
 
        'US:MA:WorkTrain',
 
        'US:Medicare',
 
        'US:OR:Unemployment',
 
        'US:SocialSecurity',
 
    ])
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.14.0',
 
    version='1.14.1',
 
    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',
 
            'budget-report = conservancy_beancount.reports.budget:entry_point',
 
            'bean-sort = conservancy_beancount.tools.sort_entries: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',
 
            'split-ods-links = conservancy_beancount.tools.split_ods_links:entry_point',
 
        ],
 
    },
 
)
0 comments (0 inline, 0 general)