使用时将工资、社保和公积金替换即可,累进税率表和起征点根据所在当地调整
import numpy as np
tax_rates = {
36000: {"tax_rate": 0.03, "quick_deduction": 0},
144000: {"tax_rate": 0.1, "quick_deduction": 2520},
300000: {"tax_rate": 0.2, "quick_deduction": 16920},
420000: {"tax_rate": 0.25, "quick_deduction": 31920},
660000: {"tax_rate": 0.3, "quick_deduction": 52920},
960000: {"tax_rate": 0.35, "quick_deduction": 85920},
float("inf"): {"tax_rate": 0.45, "quick_deduction": 181920},
}
tax_free = 5000
salaries = [
0,
0,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
]
endowment_fund = 200
public_accumulation_funds = 100
salaries = np.array(
[i - endowment_fund - public_accumulation_funds for i in salaries if i > 0]
)
sum_paid_tax = 0
for month in range(len(salaries)):
this_salary = salaries[month]
sum_need_to_tax = salaries[: month + 1].sum() - (month + 1) * tax_free
for key, v in tax_rates.items():
if sum_need_to_tax <= key and sum_need_to_tax > 0:
tax = sum_need_to_tax * v["tax_rate"] - v["quick_deduction"] - sum_paid_tax
sum_paid_tax += tax
print(
"month:",
month + 1,
"tax:",
round(tax, 2),
"salaries:",
round(this_salary - tax, 2),
)
break
print("Total tax this year:", round(sum_paid_tax, 2))
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异