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