working on US ton stuff
This commit is contained in:
parent
3401cc7c15
commit
29d9e7377c
18 changed files with 474 additions and 117 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue