python-taxes 0.1.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ from decimal import Decimal
2
+ from typing import Annotated
3
+
4
+ from pydantic import AfterValidator, StrictBool, validate_call
5
+
6
+ from python_taxes import CURRENT_TAX_YEAR, currency_field
7
+ from python_taxes.federal import is_valid_tax_year, rounding
8
+
9
+ STANDARD_TAX = Decimal("6.200") / 100
10
+
11
+ SELF_EMPLOYED_TAX = Decimal("12.400") / 100
12
+
13
+ wage_limit = {
14
+ 2023: Decimal("160200"),
15
+ 2024: Decimal("168600"),
16
+ 2025: Decimal("176100"),
17
+ }
18
+
19
+
20
+ @validate_call
21
+ def withholding(
22
+ taxable_wages: Annotated[Decimal, currency_field],
23
+ taxable_wages_ytd: Annotated[Decimal, currency_field] = Decimal("0.00"),
24
+ self_employed: StrictBool = False,
25
+ tax_year: Annotated[int, AfterValidator(is_valid_tax_year)] = CURRENT_TAX_YEAR,
26
+ rounded: StrictBool = False,
27
+ ) -> Decimal:
28
+ """
29
+ Social security tax withholding.
30
+
31
+ Parameters:
32
+ taxable_wages -- Wages earned this period
33
+ taxable_wages_ytd -- Wages earned this year
34
+ self_employed -- True if self-employed (default False)
35
+ tax_year -- Year for which you are filing (default CURRENT_TAX_YEAR)
36
+ rounded -- Round to nearest whole dollar amount (default False)
37
+ """
38
+
39
+ if self_employed:
40
+ tax_rate = SELF_EMPLOYED_TAX
41
+ taxable_wages = taxable_wages * (Decimal("92.35") / 100)
42
+ print("Taxable Wages: ", taxable_wages)
43
+ taxable_wages_ytd = taxable_wages_ytd * (Decimal("92.35") / 100)
44
+ print("Taxable Wages YTD: ", taxable_wages_ytd)
45
+ else:
46
+ tax_rate = STANDARD_TAX
47
+
48
+ limit = wage_limit[tax_year]
49
+
50
+ if taxable_wages_ytd > limit:
51
+ return Decimal("0.00") # Tax is 0 because limit is reached
52
+
53
+ if (taxable_wages + taxable_wages_ytd) > limit:
54
+ over = (taxable_wages + taxable_wages_ytd) - limit
55
+ taxable_wages = taxable_wages - over
56
+
57
+ return (taxable_wages * tax_rate).quantize(rounding[rounded])
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stacy Noland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.3
2
+ Name: python-taxes
3
+ Version: 0.4.0
4
+ Summary: A Python library for calculating US Social Security, Medicare, and Federal Income taxes.
5
+ License: MIT License
6
+
7
+ Copyright (c) 2025 Stacy Noland
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ Author: Stacy Noland
27
+ Author-email: 46572585+stacynoland@users.noreply.github.com
28
+ Requires-Python: >=3.10,<4.0
29
+ Classifier: Development Status :: 4 - Beta
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: Intended Audience :: Information Technology
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3 :: Only
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Programming Language :: Python :: 3.13
41
+ Classifier: Typing :: Typed
42
+ Classifier: Topic :: Software Development :: Libraries
43
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
44
+ Requires-Dist: pydantic (>=2.11.3,<3.0.0)
45
+ Project-URL: Homepage, https://github.com/stacynoland/python-taxes
46
+ Project-URL: Source, https://github.com/stacynoland/python-taxes
47
+ Description-Content-Type: text/markdown
48
+
49
+ ![Python Taxes Image](https://github.com/user-attachments/assets/6c62946b-e749-46bb-a84e-6321397f1753)
50
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-taxes?logo=python&logoColor=yellow&label=Python)
51
+ [![GitHub Release](https://img.shields.io/github/v/release/stacynoland/python-taxes?label=Current%20Release)](https://github.com/stacynoland/python-taxes/releases)
52
+ ![PyPI - Status](https://img.shields.io/pypi/status/python-taxes?label=Status)
53
+ [![Tests](https://github.com/stacynoland/python-taxes/actions/workflows/test.yml/badge.svg)](https://github.com/stacynoland/python-taxes/actions/workflows/test.yml)
54
+ ![Coverage](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fstacynoland%2Fpython-taxes%2Frefs%2Fheads%2Fmain%2Fcoverage.json&query=%24.totals.percent_covered_display&suffix=%25&label=Coverage&color=3fb831)
55
+ [![Poetry Package Manager](https://img.shields.io/endpoint?url=https%3A%2F%2Fpython-poetry.org%2Fbadge%2Fv0.json)](https://python-poetry.org/)
56
+ [![Black](https://img.shields.io/badge/Code%20Style-black-000000)](https://github.com/psf/black)
57
+
58
+ > Disclaimer: This library is not intended to be used for tax advice. Please consult a tax professional for any tax-related questions or concerns.
59
+
60
+ Python-Taxes is a library designed to make calculating US Federal taxes easy.
61
+
62
+ The library supports Social Security, Medicare, and Federal Income taxes for tax years 2023 to 2025. Please note, 2025 is only added for future tax season.
63
+
64
+ `CURRENT_TAX_YEAR` is set to 2024.
65
+
66
+ ## Installation
67
+
68
+ To install the library, you can use pip or another dependency manager like Poetry.
69
+
70
+ `pip install python-taxes`
71
+
72
+ or
73
+
74
+ `poetry add python-taxes`
75
+
76
+ ## Usage
77
+
78
+ ### Social Security Tax
79
+
80
+ To calculate Social Security tax, use the `social_security` module:
81
+
82
+ ```python
83
+ from python_taxes.federal import social_security
84
+
85
+ social_security.withholding(5000) # Returns the amount withheld for Social Security tax
86
+
87
+ social_security.withholding(
88
+ taxable_wages=3000,
89
+ taxable_wages_ytd=100000,
90
+ self_employed=False,
91
+ tax_year=2024,
92
+ rounded=True,
93
+ )
94
+ ```
95
+ ---
96
+ ### Medicare Tax
97
+
98
+ To calculate Medicare tax, use the `medicare` module. There are two functions available:
99
+
100
+ `medicare.required_withholding` - Returns the required amount to withhold for Medicare tax regardless of filing status.
101
+ `medicare.additional_withholding` - Returns the amount that should be withheld based on filing status, including Additional Medicare tax.
102
+
103
+ ```python
104
+ from python_taxes.federal import medicare
105
+
106
+ medicare.required_withholding(5000) # Returns the amount withheld for Medicare tax
107
+
108
+ medicare.required_withholding(
109
+ taxable_wages=5000,
110
+ taxable_wages_ytd=100000,
111
+ self_employed=True,
112
+ rounded=True,
113
+ )
114
+
115
+ medicare.additional_withholding(100000, "married") # Returns the amount withheld for Medicare Tax and Additional Medicare tax, if applicable, based on filing status.
116
+
117
+ medicare.additional_withholding(
118
+ taxable_wages_ytd=100000,
119
+ filing_status="married",
120
+ self_employed=False,
121
+ rounded=True,
122
+ )
123
+ ```
124
+ ---
125
+ ### Federal Income Tax
126
+
127
+ To calculate Federal Income tax, use the `income` package. Currently, the only payroll withholding supported is for automated systems. Specifically, the percentage tables in IRS Publication 15-T section 1 (Percentage Method Tables for Automated Payroll Systems).
128
+
129
+ ```python
130
+ from python_taxes.federal import income
131
+
132
+ income.employer_withholding(10000) # Returns the amount withheld for Federal Income tax
133
+
134
+ income.employer_withholding(
135
+ taxable_wages=10000,
136
+ pay_frequency="monthly",
137
+ filing_status="married",
138
+ multiple_jobs=False,
139
+ tax_credits=0,
140
+ other_income=0,
141
+ deductions=0,
142
+ extra_withholding=0,
143
+ tax_year=2024,
144
+ rounded=True,
145
+ )
146
+
147
+ income.employer_withholding_pre_2020(10000) # Returns the amount withheld for Federal Income tax - using this method is required if Form W-4 is from 2019 or earlier.
148
+
149
+ income.employer_withholding_pre_2020(
150
+ taxable_wages=10000,
151
+ pay_frequency="monthly",
152
+ marital_status="married",
153
+ allowances_claimed=0,
154
+ extra_withholding=0,
155
+ tax_year=2024,
156
+ rounded=False,
157
+ )
158
+ ```
159
+
@@ -0,0 +1,16 @@
1
+ python_taxes/__init__.py,sha256=Ik5XwXbg3MHgViKIDG3flx2bHK2rVjKZsKeaVmpzXdc,150
2
+ python_taxes/federal/__init__.py,sha256=l5FP5RVNh29ce_y-N1SyNXeD7M7NAsEpV5Vs7qV66yU,443
3
+ python_taxes/federal/income/__init__.py,sha256=w0--WOCcq1_y_XWpp4QhBDzEHr6A1cUP-L2UhQqZQOQ,100
4
+ python_taxes/federal/income/payroll/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ python_taxes/federal/income/payroll/automated.py,sha256=m_WTb9t6o20O4xKs06CwaOK377vRQmuagJLO8IVmaaE,6185
6
+ python_taxes/federal/income/tables/percentage/__init__.py,sha256=mNIpA4IU-sELTiI6aNdhVkiLGpV9GLgMzR6opZ-0wBc,485
7
+ python_taxes/federal/income/tables/percentage/automated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ python_taxes/federal/income/tables/percentage/automated/hoh.py,sha256=Jcs5fV66KBHD4nvD_ZBT-DMc4r0gcateNZf6b0nz2GM,8779
9
+ python_taxes/federal/income/tables/percentage/automated/married.py,sha256=BG6bRObCEnggZD5MvFQMQK7_ydq7J6_v1CP9c7QUbEU,8799
10
+ python_taxes/federal/income/tables/percentage/automated/single.py,sha256=DyZXPLnY3XQxMxCSLRdUR1oZuxAg7qpdHKCk1g0zt64,8765
11
+ python_taxes/federal/medicare.py,sha256=_xspuO9cWr6X5gLCgxS3IMQFWOid1PCrFTo-kmxoqmQ,2882
12
+ python_taxes/federal/social_security.py,sha256=ZTDY0hY7EK7S1ES8G6Ax7itRSD5kaPJdxRB0SJrpWaw,1892
13
+ python_taxes-0.4.0.dist-info/LICENSE,sha256=qXDZCZ5wi5heCp0R_uncT3yCAHireFaSFQjphGDMFU0,1090
14
+ python_taxes-0.4.0.dist-info/METADATA,sha256=oMHrlEhC-a42CK3MVCzdfYMC_qX8CnJ_3uPJSWWV0j8,7034
15
+ python_taxes-0.4.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
16
+ python_taxes-0.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,13 +0,0 @@
1
- from decimal import Decimal, getcontext, ROUND_HALF_UP
2
-
3
-
4
- getcontext().rounding = ROUND_HALF_UP
5
-
6
- ROUNDED = Decimal('1.')
7
-
8
- NOT_ROUNDED = Decimal('0.01')
9
-
10
- rounding = {
11
- True: ROUNDED,
12
- False: NOT_ROUNDED,
13
- }
@@ -1,88 +0,0 @@
1
- from decimal import Decimal
2
- from typing import Annotated, Literal, Optional
3
-
4
- from pydantic import Field, StrictBool, validate_call
5
-
6
- from . import rounding
7
-
8
-
9
- STANDARD_PERCENT = Decimal("1.45") / 100
10
-
11
- SELF_EMPLOYED_PERCENT = Decimal("2.9") / 100
12
-
13
- ADDITIONAL_PERCENT = Decimal("0.9") / 100
14
-
15
- DEFAULT_THRESHOLD = Decimal("200000")
16
-
17
- status_threshold = {
18
- 'single': DEFAULT_THRESHOLD,
19
- 'married': Decimal("250000"),
20
- 'separate': Decimal("125000"),
21
- 'hoh': DEFAULT_THRESHOLD,
22
- }
23
-
24
-
25
- @validate_call
26
- def withholding(
27
- taxable_wages: Annotated[Decimal, Field(ge=Decimal("0.01"), decimal_places=2)],
28
- taxable_wages_ytd: Optional[
29
- Annotated[Decimal, Field(ge=Decimal("0.01"), decimal_places=2)]] = None,
30
- self_employed: StrictBool = False,
31
- rounded: StrictBool = False,
32
- ) -> Decimal:
33
- """Required amount to withhold regardless of filing status
34
-
35
- Parameters:
36
- taxable_wages -- Earned this period
37
- taxable_wages_ytd -- Earned this year
38
- self_employed -- Person/employee is self-employed (default False)
39
- round -- Round response to nearest whole dollar amount (default False)
40
- """
41
-
42
- if not taxable_wages_ytd:
43
- taxable_wages_ytd = 0
44
-
45
- if self_employed:
46
- tax_rate = SELF_EMPLOYED_PERCENT
47
- else:
48
- tax_rate = STANDARD_PERCENT
49
-
50
- if (taxable_wages > DEFAULT_THRESHOLD
51
- or (taxable_wages_ytd + taxable_wages) > DEFAULT_THRESHOLD):
52
- tax_rate = tax_rate + ADDITIONAL_PERCENT
53
-
54
- return (taxable_wages * tax_rate).quantize(rounding[rounded])
55
-
56
-
57
- @validate_call
58
- def additional_withholding(
59
- taxable_wages_ytd: Annotated[Decimal, Field(ge=Decimal("0.01"), decimal_places=2)],
60
- self_employed: StrictBool = False,
61
- status: Optional[Literal['single', 'married', 'separate' 'hoh']] = 'single',
62
- rounded: StrictBool = False,
63
- ) -> Decimal:
64
- """Additional withholding based on status
65
-
66
- Parameters:
67
- taxable_wages_ytd -- Earned this year
68
- self_employed -- Person/employee is self-employed (default False)
69
- status -- Filing status of person (default 'single')
70
- round -- Round response to nearest whole dollar amount (default False)
71
- """
72
-
73
- if self_employed:
74
- tax_rate = SELF_EMPLOYED_PERCENT
75
- else:
76
- tax_rate = STANDARD_PERCENT
77
-
78
- threshold = status_threshold[status]
79
-
80
- if taxable_wages_ytd > threshold:
81
- wages_over_threshold = taxable_wages_ytd - threshold
82
- med_taxes = (taxable_wages_ytd - wages_over_threshold) * tax_rate
83
- tax_rate = tax_rate + ADDITIONAL_PERCENT
84
- med_taxes = med_taxes + (wages_over_threshold * tax_rate)
85
- else:
86
- med_taxes = taxable_wages_ytd * tax_rate
87
-
88
- return med_taxes.quantize(rounding[rounded])
@@ -1,32 +0,0 @@
1
- from decimal import Decimal
2
- from typing import Annotated, Literal, Optional
3
-
4
- from pydantic import Field, StrictBool, validate_call
5
-
6
- from . import rounding
7
-
8
- STANDARD_TAX = Decimal('6.200') / 100
9
-
10
- SELF_EMPLOYED_TAX = Decimal('12.400') / 100
11
-
12
-
13
- @validate_call
14
- def withholding(
15
- taxable_wages: Annotated[Decimal, Field(ge=0.01, decimal_places=2)],
16
- self_employed: StrictBool = False,
17
- rounded: StrictBool = False,
18
- ) -> Decimal:
19
- """Social security tax withholding.
20
-
21
- Parameters:
22
- taxable_wages -- Total wages to be taxed
23
- self_employed -- Person/employee is self-employed (default False)
24
- round -- Round response to nearest whole dollar amount (default False)
25
- """
26
-
27
- if self_employed:
28
- tax_rate = SELF_EMPLOYED_TAX
29
- else:
30
- tax_rate = STANDARD_TAX
31
-
32
- return (taxable_wages * tax_rate).quantize(rounding[rounded])
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: python-taxes
3
- Version: 0.1.0
4
- Summary: Development in progress - please come back later.
5
- Author: Stacy Noland
6
- Author-email: 46572585+stacynoland@users.noreply.github.com
7
- Requires-Python: >=3.13
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.13
10
- Requires-Dist: pydantic (>=2.10.6,<3.0.0)
11
- Description-Content-Type: text/markdown
12
-
13
-
@@ -1,7 +0,0 @@
1
- python_taxes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- python_taxes/federal/calculators/__init__.py,sha256=xSbDWGm84eO2TBwOZl_01L5pOyUhuEsO_nyZ-fTNTAw,223
3
- python_taxes/federal/calculators/medicare.py,sha256=pugSzvgyg9EDUvO0OgsQj72H4rgRMQu0Iy0OmtdOiPU,2771
4
- python_taxes/federal/calculators/social_security.py,sha256=5tMhu0V0TWzICLb3K4Y4HDT0uQnkggqEAtGCP5QNFq8,888
5
- python_taxes-0.1.0.dist-info/METADATA,sha256=w7cia8WMXGQvu0cEefMUJSmrQO5i8RXbarKMM3897HY,403
6
- python_taxes-0.1.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
7
- python_taxes-0.1.0.dist-info/RECORD,,