@harvest-profit/model-helpers
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -81,2 +81,3 @@ Object.defineProperty(exports, "__esModule", { | ||
exports['default'] = Application; | ||
exports['default'] = Application; | ||
//# sourceMappingURL=application.js.map |
@@ -231,2 +231,3 @@ Object.defineProperty(exports, "__esModule", { | ||
exports['default'] = Contract; | ||
exports['default'] = Contract; | ||
//# sourceMappingURL=contract.js.map |
@@ -81,2 +81,3 @@ Object.defineProperty(exports, "__esModule", { | ||
exports['default'] = Crop; | ||
exports['default'] = Crop; | ||
//# sourceMappingURL=crop.js.map |
@@ -5,2 +5,3 @@ /** | ||
* @property { (number|string) } value The value of the setting | ||
*/ | ||
*/ | ||
//# sourceMappingURL=setting.js.map |
@@ -22,2 +22,3 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.Contract = _contract2['default']; | ||
exports.Crop = _crop2['default']; | ||
exports.Crop = _crop2['default']; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@harvest-profit/model-helpers", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "All the calculations", | ||
@@ -13,3 +13,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "babel src -d dist", | ||
"build": "yarn run clean && babel src --source-maps -d dist", | ||
"build-docs": "jsdoc src/* -t ./node_modules/ink-docstrap/template --configure jsdoc.conf.json --destination docs --readme README.md", | ||
@@ -16,0 +16,0 @@ "clean": "rm -rf ./dist", |
@@ -11,3 +11,3 @@ <div style="text-align: center"> | ||
```bash | ||
yarn add @harvest-profit/harvest-profit-calculations | ||
yarn add @harvest-profit/model-helpers | ||
``` | ||
@@ -19,13 +19,11 @@ | ||
```javascript | ||
import { Contract } from '@harvest-profit/harvest-profit-calculations'; | ||
import { Contract } from '@harvest-profit/model-helpers'; | ||
const contractUrl = Contract.translateContractTypeToUrl(Contract.hedgeToArriveType); | ||
console.log(contractUrl); // Outputs: `hedge_to_arrive` | ||
const contractUrl = Contract.translateContractTypeToName('hedge_to_arrive'); | ||
console.log(contractUrl); // Outputs: `Hedge To Arrive` | ||
``` | ||
## Additional Notes | ||
This package is meant to standardize and document all the calculations used in the Harvest Profit App. The `Calculations` module is a good example of that. That module contains very simple functions like `calculateAvgCashPrice` which simply divides revenue by sold production, but each function documents on how to get that number which is important. If you are new to the project, that would be a good place to start reading some documentation. | ||
You should NEVER be checking what type the contract is, or setting the contract type without using the module defined types. Example: | ||
As for standardizing, the `Contract` module is a good example of that. You should NEVER be checking what type the contract is, or setting the contract type without using the module defined types. Example: | ||
```javascript | ||
@@ -40,9 +38,2 @@ // Example of BAD | ||
// Example of GOOD | ||
if (contract.type_name === Contract.cashSaleType) { | ||
// ... do something | ||
} | ||
``` | ||
Or better yet... | ||
```javascript | ||
// Example of GOOD | ||
if (Contract.isCashSaleType(contract.type_name)) { | ||
@@ -49,0 +40,0 @@ // ... do something |
43480
12
359
75