working on US ton stuff

This commit is contained in:
csawatzky 2026-03-04 12:51:10 -06:00
parent 3401cc7c15
commit 29d9e7377c
18 changed files with 474 additions and 117 deletions

View file

@ -236,7 +236,23 @@ export class Bin {
}
/**
* gets the weight in tonnes for the grain inventory provided the bushels per tonne is set
* returns the bushels per ton set in the bins settings, if not set will return 1
* @returns 1 or bushels per tonne
*/
public bushelsPerTon(): number {
//trying to avoid a divide by 0 error by only returning a value greater than 0
//since to get the weight you divide the current bushels by the bushels per tonne
let bpt = 1;
if (this.settings.inventory) {
if (this.settings.inventory.bushelsPerTon > 0) {
bpt = this.settings.inventory.bushelsPerTon;
}
}
return bpt;
}
/**
* gets the weight in tonnes (metric) for the grain inventory provided the bushels per tonne is set
* if it is not set it will divide by 1 effectively returning the bushels
* @returns grain weight
*/
@ -248,6 +264,19 @@ export class Bin {
return Math.round(weight * 100) / 100;
}
/**
* gets the weight in tons (imperial) for the grain inventory provided the bushels per ton is set
* if it is not set it will divide by 1 effectively returning the bushels
* @returns grain weight
*/
public grainTons(): number {
let weight = 0;
if (this.settings.inventory) {
weight = this.settings.inventory.grainBushels / this.bushelsPerTon();
}
return Math.round(weight * 100) / 100;
}
/**
* gets the enum value for the inventory control in the bins inventory
*/