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

@fastekph/onepayfinformula-sdk

v1.1.3

Published

An SDK for financial formulas and computations.

Downloads

31

Readme

ONEPAYFinFormula SDK

npm version node npm downloads npm downloads npm downloads npm downloads dependents types license

An SDK for financial formulas and computations.


DISCLAIMER: ONEPAYFinFormula SDK is a tool developed specifically for financial computations. While the SDK is intended for use in all countries, it is important to note that certain features may not be suitable for your specific jurisdiction as our formulas are primarily based on regulations in the Philippines. Therefore, it is recommended to review and validate the applicability of the SDK for your country's regulations before use.

The creators of this SDK make every effort to ensure its accuracy and reliability. However, they cannot guarantee the absence of errors or losses that may arise from its utilization. Therefore, the use of ONEPAYFinFormula SDK is at your own risk, and the creators disclaim any liability for any damages or losses incurred as a result of its use.

Please exercise caution and undertake proper due diligence when using the SDK to mitigate potential risks and ensure compliance with local regulations.

Note: This disclaimer is for informational purposes only and does not constitute legal advice. It is advisable to consult with legal professionals familiar with your specific jurisdiction for accurate guidance.

Documentation

Contents

Installation

$ npm i @fastekph/onepayfinformula-sdk

Sample Usage

MathUtil

/**
 * computeVatAmount(amount, targetDecimalPlace)
 * @amount [number] amount of the transaction to round off
 * @targetDecimalPlace [number] desired/target decimal place to round off to 
 **/
MathUtil.roundoff(15.12345, 2)

/**
 * computePercentage(amount, percentage)
 * @amount [number] amount of the transaction to compute percentage from
 * @percentage [number] percentage to compute from the transaction amount 
 **/
MathUtil.computePercentage(100.00, 10.00)

/**
 * decimalToCentavo(amount)
 * @amount [number] amount of the transaction to convert from decimal to centavo format
 **/
MathUtil.decimalToCentavo(5.00)

/**
 * centavoToDecimal(amount)
 * @amount [number] amount of the transaction to convert from centavo to decimal format
 **/
MathUtil.centavoToDecimal(500)

Taxation

import sdk from '@fastekph/onepayfinformula-sdk'

const taxation = sdk.ph.fastek.Taxation

/**
 * @VAT_RATE [number] default value-added tax rate percentage
 **/
taxation.VAT_RATE

/**
 * @WITHHOLDING_TAX_RATE [number] default withholding tax rate percentage
 **/
taxation.WITHHOLDING_TAX_RATE

/**
 * computeVatAmount(amount, vatInclusive)
 * @amount [number] amount of the transaction to compute vat
 * @vatInclusive [boolean] tagging if the amount is vat inclusive or not 
 **/
taxation.computeVatAmount(1458.00, true)
taxation.computeVatAmount(1292.79, false)

/**
 * computeVatAmountWithCustomRate(rate, amount, vatInclusive)
 * @rate [number] custom tax rate percentage to use
 * @amount [number] amount of the transaction to compute vat
 * @vatInclusive [boolean] tagging if the amount is vat inclusive or not 
 **/
taxation.computeVatAmountWithCustomRate(12.00, 1458.00, true)
taxation.computeVatAmountWithCustomRate(12.00, 1292.79, false)

/**
 * addVatAmount(amount)
 * @amount [number] amount of the transaction to add vat to
 **/
taxation.addVatAmount(1292.79)

/**
 * addVatAmountWithCustomRate(rate, amount)
 * @rate [number] custom tax rate percentage to use
 * @amount [number] amount of the transaction to add vat to
 **/
taxation.addVatAmountWithCustomRate(12.00, 1292.79)

/**
 * lessVatAmount(amount)
 * @amount [number] amount of the transaction to deduct vat to
 **/
taxation.lessVatAmount(1458.00)

/**
 * lessVatAmountWithCustomRate(rate, amount)
 * @rate [number] custom tax rate percentage to use
 * @amount [number] amount of the transaction to deduct vat to
 **/
taxation.lessVatAmountWithCustomRate(12.00, 1458.00)

