zoukankan      html  css  js  c++  java
  • 个人所得税计算

    写成一个方法calcMoney

    data(){

    return{

    index:-1, // 个人所得税所属的纳税阶段,
    incomeData:[{incomeTax: "0.5",money: 30000}, {incomeTax: "0.8",money: 66000}, {incomeTax: "1",money: 100000}], //个人所得税计算区间,是活的,后台返回的
    formData:{
    demandBudget:0, // 预算金额,不是固定的,是活的,输入预算金额计算个人所得税,
    income:0,// 个人所得税金额

    }

    }

    }

    
    
    // 个人所得税计算

    calcMoney() {

    for(let i=0;i<this.incomeData.length;i++){
    if(this.formData.demandBudget<=this.incomeData[i].money){
    this.index = i;
    break;
    }else{
    this.index = -1;
    }
    }
    if(this.index === 0){
    // 还未到纳税标准
    this.formData.income = 0
    }
    else if(this.index>0){
    // 在纳税区间内,未超过最高纳税标准
    let money1 = 0;
    let money2 = 0;
    money1 = (this.formData.demandBudget - this.incomeData[this.index-1].money)*this.incomeData[this.index-1].incomeTax*0.01;
    for(let i =0;i<=this.index;i++){
    if(i-2>=0){
    money2 = money2+((this.incomeData[i-1].money-this.incomeData[i-2].money)*this.incomeData[i-2].incomeTax*0.01);
    }

    }
    this.formData.income = money1 + money2;
    }
    else{
    // 已超过最高纳税金额
    if(this.formData.demandBudget>0){
    let money1 = 0;
    let money2 = 0;
    let leng = this.incomeData.length; // 个人所得税纳税标准条数
    money1 = (this.formData.demandBudget - this.incomeData[leng-1].money)*this.incomeData[leng-1].incomeTax*0.01;
    for(let i =0;i<=leng;i++){
    if(i-2>=0){
    money2 = money2+((this.incomeData[i-1].money-this.incomeData[i-2].money)*this.incomeData[i-2].incomeTax*0.01)
    }

    }
    this.formData.income = money1 + money2;

    }
    }

     

    }

  • 相关阅读:
    一些简单的逻辑题
    3种数据类型之间的转换
    搭建selenium + Python环境的总结:
    杂记
    Eclemma的安装
    LR----实现WebService测试
    LR--实现HTTP协议的接口测试
    Loadrunner---解决乱码问题
    selenium常用API实例
    JMeter中响应数据显示乱码问题解决
  • 原文地址:https://www.cnblogs.com/xiaoleilei123/p/13571921.html
Copyright © 2011-2022 走看看