Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kasko/quote-calculator-js

Package Overview
Dependencies
Maintainers
10
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kasko/quote-calculator-js

KASKO Spreadsheet Quote Calculator

  • 1.2.1
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
10
Weekly downloads
 
Created
Source

quote-calculator-js-lib

KASKO Spreadsheet Quote Calculator Lib.

When in doubt, consult documentation!

Requirements

  • Node 16+
  • Yarn 1+
  • Editorconfig plugin

Usage

yarn add @kasko/quote-calculator-js

Example:

import { Calculator } from '@kasko/quote-calculator-js';

// Initiate calculator instance
const calculator = new Calculator();

(async () => {
  // Relative location of xlsx file
  const path = './kasko-demo.xlsx';
  /**
   * This will fill `Field Value` column based on
   * `Input field` name match. It will replace empty
   * fields with `null`.
   */
  const input = {
    duration: 'P5Y',
    policy_start_date: '2018-02-10',
  };
  /**
   * This will fill `Field Value` column based on
   * `Predefined field` name match. It will leave default
   * values as is, only replacing the ones provided in config.
   */
  const config = {
    tax_rate: 0.05
  };

  // Loads xlsx file, parses it and fills input and config values.
  await calculator.init(path, input, config);

  /**
   * To get calculated field `isValid` column.
   *
   * @example output:
   * ```json
   * {
   *   duration: true,
   *   policy_start_date: true
   * }
   * ```
   */
  const validation = calculator.validateInput();

  /**
   * To get calculated output data based on
   * `Quote field` and `Quote value` columns.
   *
   * @example output:
   * ```json
   * {
   *   gross_premium: 30000,
   *   extra_data: {
   *     flow: 'default'
   *   }
   * }
   * ```
   */
  const output = calculator.getOutput();
})()

In case of loading parsed xlsx file as json:

+const workbook = require('./kasko-demo.json');
-const path = './kasko-demo.xlsx';
 ...
+await calculator.init(workbook, input, config);
-await calculator.init(path, input, config);

Development

Installation

yarn install

Building

yarn build

Developing with real pricing: First you must edit the development file /index.js to take correct input and pricing file.

Then run build command.

And finally run:

yarn start

To execute that development file and see the result.

Testing

Single run (of everything):

yarn test

Testing formulas

yarn test:formulas

Testing pricing

yarn test:pricing

Running generic tests

yarn test:generic

FAQs

Package last updated on 12 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc