export type AmortizationStrategy = (totalAmount: number, annualInterestRate: number, years: number) => number;

export const frenchMethod: AmortizationStrategy = (amount, interest, years) => {
  const periods = years * 12;
  const monthlyInterest = interest / 12;
  const quota = (amount * monthlyInterest) / (1 - Math.pow(1 + monthlyInterest, -periods));
  return Number(quota.toFixed(1));
};
