下载地址:http://lanzou.com.cn/i2f2d9c7a
📁 output/jisuanmuxitongaiban/
├── 📄 README.md196 B
├── 📄 pom.xml1.4 KB
├── 📄 package.json692 B
├── 📄 config/application.properties612 B
├── 📄 platform/Helper.php2.7 KB
├── 📄 platform/Transformer.js4.4 KB
├── 📄 websocket/Builder.ts2.5 KB
├── 📄 scenario/Server.ts2.6 KB
├── 📄 src/main/java/Registry.java5.8 KB
├── 📄 errs/Executor.php3.7 KB
├── 📄 platform/Buffer.java6.8 KB
├── 📄 utils/Util.go3.5 KB
├── 📄 src/main/java/Validator.java5.3 KB
├── 📄 config/Cache.json692 B
├── 📄 websocket/Engine.go2.6 KB
├── 📄 utils/Parser.py5.2 KB
├── 📄 errs/Resolver.py5.3 KB
├── 📄 src/main/java/Provider.java4.3 KB
├── 📄 scenario/Client.py5.1 KB
├── 📄 directive/Factory.cpp1.5 KB
├── 📄 utils/Handler.cpp1.4 KB
├── 📄 config/Listener.xml1.3 KB
├── 📄 lib/Pool.jar650 B
├── 📄 errs/Wrapper.sql3.8 KB
├── 📄 usecase/Scheduler.js3.7 KB
├── 📄 STRUCTURE.txt1.4 KB
项目入口:
Project Structure
Folder : jisuanmuxitongaiban
Files : 26
Size : 75.7 KB
Generated: 2026-03-22 16:04:47
jisuanmuxitongaiban/
├── README.md [196 B]
├── config/
│ ├── Cache.json [692 B]
│ ├── Listener.xml [1.3 KB]
│ └── application.properties [612 B]
├── directive/
│ └── Factory.cpp [1.5 KB]
├── errs/
│ ├── Executor.php [3.7 KB]
│ ├── Resolver.py [5.3 KB]
│ └── Wrapper.sql [3.8 KB]
├── lib/
│ └── Pool.jar [650 B]
├── package.json [692 B]
├── platform/
│ ├── Buffer.java [6.8 KB]
│ ├── Helper.php [2.7 KB]
│ └── Transformer.js [4.4 KB]
├── pom.xml [1.4 KB]
├── scenario/
│ ├── Client.py [5.1 KB]
│ └── Server.ts [2.6 KB]
├── scripts/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── Provider.java [4.3 KB]
│ │ │ ├── Registry.java [5.8 KB]
│ │ │ └── Validator.java [5.3 KB]
│ │ └── resources/
│ └── test/
│ └── java/
├── usecase/
│ └── Scheduler.js [3.7 KB]
├── utils/
│ ├── Handler.cpp [1.4 KB]
│ ├── Parser.py [5.2 KB]
│ └── Util.go [3.5 KB]
└── websocket/
├── Builder.ts [2.5 KB]
└── Engine.go [2.6 KB]
一、项目背景
随着个税政策的复杂化,用户对个税计算的实时性、准确性提出了更高要求。传统计算器仅支持简单累进税率,无法处理专项附加扣除、年终奖单独计税等复杂场景。为此,我们开发了一款个税模拟器APP,并为其设计了Oberon智能AI计算引擎,实现了个税计算的智能化、场景化。
二、Oberon智能AI计算引擎设计
2.1 命名由来
Oberon(奥伯龙)寓意“智慧与洞察”,该引擎的核心能力包括:
智能识别用户收入类型(工资薪金、劳务报酬、年终奖等)
动态适配最新个税政策(起征点、税率表、专项附加扣除)
场景模拟(多月份累计、跳槽补税、年终奖优化)
2.2 引擎架构
text
Oberon Engine
├── TaxPolicy Module(政策模块)
│ ├── 年度累计税率表
│ ├── 专项附加扣除规则
│ └── 年终奖单独计税规则
├── AI Inference Module(推理模块)
│ ├── 收入类型分类器
│ ├── 最优计税方案推荐
│ └── 税负波动预测
└── Calculator Core(计算核心)
├── 累计预扣法
├── 汇算清缴模拟
└── 税后收入/实发工资
三、核心代码实现(Python风格)
以下是个税模拟器APP的核心代码逻辑,涵盖Oberon引擎的主要功能。
3.1 税率表与速算扣除数定义
python
年度累计税率表(综合所得)
ANNUAL_TAX_BRACKETS = [
(0, 36000, 0.03, 0),
(36000, 144000, 0.10, 2520),
(144000, 300000, 0.20, 16920),
(300000, 420000, 0.25, 31920),
(420000, 660000, 0.30, 52920),
(660000, 960000, 0.35, 85920),
(960000, float('inf'), 0.45, 181920)
]
月度预扣税率表(累计预扣法)
MONTHLY_PRE_TAX_BRACKETS = [
(0, 3000, 0.03, 0),
(3000, 12000, 0.10, 210),
(12000, 25000, 0.20, 1410),
(25000, 35000, 0.25, 2660),
(35000, 55000, 0.30, 4410),
(55000, 80000, 0.35, 7160),
(80000, float('inf'), 0.45, 15160)
]
3.2 累计预扣法计算器
python
class CumulativeTaxCalculator:
"""累计预扣法计算器(适用于月度工资)"""
def __init__(self, start_month=1):
self.cumulative_income = 0
self.cumulative_deduction = 5000 # 每月5000元起征点累计
self.cumulative_tax_paid = 0
self.current_month = start_month - 1
def add_month(self, salary, extra_deduction=0):
"""
增加一个月度收入
:param salary: 本月税前工资
:param extra_deduction: 本月专项附加扣除
:return: 本月应纳税额
"""
self.current_month += 1
# 累计收入
self.cumulative_income += salary
# 累计扣除(起征点+专项附加)
monthly_base = 5000
self.cumulative_deduction += monthly_base + extra_deduction
# 累计应纳税所得额
taxable_income = max(0, self.cumulative_income - self.cumulative_deduction)
# 计算累计应纳税额
total_tax = self._calculate_tax(taxable_income)
# 本月应纳税额 = 累计应纳税额 - 已缴税额
month_tax = total_tax - self.cumulative_tax_paid
# 更新已缴税额
self.cumulative_tax_paid = total_tax
return round(month_tax, 2)
@staticmethod
def _calculate_tax(taxable_income):
"""根据年度税率表计算税额"""
for lower, upper, rate, deduction in ANNUAL_TAX_BRACKETS:
if lower < taxable_income <= upper:
return taxable_income * rate - deduction
return 0
3.3 Oberon AI推理模块(智能方案推荐)
python
class OberonAI:
"""Oberon智能AI计算引擎"""
def __init__(self):
self.policy_year = 2025
self.tax_calculator = CumulativeTaxCalculator()
def analyze_income_type(self, income_data):
"""
智能识别收入类型
:param income_data: dict,包含金额、发放方式、备注等
:return: 收入类型标签
"""
# 模拟AI分类逻辑
amount = income_data.get('amount', 0)
note = income_data.get('note', '').lower()
if '年终' in note or 'bonus' in note:
return 'year_end_bonus'
elif '劳务' in note or 'labor' in note:
return 'labor_service'
elif amount > 50000 and '一次性' in note:
return 'lump_sum'
else:
return 'salary'
def calculate_optimal_tax(self, salary_months, bonus=None, deductions=None):
"""
智能计算最优税负方案(例如年终奖是否并入综合所得)
:param salary_months: list,每月工资
:param bonus: 年终奖金额(可选)
:param deductions: list,每月专项附加扣除
:return: 最优方案及税额对比
"""
if not bonus:
# 无年终奖,直接计算综合所得
total_tax = self._calculate_aggregate_tax(salary_months, deductions)
return {
'optimal_plan': '综合所得计税',
'total_tax': total_tax,
'recommendation': '无年终奖,按综合所得申报'
}
# 方案1:年终奖单独计税
bonus_tax_separate = self._calculate_bonus_tax(bonus)
salary_tax = self._calculate_aggregate_tax(salary_months, deductions)
total_separate = bonus_tax_separate + salary_tax
# 方案2:年终奖并入综合所得
total_combined = self._calculate_aggregate_tax(
salary_months + [bonus],
deductions
)
# AI决策:选择税负较低的方案
if total_separate <= total_combined:
return {
'optimal_plan': '年终奖单独计税',
'total_tax': total_separate,
'separate_tax': total_separate,
'combined_tax': total_combined,
'saved': round(total_combined - total_separate, 2),
'recommendation': '建议将年终奖单独申报,可节税'
}
else:
return {
'optimal_plan': '年终奖并入综合所得',
'total_tax': total_combined,
'separate_tax': total_separate,
'combined_tax': total_combined,
'saved': round(total_separate - total_combined, 2),
'recommendation': '建议将年终奖并入综合所得,可节税'
}
def _calculate_aggregate_tax(self, incomes, deductions=None):
"""计算综合所得应纳税额(年度汇算)"""
total_income = sum(incomes)
total_deduction = 60000 # 年度起征点
if deductions:
total_deduction += sum(deductions)
taxable = max(0, total_income - total_deduction)
return self._calc_by_rate(taxable, ANNUAL_TAX_BRACKETS)
def _calculate_bonus_tax(self, bonus):
"""年终奖单独计税(除以12找税率)"""
if bonus <= 0:
return 0
monthly_avg = bonus / 12
# 使用月度税率表
for lower, upper, rate, deduction in MONTHLY_PRE_TAX_BRACKETS:
if lower < monthly_avg <= upper:
return bonus * rate - deduction
return 0
@staticmethod
def _calc_by_rate(income, brackets):
for lower, upper, rate, deduction in brackets:
if lower < income <= upper:
return income * rate - deduction
return 0
3.4 专项附加扣除管理
python
class SpecialDeductionManager:
"""专项附加扣除管理器"""
DEDUCTION_TYPES = {
'children_education': 1000, # 子女教育,每月1000元/孩
'continuing_education': 400, # 继续教育,每月400元
'housing_loan': 1000, # 住房贷款,每月1000元
'housing_rent': 1500, # 住房租金,按城市分级
'elderly_support': 2000, # 赡养老人,每月2000元
'serious_illness': None, # 大病医疗,据实扣除
}
def __init__(self):
self.deductions = {k: 0 for k in self.DEDUCTION_TYPES}
def set_deduction(self, ded_type, amount=None):
"""设置专项附加扣除"""
if ded_type not in self.DEDUCTION_TYPES:
raise ValueError(f'未知扣除类型: {ded_type}')
if amount is None:
amount = self.DEDUCTION_TYPES[ded_type] or 0
self.deductions[ded_type] = amount
def get_monthly_total(self):
"""获取月度专项附加扣除总额"""
return sum(v for v in self.deductions.values() if v is not None)
def get_yearly_total(self):
"""获取年度专项附加扣除总额"""
return self.get_monthly_total() * 12
3.5 年终奖最优方案AI决策增强
python
class BonusOptimizer:
"""年终奖优化器(Oberon AI核心决策)"""
@staticmethod
def find_optimal_split(total_income, bonus, deductions):
"""
智能寻找年终奖与工资的最优分配方案
:param total_income: 全年总收入
:param bonus: 原始年终奖金额
:param deductions: 年度专项附加扣除
:return: 最优分配结果
"""
# 总应纳税所得额
taxable_base = total_income - 60000 - deductions
if taxable_base <= 0:
return {
'optimal_bonus': 0,
'optimal_salary': total_income,
'total_tax': 0,
'reason': '应纳税所得额为负,无需缴税'
}
best_tax = float('inf')
best_bonus = 0
# 遍历年终奖金额(步长5000元,兼顾性能与精度)
for test_bonus in range(0, int(bonus * 1.2) + 1, 5000):
salary_part = total_income - test_bonus
if salary_part < 0:
continue
# 分别计算两部分税额
bonus_tax = BonusOptimizer._calc_bonus_tax(test_bonus)
salary_tax = BonusOptimizer._calc_aggregate_tax(salary_part, deductions)
total_tax = bonus_tax + salary_tax
if total_tax < best_tax:
best_tax = total_tax
best_bonus = test_bonus
return {
'optimal_bonus': best_bonus,
'optimal_salary': total_income - best_bonus,
'total_tax': best_tax,
'reason': f'通过调整年终奖金额至{best_bonus}元,达到税负最优'
}
@staticmethod
def _calc_bonus_tax(bonus):
if bonus <= 0:
return 0
monthly = bonus / 12
for lower, upper, rate, deduction in MONTHLY_PRE_TAX_BRACKETS:
if lower < monthly <= upper:
return bonus * rate - deduction
return 0
@staticmethod
def _calc_aggregate_tax(income, deductions):
taxable = max(0, income - 60000 - deductions)
for lower, upper, rate, deduction in ANNUAL_TAX_BRACKETS:
if lower < taxable <= upper:
return taxable * rate - deduction
return 0
3.6 模拟器主控类(APP核心)
python
class TaxSimulatorApp:
"""个税模拟器APP主控类"""
def __init__(self):
self.oberon = OberonAI()
self.deduction_mgr = SpecialDeductionManager()
self.calculator = CumulativeTaxCalculator()
self.user_profile = {}
def set_user_profile(self, monthly_salary, annual_bonus=0,
city_rent_level='first_tier'):
"""
设置用户基本信息
:param monthly_salary: 月薪(税前)
:param annual_bonus: 年终奖
:param city_rent_level: 租房扣除等级
"""
self.user_profile = {
'monthly_salary': monthly_salary,
'annual_bonus': annual_bonus,
'city_rent_level': city_rent_level
}
# 自动配置住房租金扣除
rent_map = {'first_tier': 1500, 'second_tier': 1100, 'third_tier': 800}
if city_rent_level in rent_map:
self.deduction_mgr.set_deduction('housing_rent', rent_map[city_rent_level])
def enable_deduction(self, ded_type, value=None):
"""启用专项附加扣除"""
self.deduction_mgr.set_deduction(ded_type, value)
def simulate_monthly(self, months=12):
"""模拟月度累计预扣"""
monthly_salary = self.user_profile.get('monthly_salary', 0)
monthly_deduction = self.deduction_mgr.get_monthly_total()
results = []
calc = CumulativeTaxCalculator()
for month in range(1, months + 1):
tax = calc.add_month(monthly_salary, monthly_deduction)
net_salary = monthly_salary - tax
results.append({
'month': month,
'pre_tax': monthly_salary,
'tax': tax,
'net': net_salary,
'cumulative_tax': calc.cumulative_tax_paid
})
return results
def annual_settlement(self):
"""年度汇算清缴模拟"""
monthly_salary = self.user_profile.get('monthly_salary', 0)
annual_bonus = self.user_profile.get('annual_bonus', 0)
total_income = monthly_salary * 12 + annual_bonus
# 年度专项附加扣除总额
total_deduction = self.deduction_mgr.get_yearly_total()
# 使用Oberon引擎进行最优计税决策
optimal = self.oberon.calculate_optimal_tax(
salary_months=[monthly_salary] * 12,
bonus=annual_bonus,
deductions=[self.deduction_mgr.get_monthly_total()] * 12
)
# 附加优化建议
if annual_bonus > 0:
optimizer = BonusOptimizer()
split_advice = optimizer.find_optimal_split(
total_income, annual_bonus, total_deduction
)
optimal['split_advice'] = split_advice
return optimal
def generate_report(self):
"""生成完整个税报告"""
monthly_results = self.simulate_monthly()
annual_result = self.annual_settlement()
total_tax_paid = sum(m['tax'] for m in monthly_results)
report = {
'summary': {
'total_income': self.user_profile['monthly_salary'] * 12 +
self.user_profile.get('annual_bonus', 0),
'total_tax_paid': total_tax_paid,
'effective_tax_rate': round(total_tax_paid / max(1, self.user_profile['monthly_salary'] * 12) * 100, 2)
},
'monthly_detail': monthly_results,
'oberon_recommendation': annual_result,
'deduction_summary': {
'monthly_total': self.deduction_mgr.get_monthly_total(),
'yearly_total': self.deduction_mgr.get_yearly_total()
}
}
return report