摘要:對(duì)象排序帶的用法計(jì)算個(gè)稅計(jì)算個(gè)稅需繳稅的收入扣除五險(xiǎn)一金等起征點(diǎn)稅和繳稅后的收入計(jì)算五險(xiǎn)一金計(jì)算五險(xiǎn)一金收入最高基數(shù)根據(jù)不同地方來(lái)改變此為上海市分別是自己的繳費(fèi)和公司的繳費(fèi),數(shù)組各元素分別代表總共養(yǎng)老醫(yī)療失業(yè)公積金總共養(yǎng)老醫(yī)療失業(yè)公積
對(duì)象排序
function sortObject(obj, recursive, sortFunc) { const result = {} Object.keys(obj).sort(sortFunc).forEach(key=>{ const curValue = obj[key] if(recursive && Object.prototype.toString.call(curValue) === "[object Object]"){ result[key] = sortObject(curValue,recursive,sortFunc) }else{ result[key] = curValue } }) return result; }帶 Progress 的 Promise.all
function promiseAll(promises) { let finishedCount = 0 let progressCb = () => {} const promisesLength = promises.length const results = new Array(promisesLength) const result = new Promise(function(resolve, reject) { promises.forEach((val, idx) => { Promise.resolve(val).then( function(res) { finishedCount++ results[idx] = res progressCb(finishedCount, results) if (finishedCount === promisesLength) { return resolve(results) } }, function(err) { return reject(err) }, ) }) }) result.progress = cb => { progressCb = cb return result } return result } // 用法 Promise.prototype.all = promiseAll var p1 = Promise.resolve(1) var p2 = Promise.resolve(2) var p3 = Promise.resolve(3) Promise.all([p1, p2, p3]) .progress((i, j) => { console.log(i, j) }) .then(function(results) { console.log(results) // [1, 2, 3] })計(jì)算個(gè)稅
/** * 計(jì)算個(gè)稅 * @param taxableIncome {number} 0 需繳稅的收入(扣除五險(xiǎn)一金等) * @param startLine {number} 5000 起征點(diǎn) * @return {afterTax, tax} 稅和繳稅后的收入 */ function calTax(taxableIncome = 0, startLine = 5000) { // configs const levels = [0, 3000, 12000, 25000, 35000, 55000, 80000]; const taxRates = [0, 0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45]; const deductions = [0, 0, 105, 555, 1005, 2755, 5505, 13505]; const toBeTaxedIncome = taxableIncome - startLine; const levelIdx = levels.findIndex(level => level > toBeTaxedIncome); const tax = toBeTaxedIncome * taxRates[levelIdx] - deductions[levelIdx]; const afterTax = taxableIncome - tax; return { afterTax, tax }; }計(jì)算五險(xiǎn)一金
/** * 計(jì)算五險(xiǎn)一金 * @param income {number} 0 收入 * @param maxBase {number} 21400 最高基數(shù),根據(jù)不同地方來(lái)改變,此為上海市 * @return {myFees, cFees} {Array,Array} 分別是自己的繳費(fèi)和公司的繳費(fèi),數(shù)組各元素分別代表: * myFees: [總共 養(yǎng)老 醫(yī)療 失業(yè) 公積金] * cFees: [總共 養(yǎng)老 醫(yī)療 失業(yè) 公積金 工傷 生育] */ function calInsurances(income, maxBase = 19512) { // configs // 我的費(fèi)率:養(yǎng)老 醫(yī)療 失業(yè) 公積金 const myRates = [0.08, 0.02, 0.005, 0.07]; // 公司費(fèi)率:養(yǎng)老 醫(yī)療 失業(yè) 公積金 工傷 生育 const cRates = [0.2, 0.1, 0.005, 0.07, 0.003, 0.01]; // 添加總費(fèi)率 myRates.unshift( myRates.reduce((totalRate, curRate) => totalRate + curRate, 0) ); cRates.unshift(cRates.reduce((totalRate, curRate) => totalRate + curRate, 0)); const base = Math.min(income, maxBase); const myFees = myRates.map(rate => (base * rate).toFixed(2)); const cFees = cRates.map(rate => (base * rate).toFixed(2)); return { myFees, cFees }; }
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/109030.html
摘要:屬性我們還可以使用來(lái)書寫樣式,它會(huì)自動(dòng)幫我們編譯為格式內(nèi)容語(yǔ)法高亮建議使用配合該擴(kuò)展支持語(yǔ)法高亮擴(kuò)展開(kāi)發(fā)項(xiàng)目,當(dāng)然你可以把文件當(dāng)作對(duì)待。 Omil 是什么? Omil是一個(gè) webpack 的 loader,它允許你以一種名為單文件組件(SFCs)的格式撰寫 Omi 組件: ${this.data.title} export default class { test(){...
摘要:插件提供內(nèi)容,負(fù)責(zé)渲染。增量更新,盡可能地減少重新渲染長(zhǎng)時(shí)間運(yùn)行的任務(wù)應(yīng)該支持,并可以取消插件能夠正確地處理對(duì)象的生命周期。使用了模式,運(yùn)行可以將這個(gè)對(duì)象銷毀。 使用 命令行使用 幫助:code --help 使用已經(jīng)打開(kāi)的窗口來(lái)打開(kāi)文件:code -r 打開(kāi)文件并滾動(dòng)到特定行:code -r -g package.json:128 比較兩個(gè)文件:code -r -d a.tx...
摘要:前端日?qǐng)?bào)精選瀏覽器兼容性問(wèn)題解決方案配置指南全新的模塊化框架,知乎專欄現(xiàn)學(xué)現(xiàn)賣中文教學(xué)向再加行代碼教你實(shí)現(xiàn)一個(gè)低配版的庫(kù)原理篇我把最美的青春都獻(xiàn)給了代碼技術(shù)周刊開(kāi)啟瀏覽器全屏模式如何進(jìn)行的操作掘金內(nèi)存分配與垃圾回收寫一 2017-08-29 前端日?qǐng)?bào) 精選 瀏覽器兼容性問(wèn)題解決方案AlloyTeam ESLint 配置指南全新的redux模塊化框架,redux-arena - 知乎專欄...
編輯器 phpstrom sublime text3 APICloudSnippets Alignment AutoFileName Bootstrap 4 Autocomplete BracketHighlighter CSS Snippets CSS3 DocBlockr Emmet Git HTML Snippets HTML5 HTMLBeautify JS Snippets Jav...
編輯器 phpstrom sublime text3 APICloudSnippets Alignment AutoFileName Bootstrap 4 Autocomplete BracketHighlighter CSS Snippets CSS3 DocBlockr Emmet Git HTML Snippets HTML5 HTMLBeautify JS Snippets Jav...
閱讀 2380·2021-11-22 14:56
閱讀 1188·2019-08-30 15:55
閱讀 3218·2019-08-29 13:29
閱讀 1367·2019-08-26 13:56
閱讀 3517·2019-08-26 13:37
閱讀 573·2019-08-26 13:33
閱讀 3358·2019-08-26 13:33
閱讀 2241·2019-08-26 13:33