calculateCardInstallment function calculates the total price and the amount of each installment for a payment plan with interest.ts
import { calculateCardInstallment } from "@arkyn/shared";
props object with the following fields:cashPricenumbernumberInstallmentsnumberfees (optional)number0.0349 (3.49%)totalPrice: The total price to be paid, rounded to two decimal places.installmentPrice: The amount of each installment, rounded to two decimal places.fees) is 0 or the number of installments (numberInstallments) is 1, no interest will be charged.Error("Number of installments must be greater than 0"): If the number of installments is less than or equal to 0.Error("Fees must be greater than or equal to 0"): If the interest rate is less than 0.javascript
import { calculateCardInstallment } from "./calculateCardInstallment";const resultado = calculateCardInstallment({cashPrice: 1000,numberInstallments: 12,fees: 0.02, // 2% interest});console.log(resultado);// Output: { totalPrice: 1124.62, installmentPrice: 93.72 }