python个人所得税实验报告+操作界面

简介: python个人所得税实验报告+操作界面

实验语言:Python

实验界面搭建:利用tkinter搭建图形化界面

实验目的:搭建方便使用的计算个人所得税的计算器

参考:https://m.taxspirit.com(个税精灵:计算个人所得税在线计算器)

计算器应用到的计算公式如下:



搭建的计算器截图如下:

进入界面:

计算结果界面如下:

使用说明:用户选择当前月份,并输入本月税前工资、本月五险一金以及专项附加扣除费用。点击计算即可得到相应的结果。


代码如下:

from tkinter import *
from tkinter import ttk
import tkinter.messagebox
def click():      
    if not salary.get():
        tkinter.messagebox.showwarning('警告','请输入本月税前工资!')
    elif not safe.get():
        tkinter.messagebox.showwarning('警告','请输入五险一金!')
    elif not cost.get():
        tkinter.messagebox.showwarning('警告','请输入专项附加扣除!')
    else:
        la.destroy()
        tree.destroy()
        reason = Label(root, text="计算结果",width=20, height=2)
        reason.grid(row=5, columnspan=4)
        month_get = float(fruit.get())
        salary_get = float(salary.get())
        safe_get = float(safe.get())
        cost_get = float(cost.get())
        salary_sum = month_get * salary_get
        Label(root, text="累计收入:",width=20, height=2).grid(row=7, column=0)
        Label(root, text="{}".format(salary_sum),width=20, height=2).grid(row=7, column=1)
        safe_sum = month_get * safe_get
        Label(root, text="累计五险一金:",width=20, height=2).grid(row=7, column=2)
        Label(root, text="{}".format(safe_sum),width=20, height=2).grid(row=7, column=3)
        cost_sum = month_get * cost_get
        Label(root, text="累计专项附加扣除:",width=20, height=2).grid(row=8, column=0)
        Label(root, text="{}".format(cost_sum),width=20, height=2).grid(row=8, column=1)
        sum_fee = 5000
        Label(root, text="累计减除费用:",width=20, height=2).grid(row=8, column=2)
        Label(root, text="{}".format(sum_fee),width=20, height=2).grid(row=8, column=3)
        tax_should_pay = salary_sum - safe_sum - cost_sum - 5000
        if tax_should_pay < 0:
            tax_should_pay = 0
        Label(root, text="应纳税所得额:",width=20, height=2).grid(row=9, column=0)
        Label(root, text="{}".format(tax_should_pay),width=20, height=2).grid(row=9, column=1)
        if tax_should_pay <= 36000:
            tax_rate = 0.03
            quicknum = 0
        elif 36000 < tax_should_pay <= 144000:
            tax_rate = 0.1
            quicknum = 2520
        elif 144000 < tax_should_pay <= 300000:
            tax_rate = 0.2
            quicknum = 16920
        elif 300000 < tax_should_pay <= 420000:
            tax_rate = 0.25
            quicknum = 31920
        elif 420000 < tax_should_pay <= 660000:
            tax_rate = 0.3
            quicknum = 52920
        elif 660000 < tax_should_pay <= 960000:
            tax_rate = 0.35
            quicknum = 85920
        else:
            tax_rate = 0.45
            quicknum = 181920
        Label(root, text="税率:",width=20, height=2).grid(row=9, column=2)
        Label(root, text="{}".format(tax_rate),width=20, height=2).grid(row=9, column=3)
        Label(root, text="速算扣除数:",width=20, height=2).grid(row=10, column=0)
        Label(root, text="{}".format(quicknum),width=20, height=2).grid(row=10, column=1) 
        last_month_salary_sum = salary_sum - salary_get
        last_month_safe_sum = safe_sum - safe_get
        last_month_cost_sum = cost_sum - cost_get
        last_month_tax_should_pay = last_month_salary_sum - last_month_safe_sum - last_month_cost_sum
        if last_month_tax_should_pay <= 36000:
            last_tax_rate = 0.03
            last_quicknum = 0
        elif 36000 < last_month_tax_should_pay <= 144000:
            last_tax_rate = 0.1
            last_quicknum = 2520
        elif 144000 < last_month_tax_should_pay <= 300000:
            last_tax_rate = 0.2
            last_quicknum = 16920
        elif 300000 < last_month_tax_should_pay <= 420000:
            last_tax_rate = 0.25
            last_quicknum = 31920
        elif 420000 < last_month_tax_should_pay <= 660000:
            last_tax_rate = 0.3
            last_quicknum = 52920
        elif 660000 < last_month_tax_should_pay <= 960000:
            last_tax_rate = 0.35
            last_quicknum = 85920
        else:
            last_tax_rate = 0.45
            last_quicknum = 181920
        sum_tax_should_pay = tax_should_pay * tax_rate - quicknum
        Label(root, text="累计应纳税额:",width=20, height=2).grid(row=10, column=2)
        Label(root, text="{}".format(sum_tax_should_pay),width=20, height=2).grid(row=10, column=3)
        sum_tax_payed = last_month_tax_should_pay * last_tax_rate - last_quicknum
        Label(root, text="累计已缴税额:",width=20, height=2).grid(row=11, column=0)
        Label(root, text="{}".format(sum_tax_payed),width=20, height=2).grid(row=11, column=1)
        this_month_pay = sum_tax_should_pay - sum_tax_payed
        Label(root, text="当月应纳税额:",width=20, height=2).grid(row=11, column=2)
        Label(root, text="{}".format(this_month_pay),width=20, height=2).grid(row=11, column=3)
        really_salary = salary_get - safe_get - this_month_pay
        Label(root, text="本月税后工资:",width=20, height=2).grid(row=12, column=0)
        Label(root, text="{}".format(really_salary),width=20, height=2).grid(row=12, column=1)
