019年1月1日即將到來,碼農(nóng)們除了關(guān)心自己的技能之外,還有薪資是不是可以多拿點。 每次算的時候 都要百度一下個人所得稅,但是很多都是老的稅率計算,找一個新的出來還是比較麻煩,所以個人開發(fā)了一個最新稅率的小程序。解決和我有著一樣痛苦的碼農(nóng)們的問題。根據(jù)最新稅改后計算個人所得稅的計算器。目前支持南京,后續(xù)開放 杭州 上海 北京等城市。 如果有疑問的可以加最下方 開發(fā)者微信。
實例查看二維碼:
先使用weui 小程序ui框架就行頁面布局
<button block type="dark" bindtap='calculationBindtap'>計算</button>
其次寫JS代碼(計算按鈕邏輯代碼)
import data from './data' const app = getApp; Page({ data: { options1: data, value: '1', checked: true, standard: 1, marking: 5000, beforetaxCount: 0, specialitemCount: 0 }, calculationBindtap:function(){ // 開始計算 計算完成把計算結(jié)果放在result對象中 var beforetaxCount = this.data.beforetaxCount; var specialitemCount = this.data.specialitemCount; var marking = this.data.marking; if (beforetaxCount == null || beforetaxCount == 0 || beforetaxCount == ''){ wx.showToast({ title: '輸入正確薪資', mask: true, icon: 'loading' }) return; } if (specialitemCount == null || specialitemCount == ''){ specialitemCount = 0; } // 開始計算 var oldNum = 0.08; var medNum = 0.02; var unemNum = 0.005; var workNum = 0; var giveNum = 0; var providentfundNum = 0.08; var insuranceBase = 19935; var providentfundBase = 25300; var oldcount = 0; var medcount = 0; var unemcount = 0; var workcount = 0; var givecount = 0; var providentfundcount = 0; var privateFee = 0; var plusFee = 0; if(this.data.checked){ if (parseFloat(beforetaxCount) > parseFloat(insuranceBase)) { oldcount = parseFloat(insuranceBase) * parseFloat(oldNum); medcount = parseFloat(insuranceBase) * parseFloat(medNum); unemcount = parseFloat(insuranceBase) * parseFloat(unemNum); workcount = parseFloat(insuranceBase) * parseFloat(workNum); givecount = parseFloat(insuranceBase) * parseFloat(giveNum); } else { oldcount = parseFloat(beforetaxCount) * parseFloat(oldNum); medcount = parseFloat(beforetaxCount) * parseFloat(medNum); unemcount = parseFloat(beforetaxCount) * parseFloat(unemNum); workcount = parseFloat(beforetaxCount) * parseFloat(workNum); givecount = parseFloat(beforetaxCount) * parseFloat(giveNum); } if (parseFloat(beforetaxCount) > parseFloat(providentfundBase)) { providentfundcount = parseFloat(providentfundBase) * parseFloat(providentfundNum); } else { providentfundcount = parseFloat(beforetaxCount) * parseFloat(providentfundNum); } } // 保險總費用 var totalInsuranceFee = parseFloat(oldcount) + parseFloat(medcount) + parseFloat(unemcount) + parseFloat(workcount) + parseFloat(givecount); // 公積金費用 var totalProvidentfundFee = providentfundcount; // 下面的錢 交稅 console.log(this.data.marking); var otherFee = parseFloat(beforetaxCount) - parseFloat(totalInsuranceFee) - parseFloat(totalProvidentfundFee) - parseFloat(this.data.marking) - parseFloat(specialitemCount); if (parseFloat(otherFee) <= 3000 && parseFloat(otherFee) > 0) { privateFee = parseFloat(otherFee) * 0.03; plusFee = 0; } if (parseFloat(otherFee) <= 12000 && parseFloat(otherFee) > 3000) { privateFee = parseFloat(otherFee) * 0.1; plusFee = 210; } if (parseFloat(otherFee) <= 25000 && parseFloat(otherFee) > 12000) { privateFee = parseFloat(otherFee) * 0.2; plusFee = 1410; } if (parseFloat(otherFee) <= 35000 && parseFloat(otherFee) > 25000) { privateFee = parseFloat(otherFee) * 0.25; plusFee = 2660; } if (parseFloat(otherFee) <= 55000 && parseFloat(otherFee) > 35000) { privateFee = parseFloat(otherFee) * 0.3; plusFee = 4410; } if (parseFloat(otherFee) <= 80000 && parseFloat(otherFee) > 55000) { privateFee = parseFloat(otherFee) * 0.35; plusFee = 7160; } if ( parseFloat(otherFee) > 80000) { privateFee = parseFloat(otherFee) * 0.45; plusFee = 15160; } var result = {}; result.insuranceCount = totalInsuranceFee; result.providentfundCount = totalProvidentfundFee; result.providentfundNum = parseFloat(providentfundNum) * 100; result.money = parseFloat(beforetaxCount) - parseFloat(totalInsuranceFee) - parseFloat(totalProvidentfundFee) - parseFloat(privateFee) + parseFloat(plusFee); result.privateFee = privateFee - parseFloat(plusFee); result.specialitemCount = specialitemCount; result.oldNum = parseFloat(oldNum) * 100; result.medNum = parseFloat(medNum) * 100; result.unemNum = parseFloat(unemNum) * 100; result.workNum = parseFloat(workNum) * 100; result.giveNum = parseFloat(giveNum) * 100; result.oldcount = parseFloat(oldcount); result.medcount = parseFloat(medcount); result.unemcount = parseFloat(unemcount); result.workcount = parseFloat(workcount); result.givecount = parseFloat(givecount); wx.setStorage({ key: 'result', data: result, success:function(){ wx.navigateTo({ url: '../calculation/calculationResult', }) } }) }, })
把計算好的結(jié)果放在result對象中 通過wx.setStorage 放在緩存中,傳到下一個頁面。最后展示出來。