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:
- ## 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:
- ## 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:
13536
- ## 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:
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:
- Install dependencies with:
Developing
Built With
The following dependencies were used:
"devDependencies": "dependencies":
All of which are automatically installed with the command:
npm install
Prerequisites
What is needed to set up the dev environment.
- Instal Node.js, see instructions
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-librarycd hash-anticipation-calc-librarynpm installnpm 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