Changeset - 64aaeb7573b7
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 3 years ago 2021-12-30 06:49:52
bkuhn@ebb.org
Expenses:Payroll:Benefits:Other — `payroll-type` of `US:403b:Other`

Certain adjustments to 403(b) accounts that benefit the employee
should be classified with this account and the `payroll_type` added
herein.
1 file changed with 1 insertions and 0 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
 
# License: AGPLv3-or-later WITH Beancount-Plugin-Additional-Permission-1.0
 
#
 
# Full copyright and licensing details can be found at toplevel file
 
# LICENSE.txt in the repository.
 

	
 
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',
 
        'US:403b:Other',
 
        'US:Education',
 
        'US:ProfessionalMembership',
 
    ])
 

	
 

	
 
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:Earned',
 
        'CA:PTO:Taken',
 
        'US:403b:Employee',
 
        'US:403b:Match',
 
        'US:General',
 
        'US:MA:Disability:PFL',
 
        'US:MA:Disability:PML',
 
        'US:NY:Disability',
 
        'US:NY:Disability:PFL',
 
        'US:PTO:Earned',
 
        'US:PTO:Taken',
 
        *_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',
0 comments (0 inline, 0 general)