finished updating for US tons

This commit is contained in:
csawatzky 2026-03-06 10:24:12 -06:00
parent 9414e30cea
commit 62c2f6a63c
16 changed files with 180 additions and 211 deletions

View file

@ -2,6 +2,7 @@ import GrainDescriber from "grain/GrainDescriber";
import { cloneDeep } from "lodash";
import { MarkerData } from "maps/mapMarkers/Markers";
import { pond } from "protobuf-ts/pond";
import { getGrainUnit } from "utils";
import { stringToMaterialColour } from "utils/strings";
import { or } from "utils/types";
@ -235,46 +236,14 @@ export class Bin {
return bpt;
}
/**
* 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;
}
public grainInventory(): number {
let grain = this.bushels()
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && this.bushelsPerTonne() > 1){
grain = this.bushels() / this.bushelsPerTonne()
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && this.bushelsPerTonne() > 1){
grain = this.bushels() / (this.bushelsPerTonne() * 0.907)
}
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
*/
public grainTonnes(): number {
let weight = 0;
if (this.settings.inventory) {
weight = this.settings.inventory.grainBushels / this.bushelsPerTonne();
}
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;
return Math.round(grain*100)/100
}
/**