<commit_before>if (typeof define !== 'function') {
  var define = require('amdefine')(module);
}

define([], function() {

  //TODO rename as this is more than tax but also living feeds

  var _calculator = {};

  var rates = {
    "y2013": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    },
    "y2014": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    },
    "y2015": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    }
  };
  //TODO married
  //resided with
  var allowances = {
    "y2013": {
      "basic": 120000,
      "married": 240000,
      "child": 70000,
      "bornChild": 140000,
      "dependentSiblings": 33000,
      // "dependentDisabledParents": 38000,
      // "dependentDisabledParentsResidedWith": 76000,
      "dependent60Parents": 38000,
      "dependent60ParentsResidedWith": 76000,
      "dependent55Parents": 19000,
      "dependent55ParentsResidedWith": 38000,
      "singleParent": 120000,
      "disabledDependent": 66000
    },
    "y2014": {
      "basic": 120000,
      "married": 240000,
      "child": 70000,
      "bornChild": 140000,
      "dependentSiblings": 33000,
      // "dependentDisabledParents": 40000,
      "dependent60Parents": 40000,
      "dependent60ParentsResidedWith": 80000,
      "dependent55Parents": 20000,
      "dependent55ParentsResidedWith": 40000,
      "singleParent": 120000,
      "disabledDependent": 66000
    },
    "y2015": {
      //TODO only updated child, bornChild,  another just copied 2014, need to verify, http://www.budget.gov.hk/2015/chi/pdf/c_budgetspeech2015-16.pdf page 51
      "basic": 120000,
      "married": 240000,
      "child": 100000,
      "bornChild": 200000,
      "dependentSiblings": 33000,
      //"dependentDisabledParents": 40000,
      "dependent60Parents": 40000,
      "dependent60ParentsResidedWith": 80000,
      "dependent55Parents": 20000,
      "dependent55ParentsResidedWith": 40000,
      "singleParent": 120000,
      "disabledDependent": 66000
    }
  };

  var reduction = {
    "y2013": {
      "percent": 0.75,
      "maximum": "10000",
      "cases": ["salary", "profits", "personal"]
    },
    "y2014": {
      "percent": 0.75,
      "maximum": "10000",
      "cases": ["salary", "profits", "personal"]
    },
    "y2015": {
      "percent": 0.75,
      "maximum": "20000",
      "cases": ["salary", "profits", "personal"]
    }
  };

  _calculator.calReductions = function(year, taxPayable) {
    var exceedMax = taxPayable > reduction[year]["maximum"];
    return exceedMax ? reduction[year]["maximum"] : (taxPayable *
      reduction[year]["percent"]);
  };

  _calculator.calAllowances = function(year, key, count) {
    return allowances[year][key] * (count | 0);
  };
  //not same as deduction



  _calculator.calProgressive = function(income, year) {
    var taxable = [];
    var tax = [];<commit_msg>fix a bug<commit_after>if (typeof define !== 'function') {
  var define = require('amdefine')(module);
}

define([], function() {

  //TODO rename as this is more than tax but also living feeds

  var _calculator = {};

  var rates = {
    "y2013": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    },
    "y2014": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    },
    "y2015": {
      "0": {
        "limit": 40000,
        "rate": 0.02
      },
      "1": {
        "limit": 40000,
        "rate": 0.07
      },
      "2": {
        "limit": 40000,
        "rate": 0.12
      },
      "3": {
        "limit": Number.MAX_VALUE,
        "rate": 0.17
      },
      "standard": {
        "limit": -1,
        "rate": 0.15
      }
    }
  };
  //TODO married
  //resided with
  var allowances = {
    "y2013": {
      "basic": 120000,
      "married": 240000,
      "child": 70000,
      "bornChild": 140000,
      "dependentSiblings": 33000,
      // "dependentDisabledParents": 38000,
      // "dependentDisabledParentsResidedWith": 76000,
      "dependent60Parents": 38000,
      "dependent60ParentsResidedWith": 76000,
      "dependent55Parents": 19000,
      "dependent55ParentsResidedWith": 38000,
      "singleParent": 120000,
      "disabledDependent": 66000
    },
    "y2014": {
      "basic": 120000,
      "married": 240000,
      "child": 70000,
      "bornChild": 140000,
      "dependentSiblings": 33000,
      // "dependentDisabledParents": 40000,
      "dependent60Parents": 40000,
      "dependent60ParentsResidedWith": 80000,
      "dependent55Parents": 20000,
      "dependent55ParentsResidedWith": 40000,
      "singleParent": 120000,
      "disabledDependent": 66000
    },
    "y2015": {
      //TODO only updated child, bornChild,  another just copied 2014, need to verify, http://www.budget.gov.hk/2015/chi/pdf/c_budgetspeech2015-16.pdf page 51
      "basic": 120000,
      "married": 240000,
      "child": 100000,
      "bornChild": 200000,
      "dependentSiblings": 33000,
      //"dependentDisabledParents": 40000,
      "dependent60Parents": 40000,
      "dependent60ParentsResidedWith": 80000,
      "dependent55Parents": 20000,
      "dependent55ParentsResidedWith": 40000,
      "singleParent": 120000,
      "disabledDependent": 66000
    }
  };

  var reduction = {
    "y2013": {
      "percent": 0.75,
      "maximum": "10000",
      "cases": ["salary", "profits", "personal"]
    },
    "y2014": {
      "percent": 0.75,
      "maximum": "10000",
      "cases": ["salary", "profits", "personal"]
    },
    "y2015": {
      "percent": 0.75,
      "maximum": "20000",
      "cases": ["salary", "profits", "personal"]
    }
  };

  _calculator.calReductions = function(year, taxPayable) {
    var exceedMax = parseFloat(taxPayable) > parseFloat(reduction[year][
      "maximum"
    ]);
    return exceedMax ? reduction[year]["maximum"] : (taxPayable *
      reduction[year]["percent"]);
  };

  _calculator.calAllowances = function(year, key, count) {
    return allowances[year][key] * (count | 0);
  };
  //not same as deduction



  _calculator.calProgressive = function(income, year) {
    var taxable = [];
    var tax = [];
{'fraction_non_alphanumeric': 0.16671098112204202, 'fraction_numerical': 0.1074182398298325, 'mean_word_length': 1.9984057393383818, 'pattern_counts': {'":': 200, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2820818', 'n_tokens_mistral': 3184, 'n_tokens_neox': 2530, 'n_words': 525}