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