// IRS Publication 946, Appendix A — GDS optional depreciation tables (percentage of unadjusted basis
// deducted each recovery year), half-year convention. 3/5/7/10-year property use 200% declining balance;
// 15/20-year property use 150% declining balance. These are the published, rounded percentages used for
// the "MACRS Tables" method (MT200); the formula method reproduces them mathematically. Mid-quarter and
// other conventions fall back to the formula in the engine.

const GDS_HALF_YEAR = {
  3: [33.33, 44.45, 14.81, 7.41],
  5: [20.00, 32.00, 19.20, 11.52, 11.52, 5.76],
  7: [14.29, 24.49, 17.49, 12.49, 8.93, 8.92, 8.93, 4.46],
  10: [10.00, 18.00, 14.40, 11.52, 9.22, 7.37, 6.55, 6.55, 6.56, 6.55, 3.28],
  15: [5.00, 9.50, 8.55, 7.70, 6.93, 6.23, 5.90, 5.90, 5.91, 5.90, 5.91, 5.90, 5.91, 5.90, 5.91, 2.95],
  20: [3.750, 7.219, 6.677, 6.177, 5.713, 5.285, 4.888, 4.522, 4.462, 4.461, 4.462, 4.461, 4.462, 4.461, 4.462, 4.461, 4.462, 4.461, 4.462, 4.461, 2.231]
};

// Returns the published half-year percentage array for a recovery period (years), or null if unsupported.
function gdsHalfYear(years) {
  return GDS_HALF_YEAR[years] || null;
}

module.exports = { gdsHalfYear };
