Skip to content

Form results are off/miscalculated #28

@egpennington

Description

@egpennington

Math is wrong in foam applications calcs.

Use this

  if (diameter < 150) return 0.20;
  if (diameter <= 200) return 0.23;
  if (diameter <= 250) return 0.25;
  if (diameter <= 300) return 0.28;
  return 0.31;
}

function getTankArea(diameter) {
  const radius = diameter / 2;
  return Math.PI * radius * radius;
}

function calculateUpdatedFoamRates(tanks) {
  const result = {};

  for (const tankId in tanks) {
    const { diameter, material, location } = tanks[tankId];
    const rate = getUpdatedFoamRateByDiameter(diameter);
    const area = getTankArea(diameter);
    const foamGPM = area * rate;

    result[tankId] = {
      diameter,
      material,
      location,
      applicationRate: rate,
      surfaceArea: area.toFixed(2),
      foamGPM: foamGPM.toFixed(0)
    };
  }

  return result;
}

console.log(calculateUpdatedFoamRates(tankData));```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions