Two things were wrong with this code: 1. The exchange rate conversion was backward. Since we work in USD, I removed the conversion and used value_usd instead. 2. The calculation of pscale.factor was incorrect. If the old value is 1000, and we need to get to 1020, the record to be inserted must have a value of 20, thus the value for factor needs to be: (1020 - 1000) / 1000 = (1020 / 1000) - 1 = 0.02 0.02 * 1000 = 20, which is inserted in the new record. The subtraction was missing before, which of course caused WAY wrong numbers that should have been caught a long time ago. It was doing: 1020 / 1000 = 1.02 1.02 * 1000 = 1020 was inserted, doubling the intended adjustment. |
||
|---|---|---|
| build | ||
| inquirey | ||
| Master Template.xlsm_EXPORTS | ||
| offline | ||
| route_sql | ||
| VBA | ||
| .env.sample | ||
| .gitignore | ||
| columns.md | ||
| create_certs.sh | ||
| forecast_api.service | ||
| index.js | ||
| LICENSE | ||
| Master Template.xlsm | ||
| msauth.html | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| sample_request.json | ||
This will not work without exactly the right database schema which is out of scope. this is only the running process part of the forecast.
Setup
- git clone (to //opt for verbatim use of the .service file)
npm install- create certs:
chmod 700 create_certs.sh,./create_certs.sh - clone sample env
cp .env.sample .envand specify 1) database creds 2) working directory 3) listening port - run:
node index.js - navigate to
https://localhost:8080/to valide it's connectable - open the spreadsheet and specify the target connection
additionally, to setup as service
- copy .service file to //etc/systemd/system/ (adjust user/working direct if needed)
sudo systemctl enable forecast_api.service
Initial Forecast
- all SQL depends on unchanged core sales matrix table schema