Skip to content

Fix: Replace hardcoded CO₂ factor with IPCC-sourced waste-type-specific emission map#172

Merged
Shruti070107 merged 2 commits into
Shruti070107:mainfrom
MehtabSandhu11:fix/co2-dynamic-emission-factors
May 23, 2026
Merged

Fix: Replace hardcoded CO₂ factor with IPCC-sourced waste-type-specific emission map#172
Shruti070107 merged 2 commits into
Shruti070107:mainfrom
MehtabSandhu11:fix/co2-dynamic-emission-factors

Conversation

@MehtabSandhu11

Copy link
Copy Markdown
Contributor

📝 PR Description

The platform previously used a single hardcoded constant (0.62 kg CO₂/kg)
across all waste types and processing methods in 5 separate locations. ESG
PDF reports generated from this figure were being used by organizations for
real CSR disclosures, making scientific accuracy a critical requirement — not
a cosmetic one.

This PR replaces every instance of the flat constant with a CO2_FACTORS
lookup map keyed by wasteType × processingMethod, sourced from IPCC 2006
Guidelines (Volume 5 — Waste) and the GHG Protocol Scope 3 Technical
Guidance. The ESG PDF now includes a per-row methodology table showing
exactly which factor was applied to each dispatch and why.

🎯 GSSoC Points Target

  • Difficulty: level:critical
  • Quality: quality:exceptional
  • Labels Requested: gssoc:approved, level:critical, quality:exceptional

💎 Quality Checklist (Mandatory for "Exceptional")

  • Aesthetics: Glassmorphism applied? — N/A (logic change; PDF methodology table uses existing design language)
  • Animations: Micro-animations added? — N/A (no new UI components)
  • Performance: getCO2Factor is a pure O(1) lookup. co2Details map runs once at report generation — zero re-renders.
  • PWA: No manifest or service worker changes required.
  • Code Quality: Full JSDoc on getCO2Factor. CO2_FACTORS and PROCESSING_METHODS fully commented with data source. Zero new console logs.

📸 Screenshots / Video

The ESG PDF now includes a Emission Factor Methodology section showing:

Waste Type Qty (kg) Factor (kg CO₂eq/kg) CO₂ Offset (kg)
Food waste (wet) 120.0 0.67 80.4
Vegetable scraps 80.0 0.54 43.2

With a source attribution footnote: "IPCC 2006 Guidelines for National
Greenhouse Gas Inventories (Volume 5 — Waste) and GHG Protocol Scope 3
Technical Guidance."

Plant operators now see a Processing Method dropdown in their Log Output
form (Anaerobic Digestion / Composting / Biogas Recovery), which persists to
their account and is applied to all subsequent CO₂ calculations.

🧪 Testing Done

  1. Registered a Provider and created dispatches with different waste types
  2. Confirmed dispatch as Plant with each of the 3 processing methods — verified offsetKg in emissions ledger differs correctly per method
  3. Downloaded ESG PDF — confirmed methodology table renders with correct per-row factors and source footnote
  4. Switched processing method in Log Output → re-confirmed a dispatch → verified new factor applied
  5. Verified provider analytics CO₂ metric card and weekly/monthly chart both use dynamic factors
  6. Verified fallback (0.55) applies cleanly for any unrecognised waste type string

Closes #131

…ic emission map- Add CO2_FACTORS map keyed by wasteType × processingMethod (IPCC 2006 / GHG Protocol)- Add getCO2Factor(wasteType, processingMethod) resolver with fallback for unknown types- Replace all 4 usages of hardcoded 0.62 in app.js with dynamic per-order factor- Replace flat ESG totalCO2 calculation with per-order breakdown using getCO2Factor- Add Emission Factor Methodology table to ESG PDF with per-row factor attribution- Add Processing Method selector to plant Log Output form (anaerobic digestion / composting / biogas)- Persist plant's chosen processingMethod to account for consistent CO₂ calculations- Pre-select saved processingMethod on Log Output form re-renderCloses Shruti070107#131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment