个人所得税计算器

2023-06-04  本文已影响0人  黄yy家的jby

def cal_tax(income,signal='pre',unit='w'):
    if unit == 'w':
        income = 10000 * income
    if signal == 'pre':
      #税前计算税后
        if income <= 0:
            tax = 0
        elif income <= 36000:
            tax = income * 0.03
        elif income <= 144000:
            tax =  (income - 36000) * 0.1 + 1080
        elif income <= 300000:
            tax =  (income - 144000) * 0.2 + 12480
        elif income <= 420000:
            tax =  (income - 300000) * 0.25 + 27480
        elif income <= 660000:
            tax =  (income - 420000) * 0.3 + 49480
        elif income <= 960000:
            tax =  (income - 660000) * 0.35 + 116480
        else:
            tax =  (income - 960000) * 0.45 + 208480
        return (round(tax/1e4,2),round((income-tax)/1e4,2))
    else:
       #税后计算税前
        if income <= 0:
            before = 0
        elif income <= 36000 - 1080:
            before = income * 1/(1-0.03)
        elif income <= 144000 - 11880:
            before = (income+1080-36000*0.1)*1/(1-0.1)
        elif income <= 300000 - 43680:
            before = (income+12480-144000*0.2)*1/(1-0.2)
        elif income <= 420000 - 57480:
            before = (income + 27480 - 300000*0.25)/(1-0.25)
        elif income <= 660000 - 121480:
            before = (income + 49480 - 420000*0.3)/(1-0.3)
        elif income <= 960000 - 221480:
            before = (income+116480-660000*0.35)/(1-0.35)
        else:
            before = (income+208480-960000*0.45)/(1-0.45)
        return (round((before-income)/1e4,2),round(before/1e4,2))
上一篇 下一篇

猜你喜欢

热点阅读