[Python] 2018新税法下工资计算

新个税的草案,明确了新版7级税率明细:全年应纳税所得额不超过3.6万元的,适用3%税率;超过3.6万元至14.4万元的部分,适用10%税率;超过14.4万元至30万元的部分,适用20%税率;超过30万元至42万元的部分,适用25%税率;超过42万元至66万元的部分,适用30%税率;超过66万元至96万元的部分,适用35%税率;超过96万元的部分,适用45%税率。

再根据速扣公式  速扣数的公式(本档次税率-上档次税率)*上档次最高应纳税工资薪金的金额+上档次的速算扣除数

趁着改税率档,也把之前的个税计算器,写成了模块,这样当计算年终奖和赔偿金可以重用

Tax.py

# coding=utf-8
"""
@author:FiaFia
@data:2018/7/6
@version:Python3.6
"""


class Tax():
    @staticmethod
    def oldTaxRate(base):
        '''
        旧的税率表及速扣数
        速扣数的公式(本档次税率-上档次税率)*上档次最高应纳税工资薪金的金额+上档次的速算扣除数
        纳税额          税率    速扣数
        <1500           3%      0
        1500-4500       10%     105
        4500-9000       20%     555
        9000-35000      25%     1005
        35000-55000     30%     2755
        55000-80000     35%     5505
        >80000          45%     13505
        '''
        if base < 0:
            tax = 0
        elif base <= 1500:
            tax = base * 0.03
        elif base > 1500 and base <= 4500:
            tax = base * 0.1 - 105
        elif base > 4500 and base <= 9000:
            tax = base * 0.2 - 555
        elif base > 9000 and base <= 35000:
            tax = base * 0.25 - 1005
        elif base > 35000 and base <= 55000:
            tax = base * 0.3 - 2755
        elif base > 55000 and base <= 80000:
            tax = base * 0.35 - 5505
        elif base > 80000:
            tax = base * 0.45 - 13505

        return tax

    @staticmethod
    def newTaxRate(base):
        '''
        新的税率表及速扣数
        速扣数的公式(本档次税率-上档次税率)*上档次最高应纳税工资薪金的金额+上档次的速算扣除数
        纳税额          税率    速扣数
        <3000           3%      0
        3000-12000      10%     210
        12000-25000     20%     1410
        25000-35000     25%     2660
        35000-55000     30%     4410
        55000-80000     35%     7160
        >80000          45%     15160
        '''
        if base < 0:
            tax = 0
        elif base <= 3000:
            tax = base * 0.03
        elif base > 3000 and base <= 12000:
            tax = base * 0.1 - 210
        elif base > 12000 and base <= 25000:
            tax = base * 0.2 - 1410
        elif base > 25000 and base <= 35000:
            tax = base * 0.25 - 2660
        elif base > 35000 and base <= 55000:
            tax = base * 0.3 - 4410
        elif base > 55000 and base <= 80000:
            tax = base * 0.35 - 7160
        elif base > 80000:
            tax = base * 0.45 - 15160

        return tax

税后工资计算 SalaryAfterTax.py

# coding=utf-8
"""
@author:FiaFia
@data:2018/7/6
@version:Python3.6
"""
from Tax import Tax


class Main():
    @staticmethod
    def salaryAfterTax(salary):
        #旧个税免征点3500,新个税免征点5000,个人五险一金比率,养老8%,医疗2%,失业0.2%,公积金12%
        oldThreshold = 3500
        newThreshold = 5000
        oldAgeRating = 0.08
        medicalRating = 0.02
        unemployRating = 0.002
        housingFundRating = 0.12

        # 五险一金上限是社评三倍工资
        averageSalary = 8467   # 2016社平工资7706, 2017社平工资8467
        tripleAverageSalary = 3 * averageSalary

        if salary < tripleAverageSalary:
            totalInsurance = salary * (oldAgeRating + medicalRating + unemployRating + housingFundRating)
            housingFund = salary * housingFundRating
        else:
            totalInsurance = tripleAverageSalary * (
                oldAgeRating + medicalRating + unemployRating + housingFundRating)
            housingFund = tripleAverageSalary * housingFundRating   #公积金封顶
            #housingFund = salaryBeforeTax * housingFundRating     #如果公司给补超额公积金部分,则用这个计算

        # 纳税额
        oldPayment = salary - totalInsurance - oldThreshold
        oldTax = Tax.oldTaxRate(oldPayment)
        newPayment = salary - totalInsurance - newThreshold
        newTax = Tax.newTaxRate(newPayment)

        # 税后工资
        oldSalaryAfterTax = salary - totalInsurance - oldTax
        oldActualIncome = oldSalaryAfterTax + housingFund * 2
        newSalaryAfterTax = salary - totalInsurance - newTax
        newActualIncome = newSalaryAfterTax + housingFund * 2
        Gap = newActualIncome - oldActualIncome

        print('***Total insurance is %d and Housing fund is %d***' % (totalInsurance, housingFund))
        print('New salaryAfterTax is %d (tax is %d) and current salaryAfterTax is %d (tax is %d), receive more %d' % (newSalaryAfterTax,newTax,oldSalaryAfterTax, oldTax,  Gap))
        print('New income with housing fund is %d and current income with housing fund is %d ' % (newActualIncome, oldActualIncome))
        print('New Actual income Percentage is : %.2f %%' % float(newActualIncome * 100 / salary))
        print('Current Actual income Percentage is : %.2f %%' % float(oldActualIncome * 100 / salary))

        return oldSalaryAfterTax, newSalaryAfterTax


if __name__ == '__main__':
    salary = int(input('Please input your Salary before tax:'))
    Main.salaryAfterTax(salary)

猜你喜欢

转载自www.cnblogs.com/FiaFia/p/9272329.html
今日推荐