npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

calculo-cuotas-frances-co

v1.8.0

Published

Script para el cálculo de cuotas según un valor y un enganche ingresado.

Downloads

10

Readme

calculo-cuotas-frances

Librería para el cálculo/generación de cuotas dado un valor inicial o pie. Opcionalmente, se puede pasar por parámetro un objeto de configuración, el cual alterará los cálculos según los valores dados en dicha configuración.

Install

npm install -S calculo-cuotas-frances

Usage

import getSimulation from 'calculo-cuotas-frances'
// Se necesita pasar un objeto con 2 propiedades obligatorias: creditValue y carValue.
const opts = {
    creditValue,
    carValue
}

const installments = getSimulation(opts)

// =>
        Simulation {
            creditValue: 5600000,
            carValue: 9000000,
            installments: [
                Installment { plan: 18, amount: 429678 },
                Installment { plan: 24, amount: 347644 },
                Installment { plan: 36, amount: 266292 },
                Installment { plan: 48, amount: 226287 },
                Installment { plan: 60, amount: 202809 },
                Installment { plan: 72, amount: 187580 }
            ],
            _config: {
                 installments: [ 18, 24, 36, 48, 60, 72 ],
                interest_rate: 0.0158,
                insurance: {
                    life: 0.0008,
                    unemployment: 0.0006,
                    vehicle: 0.05,
                    vehicle_iva: 0.19
                },
                charges: { movable_warranty: 200000, additive_charge_rate: 0.02 },
                max_credit_amount: 40000000,
                _defaultConfig: true
            },
            _errors: []
        }

Using a custom configuration object

import getSimulation from 'calculo-cuotas-frances
const CONFIG = {} // OBJETO DE CONFIGURACION

const opts = {
    creditValue,
    carValue,
    config: CONFIG
}

const installments = getSimulation(opts)

// =>  Simulation {
       ...simulationObject,
        _config: {
            ..CONFIG // CONFIGURACION PASADA POR PARAMETRO
        }
        _errors: []  // NO HUBO ERRORES
      }

NOTE: al pasar la propiedad config como un objeto de configuración personalizado, este objeto será validado internamente por el método validateConfigObject().

En caso de que el objeto pasado por parámetro contenga errores, se aplicará el objeto de configuración por defecto.

// =>
    Simulation {
        ...simulationObject,
        // CONFIGURACION PASADA POR PARAMETRO ,
        _config: {
            installments: [ 18, 24, 36, 48, 60, 72 ],
            interest_rate: 0.0158,
            insurance: {
                life: 0.0008,
                unemployment: 0.0006,
                vehicle: 0.05,
                vehicle_iva: 0.19
            },
            charges: {
                movable_warranty: 200000,
                additive_charge_rate: 0.02
            },
            max_credit_amount: 40000000,
            _defaultConfig: true
        },
       _errors: [
            {
                name: 'ValidationError',
                message: 'insurance.vehicle is a required field'
            }
       ]
    }

Configuration object schema

De que tipo es cada propiedad y si es requerida

const configObjectSchema = yup.object().shape({
    installments: yup.array().required(),
    interest_rate: yup.number().required(),
    insurance: yup.object().shape({
        life: yup.number().required(),
        unemployment: yup.number().required(),
        vehicle: yup.number().required(),
        vehicle_iva: yup.number().required(),
    }),
    charges: yup.object().shape({
        movable_warranty: yup.number().required(),
        additive_charge_rate: yup.number().required(),
    }),
    max_credit_amount: yup.number().required(),
    _defaultConfig: yup.bool().required(),
})

Running library

Podemos ejecutar la librería sobre node.js ejecutando el script por consola npm start y dentro de la misma, nos dará la opción de ingresar un monto inicial y un pie y así poder generar un plan de cuotas.

npm start

Running tests

npm test