個稅 = (稅前工資 - 五險一金 - 免征額) * 稅率 - 速扣數
稅后工資 = 稅前工資 - 五險一金 - 個稅
salary_before_tax = int(input('Please input your Salary before tax:')) threshold = 3500 #免征點 #個人五險一金比率,養老8%,醫療2%,失業0.2%,公積金12% old_age_rating = 0.08 medical_rating = 0.02 unemployment_rating = 0.002 housing_fund_rating = 0.12 # 2016年社平工資7706,五險一金的上限是社評三倍工資為基數 average_salary = 7706 triple_average_salary = 3 * average_salary if salary_before_tax < triple_average_salary: total_insurance = salary_before_tax * (old_age_rating + medical_rating + unemployment_rating + housing_fund_rating) else: total_insurance = triple_average_salary * (old_age_rating + medical_rating + unemployment_rating + housing_fund_rating) # 納稅額 payment = salary_before_tax - total_insurance - threshold if payment <= 1500: tax = payment * 0.03 elif payment > 1500 and payment <= 4500: tax = payment * 0.1 - 105 elif payment > 4500 and payment <= 9000: tax = payment * 0.2 - 555 elif payment > 9000 and payment <= 35000: tax = payment * 0.25 - 1005 elif payment > 35000 and payment <= 55000: tax = payment * 0.3 - 2755 elif payment > 55000 and payment <= 80000: tax = payment * 0.35 - 5505 elif payment > 80000: tax = payment * 0.45 - 13505 # 稅后工資 salary_after_tax = salary_before_tax - total_insurance - tax print('Salary after tax is %d' % salary_after_tax)
2018年3月更新,稍微改了一下,用函數處理
def taxRate(base): 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 print('Tax of salary is : %d' % tax) return tax def salaryAfterTax(salaryBeforeTax): #免征點3500 ,個人五險一金比率,養老8%,醫療2%,失業0.2%,公積金12% threshold = 3500 oldAgeRating = 0.08 medicalRating = 0.02 unemployRating = 0.002 housingFundRating = 0.12 # 2016年社平工資7706,五險一金上限是社評三倍工資 averageSalary = 7706 tripleAverageSalary = 3 * averageSalary if salaryBeforeTax < tripleAverageSalary: totalInsurance = salaryBeforeTax * (oldAgeRating + medicalRating + unemployRating + housingFundRating) housingFund = salaryBeforeTax * housingFundRating else: totalInsurance = tripleAverageSalary * ( oldAgeRating + medicalRating + unemployRating + housingFundRating) housingFund = tripleAverageSalary * housingFundRating #公積金封頂 #housingFund = salaryBeforeTax * housingFundRating #公司給補超額公積金部分 # 納稅額 payment = salaryBeforeTax - totalInsurance - threshold tax = taxRate(payment) # 稅后工資 salaryAfterTax = salaryBeforeTax - totalInsurance - tax actualIncome = salaryAfterTax + housingFund * 2 print('Housing Fund is : %d' % housingFund) print('Total insurance is : %d ' % totalInsurance) print('Tax of salary is : %d' % tax) print('Salary after tax is : %d' % salaryAfterTax) print('Actual income including housing fund is : %d ' % actualIncome) print('Actual income Percent is : %.2f %%' % float(actualIncome * 100 / salaryBeforeTax)) return salaryAfterTax if __name__ == '__main__': salary = int(input('Please input your Salary before tax:')) salaryAfterTax(salary)