
The main motivation for this change is to make sure that higher-level code deals with the fact that self.units.number can be None, and has an easy way to do so. I'm not sure all our code is *currently* doing the right thing for this case, because I'm not sure it will ever actually come up. It's possible that earlier Beancount plugins fill in decimal amounts for postings that are originally loaded with self.units.number=None. I'll have to see later whether this case comes up in reality, and then deal with it if so. For now the safest strategy seems to be that most code should operate when self.units.number is None.
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""meta_tax_implication - Validate tax-implication 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/>.
|
|
|
|
import decimal
|
|
|
|
from . import core
|
|
from .. import config as configmod
|
|
from .. import data
|
|
from ..beancount_types import (
|
|
Transaction,
|
|
)
|
|
|
|
class MetaTaxImplication(core._NormalizePostingMetadataHook):
|
|
VALUES_ENUM = core.MetadataEnum('tax-implication', [
|
|
'1099',
|
|
'Accountant-Advises-No-1099',
|
|
'Bank-Transfer',
|
|
'Foreign-Corporation',
|
|
'Foreign-Individual-Contractor',
|
|
'Fraud',
|
|
'HSA-Contribution',
|
|
'Loan',
|
|
'Payroll',
|
|
'Refund',
|
|
'Reimbursement',
|
|
'Retirement-Pretax',
|
|
'Tax-Payment',
|
|
'USA-501c3',
|
|
'USA-Corporation',
|
|
'USA-LLC-No-1099',
|
|
'W2',
|
|
])
|
|
|
|
def __init__(self, config: configmod.Config) -> None:
|
|
self.payment_threshold = config.payment_threshold()
|
|
|
|
def _run_on_post(self, txn: Transaction, post: data.Posting) -> bool:
|
|
return post.is_payment(self.payment_threshold) is not False
|