/**
 * computeWithholdingTaxAmount(amount)
 * @amount [number] amount of the transaction to compute withholding tax
 **/
taxation.computeWithholdingTaxAmount(1.00)

/**
 * computeWithholdingTaxAmountWithCustomRate(amount)
 * @rate [number] custom tax rate percentage to use
 * @amount [number] amount of the transaction to compute withholding tax
 **/
taxation.computeWithholdingTaxAmountWithCustomRate(2.00, 1.00)

Receipt

import sdk from '@fastekph/onepayfinformula-sdk'

/**
 * Notes:
 * 
 * - discountType allowable values are "promos", which are durational or event-based; 
 *   and "specialDiscounts", which are based on the person's classification such as 
 *   Persons-with-Disability (PWD), Senior Citizen, Solo Parent
 * 
 * - it is adviseble to use only one of the following, discountAmount or discountedPercentage, 
 *   pass 0 value on the field if it will not be used
 * 
 * - totalZeroRatedSalesAmount was defaulted to 0.00 for the meantime, computational formula
 *   will be added on the future updates
 *
 * - .addItem can be repeated to add multiple items 
 *
 * - receipt builder will output a Receipt object having the following fields
 *   {
 *      "summarizedItems": [
 *         { 
 *            "name": "",
 *            "amount": 0,
 *            "quantity": 0,
 *            "grossSalesAmount": 0,
 *            "isVatExempt": false,
 *            "regularDiscountAmount": 0,
 *            "specialDiscountAmount": 0,
 *            "vatableSalesAmount": 0,
 *            "vatAmount": 0,
 *            "vatExemptSalesAmount": 0,
 *            "zeroRatedSalesAmount": 0,
 *            "netSalesAmount": 0,
 *      ]
 *      "totalGrossSalesAmount": 0.00,
 *      "totalRegularDiscountAmount": 0.00,
 *      "totalSpecialDiscountAmount": 0.00,
 *      "totalVatableSalesAmount": 0.00,
 *      "totalVatAmount": 0.00,
 *      "totalZeroRatedSalesAmount": 0.00,
 *      "totalVatExemptSalesAmount": 0.00,
 *      "totalNetSalesAmount": 0.00
 *   }
 **/
const receipt = new sdk.ph.fastek.Receipt.Builder()
    .addItem({
        name: "HERSHEYS",
        amount: "10",
        discountType: "promos",
        discountCode: "PROMO",
        isVatExempt: "true",
        discountAmount: "5",
        discountedPercentage: "0",
        quantity: "1"
    })
    .build()

const summarizedItems = receipt.summarizedItems

summarizedItems.forEach(item => {
    console.log("name: " + item.name)
    console.log("amount: " + item.amount)
    console.log("quantity: " + item.quantity)
    console.log("grossSalesAmount: " + item.grossSalesAmount)
    console.log("isVatExempt: " + item.isVatExempt)
    console.log("regularDiscountAmount: " + item.regularDiscountAmount)
    console.log("specialDiscountAmount: " + item.specialDiscountAmount)
    console.log("vatableSalesAmount: " + item.vatableSalesAmount)
    console.log("vatAmount: " + item.vatAmount)
    console.log("vatExemptSalesAmount: " + item.vatExemptSalesAmount)
    console.log("zeroRatedSalesAmount: " + item.zeroRatedSalesAmount)
    console.log("netSalesAmount: " + item.netSalesAmount)
})

console.log("totalGrossSalesAmount: " + receipt.totalGrossSalesAmount)
console.log("totalRegularDiscountAmount: " + receipt.totalRegularDiscountAmount)
console.log("totalSpecialDiscountAmount: " + receipt.totalSpecialDiscountAmount)
console.log("totalVatableSalesAmount: " + receipt.totalVatableSalesAmount)
console.log("totalVatAmount: " + receipt.totalVatAmount)
console.log("totalVatExemptSalesAmount: " + receipt.totalVatExemptSalesAmount)
console.log("totalZeroRatedSalesAmount: " + receipt.totalZeroRatedSalesAmount)
console.log("totalNetSalesAmount: " + receipt.totalNetSalesAmount)