updated the yard with the new ton stuff working through contracts
This commit is contained in:
parent
dd6a842fda
commit
9414e30cea
7 changed files with 126 additions and 57 deletions
|
|
@ -668,25 +668,31 @@ export default function BinyardDisplay(props: Props) {
|
|||
}
|
||||
};
|
||||
|
||||
const grainQuantityDisplay = (bushels: number, custom?: pond.CustomInventory) => {
|
||||
if (custom && custom.bushelsPerTonne <= 1) {
|
||||
return bushels;
|
||||
const customQuantityDisplay = (customInventory: pond.CustomInventory, bushels: number) => {
|
||||
let amount = bushels
|
||||
if(customInventory.bushelsPerTonne > 1){
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
amount = bushels/customInventory.bushelsPerTonne
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
amount = bushels/(customInventory.bushelsPerTonne*0.907)
|
||||
}
|
||||
}
|
||||
|
||||
switch (getGrainUnit()) {
|
||||
case pond.GrainUnit.GRAIN_UNIT_TONNE:
|
||||
return " mT";
|
||||
case pond.GrainUnit.GRAIN_UNIT_TON:
|
||||
return " t";
|
||||
default:
|
||||
return bushels;
|
||||
return Math.round(amount*100)/100
|
||||
}
|
||||
|
||||
const supportedGrainDisplay = (grain: pond.Grain, bushels: number) => {
|
||||
const describer = GrainDescriber(grain)
|
||||
let amount = bushels
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
amount = bushels/describer.bushelsPerTonne
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
amount = bushels/describer.bushelsPerTon
|
||||
}
|
||||
return Math.round(amount*100)/100
|
||||
}
|
||||
|
||||
const binUtilizationList = () => {
|
||||
const hasInventory = binMetrics && binMetrics.grainInventory.length > 0;
|
||||
console.log(binMetrics)
|
||||
const useWeight = getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT;
|
||||
return (
|
||||
<Accordion
|
||||
className={classes.accordion}
|
||||
|
|
@ -728,16 +734,8 @@ export default function BinyardDisplay(props: Props) {
|
|||
<BinUtilizationChart
|
||||
grain={inv.grainType}
|
||||
customUnit={grainUnitDisplay()}
|
||||
bushelAmount={
|
||||
useWeight
|
||||
? inv.bushelAmount / GrainDescriber(inv.grainType).bushelsPerTonne
|
||||
: inv.bushelAmount
|
||||
}
|
||||
bushelCapacity={
|
||||
useWeight
|
||||
? inv.bushelCapacity / GrainDescriber(inv.grainType).bushelsPerTonne
|
||||
: inv.bushelCapacity
|
||||
}
|
||||
bushelAmount={supportedGrainDisplay(inv.grainType, inv.bushelAmount)}
|
||||
bushelCapacity={supportedGrainDisplay(inv.grainType, inv.bushelCapacity)}
|
||||
onClick={() => {
|
||||
setContentFilter(pond.Grain[inv.grainType]);
|
||||
loadMoreBins(pond.Grain[inv.grainType]);
|
||||
|
|
@ -757,8 +755,8 @@ export default function BinyardDisplay(props: Props) {
|
|||
cap = cap * 35.239;
|
||||
unit = " L";
|
||||
}else{
|
||||
amount
|
||||
cap
|
||||
amount = customQuantityDisplay(inv, amount)
|
||||
cap = customQuantityDisplay(inv, cap)
|
||||
unit = grainUnitDisplay(inv)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,12 +120,17 @@ export default function BinLevelOverTime(props: Props) {
|
|||
let currentTime = moment().valueOf();
|
||||
if (data.length === 0) {
|
||||
let bushels = bin.bushels();
|
||||
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;
|
||||
}
|
||||
data.push({
|
||||
value: fertilizerBin
|
||||
? Math.round(bushels * 35.239)
|
||||
: getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT
|
||||
? Math.round((bushels / bin.bushelsPerTonne()) * 100) / 100
|
||||
: bushels,
|
||||
: grainDisplay,
|
||||
timestamp: currentTime
|
||||
});
|
||||
}
|
||||
|
|
@ -151,9 +156,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);
|
||||
let autoBarData: BarData[] = [];
|
||||
|
||||
|
|
@ -190,12 +198,17 @@ export default function BinLevelOverTime(props: Props) {
|
|||
if (autoBarData.length === 0) {
|
||||
let bushels = bin.bushels();
|
||||
let currentTime = moment().valueOf();
|
||||
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;
|
||||
}
|
||||
autoBarData.push({
|
||||
value: fertilizerBin
|
||||
? Math.round(bushels * 35.239)
|
||||
: getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_WEIGHT
|
||||
? Math.round((bushels / bin.bushelsPerTonne()) * 100) / 100
|
||||
: bushels,
|
||||
: grainDisplay,
|
||||
timestamp: currentTime
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue