[Python] 年终奖税后计算器

去年年终奖比前年涨了一些,但实际到手反而少了,当时只知道是因为税率提了一档导致的,但没有深究为什么

最近研究了一下,发现这就是著名的年终奖一元陷阱

年终奖的税率计算是,先把年终奖平分到12个月,根据个人所得税税率表找到对应的税率

于是年终奖扣税 = 年终奖×对应税率 - 速算扣除数

如果年终奖多了1块钱,进入下一档税率,根据跨度,会多扣5到15个点,但对应的速扣数没有增加12倍,就导致了年终奖多发一元,实际到手少很多的年终奖一元陷阱

 

 [Python] 年终奖税后计算器_第1张图片

 

举例说明,假如13薪和年终奖一起发,两个加一起算总年终奖。

比如13薪是10000,年终奖44000,总年终奖是54000,得出54000/12 = 1500, 查表得出用10%那档税率, 实际到手 = 54000 - (54000 × 10% - 105) = 48705

假如年终奖涨了1000,总年终奖变成55000,55000/12 = 4583, 查表得出用20% 那档税率, 实际到手 = 55000 - (55000 × 20% - 555) =44555

税率档从10%升到20%,所以虽然总年终奖多了1000,但扣的税多了5150,导致实际到手反而少了4150

[Python] 年终奖税后计算器_第2张图片

 

代码如下

def taxRate(bonus,thirteen_month_salary):

    total = bonus + thirteen_month_salary
    base = total/12

    if base < 0:
        bonus_tax = 0
    if base <= 1500:
        bonus_tax = total * 0.03
    elif base > 1500 and base <= 4500:
        bonus_tax = total * 0.1 - 105
    elif base > 4500 and base <= 9000:
        bonus_tax = total * 0.2 - 555
    elif base > 9000 and base <= 35000:
        bonus_tax = total * 0.25 - 1005
    elif base > 35000 and base <= 55000:
        bonus_tax = total * 0.3 - 2755
    elif base > 55000 and base <= 80000:
        bonus_tax = total * 0.35 - 5505
    elif base > 80000:
        bonus_tax = total * 0.45 - 13505

    print('Bonus tax payable is : %d' % bonus_tax)

    return bonus_tax

def BonusAfterTax(bonus, thirteen_month_salary):
    # 纳税额
    tax = taxRate(bonus,thirteen_month_salary)

    # 税后bonus
    bonus_after_tax = bonus + thirteen_month_salary - tax

    print('Bonus after tax is : %d' % bonus_after_tax)
    print('bonus_after_tax percentage is : %.2f %%' % float(bonus_after_tax * 100 / (bonus + thirteen_month_salary)))

    return bonus_after_tax



if __name__ == '__main__':
    bonus_before_tax = int(input('Please input your Bonus before tax:'))
    thirteen_month_salary = int(input('Please input your 13rd Salary before tax:'))
    BonusAfterTax(bonus_before_tax, thirteen_month_salary)

 

如果速扣数也能对应增加12倍,年终奖一元陷阱就解决了

同样总年终奖从54000涨到55000,如果速扣数相应增加12倍,得出税后年终奖从49860涨到50660

这样税前年终奖涨1000,实际到手涨800,而不是少4150,这才符合期望

 

期待税法能早点把这个失误改过来

[Python] 年终奖税后计算器_第3张图片

 

 代码如下

def bonusTaxRate(bonus,thirteen_month_salary):

    total = bonus + thirteen_month_salary
    base = total/12

    if base < 0:
        bonus_tax = 0
    if base <= 1500:
        bonus_tax = total * 0.03
    elif base > 1500 and base <= 4500:
        bonus_tax = total * 0.1 - 105
    elif base > 4500 and base <= 9000:
        bonus_tax = total * 0.2 - 555
    elif base > 9000 and base <= 35000:
        bonus_tax = total * 0.25 - 1005
    elif base > 35000 and base <= 55000:
        bonus_tax = total * 0.3 - 2755
    elif base > 55000 and base <= 80000:
        bonus_tax = total * 0.35 - 5505
    elif base > 80000:
        bonus_tax = total * 0.45 - 13505

    print('Bonus tax payable is : %d' % bonus_tax)

    return bonus_tax


def bonusAfterTax(bonus, thirteen_month_salary):
    # 纳税额
    tax = bonusTaxRate(bonus,thirteen_month_salary)

    # 税后bonus
    bonus_after_tax = bonus + thirteen_month_salary - tax

    print('Bonus after tax is : %d' % bonus_after_tax)
    print('bonus_after_tax percentage is : %.2f %%' % float(bonus_after_tax * 100 / (bonus + thirteen_month_salary)))
    print('                 ')

    return bonus_after_tax



def newBonusTaxRate(bonus, thirteen_month_salary):

    total = bonus + thirteen_month_salary
    base = total / 12
  #速扣数相应增大12倍
    if base < 0:
        bonus_tax = 0
    if base <= 1500:
        bonus_tax = total * 0.03
    elif base > 1500 and base <= 4500:
        bonus_tax = total * 0.1 - 105 * 12
    elif base > 4500 and base <= 9000:
        bonus_tax = total * 0.2 - 555 * 12
    elif base > 9000 and base <= 35000:
        bonus_tax = total * 0.25 - 1005 * 12
    elif base > 35000 and base <= 55000:
        bonus_tax = total * 0.3 - 2755 * 12
    elif base > 55000 and base <= 80000:
        bonus_tax = total * 0.35 - 5505 * 12
    elif base > 80000:
        bonus_tax = total * 0.45 - 13505 * 12

    print('New bonus tax payable is : %d' % bonus_tax)

    return bonus_tax


def newBonusAfterTax(bonus, thirteen_month_salary):
    total = bonus + thirteen_month_salary

    # 纳税额
    new_bonus_tax = newBonusTaxRate(bonus,thirteen_month_salary)

    # 税后bonus
    bonus_after_tax = total - new_bonus_tax

    print('New Bonus after tax is : %d' % bonus_after_tax)
    print('New bonus_after_tax percentage is : %.2f %%' % float(bonus_after_tax * 100 / total))
    print('                ')

    return bonus_after_tax

if __name__ == '__main__':
    bonus_before_tax = int(input('Please input your Bonus before tax:'))
    thirteen_month_salary = int(input('Please input your 13rd Salary before tax:'))
    bonusAfterTax(bonus_before_tax, thirteen_month_salary)
    newBonusAfterTax(bonus_before_tax, thirteen_month_salary)

 

转载于:https://www.cnblogs.com/FiaFia/p/8581234.html

你可能感兴趣的:([Python] 年终奖税后计算器)