calculate.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // const low = [
  2. // [380.34, 105],
  3. // [199.3, 110],
  4. // [379.33, 120.4],
  5. // [449.3, 115]
  6. // ]
  7. // const position = [
  8. // [18213, 22275, 24654],
  9. // [22440, 25044],
  10. // [21258, 25401],
  11. // [21396]
  12. // ]
  13. // const value = [
  14. // [ (m, p) => { return [m * 0.102, m * p] },
  15. // (m, p) => { return [1457 + m * 0.022, m * p] },
  16. // (m, p) => { return [1947.05, m * p] },
  17. // (m, p) => { return [1947.05, 24654 * p] } ],
  18. // [ (m, p) => { return [m * 0.08, m * p] },
  19. // (m, p) => { return [1822.9, m * p] },
  20. // (m, p) => { return [1822.9, 25044 * p] }],
  21. // [ (m, p) => { return [m * 0.102, m * p] },
  22. // (m, p) => { return [m * 0.102, 21258 * p] },
  23. // (m, p) => { return [2590.9, 21258 * p] } ],
  24. // [ (m, p) => { return [m * 0.105, m * p] },
  25. // (m, p) => { return [2246.58, 21396 * p] } ]
  26. // ]
  27. function calculate(m, s, a, p, d, md) {
  28. // var A = 0
  29. // var B = 0
  30. // if (s < 2 || a < 2) {
  31. // var l = low[c]//最低标准
  32. // var v = value[c]
  33. // var po = []//工资标准
  34. // var P = position[c]
  35. // for (var i = 0; i < P.length; i++) {
  36. // if (m <= P[i]) {
  37. // po = v[i](m, 0.05 + p * 0.01)
  38. // break
  39. // }
  40. // }
  41. // if (po.length == 0) {
  42. // po = v[P.length](m, 0.05 + p * 0.01)
  43. // }
  44. // if (s < 2) {
  45. // var A = s == 0 ? l[0] : po[0]//社保缴纳
  46. // }
  47. // if (a < 2) {
  48. // var B = a == 0 ? l[1] : po[1]//公积金缴纳
  49. // }
  50. // }
  51. var A = Number(s).toFixed(2)
  52. var B = Number(a).toFixed(2)
  53. // var A = 0
  54. // var B = 0
  55. console.log(d)
  56. var salary = m - A - B//每月应纳税工资
  57. var taxesS = m - A - B - d//每月实际纳税工资
  58. var ex = 5000//每个月免税额度
  59. var lastC = 0//累计个税
  60. var lastT = 0//累计税后工资
  61. var result = []
  62. var income = []
  63. for (var i = 1; i < 13; i ++) {
  64. var allE = ex * i
  65. var allT = taxesS * i - allE//需交税部分工资
  66. // console.log(allT)
  67. var C = calculateTax(allT)
  68. // console.log(C)
  69. result.push((C - lastC).toFixed(2))
  70. income.push((salary - C + lastC).toFixed(2))
  71. lastT = lastT + salary - C + lastC
  72. lastC = C
  73. }
  74. result.push(lastC.toFixed(2))
  75. income.push(lastT.toFixed(2))
  76. // console.log(result)
  77. // console.log(lastC)
  78. // C = C.toFixed(1)
  79. // var income = (taxesS - C).toFixed(2)//税后收入
  80. // console.log(taxesS)
  81. // console.log(B)
  82. // console.log(C)
  83. // console.log(income)
  84. //算大病医疗退税
  85. var allT = (taxesS - ex) * 12 - md//年度需交税部分工资
  86. var rebate = calculateTax(allT)
  87. rebate = result[12] - rebate
  88. if (rebate < 0) {
  89. rebate = 0
  90. }
  91. return [A, B, result, income, rebate]
  92. }
  93. function calculateTax(s) {
  94. var C = 0//个税
  95. if (s > 960000) {
  96. C = s * 0.45 - 181920
  97. } else if (s > 660000) {
  98. C = s * 0.35 - 85920
  99. } else if (s > 420000) {
  100. C = s * 0.3 - 52920
  101. } else if (s > 300000) {
  102. C = s * 0.25 - 31920
  103. } else if (s > 144000) {
  104. C = s * 0.2 - 16920
  105. } else if (s > 36000) {
  106. C = s * 0.1 - 2520
  107. } else if (s > 0) {
  108. C = s * 0.03
  109. }
  110. return C
  111. }
  112. module.exports = {
  113. calculate: calculate
  114. }