# -*- coding: utf-8 -*- def get_tax(x, is_year =False): if(is_year): p =x/12. else: p =x if(p<=1500): return x *.03 elif(p<=4500): return x*.10 -105 elif(p<=9000): return x*.20-555 elif(p<35000): return x*.25-1005 #年终奖 税前、税后计算方法 #pre_taxs =[] #after_taxs =[] #for a in range(10*10000): #pre_tax = a #pre_taxs.append(pre_tax) #after_taxs.append( pre_tax -get_tax(pre_tax,is_year=True)) #import matplotlib.pyplot as plt #plt.plot(pre_taxs, after_taxs) #plt.show() #### #应税额度 = 个人工资总额 - 公积金10%-医保80-每月免税部分3500 pre_year_money = int( 128400*.9 -(3500+80)*12) #128400为工资总额 year_end_bonus_list=[] #年终奖所得 month_tax_part_list=[] #含税级距,月税前所得为month_tax_part + 3500 tax_list =[] #全年的个人所得税数 min_tax = pre_year_money #最少纳税额度 min_year_end_bonus = None # 最少纳税额度下对应的年终奖数 min_month_tax_part =None # 最少纳税额度下对应的月含税级据 for year_end_bonus in range(int(pre_year_money)): month_tax_part = (pre_year_money - year_end_bonus)/12. tax = get_tax(year_end_bonus,is_year=True)+ 12* get_tax(month_tax_part) #年终奖扣税部分+ 月个人所得税部分 year_end_bonus_list.append(year_end_bonus) tax_list.append(tax) if(min_tax > tax): min_tax = tax min_year_end_bonus = year_end_bonus min_month_tax_part = month_tax_part print min_tax, min_year_end_bonus,min_month_tax_part+3500 #import matplotlib.pyplot as plt #plt.plot(year_end_bonus_list, tax_list) #import matplotlib #zhfont1 = matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\STKAITI.TTF') #plt.xlabel(u'年终奖数',fontproperties=zhfont1) #plt.ylabel(u'年个人所得税',fontproperties=zhfont1) #plt.title(u'不同发放方法下的个人所得税(工资总额固定)',fontproperties=zhfont1) #plt.show() mymin_tax = ((8050-3500)*.20-555)*12 + 18000*.03 assert int(mymin_tax) == min_tax assert 8050*12+ 18000+ 12840+80*12 ==128400