---
# System prepended metadata

title: Pricing calculator

---

# Pricing calculator

Goal: allow clients to create raw estimate of our solution
We need flexible solution where math could be easily modified without dev team intervention.

## assumption
- we want to embed calculator to external resource
- we have no fixed model of price calculation - multifactor model
- client input limited to less then 10 parameters, new parameters should be added by developers (not by manager)

## idea
We can store user input as cells in google sheet, and define one cell for result.

input param     | value     | calc   | reuslt 
----            | -----     | ----   | ------
count of panels | 50        | magic  | 30000 usd 
continent       | australia | magic  |
some param      | value     | magic  |

Using google sheets as engine allows us to benefit from sheets flexibility. Any manager will be able to add complex calculations, with some substitution tables etc (magic!). But! It's only for small amount of visitors on site.

Google Script has daily limits: https://developers.google.com/apps-script/guides/services/quotas
*90 min* of compute time a day on a free accounts
*6 hr* of compute time a day on a gsuite accounts

If you expect extensive price api usage, that wouldn't fit to daily limits of gsuite then we should check for other solution.
For example if you have less then 1000 users in a day it's ok to use google apps script as compute engine.

## implementation
- we will create google sheets instance, with list of input parameters and ask you to fill it with calculation formulas. Please remember that less input parameters for user input will boost amount of filled requests for calculation
- We will attach git repo to google apps script using 	
https://github.com/google/clasp
- we will write http api endpoint using google apps script (it should implement correct CORS, it should use lock service to avoid race condition if parallel requests recieved)
- we will create widget, using [svelte](https://svelte.dev/) or similar instrument, widget will ask visitor for list of fields, and then estimate price using API created on previous step
- style widget to fit design (or corporate style)

## examples
Widget: https://global24.ua/wid
CLASP: no visible example, it just works as backend :)