Changeset - 1a0ccd39b075
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 6 months ago 2023-12-20 01:57:34
bkuhn@ebb.org
Add `tax-implication` metadata type of Asset-Sale

This will be used for sale of stocks, for example.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/meta_tax_implication.py
Show inline comments
...
 
@@ -33,40 +33,41 @@ def _make_aliases(s: str, stdname: Optional[str]=None) -> Iterator[Tuple[str, st
 
        yield from _make_aliases(f'1099{s[5:]}', stdname)
 
    elif s.startswith('USA-'):
 
        yield from _make_aliases(f'US-{s[4:]}', stdname)
 
    if s.endswith('-Corporation'):
 
        yield from _make_aliases(f'{s[:-12]}-Corp', stdname)
 

	
 
class MetaTaxImplication(core._NormalizePostingMetadataHook):
 
    _STDNAMES = [
 
        '1099-MISC-Other',
 
        '1099-NEC',
 
        'Bank-Transfer',
 
        'Chargeback',
 
        'Foreign-Corporation',
 
        'Foreign-Grantee',
 
        'Foreign-Individual-Contractor',
 
        'Loan',
 
        'Refund',
 
        'Reimbursement',
 
        'Retirement-Pretax',
 
        'Tax-Payment',
 
        'USA-501c3',
 
        'USA-Corporation',
 
        'USA-Grantee',
 
        'W2',
 
        'Asset-Sale'
 
    ]
 
    _ALIASES = dict(
 
        alias for value in _STDNAMES for alias in _make_aliases(value)
 
    )
 
    _ALIASES['1099'] = '1099-NEC'
 
    VALUES_ENUM = core.MetadataEnum('tax-implication', _STDNAMES, _ALIASES)
 
    del _STDNAMES, _ALIASES
 

	
 
    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.account.is_cash_equivalent()
 
            and post.units.number < self.payment_threshold
 
        )
0 comments (0 inline, 0 general)