一篇以PHP根据最新劳务个税税率计算所得税、奖金的PHP类

bloger 2019-11-15 PM 3535℃ 0条

2018-2019 最新劳务个税税率表
微信图片_20191115182452.png

表格数据如下:

QQ截图20191115180857.jpg

class Calculator{
    public function __set($name, $value)
    {
        // TODO: Implement __set() method.
        $this->$name = $value;
    }

    public function __get($name)
    {
        // TODO: Implement __get() method.
        return $this->$name;
    }

    public function wage()
    {
     switch ($this->js){
            case $this->js >= 23566:
                $ssb_js = 23565;
                break;
            case $this->js >= 3613 :
                $ssb_js = $this->js;
                break;
            default:
                $ssb_js = 3613;
                break;
        }
        $this->gr_ssb    = $ssb_js * 8 / 100;
        $this->qy_ssb    = $ssb_js * 16 / 100;
        $this->gr_syx    = $ssb_js * 0.2 / 100;
        $this->qy_syx    = $ssb_js * 0.8 / 100;

        switch ($this->js){
            case $this->js > 27786:
                $ylx_js = 27786;
                break;
            case $this->js >=5557:
                $ylx_js = $this->js;
                break;
            default:
                $ylx_js = 5557;
                break;
        }
        $this->gr_ylx = $ylx_js * 2 / 100;
        $this->qy_ylx = $ylx_js * 10 / 100;
        $this->gr_ssx = 0;
        $this->qy_ssx = $ylx_js * 0.8 / 100;

        switch ($this->js){
            case $this->js > 23565:
                $gsxjs = 23565;
                break;
            case $this->js >=4713:
                $gsxjs = $this->js;
                break;
            default:
                $gsxjs = 4713;
                break;
        }
        $this->gr_gsx = 0;
        $this->qy_gsx = $gsxjs * 0.4 / 100;
        $this->gr_total = $this->gr_ssb + $this->gr_syx + $this->gr_ylx + $this->gr_ssx + $this->gr_gsx;
        $this->qy_total = $this->qy_ssb + $this->qy_syx + $this->qy_ylx + $this->qy_ssx + $this->qy_gsx;
        $fjf = $this->jy + $this->xl + $this->fz + $this->lr;
        $bd   = $this->gz - $fjf - $this->gr_total - 5000;
        $gzxs = [0,210,1410,2660,4410,7160,15160];
        $sl   = [0.03,0.1,0.2,0.25,0.3,0.35,0.45];
        $news = [0];
        foreach ($sl as $key =>$value) $news[] = $bd * $value - $gzxs[$key];
        rsort($news);
        $max = $news[0];
        $this->gs = $this->bl($max);
        $lwbc = min([$this->gz * 0.8,$this->gz -800]);
        $lwsl = [0,20,30,40];
        $lwkc = [0,0,2,7];
        $dws = [];
        foreach ($lwsl as $key => $value) $dws [] = ($value * $lwbc / 100) - (1000 * $lwkc[$key]);
        $this->bcgs = max($dws);
        switch ($this->gz){
            case $this->gz >= 4000:
                $this->cggs = $this->gz * 0.112;
                break;
            case $this->gz >= 800:
                $this->cggs = ($this->gz - 800) * 0.14;
                break;
            default:
                $this->cggs = 0;
                break;
        }
        $max_jjgs = max([0,0001,$this->jj / 12]);
        switch ($max_jjgs){
            case  $max_jjgs >= 160 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 9 / 100 - 10 * 1516;
                break;
            case  $max_jjgs >= 110 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 7 / 100 - 10 * 716;
                break;
            case  $max_jjgs >= 70 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 6 / 100 - 10 * 441;
                break;
            case  $max_jjgs >= 50 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 5 / 100 - 10 * 266;
                break;
            case  $max_jjgs >= 24 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 4 / 100 - 10 * 141;
                break;
            case  $max_jjgs >= 6 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 2 /100 - 10 * 21;
                break;
            case  $max_jjgs >= 0 * 500 + 0.0001:
                $this->jjgs = 5 * max([0,$this->jj]) * 0.6 / 100 - 10 * 0;
                break;
            default:
                $this->jjgs = 0;
                break;
        }

$res = [
            'gr_ylbx' => $this->gr_ssb,
            'qy_ylbx' => $this->qy_ssb,
            'gr_syx'  => $this->gr_syx,
            'qy_syx'  => $this->qy_syx,
            'gr_ylx'  => $this->gr_ylx,
            'qy_ylx'  => $this->qy_ylx,
            'gr_gsx'  => $this->gr_gsx,
            'qy_gsx'  => $this->qy_gsx,
            'gr_ssx'  => $this->gr_ssx,
            'qy_ssx'  => $this->qy_ssx,
            'gr_total'=> $this->gr_total,
            'qy_total'=> $this->qy_total,
            'gz'      => $this->gz,
            'lw'      => $this->gz,
            'gc'      => $this->gz,
            'jj'      => $this->jj,
            'gs'      => $this->gs,
            'bcgs'    => $this->bcgs,
            'cggs'    => $this->cggs,
            'jjgs'    => $this->jjgs,
        ];
        foreach ($res as $key => $value) $res[$key] = $this->bl($value);
        return $res;
    }

}

