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

hash-anticipation-calc-library

v0.0.1

Published

Calculates installment anticipation.

Downloads

4

Readme

Logo of the project

Hash Library Challenge - This project presents the construction of a library using only javascript to perform the advance calculation of installments in a given sale.

The project does not use any features like Reatc, Vue, Angular, Polymer, etc. Only Javascript with Polyfill is used.

The following methods are available:

  • calcHashAnticipationDefault

Performs the default calculation for the advance periods previously defined on the later day, 15, 30, and 90 days.

  • Call Example: calcHashAnticipationDefault(3, 4, 150) calcHashAnticipationDefault(installments, mdrPercentage, grossValue)
  • installments - Identifies the number of installments to be considered in the calculation.
  • mdrPercentage - Identifies the MDR percentage that will be used to calculate the discount.
  • grossValue - Amount of the total over which the anticipation will be applied.
  • Return Example:
 [
   { anticipationDate: "tomorrow", discountedInstallment: "132.67" },
   { anticipationDate: "15 days", discountedInstallment: "135.36" },
   { anticipationDate: "30 days", discountedInstallment: "138.24" },
   { anticipationDate: "90 days", discountedInstallment: "144.00" } 
 ]
  • calcGenericAnticipationToObject

Performs the calculation for any advance date, displaying the result in the structure of an object, only for the requested period.

  • Call Example: calcGenericAnticipationToObject(3, 4, 150, 15) calcGenericAnticipationToObject(installments, mdrPercentage, grossValue, numberOfDays)
  • installments - Identifies the number of installments to be considered in the calculation.
  • mdrPercentage - Identifies the MDR percentage that will be used to calculate the discount.
  • grossValue - Amount of the total over which the anticipation will be applied.
  • numberOfDays - Specifies the period (number of days) that will be used as a reference for the anticipation calculation.
  • Return Example:
 [
 { anticipationDate: 15, discountedInstallment: "135.36" }
]
  • calcGenericAnticipationToNumber

Performs the calculation for any advance date, returning the result in numeric format.

  • Call Example: calcGenericAnticipationToNumber(3, 4, 150, 15) calcGenericAnticipationToObject(installments, mdrPercentage, grossValue, numberOfDays)
  • installments - Identifies the number of installments to be considered in the calculation.
  • mdrPercentage - Identifies the MDR percentage that will be used to calculate the discount.
  • grossValue - Amount of the total over which the anticipation will be applied.
  • numberOfDays - Specifies the period (number of days) that will be used as a reference for the anticipation calculation.
  • Return Example:
 135.36
  • calcGenericAnticipationToNumber

Performs the calculation of a value subtracted from a certain percentage by returning an object with information of the original value, the discount percentage, and the amount already discounted.

  • Call Example: calcDiscountPercentage(10, 150) calcDiscountPercentage(mdrPercentage, grossValue)
  • mdrPercentage - Identifies the MDR percentage that will be used to calculate the discount.
  • grossValue - Amount of the total over which the anticipation will be applied.
  • Return Example:
[
 { originalValue: 150, percentage: 10, discountedValue: 135 }
]

Installing / Getting started

To start in your node server:

  • Instal Node.js, see instructions

  • To start your Node server:

    • Install dependencies with: npm install
    • Generate library in / lib directory: npm run build
    • To use in your project perform the following import:
import {
    calcGenericAnticipationToNumber,
    calcHashAnticipationDefault,
    calcDiscountPercentage,
    calcGenericAnticipationToJson
} from 'hash-anticipation-calc-library'

Developing

Built With

The following dependencies were used:

    "devDependencies": {
    "@babel/core": "^7.3.4",
    "@babel/plugin-proposal-class-properties": "^7.3.4",
    "@babel/preset-env": "^7.3.4",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.5",
    "eslint": "^5.15.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "jest": "^24.1.0",
    "webpack": "^4.29.6",
    "webpack-cli": "^3.2.3"
  }
  "dependencies": {
    "@babel/plugin-transform-arrow-functions": "^7.7.4",
    "@babel/plugin-transform-runtime": "^7.7.4",
    "@babel/polyfill": "^7.7.0",
    "@babel/runtime": "^7.7.6"
  }

All of which are automatically installed with the command:

npm install

Prerequisites

What is needed to set up the dev environment.

Setting up Dev

Here's a brief intro about what a developer must do in order to start developing the project further:

git clone https://github.com/orlandopamplona/hash-anticipation-calc-library
cd hash-anticipation-calc-library
npm install
npm run build

Deploying / Publishing

npm run build

Its library is already available in the npm repository to install using:

npm install hash-anticipation-calc-library

Running tests

Run the following command:

npm run test

The tests were implemented using jest