New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@harvest-profit/harvest-profit-calculations

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harvest-profit/harvest-profit-calculations - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

56

dist/calculations/crop.js

@@ -22,2 +22,14 @@ Object.defineProperty(exports, "__esModule", {

/**
* @typedef {Object} crop
* @property {number} market_crop_id The market crop associated to the crop
* @property {string} name The name of the crop
*/
/**
* @typedef {Object} market_crop
* @property {string} name The name of the market crop
* @property {string} symbol The market symbol of the market crop
*/
/**
* Crops are what people plant in the ground

@@ -54,2 +66,46 @@ * @module Crop

Crop.findMarketCropForCrop = function (crop, marketCrops) {
if (crop.market_crop_id) {
return _lodash2['default'].find(marketCrops, function (mc) {
return mc.id === crop.market_crop_id;
});
}
var namesToFutures = {
Corn: 'ZC',
'Corn - Irrigated': 'ZC',
'Corn - Misc': 'ZC',
'Corn - Non-GMO': 'ZC',
'Corn - Seed': 'ZC',
'Hard Red Wheat': 'KE',
'Hard Red Wheat - Irrigated': 'KE',
'Hard Red Wheat - Misc': 'KE',
'Hard Red Wheat - Non-GMO': 'KE',
'Hard Red Wheat - Seed': 'KE',
Oats: 'ZO',
'Sorghum (Corn': 'ZC',
'Soybean Meal': 'ZM',
'Soybean Oil': 'ZL',
Soybeans: 'ZS',
'Soybeans - Irrigated': 'ZS',
'Soybeans - Misc': 'ZS',
'Soybeans - Non-GMO': 'ZS',
'Soybeans - Seed': 'ZS',
'Spring Wheat': 'MW',
'Spring Wheat - Irrigated': 'MW',
'Spring Wheat - Misc': 'MW',
'Spring Wheat - Non-GMO': 'MW',
'Spring Wheat - Seed': 'MW',
Wheat: 'ZW',
'Wheat - Irrigated': 'ZW',
'Wheat - Misc': 'ZW',
'Wheat - Non-GMO': 'ZW',
'Wheat - Seed': 'ZW'
};
return _lodash2['default'].find(marketCrops, function (mc) {
return mc.symbol === namesToFutures[crop.name];
}) || null;
};
exports['default'] = Crop;

2

package.json
{
"name": "@harvest-profit/harvest-profit-calculations",
"version": "1.2.1",
"version": "1.2.2",
"description": "All the calculations",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -18,8 +18,34 @@ <div style="text-align: center">

```javascript
import { Contract } from 'harvest-profit';
import { Contract } from '@harvest-profit/harvest-profit-calculations';
const contractUrl = Contract.translateContractTypeToUrl('hedgetoarrive');
const contractUrl = Contract.translateContractTypeToUrl(Contract.hedgeToArriveType);
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.
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
// Example of BAD
if (contract.type_name === 'cashsale') {
// ... do something
}
```
```javascript
// Example of GOOD
if (contract.type_name === Contract.cashSaleType) {
// ... do something
}
```
Or better yet...
```javascript
// Example of GOOD
if (Contract.isCashSaleType(contract.type_name)) {
// ... do something
}
```
## Development

@@ -26,0 +52,0 @@ [Clone](https://help.github.com/articles/cloning-a-repository/) this repo, and begin committing changes. PRs are preferred over committing directly to master.

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