调用方法:

$cal = new \Servers\Calculator();
        $cal->gz = 30000;  //工资
        $cal->js = 30000;  //社保实缴基数
        $cal->jj = 40000;  //年底一次性奖金
        $cal->jy = 0;      //子女教育
        $cal->xl = 0;      //学历继续教育
        $cal->fz = 1500;   //房租/利息
        $cal->lr = 0;      //赡养老人
        $res = $cal->wage();
        echo '<pre>';
        print_r($res);

结果为:

QQ截图20191115181740.jpg

变量说明:

gr_ylbx 个人缴纳养老保险
qy_ylbx 企业缴纳养老保险
gr_syx 个人缴纳失业保险
qy_syx 企业缴纳失业保险
gr_ylx 个人医疗保险
qy_ylx 企业医疗保险
gr_gsx 个人工伤保险
qy_gsx 企业工伤保险
qy_ssx 个人生育保险
qy_ssx 企业生育保险
gr_total 个人五险和
qy_total 企业五险和
gz 基本工资
lw 劳务报酬
gc 酬稿
jj 奖金
gs 个人所得税
bcgs报酬个税
cggs 酬稿个税
jjgs 奖金个税

备注:
一、子女教育:小于3岁扣除额为0;一个孩子双方分别扣除为500;一个孩子一方扣除为1000。
二、 学历(学位)继续教育:每月400元定额扣除。
三、婚后住房贷款利息:首套按照每月1000元的标准定额扣除,可以选择由其中一方扣除。
四、婚前住房贷款利息:可以选择其中一套购买的住房,由购买方按扣除标准的100%扣除,也可以由双方对各自购买的住房分别按扣除标准的50%扣除。
五、住房租金支出:由签订租赁住房合同的承租人扣除。
六、赡养老人:纳税人为独生子女的,按照每月2000元的标准定额扣除。

Excel表格计算公式:

预缴个税:ROUND(MAX((B1-B17-B9-5000)*{0.03,0.1,0.2,0.25,0.3,0.35,0.45}-{0,210,1410,2660,4410,7160,15160},0),2)
劳务报酬:=MAX((MIN(C200.8,C20-800){0;20;30;40}%-1000*{0;0;2;7}),0)
稿酬:=IF(D20>4000,0.112D20,IF(D20>=800,0.14(D20-800),0))
一次性奖金:=LOOKUP(MAX(0.0001,E20/12),{0;6;24;50;70;110;160}500+0.0001,5MAX(0,E20){0.6;2;4;5;6;7;9}%-10{0;21;141;266;441;716;1516})

以上算法根据Excel 表格而来。

标签: 个税, 税收

非特殊说明,本博所有文章均为博主原创。

评论啦~