清风竹林

ぷ雪飘绛梅映残红
   ぷ花舞霜飞映苍松
     ----- Do more,suffer less

2009年终奖个税计算器 python

 看看你的年终奖发的是否合理:



def getTaxRatio(taxSalary):

    ratiolist    
=(
            (
500,    0.05, 0),
            (
2000,   0.1025),
            (
5000,   0.15125),
            (
20000,  0.20375),
            (
40000,  0.251375),
            (
60000,  0.303375),
            (
80000,  0.356375),
            (
1000000.4010375),
            (
9999999,0.4515375)
            )

    
if taxSalary>= 0:        
        
for ratio in ratiolist:
            
if taxSalary<= ratio[0]:
                
return (ratio[1], ratio[2])
    
return (0, 0)

def calcYearAwardTax(yearAward):

    monthAward            
= yearAward / 12
    taxRatio, taxAdjust    
= getTaxRatio(monthAward)

    tax                    
= yearAward * taxRatio - taxAdjust
    resultAward            
= yearAward - tax
    
    retcode                
= (yearAward, resultAward, tax, taxRatio, taxAdjust)
    
#print('yearAward= %d, resultAward= %f, tax= %f, taxRatio= %f, taxAdjust= %d'%retcode)
    return retcode


################################################################################

import sys
import os

argNum    
= len(sys.argv)
if argNum == 1:
    scriptName    
= os.path.basename(__file__)
    
print('usage1:    %s awardUpperBound'%scriptName)
    
print('usage2:    %s awardLowerBound awardUpperBound'%scriptName)
    sys.exit()


print('-----------------------------------------------------------------------')

awardLowerBound, awardUpperBound        
= 0, 0
if argNum   == 2:
    awardUpperBound                        
= int(sys.argv[1])
elif argNum == 3:
    awardLowerBound, awardUpperBound    
= int(sys.argv[1]), int(sys.argv[2])

if awardLowerBound> awardUpperBound:
        swap(awardLowerBound, awardUpperBound)
    
perfectAward, perfectGain                
= 0, 0

for award in range(awardLowerBound, awardUpperBound + 1):
    retcode        
= calcYearAwardTax(award)    
    
if len(retcode) > 2:
        
if retcode[1]> perfectGain:
            perfectAward    
= retcode[0]
            perfectGain        
= retcode[1]
        
        
if award== awardUpperBound:
            
print('upperBoundAward= %d,\tgain= %f,\ttax= %f'%(retcode[0], retcode[1], retcode[0] - retcode[1]))    

print("perfectAward= %d,\tgain= %f,\ttax= %f"%(perfectAward, perfectGain, perfectAward - perfectGain))



保存成文件 awardTax.py 然后在命令行调用即可。
比如你年终奖发了25000,则:

ok, 那么你亏了,你比拿24000的同志多交税3625-2375= 1250元,最终收益还比他少21625-21375= 250元。
这个数值段最佳的年终奖数额为24000,因此还是向老板申请少给你发点年终奖吧。

posted on 2010-02-11 15:32 李现民 阅读(3029) 评论(0)  编辑 收藏 引用 所属分类: minitools


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理