\n {term.quotaText && (\n
\n \n \n
\n \n \n \n \n
\n \n \n \n )}\n
\n )\n}\n","export const credit = {\n rate: 15.60/100,\n terms: [ 12, 24, 36, 48, 60 ],\n paymentPeriod: 12,\n} ","import { credit } from 'constants/credit'\n\n/* Fornula para el calculo de la cuota en base a un plazo, capital inicial y tasa de interes\n A = VP ((i(1 + i)^n) / ((1 + i)^n – 1))\n*/\nexport const quotaFormula = (amount: string) => {\n const regex = /\\./g\n const capital = parseInt(amount.replace(regex, ''),10)\n return credit.terms.map((term) => {\n return quotaSingleFormula(capital, term)\n })\n}\n\nexport const quotaSingleFormula = (capital: number, term: number) => {\n const efectiveRate = credit.rate / credit.paymentPeriod\n const numerator = efectiveRate * Math.pow(1 + efectiveRate, term)\n const denominator = Math.pow(1 + efectiveRate, term) - 1\n const quota = capital * (numerator / denominator)\n const queotaWithInsurance = quota + ((1.1232 / 100) * capital * 30) / 360\n const totalInterest = calcTotalInterest(term, capital, quota)\n const insurance = totalInterest * (10.83 / 100) \n const totalAPagar =\n capital +\n parseFloat(totalInterest.toFixed(2)) +\n parseFloat(insurance.toFixed(2))\n const numberFormater = new Intl.NumberFormat('de-DE', {\n minimumFractionDigits: 2,\n })\n return {\n capital: capital.toLocaleString('de-DE'),\n term: term,\n quota: numberFormater.format(Number(queotaWithInsurance.toFixed(2))),\n totalInterest: numberFormater.format(Number(totalInterest.toFixed(2))),\n seguro: numberFormater.format(Number(insurance.toFixed(2))),\n total: numberFormater.format(Number(totalAPagar.toFixed(2))),\n }\n}\n\nconst calcTotalInterest = (term: number, capital: number, quota: number) => {\n let balance = capital\n const quotasRate: number[] = []\n for (let i = 0; i < term; i++) {\n const quotaRate = (balance * credit.rate) / credit.paymentPeriod\n balance = balance - (quota - quotaRate)\n quotasRate.push(quotaRate)\n }\n return quotasRate.reduce((a, b) => a + b, 0)\n}\n\n","import React, { useEffect, useState } from 'react'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { animated } from 'react-spring'\nimport { setTermState, setInitialQuota } from 'context/reducer/quota'\nimport { Grid } from '@mui/material'\nimport { RootState } from 'context'\nimport { quotaSingleFormula } from 'utils/quotaFormula'\nimport { QuotaState } from 'interfaces/quota'\nimport { CreditDetail } from '../credit-detail'\nimport { DEBOUNCE_TIMER } from 'constants/index'\nimport './index.css'\nimport useFadeInFromAvobe from 'hooks/useFadeInFromAvobe'\n\nexport const TermInput = () => {\n const dispatch = useDispatch()\n const props = useFadeInFromAvobe(0)\n\n const { amount } = useSelector