[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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM