实例:
(salary-show 10000)
=> "税前(10000) - 个税(1225) - 四险一金(2245) = 最后到手(6529)"
数据均基于北京的标准。
elisp 代码如下:
;; ,----
;; | salary
;; `----
;; 保险
(defun salary-insurances (salary)
;; 养老、医疗(另加3元)、失业、公积金
(let ((s salary))
(when (> s 9966) ; 上限是 1196 左右
(setq s 9966))
(+ (* s (+ 0.08 0.02 0.005 0.12)) 3)))
;; 个税起征点
(setq salary-tax-base 2000) ; 北京
(defconst salary-tax-table
;; from to rate 扣除额?
'((0 500 0.10 0) ; (0, 500]
(500 2000 0.10 25)
(2000 5000 0.15 125)
(5000 20000 0.20 375)
(20000 40000 0.25 1375)
(40000 60000 0.30 3375)
(60000 80000 0.35 6375)
(80000 100000 0.40 10375)
(10000 0.45 15375)))
(defun salary-tax (salary)
(let ((table salary-tax-table)
(i nil)
(exceeded (- salary salary-tax-base))
(rate 0)
(to-substract 0))
(while table
(setq i (car table))
(setq table (cdr table))
(if (= (list-length i) 3)
(when (> exceeded (car i))
(setq rate (nth 1 i)
to-substract (nth 2 i))
(setq table nil))
(let ((low (nth 0 i))
(high (nth 1 i)))
(when (and (> exceeded low) (<= exceeded high))
(setq rate (nth 2 i)
to-substract (nth 3 i))
(setq table nil)))))
(- (* exceeded rate) to-substract)))
(defun salary-at-hand (salary)
"除掉个税、保险后真正到手的钱。"
(- salary (salary-insurances salary) (salary-tax salary)))
(defun salary-show (salary)
(interactive "n税前:")
(message "税前(%d) - 个税(%d) - 四险一金(%d) = 最后到手(%d)"
salary
(salary-tax salary)
(salary-insurances salary)
(salary-at-hand salary)))
Comments [0]