个人所得税计算函数,包含相关数据和计算所得税的函数,以及设置税率的程序.
1.数据表:
create table taxratetable(Tax_Year i,Tax_Month i,Tax_Salary i,Tax_Lower i,Tax_Upper i,Tax_Rate i,Tax_Deduct i)
index on (tax_year*12+tax_month)*tax_rate tag YM_Tax candidate for not delete()
2.函数:
function GetTaxRate
lPara iYear,iMonth,nSalary
nTaxRate=0
cAlias=alias()
*1.返回當前計算年月以後的最小年月的總月數
select min(tax_year*12+tax_Month) as minMonths from taxRateTable where tax_year*12+tax_Month>iYear*12+iMonth into curs tmp123
minMonths=tmp123.minMonths
use in tmp123
*2.返回當前計算年月對應的總月數
if minMonths>0
select max(tax_year*12+tax_Month) as currentMonths from TaxRateTable where tax_year*12+tax_Month<minMonths into curs tmpTax
else
select max(tax_year*12+tax_Month) as currentMonths from TaxRateTable into curs tmpTax
endif
currentMonths=tmpTax.currentMonths
*3.獲得當前年月應收金額對應的稅款
if currentMonths=0
*返回錯誤信息:沒有適合當前年月的稅率表
*!* messagebox("沒有適合當前<"+tran(iYear)+"年"+tran(iMonth)+"月>的稅率表,會返回的稅額為0")
return nSalary &&提示並產生錯誤,要不讓其返回0
else
select * from TaxRateTable where tax_year*12+tax_Month=currentMonths and (nSalary-Tax_Salary>Tax_Lower and nSalary-Tax_Salary<=Tax_Upper) into curs tmpTax
nTaxRate=(nSalary-tmpTax.Tax_Salary)*(tmpTax.Tax_Rate/100)-tmpTax.Tax_Deduct
endif
if not empty(cAlias)
select (cAlias)
endif
use in tmpTax
return nTaxRate
Function ReturnRowTotal
parameter cTable
local cAlias,nSum,cFilter
cAlias=alias()
cFilter=set("Filter")
if empty(cFilter)
cFilter=".T."
endif
nSum=0
if used(cTable)
sele field(1) from (cTable) into curs tmp9768 where &cFilter
nSum=reccount("tmp9768")
use in tmp9768
if not empty(cAlias)
sele (cAlias)
endif
endif
return nSum
完整的数据和代码请在http://download.csdn.net/detail/cnjack/3581534下载