updated the yard with the new ton stuff working through contracts

This commit is contained in:
csawatzky 2026-03-05 12:45:36 -06:00
parent dd6a842fda
commit 9414e30cea
7 changed files with 126 additions and 57 deletions

View file

@ -102,12 +102,21 @@ export default function ContractSettings(props: Props) {
useEffect(() => {
switch (contractType) {
case pond.ContractType.CONTRACT_TYPE_GRAIN:
let conversionLabel = "Bushels Per Tonne"
let adornment = "bu"
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
adornment = "mT"
}
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
conversionLabel = "Bushels Per Ton"
adornment = "t"
}
setLabels({
sizeLabel: "Total Grain on Contract",
commodityLabel: "Select Grain Type",
conversionLabel: "Bushels Per Tonne",
conversionLabel: conversionLabel,
deliveryLabel: "Grain Delivered",
adornment: getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT ? "mT" : "bu"
adornment: adornment
});
break;
default:
@ -148,7 +157,12 @@ export default function ContractSettings(props: Props) {
};
const submit = () => {
const conVal = isNaN(parseFloat(conversionValue)) ? 1 : parseFloat(conversionValue);
let conVal = isNaN(parseFloat(conversionValue)) ? 1 : parseFloat(conversionValue);
if(contractType === pond.ContractType.CONTRACT_TYPE_GRAIN){
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
conVal = conVal/1.102 //convert the ton they entered to mT to be sotred in the contract
}
}
const deliveredVal = isNaN(parseFloat(deliveredAmount))
? 0
: Math.round(Contract.toStoredUnit(parseFloat(deliveredAmount), contractType, conVal));
@ -490,7 +504,9 @@ export default function ContractSettings(props: Props) {
InputLabelProps={{ shrink: true }}
error={isNaN(parseFloat(conversionValue))}
helperText={isNaN(parseFloat(conversionValue)) ? "Must be a valid number" : ""}
onChange={e => setConversionValue(e.target.value)}
onChange={e => {
setConversionValue(e.target.value)
}}
/>
</React.Fragment>
)}