pollseed/mf-cloud-aid

所得税計算用メモ

pollseed opened this issue · 0 comments

router.get('/income', function(req, res, next) {
  var income = req.query.income,
      tax = new Tax();
  tax.build(income, true, 0,0,0);
  console.log(tax.getIncomeTax());
});

class Tax {
  build(
    income,
    is_blue_return_special,
    social_insurance,
    life_insurance,
    earthquake_insurance) {
    var deduction = 0;
    if (is_blue_return_special) {
      deduction += 650000;
    } else {
      deduction += 100000;
    }
    deduction += social_insurance + life_insurance + earthquake_insurance;
    income = income - deduction;

    if (income <= 1950000) {
      this.tax_rate = 5;
      this.deduction = 0;
    } else if (1950000 < income && income <= 3300000) {
      this.tax_rate = 10;
      this.deduction = 97500;
    } else if (3300000 < income && income <= 6950000) {
      this.tax_rate = 20;
      this.deduction = 427500;
    } else if (6950000 < income && income <= 9000000) {
      this.tax_rate = 23;
      this.deduction = 636000;
    } else if (9000000 < income && income <= 18000000) {
      this.tax_rate = 33;
      this.deduction = 1536000;
    } else if (18000000 < income && income <= 40000000) {
      this.tax_rate = 40;
      this.deduction = 2796000;
    } else {
      this.tax_rate = 45;
      this.deduction = 4796000;
    }
    this.income = income;
    console.log(`tax_rate: ${this.tax_rate}`);
    console.log(`deduction: ${this.deduction}`);
    console.log(`income: ${this.income}`);
  }
  getIncomeTax() {
    return ((this.income * this.tax_rate / 100) - this.deduction);
  }
}