root = Tk()
root.title('个人所得税计算器')
root.geometry('%dx%d' % (600, 600))
Label(root, text="工资累计预缴个税计算器",width=20, height=2).grid(row=0, columnspan=4)
items = [1,2,3,4,5,6,7,8,10,11,12]
Label(root, text="当前月份:",width=20, height=2).grid(row=1, column=0)
fruit = StringVar()
fruit.set(items[6]) 
menu = OptionMenu(root, fruit, *items) 
menu.grid(row=1, column=1)
Label(root, text="本月税前工资:",width=20, height=2).grid(row=1, column=2)
salary = Entry(root)
salary.grid(row=1, column=3)
Label(root, text="五险一金:",width=20, height=2).grid(row=2, column=0)
safe = Entry(root)
safe.grid(row=2, column=1)
Label(root, text="专项附加扣除:",width=20, height=2).grid(row=2, column=2)
cost = Entry(root)
cost.grid(row=2, column=3)
Label(root, text="五险一金由个人缴纳部分与公司缴纳部分组成,具体数值请移至五险一金计算窗口计算").grid(row=3, columnspan=4)
Label(root, text="减除费用(起征点):",width=20, height=2).grid(row=4, column=0)
Label(root, text="5000元",width=20, height=2).grid(row=4, column=1)
Button(root, text="计算",command=click ,width=50, height=2).grid(row=5, columnspan=4)
la = Label(root, text="工收入个税资薪金",width=20, height=2)
la.grid(row=6, columnspan=4)
tree = ttk.Treeview(root)
tree["columns"] = ('累计预扣预缴应纳税所得额','预扣税率','速算扣除数')       
tree.column("累计预扣预缴应纳税所得额", width=250)
tree.column("预扣税率", width=60)
tree.column("速算扣除数", width=60)     
tree.heading("累计预扣预缴应纳税所得额", text="累计预扣预缴应纳税所得额")
tree.heading("预扣税率", text="预扣税率")
tree.heading("速算扣除数", text="速算扣除数")
tree.insert("", 0, text="line1", values=("不超过36000元部分", "3%", "0"))   
tree.insert("", 1, text="line2", values=( "超过36000元至144000元的部分", "10%", "2520"))
tree.insert("", 2, text="line3", values=( "超过144000元至300000元的部分", "20%", "16920"))
tree.insert("", 3, text="line4", values=( "超过300000元至420000元的部分", "25%", "31920"))
tree.insert("", 4, text="line5", values=( "超过420000元至660000元的部分", "30%", "52920"))
tree.insert("", 5, text="line6", values=( "超过660000元至960000元的部分", "35%", "85920"))
tree.insert("", 6, text="line6", values=( "超过960000元的部分", "45%", "181920"))
tree.grid(row=7,columnspan=4 )
#root.mainloop()

相关文章
|
3天前
|
Python
557: 程序设计C 实验四 题目三 字符串交叉插入(python)
557: 程序设计C 实验四 题目三 字符串交叉插入(python)
|
3天前
|
Python
277: 程序设计C 实验二 题目五 统计二进制数中的1的个数(python)
277: 程序设计C 实验二 题目五 统计二进制数中的1的个数(python)
|
3天前
|
API 数据库 Python
Python 教程之 Django(8)在 Django 管理界面中渲染模型
Python 教程之 Django(8)在 Django 管理界面中渲染模型
26 0
Python 教程之 Django(8)在 Django 管理界面中渲染模型
|
3天前
|
Python
Python无法拒绝的表白界面完整代码
Python无法拒绝的表白界面完整代码
58 0
|
3天前
|
机器学习/深度学习 算法 TensorFlow
文本分类识别Python+卷积神经网络算法+TensorFlow模型训练+Django可视化界面
文本分类识别Python+卷积神经网络算法+TensorFlow模型训练+Django可视化界面
72 0
文本分类识别Python+卷积神经网络算法+TensorFlow模型训练+Django可视化界面
|
6月前
|
Python
python pyqt5 cmd 命令行 控制台 打印 print 输出 显示打印内容 实时显示 界面
python pyqt5 cmd 命令行 控制台 打印 print 输出 显示打印内容 实时显示 界面
203 0
|
3天前
|
前端开发 数据库 Python
使用 Python 的 Web 框架(如 Django 或 Flask)来建立后端接口,用于处理用户的请求,从数据库中查找答案并返回给前端界面
【1月更文挑战第13天】使用 Python 的 Web 框架(如 Django 或 Flask)来建立后端接口,用于处理用户的请求,从数据库中查找答案并返回给前端界面
99 7
|
3天前
|
机器学习/深度学习 JavaScript 前端开发
机器学习模型部署:使用Python和Vue搭建用户友好的预测界面
【4月更文挑战第10天】本文介绍了如何使用Python和Vue.js构建机器学习模型预测界面。Python作为机器学习的首选语言,结合Vue.js的前端框架,能有效部署模型并提供直观的预测服务。步骤包括:1) 使用Python训练模型并保存;2) 创建Python后端应用提供API接口;3) 利用Vue CLI构建前端项目;4) 设计Vue组件实现用户界面;5) 前后端交互通过HTTP请求;6) 优化用户体验;7) 全面测试并部署。这种技术组合为机器学习模型的实用化提供了高效解决方案,未来有望更加智能和个性化。
|
3天前
|
存储 SQL 数据库
【python】python鲜花管理系统(界面GUI版本)(源码+数据库)【独一无二】
【python】python鲜花管理系统(界面GUI版本)(源码+数据库)【独一无二】
|
3天前
|
安全 数据安全/隐私保护 Python
292: 程序设计C 实验五 题目三 设计密码(python)
292: 程序设计C 实验五 题目三 设计密码(python)