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

@ -443,14 +443,24 @@ export default function BinCard(props: Props) {
" L"
);
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT && bin.bushelsPerTonne() > 1) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1) {
return (
bin.grainTonnes().toLocaleString() +
" mT " +
bin.fillPercent() +
"%"
);
} else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1) {
return (
bin.grainTons().toLocaleString() +
" t " +
bin.fillPercent() +
"%"
);
}
return (
current.toLocaleString() +
"/" +

View file

@ -126,14 +126,13 @@ interface BinFormExtension {
hopperHeight: string;
diameter: string;
grainBushels: string;
grainTonnes: string;
grainWeight: string;
grainType: Option | null;
grainUse: Option | null;
grainSubtype: string;
customTypeName: string;
highTemp: number;
lowTemp: number;
bushelsPerTonne: string;
tempTarget: number;
}
@ -160,14 +159,13 @@ export default function BinSettings(props: Props) {
hopperHeight: "",
diameter: "",
grainBushels: "",
grainTonnes: "",
grainWeight: "",
grainType: null,
grainUse: null,
grainSubtype: "",
customTypeName: "",
highTemp: 20,
lowTemp: 10,
bushelsPerTonne: "",
tempTarget: 15
});
const [initialized, setInitialized] = useState(false);
@ -194,6 +192,7 @@ export default function BinSettings(props: Props) {
const [isCustomBin, setIsCustomBin] = useState(false);
const [binModelOps, setBinModelOptions] = useState<Option[]>([]);
const [selectedBinModel, setSelectedBinModel] = useState<Option | null>(null);
const [bushelConversion, setBushelConversion] = useState(0) //the number used to convert the bushels to either tonne or ton based on user preference
const [modelID, setModelID] = useState(0);
const [autoTopNode, setAutoTopNode] = useState(false);
const [inventoryControl, setInventoryControl] = useState<pond.BinInventoryControl>(
@ -232,14 +231,30 @@ export default function BinSettings(props: Props) {
if (initForm.inventory) {
setInventoryControl(initForm.inventory.inventoryControl);
//make sure bushels per tonne is set so bins that don't have it in the settings yet can still do it before they get updated properly
if (!initForm.inventory.bushelsPerTonne) {
initForm.inventory.bushelsPerTonne = GrainDescriber(
//make sure bushels per ton/ne is set so bins that don't have it in the settings yet can still do it before they get updated properly
const grain = GrainDescriber(
initForm.inventory.grainType
).bushelsPerTonne;
)
if (!initForm.inventory.bushelsPerTonne) {
initForm.inventory.bushelsPerTonne = grain.bushelsPerTonne;
}
if (!initForm.inventory.bushelsPerTon) {
initForm.inventory.bushelsPerTon = grain.bushelsPerTon;
}
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
setBushelConversion(initForm.inventory.bushelsPerTonne)
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
setBushelConversion(initForm.inventory.bushelsPerTon)
}
if (initForm.inventory.customGrain){
setCustomGrain(initForm.inventory.customGrain)
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
setBushelConversion(initForm.inventory.customGrain.bushelsPerTonne)
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
setBushelConversion(initForm.inventory.customGrain.bushelsPerTon)
}
}
//if the target temp is not set (older bins) make it the midpoint of the high and low temps assuming they are set otherwise make it 15
if (!initForm.inventory.targetTemperature || initForm.inventory.targetTemperature) {
@ -290,6 +305,21 @@ export default function BinSettings(props: Props) {
? initForm.inventory.grainBushels * 35.239
: 0
: initForm.inventory?.grainBushels ?? 0;
let weight = ""
if(initForm.inventory){
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
weight = (gb/initForm.inventory.bushelsPerTonne).toFixed(2)
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
weight = (gb/initForm.inventory.bushelsPerTon).toFixed(2)
}
if(initForm.inventory.customGrain){
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
weight = (gb/initForm.inventory.customGrain.bushelsPerTonne).toFixed(2)
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
weight = (gb/initForm.inventory.customGrain.bushelsPerTon).toFixed(2)
}
}
}
setForm(initForm);
setHighTempC(initForm.highTemp ?? 20);
@ -299,9 +329,10 @@ export default function BinSettings(props: Props) {
height: h,
diameter: d,
grainBushels: gb.toFixed(2),
grainTonnes: initForm.inventory?.bushelsPerTonne
? (gb / initForm.inventory.bushelsPerTonne).toFixed(2)
: "",
grainWeight: weight,
// grainTons: initForm.inventory?.bushelsPerTon
// ? (gb / initForm.inventory.bushelsPerTon).toFixed(2)
// : "",
grainType: initForm.inventory?.grainType
? ToGrainOption(initForm.inventory.grainType)
: null,
@ -315,8 +346,7 @@ export default function BinSettings(props: Props) {
tempTarget: target,
hopperHeight: hopperHeight,
topConeHeight: topconeHeight,
sidewallHeight: sidewallHeight,
bushelsPerTonne: initForm.inventory?.bushelsPerTonne.toString() ?? "0"
sidewallHeight: sidewallHeight
});
setInMoistureString(initForm.inventory?.initialMoisture.toString() ?? "0");
setTMoistureString(initForm.inventory?.targetMoisture.toString() ?? "0");
@ -771,12 +801,103 @@ export default function BinSettings(props: Props) {
}
};
const inventoryAmount = () => {
const grainWeight = formExtension.grainWeight;
const binQuantity = formExtension.grainBushels;
//as long as the storage type is not fertilizer it is some sort of grain, whether it is supported or custom is not important in this instance so we do not need to check for unknown
if(storageType !== pond.BinStorage.BIN_STORAGE_FERTILIZER && ((getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE || getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON) && bushelConversion !== 0 && grainWeight !== "")){
return (
<TextField
label="Amount"
value={grainWeight}
type="number"
onChange={event => {
let newWeight = event.target.value;
//get the bushel amount
if (!isNaN(+newWeight)) {
let newBushels = Math.round(+newWeight * bushelConversion * 100) / 100;
updateForm(
"inventory",
pond.BinInventory.create({
...form.inventory,
grainBushels: newBushels
})
);
//updateFormExtension("grainBushels", newBushels.toString())
updateFormExtension("grainWeight", newWeight);
}
}}
fullWidth
variant="outlined"
disabled={!canEdit}
InputProps={{
endAdornment: <InputAdornment position="end">{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE ? "mT" : "t"}</InputAdornment>
}}
className={classes.bottomSpacing}
/>
)
}else{
return (
<TextField
label="Amount"
value={binQuantity}
type="number"
onChange={event => {
let capacity =
bin?.settings.storage === pond.BinStorage.BIN_STORAGE_FERTILIZER
? +inputCapacity * 35.239
: inputCapacity;
let value = event?.target.value;
let v =
value === ""
? 0
: isNaN(parseFloat(value))
? 0
: parseFloat(value) >= +capacity
? +capacity
: parseFloat(value) <= 0
? 0
: parseFloat(value);
if (bin?.storage() === pond.BinStorage.BIN_STORAGE_FERTILIZER && v) {
v = v / 35.239;
}
//setNewGrainQuantity(v);
updateForm(
"inventory",
pond.BinInventory.create({
...form.inventory,
grainBushels: v
})
);
updateFormExtension("grainBushels", value);
}}
InputProps={{
endAdornment: (
<InputAdornment position="end">
{storageType === pond.BinStorage.BIN_STORAGE_FERTILIZER
? "Litres"
: "Bushels"}
</InputAdornment>
)
}}
fullWidth
variant="outlined"
disabled={
!canEdit ||
inventoryControl === pond.BinInventoryControl.BIN_INVENTORY_CONTROL_AUTOMATIC
}
className={classes.bottomSpacing}
/>
)
}
}
const inventoryForm = () => {
const inventory = form.inventory;
const empty = inventory ? inventory.empty : false;
const bushPerTonne = formExtension.bushelsPerTonne;
const binQuantity = formExtension.grainBushels;
const grainTonnes = formExtension.grainTonnes;
const grainType = formExtension.grainType;
const grainSubtype = formExtension.grainSubtype;
const grainUse = formExtension.grainUse;
@ -805,11 +926,12 @@ export default function BinSettings(props: Props) {
pond.BinInventory.create({
...form.inventory,
grainType: pond.Grain.GRAIN_CUSTOM,
bushelsPerTonne: 0
bushelsPerTonne: 0,
bushelsPerTon: 0
})
);
updateFormExtension("grainType", null);
updateFormExtension("bushelsPerTonne", "");
setBushelConversion(0)
} else {
setStorageType(pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN);
updateForm(
@ -859,7 +981,8 @@ export default function BinSettings(props: Props) {
let storageType = parseFloat(value) as pond.BinStorage;
setStorageType(storageType);
if (storageType === pond.BinStorage.BIN_STORAGE_FERTILIZER) {
formExtension.bushelsPerTonne = "";
// formExtension.bushelsPerTonne = "";
setBushelConversion(0)
formExtension.grainBushels = (
parseFloat(formExtension.grainBushels) * 35.239
).toFixed(0);
@ -1054,7 +1177,30 @@ export default function BinSettings(props: Props) {
</React.Fragment>
:
<Box sx={{border: "1px solid white", borderRadius: 2, padding: 2, marginBottom: 2}}>
<CustomGrainSelector initialGrain={customGrain} onGrainSettingsChange={(newGrainSettings) => {setCustomGrain(newGrainSettings)}}/>
<CustomGrainSelector
initialGrain={customGrain}
onGrainSettingsChange={(newGrainSettings) => {
setCustomGrain(newGrainSettings)
let conversion = 0
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
conversion = newGrainSettings.bushelsPerTonne
}else if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
conversion = newGrainSettings.bushelsPerTon
}
updateForm(
"inventory",
pond.BinInventory.create({
...form.inventory,
bushelsPerTonne: newGrainSettings.bushelsPerTonne,
bushelsPerTon: newGrainSettings.bushelsPerTon
})
);
setBushelConversion(conversion)
if(conversion !== 0 && !isNaN(+binQuantity)){
updateFormExtension("grainWeight", (+binQuantity/conversion).toFixed(2))
}
}}/>
</Box>
}
</React.Fragment>
@ -1073,11 +1219,22 @@ export default function BinSettings(props: Props) {
pond.BinInventory.create({
...form.inventory,
grainType: newGrainType,
bushelsPerTonne: GrainDescriber(newGrainType).bushelsPerTonne
bushelsPerTonne: GrainDescriber(newGrainType).bushelsPerTonne,
bushelsPerTon: GrainDescriber(newGrainType).bushelsPerTon
})
);
//doesn't need to update the form extension to display the bushels per tonne as it is not changeable for the supported grain
//and is reset whenever the user switches between custom or not
let conversion = 0
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
conversion = GrainDescriber(newGrainType).bushelsPerTonne
}else if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
conversion = GrainDescriber(newGrainType).bushelsPerTon
}
setBushelConversion(conversion)
if(conversion !== 0 && !isNaN(+binQuantity)){
//updateFormExtension("grainWeight", (+binQuantity/conversion).toFixed(2))
let newWeight = (+binQuantity/conversion).toFixed(2)
formExtension.grainWeight = newWeight
}
updateFormExtension("grainType", option);
}}
group
@ -1106,7 +1263,8 @@ export default function BinSettings(props: Props) {
/>
</React.Fragment>
}
{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_BUSHELS ||
{inventoryAmount()}
{/* {getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_BUSHELS ||
storageType === pond.BinStorage.BIN_STORAGE_FERTILIZER ||
formExtension.bushelsPerTonne === "0" ||
formExtension.bushelsPerTonne === "" ? (
@ -1163,7 +1321,7 @@ export default function BinSettings(props: Props) {
) : (
<TextField
label="Amount"
value={grainTonnes}
value={grainWeight}
type="number"
onChange={event => {
let newWeight = event.target.value;
@ -1180,7 +1338,7 @@ export default function BinSettings(props: Props) {
})
);
//updateFormExtension("grainBushels", newBushels.toString())
updateFormExtension("grainTonnes", newWeight);
updateFormExtension("grainWeight", newWeight);
}
}}
fullWidth
@ -1191,7 +1349,7 @@ export default function BinSettings(props: Props) {
}}
className={classes.bottomSpacing}
/>
)}
)} */}
{!isCustomInventory && (
<SearchSelect
label="Use"

View file

@ -196,14 +196,27 @@ export default function BinTransactions(props: Props){
}
}
const grainQuantityDisplay = (bushels: number) => {
const grainTransaction = selectedTransaction?.transaction.transaction?.grainTransaction ?? pond.GrainTransaction.create()
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && grainTransaction.bushelsPerTonne > 1){
let tonneWeight = bushels / grainTransaction.bushelsPerTonne
return tonneWeight + " mT"
}
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && grainTransaction.bushelsPerTon > 1){
let tonneWeight = bushels / grainTransaction.bushelsPerTon
return tonneWeight + " t"
}
return bushels + " bushels"
}
// dialog for approving a transaction
const approvalDialog = () => {
// get the display information for the transaction
const grainTransaction = selectedTransaction?.transaction.transaction?.grainTransaction ?? pond.GrainTransaction.create()
const bushels = grainTransaction.bushels ?? 0
const weight = bushels / grainTransaction.bushelsPerTonne
//const weight = bushels / grainTransaction.bushelsPerTonne
let graintype = grainTransaction.grainType ?? pond.Grain.GRAIN_INVALID
const grainDisplay = graintype === pond.Grain.GRAIN_CUSTOM
const grainTypeDisplay = graintype === pond.Grain.GRAIN_CUSTOM
? grainTransaction.customGrain
: GrainDescriber(grainTransaction.grainType).name
@ -215,7 +228,7 @@ export default function BinTransactions(props: Props){
<DialogTitle>Accept Transaction</DialogTitle>
<DialogContent>
<Box>
<Typography>{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? weight + " mT" : bushels + " bushels"} of {grainTransaction.subtype} {grainDisplay} moved</Typography>
<Typography>{grainQuantityDisplay(bushels)} of {grainTransaction.subtype} {grainTypeDisplay} moved</Typography>
<Typography margin={1} fontWeight={650}>From:</Typography>
{/*Object type selection*/}
<Autocomplete
@ -378,9 +391,9 @@ export default function BinTransactions(props: Props){
// get the display information for the transaction
const grainTransaction = t.transaction.transaction?.grainTransaction ?? pond.GrainTransaction.create()
const bushels = grainTransaction.bushels ?? 0
const weight = bushels / grainTransaction.bushelsPerTonne
// const weight = bushels / grainTransaction.bushelsPerTonne
let graintype = grainTransaction.grainType ?? pond.Grain.GRAIN_INVALID
const grainDisplay = graintype === pond.Grain.GRAIN_CUSTOM
const grainTypeDisplay = graintype === pond.Grain.GRAIN_CUSTOM
? grainTransaction.customGrain
: GrainDescriber(grainTransaction.grainType).name
return (
@ -394,7 +407,7 @@ export default function BinTransactions(props: Props){
</Box>
</Box>
<Box display="flex" justifyContent="space-between">
<Typography sx={{margin: "auto", marginLeft: 0}}>{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? weight + " mT" : bushels + " bushels"} of {grainTransaction.subtype} {grainDisplay} moved</Typography>
<Typography sx={{margin: "auto", marginLeft: 0}}>{grainQuantityDisplay(bushels)} of {grainTransaction.subtype} {grainTypeDisplay} moved</Typography>
<Button
variant="contained"
disabled={selectedMatch?.transaction.key === t.transaction.key}

View file

@ -270,7 +270,7 @@ export default function BinVisualizer(props: Props) {
const [storageType, setStorageType] = useState<pond.BinStorage>(
pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN
);
const [bushPerTonne, setBushPerTonne] = useState("0");
//const [bushPerTonne, setBushPerTonne] = useState("0");
const [grainSubtype, setGrainSubtype] = useState("");
const [loadingTrend, setLoadingTrend] = useState(false);
@ -326,7 +326,7 @@ export default function BinVisualizer(props: Props) {
setCustomTypeName(bin.settings.inventory.customTypeName);
setGrainType(bin.settings.inventory.grainType);
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
//setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
setGrainSubtype(bin.subtype());
setNewBinMode(bin.settings.mode);
setNewGrainSettings(bin.customGrain());
@ -495,8 +495,10 @@ export default function BinVisualizer(props: Props) {
if (bin.storage() === pond.BinStorage.BIN_STORAGE_FERTILIZER) {
return Math.round(val * 35.239 * 100) / 100;
} else {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT && bin.bushelsPerTonne() > 1) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1) {
return Math.round((val / bin.bushelsPerTonne()) * 100) / 100;
} else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1) {
return Math.round((val / bin.bushelsPerTon()) * 100) / 100;
}
}
return val;
@ -511,17 +513,19 @@ export default function BinVisualizer(props: Props) {
if (bin.storage() === pond.BinStorage.BIN_STORAGE_FERTILIZER) {
return " / " + capacity.toLocaleString() + " L";
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT && bin.bushelsPerTonne() > 1) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1) {
return "mT (" + bin.fillPercent() + "%)";
} else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1) {
return "t (" + bin.fillPercent() + "%)";
} else {
return " / " + capacity.toLocaleString() + " bu";
}
};
const grainErrorCheck = () => {
if (isNaN(parseFloat(bushPerTonne))) return true;
return false;
};
// const grainErrorCheck = () => {
// if (isNaN(parseFloat(bushPerTonne))) return true;
// return false;
// };
const inventoryOverview = () => {
const capacity = bin.settings.specs?.bushelCapacity ?? 0;
@ -774,7 +778,7 @@ export default function BinVisualizer(props: Props) {
setCustomTypeName(bin.settings.inventory.customTypeName);
setGrainType(bin.settings.inventory.grainType);
setGrainOption(ToGrainOption(bin.settings.inventory.grainType));
setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
//setBushPerTonne(bin.settings.inventory.bushelsPerTonne.toFixed(2));
setNewGrainSettings(bin.customGrain())
setGrainSubtype(bin.subtype());
}
@ -802,7 +806,7 @@ export default function BinVisualizer(props: Props) {
checked={isCustomInventory}
onChange={(_, checked) => {
setIsCustomInventory(checked);
setBushPerTonne("0");
//setBushPerTonne("0");
setGrainSubtype("");
setCustomTypeName("");
setGrainOption(ToGrainOption(pond.Grain.GRAIN_NONE));
@ -834,7 +838,7 @@ export default function BinVisualizer(props: Props) {
: pond.Grain.GRAIN_INVALID;
setGrainOption(ToGrainOption(newGrainType));
setGrainType(newGrainType);
setBushPerTonne(GrainDescriber(newGrainType).bushelsPerTonne.toFixed(2));
//setBushPerTonne(GrainDescriber(newGrainType).bushelsPerTonne.toFixed(2));
}}
group
disabled={!canEdit}
@ -897,7 +901,7 @@ export default function BinVisualizer(props: Props) {
<Button
variant="contained"
color="primary"
disabled={grainErrorCheck()}
// disabled={grainErrorCheck()}
onClick={() => {
updateBin();
setGrainChangeDialog(false);
@ -1321,13 +1325,20 @@ export default function BinVisualizer(props: Props) {
}
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT && bin.bushelsPerTonne() > 1) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1) {
diffDisplay = diffDisplay / bin.bushelsPerTonne();
if (pendingDisplay) {
pendingDisplay = pendingDisplay / bin.bushelsPerTonne();
}
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1) {
diffDisplay = diffDisplay / bin.bushelsPerTon();
if (pendingDisplay) {
pendingDisplay = pendingDisplay / bin.bushelsPerTon();
}
}
return (
<Box display="flex" width={1} justifyContent="flex-end">
<FullScreen handle={fullScreenHandler}>
@ -1987,9 +1998,11 @@ export default function BinVisualizer(props: Props) {
//update all the grain stuff
b.settings.inventory.grainType = grainType;
b.settings.inventory.customTypeName = customTypeName;
b.settings.inventory.bushelsPerTonne = isNaN(parseFloat(bushPerTonne))
? 0
: parseFloat(bushPerTonne);
b.settings.inventory.bushelsPerTonne = GrainDescriber(grainType).bushelsPerTonne
b.settings.inventory.bushelsPerTon = GrainDescriber(grainType).bushelsPerTon
// b.settings.inventory.bushelsPerTonne = isNaN(parseFloat(bushPerTonne))
// ? 0
// : parseFloat(bushPerTonne);
b.settings.inventory.grainSubtype = grainSubtype;
b.settings.inventory.customGrain = newGrainSettings
}
@ -2010,7 +2023,6 @@ export default function BinVisualizer(props: Props) {
}
b.settings.mode = newBinMode;
}
console.log(b.settings)
binAPI.updateBin(bin.key(), b.settings, as).then(resp => {
refresh();
});

View file

@ -652,8 +652,29 @@ export default function BinyardDisplay(props: Props) {
);
};
const grainUnitDisplay = (custom?: pond.CustomInventory) => {
// If custom and not convertible, always bushels
if (custom && custom.bushelsPerTonne <= 1) {
return " bu";
}
switch (getGrainUnit()) {
case pond.GrainUnit.GRAIN_UNIT_TONNE:
return " mT";
case pond.GrainUnit.GRAIN_UNIT_TON:
return " t";
default:
return " bu";
}
};
const grainQuantityDisplay = (custom?: pond.CustomInventory) => {
}
const binUtilizationList = () => {
const hasInventory = binMetrics && binMetrics.grainInventory.length > 0;
console.log(binMetrics)
const useWeight = getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT;
return (
<Accordion
@ -695,7 +716,7 @@ export default function BinyardDisplay(props: Props) {
<GridListTile key={key}>
<BinUtilizationChart
grain={inv.grainType}
customUnit={useWeight ? " mT" : " bu"}
customUnit={grainUnitDisplay()}
bushelAmount={
useWeight
? inv.bushelAmount / GrainDescriber(inv.grainType).bushelsPerTonne
@ -724,11 +745,8 @@ export default function BinyardDisplay(props: Props) {
amount = amount * 35.239;
cap = cap * 35.239;
unit = " L";
}
if (useWeight && inv.bushelsPerTonne > 1) {
amount = amount / inv.bushelsPerTonne;
cap = cap / inv.bushelsPerTonne;
unit = " mT";
}else{
unit = grainUnitDisplay(inv)
}
return (

View file

@ -69,9 +69,12 @@ export default function BinLevelOverTime(props: Props) {
if (fertilizerBin && cap) {
cap = cap * 35.239;
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT && cap) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && cap) {
cap = cap / bin.bushelsPerTonne();
}
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && cap) {
cap = cap / bin.bushelsPerTon();
}
setCapacity(cap);
binAPI
.listHistoryBetween(bin.key(), 500, startDate.toISOString(), endDate.toISOString())
@ -85,13 +88,18 @@ export default function BinLevelOverTime(props: Props) {
if (hist.settings?.inventory) {
let bushels = hist.settings.inventory.grainBushels ?? 0;
if (bushels !== lastBushels) {
let grainDisplay = bushels
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1){
grainDisplay = Math.round((bushels / bin.bushelsPerTonne()) * 100) / 100;
}
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1){
grainDisplay = Math.round((bushels / bin.bushelsPerTon()) * 100) / 100;
}
let newData: InventoryAt = {
timestamp: moment(hist.timestamp).valueOf(),
value: fertilizerBin
? Math.round(bushels * 35.239)
: getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT
? Math.round((bushels / bin.bushelsPerTonne()) * 100) / 100
: bushels
: grainDisplay
};
data.push(newData);
lastBushels = bushels;
@ -163,8 +171,15 @@ export default function BinLevelOverTime(props: Props) {
m.values.forEach((val, i) => {
if (val.values[0] && m.timestamps[i]) {
if (lastBushels !== val.values[0]) {
let grainDisplay = val.values[0]
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE && bin.bushelsPerTonne() > 1){
grainDisplay = Math.round((grainDisplay / bin.bushelsPerTonne()) * 100) / 100;
}
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON && bin.bushelsPerTon() > 1){
grainDisplay = Math.round((grainDisplay / bin.bushelsPerTon()) * 100) / 100;
}
autoBarData.push({
value: val.values[0],
value: grainDisplay,
timestamp: moment(m.timestamps[i]).valueOf(),
});
lastBushels = val.values[0];

View file

@ -88,6 +88,7 @@ export default function FieldSettings(props: Props) {
settings.grainSubtype = grainSubtype;
settings.landLocation = landLocation;
settings.acres = acres;
settings.bushelsPerTonne = isNaN(parseFloat(bushelsPerTonne)) ? 1 : parseFloat(bushelsPerTonne);
fieldAPI
.updateField(selectedField.key(), settings, undefined, as)
@ -121,6 +122,7 @@ export default function FieldSettings(props: Props) {
geo.shapes = borders;
}
settings.fieldGeoData = geo;
settings.bushelsPerTonne = isNaN(parseFloat(bushelsPerTonne)) ? 1 : parseFloat(bushelsPerTonne);
fieldAPI
.addField(settings, as)
.then(resp => {
@ -226,6 +228,7 @@ export default function FieldSettings(props: Props) {
if (option) {
let grainType = pond.Grain[option.value as keyof typeof pond.Grain];
setCropType(grainType);
console.log("set bpt here")
setBushelsPerTonne(GrainDescriber(grainType).bushelsPerTonne.toString());
}
}}

View file

@ -20,7 +20,7 @@ export default function CustomGrainForm(props: Props) {
const [kgPerBushel, setKgPerBushel] = useState("0")
const [bushelsPerTonne, setBushelsPerTonne] = useState("0")//this is metric
const [lbPerBushel, setLbPerBushel] = useState("0")
const [bushelsPerTon, setBushelsPerTon] = useState("0")//this is imperial
const [bushelsPerTon, setBushelsPerTon] = useState("0")//this is US ton
const valid = useRef(false)
useEffect(()=>{
@ -33,6 +33,8 @@ export default function CustomGrainForm(props: Props) {
setConstantC(grainSettings.c.toString())
setKgPerBushel(grainSettings.kgPerBushel.toString())
setBushelsPerTonne(grainSettings.bushelsPerTonne.toString())
setLbPerBushel(grainSettings.poundsPerBushel.toString())
setBushelsPerTon(grainSettings.bushelsPerTon.toString())
setNewGrainSettings(grainSettings)
}
},[grainSettings])
@ -236,7 +238,7 @@ export default function CustomGrainForm(props: Props) {
let settings = cloneDeep(newGrainSettings)
if(!isNaN(parseFloat(val))){
settings.bushelsPerTonne = parseFloat(val)
let newTon = Math.round((parseFloat(val)*1.102)*100)/100
let newTon = Math.round((parseFloat(val)*0.907)*100)/100
settings.bushelsPerTon = newTon
setBushelsPerTon(newTon.toString())
}
@ -257,7 +259,7 @@ export default function CustomGrainForm(props: Props) {
let settings = cloneDeep(newGrainSettings)
if(!isNaN(parseFloat(val))){
settings.bushelsPerTon = parseFloat(val)
let newTonne = Math.round((parseFloat(val)/1.102)*100)/100
let newTonne = Math.round((parseFloat(val)/0.907)*100)/100
settings.bushelsPerTonne = newTonne
setBushelsPerTonne(newTonne.toString())
}

View file

@ -30,6 +30,7 @@ export interface GrainExtension {
colour: string;
weightConversionKg: number;
bushelsPerTonne: number;
bushelsPerTon: number; //NOTE: this is US tons (2000lB/t)
}
const defaultSetTemp = 30.0;
@ -45,7 +46,8 @@ const defaultGrain: GrainExtension = {
targetMC: 15.0,
colour: "#424242",
weightConversionKg: 0,
bushelsPerTonne: 0
bushelsPerTonne: 0,
bushelsPerTon: 0
};
export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
@ -64,7 +66,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "yellow",
weightConversionKg: 0,
bushelsPerTonne: 0
bushelsPerTonne: 0,
bushelsPerTon: 0
}
],
[
@ -81,7 +84,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: BarleyImg,
colour: "#27632a",
weightConversionKg: 21.772657171369,
bushelsPerTonne: 45.93
bushelsPerTonne: 45.93,
bushelsPerTon: 41.66
}
],
[
@ -98,7 +102,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 16.1,
colour: "#46b298",
weightConversionKg: 1,
bushelsPerTonne: 45.93
bushelsPerTonne: 45.93,
bushelsPerTon: 50.63
}
],
[
@ -116,7 +121,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
// colour: "#cddc39",
colour: "#ffff00",
weightConversionKg: 22.67961461,
bushelsPerTonne: 44.092
bushelsPerTonne: 44.092,
bushelsPerTon: 39.99
}
],
[
@ -133,7 +139,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CanolaImg,
colour: "#cddc39",
weightConversionKg: 27.215537532,
bushelsPerTonne: 44.092
bushelsPerTonne: 44.092,
bushelsPerTon: 39.9
}
],
[
@ -150,7 +157,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CornImg,
colour: "#ffef62",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -167,7 +175,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CornImg,
colour: "#ffef62",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -184,7 +193,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CornImg,
colour: "#ffef62",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -201,7 +211,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CornImg,
colour: "#ffef62",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -218,7 +229,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: CornImg,
colour: "#ffef62",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -235,7 +247,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: OatImg,
colour: "#79955a",
weightConversionKg: 15.4222988297197,
bushelsPerTonne: 64.842
bushelsPerTonne: 64.842,
bushelsPerTon: 58.81
}
],
[
@ -252,7 +265,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: OatImg,
colour: "#79955a",
weightConversionKg: 15.4222988297197,
bushelsPerTonne: 64.842
bushelsPerTonne: 64.842,
bushelsPerTon: 58.81
}
],
[
@ -269,7 +283,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: OatImg,
colour: "#79955a",
weightConversionKg: 15.4222988297197,
bushelsPerTonne: 64.842
bushelsPerTonne: 64.842,
bushelsPerTon: 58.81
}
],
[
@ -286,7 +301,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: PeanutImg,
colour: "#b2a058",
weightConversionKg: 23.3124,
bushelsPerTonne: 105.263
bushelsPerTonne: 105.263,
bushelsPerTon: 95.47
}
],
[
@ -303,7 +319,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: RiceImg,
colour: "#7c9c99",
weightConversionKg: 28.439,
bushelsPerTonne: 49.02
bushelsPerTonne: 49.02,
bushelsPerTon: 44.46
}
],
[
@ -320,7 +337,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: RiceImg,
colour: "#7c9c99",
weightConversionKg: 29.979,
bushelsPerTonne: 49.02
bushelsPerTonne: 49.02,
bushelsPerTon: 44.46
}
],
[
@ -337,7 +355,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: RiceImg,
colour: "#7c9c99",
weightConversionKg: 30.744,
bushelsPerTonne: 49.02
bushelsPerTonne: 49.02,
bushelsPerTon: 44.46
}
],
[
@ -354,7 +373,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: SorghumImg,
colour: "#829baf",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -371,7 +391,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: SoybeanImg,
colour: "#7d6d99",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -388,7 +409,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: SunflowerImg,
colour: "#ffab40",
weightConversionKg: 13.6079107321056,
bushelsPerTonne: 73.487
bushelsPerTonne: 73.487,
bushelsPerTon: 66.65
}
],
[
@ -405,7 +427,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: WheatImg,
colour: "#46b298",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -422,7 +445,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: WheatImg,
colour: "#46b298",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -439,7 +463,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: WheatImg,
colour: "#46b298",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -456,7 +481,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: FlaxImg,
colour: "#6e6d19",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -473,7 +499,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: FlaxImg,
colour: "#6e6d19",
weightConversionKg: 25.4014333665971,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],
[
@ -490,7 +517,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: PeaImg,
colour: "#ffe100",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -507,7 +535,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: LentilImg,
colour: "#cb5e3c",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -524,7 +553,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: LentilImg,
colour: "#cb5e3c",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -541,7 +571,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
img: LentilImg,
colour: "#cb5e3c",
weightConversionKg: 27.2158214642112,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],
[
@ -557,7 +588,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "red",
weightConversionKg: 27.2155,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],[
pond.Grain.GRAIN_DRY_BEANS_BLACK,
@ -572,7 +604,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "grey",
weightConversionKg: 27.2155,
bushelsPerTonne: 36.744
bushelsPerTonne: 36.744,
bushelsPerTon: 33.33
}
],[
pond.Grain.GRAIN_RYE_A,
@ -587,7 +620,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "grey",
weightConversionKg: 25.4,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
],[
pond.Grain.GRAIN_RYE_B,
@ -602,7 +636,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "grey",
weightConversionKg: 25.4,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
},
],[
pond.Grain.GRAIN_RYE_C,
@ -617,7 +652,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "grey",
weightConversionKg: 25.4,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
},
],[
pond.Grain.GRAIN_RYE_D,
@ -632,7 +668,8 @@ export const GrainExtensions: Map<pond.Grain, GrainExtension> = new Map([
targetMC: 15.0,
colour: "grey",
weightConversionKg: 25.4,
bushelsPerTonne: 39.368
bushelsPerTonne: 39.368,
bushelsPerTon: 35.71
}
]
]);

View file

@ -225,12 +225,19 @@ export default function GrainTransaction(props: Props) {
const createTransaction = (finalVal: number) => {
let dest = selectedDestination;
let source = selectedSource;
let bpt = 1;
let bPerTonne = 1;
let bPerTon = 1;
//use the sources bushel per tonne if one was selected otherwise use the destination
if (source) {
bpt = source.value.bushelsPerTonne();
bPerTonne = source.value.bushelsPerTonne();
if(source.value.bushelsPerTon){
bPerTon = source.value.bushelsPerTon()
}
} else if (dest) {
bpt = dest.value.bushelsPerTonne();
bPerTonne = dest.value.bushelsPerTonne();
if(dest.value.bushelsPerTon){
bPerTon = dest.value.bushelsPerTon()
}
}
let newTransaction = pond.Transaction.create({
@ -239,7 +246,8 @@ export default function GrainTransaction(props: Props) {
grainTransaction: pond.GrainTransaction.create({
bushels: finalVal,
message: grainMessage,
bushelsPerTonne: bpt
bushelsPerTonne: bPerTonne,
bushelsPerTon: bPerTonne * 0.907
})
})
});
@ -449,6 +457,17 @@ export default function GrainTransaction(props: Props) {
);
};
const grainUnitDisplay = () => {
switch (getGrainUnit()){
case pond.GrainUnit.GRAIN_UNIT_TONNE:
return "mT"
case pond.GrainUnit.GRAIN_UNIT_TON:
return "t"
default:
return "bu"
}
}
return (
<ResponsiveDialog
open={open}
@ -506,14 +525,14 @@ export default function GrainTransaction(props: Props) {
InputProps={{
endAdornment: (
<InputAdornment position="end">
{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? "mT" : "bu"}
{grainUnitDisplay()}
</InputAdornment>
)
}}
onChange={e => {
//if the user is viewing the grain in weight
let grainVal = e.target.value;
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT) {
if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE) {
//need to convert what the user input (weight) into what is actually stored (bushels)
//use source of the conversion value if it was selected, otherwise use the destination
if (!isNaN(parseFloat(e.target.value))) {
@ -523,6 +542,22 @@ export default function GrainTransaction(props: Props) {
grainVal = (+grainVal * selectedDestination.value.bushelsPerTonne()).toFixed(2);
}
}
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE) {
if (!isNaN(parseFloat(e.target.value))) {
if (selectedSource) {
if(selectedSource.value.bushelsPerTonne){
grainVal = (+grainVal * selectedSource.value.bushelsPerTon()).toFixed(2);
}else{
grainVal = (+grainVal * (selectedSource.value.bushelsPerTonne() * 0.907)).toFixed(2);
}
} else if (selectedDestination) {
if(selectedDestination.value.bushelsPerTonne){
grainVal = (+grainVal * selectedDestination.value.bushelsPerTon()).toFixed(2);
}else{
grainVal = (+grainVal * (selectedDestination.value.bushelsPerTonne() * 0.907)).toFixed(2);
}
}
}
}
setGrainEntry(e.target.value);
setGrainChangeVal(grainVal);

View file

@ -161,6 +161,7 @@ export default function GrainBagSettings(props: Props) {
settings.currentBushels = grainBushels;
settings.grainSubtype = grainSubtype;
settings.fillDate = fillDate;
settings.bushelsPerTonne = bushelsPerTonne;
settings.storageType = isCustom
? pond.BinStorage.BIN_STORAGE_UNSUPPORTED_GRAIN
: pond.BinStorage.BIN_STORAGE_SUPPORTED_GRAIN;

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
*/

View file

@ -59,7 +59,6 @@ export default function GrainBag(props: Props) {
}
console.log
userAPI.getUser(user.id(), { key: key, kind: kind } as Scope).then(resp => {
console.log(resp)
setPermissions(resp.permissions);
});
}, [as, bagID, userAPI, user]);

View file

@ -147,7 +147,7 @@ export default function GrainBagProvider(props: PropsWithChildren<Props>) {
(end && "&end=" + end)
)
if (view) {
url = url + "?as=" + view
url = url + "&as=" + view
}
return get<pond.ListGrainBagHistoryResponse>(url);
};

View file

@ -11,6 +11,7 @@ interface Props {
export default function TransactionDataDisplay(props: Props) {
const { transaction } = props;
console.log(transaction)
const display = () => {
let transactionData = transaction.transaction.transaction;

View file

@ -455,8 +455,11 @@ export default function UserSettings(props: Props) {
case 1:
grainUnit = pond.GrainUnit.GRAIN_UNIT_BUSHELS;
break;
case 2:
grainUnit = pond.GrainUnit.GRAIN_UNIT_WEIGHT;
case 3:
grainUnit = pond.GrainUnit.GRAIN_UNIT_TONNE;
break;
case 4:
grainUnit = pond.GrainUnit.GRAIN_UNIT_TON;
break;
default:
grainUnit = pond.GrainUnit.GRAIN_UNIT_UNKNOWN;
@ -540,7 +543,8 @@ export default function UserSettings(props: Props) {
variant="outlined"
InputLabelProps={{ shrink: true }}>
<MenuItem value={pond.GrainUnit.GRAIN_UNIT_BUSHELS}>Bushels (bu)</MenuItem>
<MenuItem value={pond.GrainUnit.GRAIN_UNIT_WEIGHT}>Tonnes (mT)</MenuItem>
<MenuItem value={pond.GrainUnit.GRAIN_UNIT_TONNE}>Tonnes (mT)</MenuItem>
<MenuItem value={pond.GrainUnit.GRAIN_UNIT_TON}>US Tons (t)</MenuItem>
</TextField>
</Grid2>
)}

View file

@ -55,13 +55,33 @@ export function setDistanceUnit(unit: pond.DistanceUnit) {
}
export function getGrainUnit(): pond.GrainUnit {
return localStorage.getItem("grainUnit") === "mT"
? pond.GrainUnit.GRAIN_UNIT_WEIGHT
: pond.GrainUnit.GRAIN_UNIT_BUSHELS;
switch(localStorage.getItem("grainUnit")){
case "mT":
return pond.GrainUnit.GRAIN_UNIT_TONNE
case "t":
return pond.GrainUnit.GRAIN_UNIT_TON
default:
return pond.GrainUnit.GRAIN_UNIT_BUSHELS
}
// return localStorage.getItem("grainUnit") === "mT"
// ? pond.GrainUnit.GRAIN_UNIT_WEIGHT
// : pond.GrainUnit.GRAIN_UNIT_BUSHELS;
}
export function setGrainUnit(unit: pond.GrainUnit) {
localStorage.setItem("grainUnit", unit === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? "mT" : "bu");
switch(unit){
case pond.GrainUnit.GRAIN_UNIT_WEIGHT:
case pond.GrainUnit.GRAIN_UNIT_TONNE:
localStorage.setItem("grainUnit", "mT")
break;
case pond.GrainUnit.GRAIN_UNIT_TON:
localStorage.setItem("grainUnit", "t")
break;
default:
localStorage.setItem("grainUnit", "bu")
}
// localStorage.setItem("grainUnit", unit === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? "mT" : "bu");
}
export const distanceConversion = (val: number) => {