@zerocarbon/erp-config-sdk 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1472,42 +1472,6 @@ declare const getIntensityFormulas: () => {
1472
1472
  totalProductionFormula: string;
1473
1473
  };
1474
1474
  declare const supportsIntensityCalculations: (industry: string) => boolean;
1475
- interface UserData {
1476
- buissnessID?: {
1477
- industry?: string;
1478
- };
1479
- additionalConfig?: {
1480
- erp?: {
1481
- [industry: string]: any;
1482
- };
1483
- };
1484
- }
1485
- interface CarbonIntensityApiMapping {
1486
- [apiField: string]: {
1487
- userDataPath: string;
1488
- transform?: (value: any) => number;
1489
- fallback?: number;
1490
- required?: boolean;
1491
- fieldLabel?: string;
1492
- industryFieldKey?: string;
1493
- };
1494
- }
1495
- declare const CARBON_INTENSITY_FIELD_MAPPINGS: Record<string, CarbonIntensityApiMapping>;
1496
- declare const getNestedValue: (obj: any, path: string) => any;
1497
- declare const extractCarbonIntensityData: (userData: UserData, industry: string) => Record<string, number>;
1498
- declare const mapIndustryToApiType: (industryName: string) => string;
1499
- declare const getAvailableFieldsForIndustry: (userData: UserData, industry: string) => string[];
1500
- declare const validateCarbonIntensityData: (userData: UserData, industry: string) => {
1501
- isValid: boolean;
1502
- missingFields: Array<{
1503
- apiField: string;
1504
- fieldLabel: string;
1505
- industryFieldKey: string;
1506
- userDataPath: string;
1507
- }>;
1508
- errors: string[];
1509
- };
1510
- declare const debugCarbonIntensityMapping: (userData: UserData, industry: string) => void;
1511
1475
 
1512
1476
  /**
1513
1477
  * UI Features Configuration System
@@ -4020,5 +3984,5 @@ declare namespace index {
4020
3984
  };
4021
3985
  }
4022
3986
 
4023
- export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CARBON_INTENSITY_FIELD_MAPPINGS, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
4024
- export type { AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, CarbonIntensityApiMapping, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FieldConfig, FieldOption, FieldType, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig, EmissionData as IndustryEmissionData, IndustryFieldConfig, IndustryFieldSection, ProductionData as IndustryProductionData, IndustryType, IntensityCalculation, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, PlantNameConfig, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, ProductionData, RealEstateRequest, RealEstateResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UserData, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
3987
+ export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getIndustryConfig$1 as getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, sanitizeNumber, supportsIntensityCalculations };
3988
+ export type { AlloyRequest, AlloyResponse, AluminiumRequest, AluminiumResponse, ApiEndpointConfig, ApiResponse, AutomobileRequest, AutomobileResponse, AviationRequest, AviationResponse, BaseRequest, BaseResponse, Bill, BillCalculationConfig, BillFilterOptions, BillMatchingConfig, BusinessTravelEmission, BusinessTravelEmissionAttributes, BusinessTravelEmissionsResponse, CarbonIntensityRequest, CarbonIntensityResponse, ChemicalRequest, ChemicalResponse, DetailedCarbonIntensityResponse, EditableItem, EmissionSource, Emissions$j as Emissions, EmissionsDataAttributes, EmissionsDataResponse, FoodBeveragesRequest, FoodBeveragesResponse, FormData, FormValidationResult, FrontendIndustryConfig, HospitalityRequest, HospitalityResponse, IndustryConfig, EmissionData as IndustryEmissionData, ProductionData as IndustryProductionData, IndustryType, IntensityValue, LogisticsRequest, LogisticsResponse, ManufacturingRequest, ManufacturingResponse, Meta, MetalEnergyRequest, MetalEnergyResponse, PackagingRequest, PackagingResponse, Pagination, PetrochemicalRequest, PetrochemicalResponse, PharmaRequest, PharmaResponse, ProcessedEmissionCategory, ProcessedEmissionItem, ProcessedScope3Data, RealEstateRequest, RealEstateResponse, ScopeConfig, ScopeProduct, ShippingRequest, ShippingResponse, SteelRequest, SteelResponse, StrapiItem, StrapiResponse, TelecommunicationRequest, TelecommunicationResponse, TextileRequest, TextileResponse, TransportationEmission, TransportationEmissionAttributes, TransportationEmissionsResponse, UtilitiesRequest, UtilitiesResponse, ValidationError, VehicleEmission, VehicleEmissionAttributes, VehicleEmissionsResponse };
package/dist/index.esm.js CHANGED
@@ -38363,505 +38363,6 @@ const supportsIntensityCalculations = (industry) => {
38363
38363
  const config = getIndustryFieldConfig(industry);
38364
38364
  return config.enableIntensityCalculations || false;
38365
38365
  };
38366
- // Industry-specific mappings from user data to Carbon Intensity API requirements
38367
- const CARBON_INTENSITY_FIELD_MAPPINGS = {
38368
- // Steel Industry Mapping (API expects: revenue + steel_production)
38369
- Steel: {
38370
- revenue: {
38371
- userDataPath: "additionalConfig.erp.steel.plants.{plantName}.revenue",
38372
- transform: (value) => parseFloat(value) || 0,
38373
- required: true,
38374
- fieldLabel: "Revenue (₹Cr)",
38375
- industryFieldKey: "revenue",
38376
- },
38377
- steel_production: {
38378
- userDataPath: "additionalConfig.erp.steel.plants.{plantName}.crudeSteel",
38379
- transform: (value) => parseFloat(value) || 0,
38380
- required: true,
38381
- fieldLabel: "Crude Steel Production (tonnes)",
38382
- industryFieldKey: "crudeSteel",
38383
- },
38384
- },
38385
- // Pharmaceutical Industry Mapping (API expects: area + production)
38386
- Pharmaceutical: {
38387
- area: {
38388
- userDataPath: "additionalConfig.erp.pharmaceutical.plants.{plantName}.productionFacilityArea",
38389
- transform: (value) => parseFloat(value) || 0,
38390
- required: true,
38391
- fieldLabel: "Production Facility Area (m²)",
38392
- industryFieldKey: "productionFacilityArea",
38393
- },
38394
- production: {
38395
- userDataPath: "additionalConfig.erp.pharmaceutical.plants.{plantName}.annualProductionVolume",
38396
- transform: (value) => parseFloat(value) || 0,
38397
- required: true,
38398
- fieldLabel: "Annual Production Volume (tonnes)",
38399
- industryFieldKey: "annualProductionVolume",
38400
- },
38401
- },
38402
- // Chemical Industry Mapping (API expects: production only)
38403
- Chemical: {
38404
- production: {
38405
- userDataPath: "additionalConfig.erp.chemical.plants.{plantName}.totalProduction",
38406
- transform: (value) => parseFloat(value) || 0,
38407
- required: true,
38408
- fieldLabel: "Total Chemical Production (tonnes)",
38409
- industryFieldKey: "totalProduction",
38410
- },
38411
- },
38412
- // Aluminum Industry Mapping (API expects: production only)
38413
- Aluminum: {
38414
- production: {
38415
- userDataPath: "additionalConfig.erp.aluminum.plants.{plantName}.annualProduction",
38416
- transform: (value) => parseFloat(value) || 0,
38417
- required: true,
38418
- fieldLabel: "Annual Production (tonnes)",
38419
- industryFieldKey: "annualProduction",
38420
- },
38421
- },
38422
- // Alloy Industry Mapping (API expects: area + production)
38423
- Alloy: {
38424
- area: {
38425
- userDataPath: "additionalConfig.erp.alloy.plants.{plantName}.facilityArea",
38426
- transform: (value) => parseFloat(value) || 0,
38427
- required: true,
38428
- fieldLabel: "Facility Area (m²)",
38429
- industryFieldKey: "facilityArea",
38430
- },
38431
- production: {
38432
- userDataPath: "additionalConfig.erp.alloy.plants.{plantName}.annualProductionVolume",
38433
- transform: (value) => parseFloat(value) || 0,
38434
- required: true,
38435
- fieldLabel: "Annual Production Volume (tonnes)",
38436
- industryFieldKey: "annualProductionVolume",
38437
- },
38438
- },
38439
- // Textile Industry Mapping (API expects: area + production)
38440
- Textile: {
38441
- area: {
38442
- userDataPath: "additionalConfig.erp.textile.plants.{plantName}.productionFacilityArea",
38443
- transform: (value) => parseFloat(value) || 0,
38444
- required: true,
38445
- fieldLabel: "Production Facility Area (m²)",
38446
- industryFieldKey: "productionFacilityArea",
38447
- },
38448
- production: {
38449
- userDataPath: "additionalConfig.erp.textile.plants.{plantName}.annualProductionVolume",
38450
- transform: (value) => parseFloat(value) || 0,
38451
- required: true,
38452
- fieldLabel: "Annual Production Volume (tonnes)",
38453
- industryFieldKey: "annualProductionVolume",
38454
- },
38455
- },
38456
- // Automobile Industry Mapping (API expects: annual_production_units)
38457
- Automobiles: {
38458
- annual_production_units: {
38459
- userDataPath: "additionalConfig.erp.automobiles.plants.{plantName}.annualProductionVolume",
38460
- transform: (value) => parseFloat(value) || 0,
38461
- required: true,
38462
- fieldLabel: "Annual Production Volume (Units)",
38463
- industryFieldKey: "annualProductionVolume",
38464
- },
38465
- },
38466
- // Aviation Industry Mapping (API expects: area only)
38467
- Aviation: {
38468
- area: {
38469
- userDataPath: "additionalConfig.erp.aviation.plants.{plantName}.facilitiesArea",
38470
- transform: (value) => parseFloat(value) || 0,
38471
- required: true,
38472
- fieldLabel: "Facilities Area (m²)",
38473
- industryFieldKey: "facilitiesArea",
38474
- },
38475
- },
38476
- // Shipping Industry Mapping (API expects: area + employees)
38477
- Shipping: {
38478
- area: {
38479
- userDataPath: "additionalConfig.erp.shipping.plants.{plantName}.portTerminalFacilitiesArea",
38480
- transform: (value) => parseFloat(value) || 0,
38481
- required: true,
38482
- fieldLabel: "Port & Terminal Facilities Area (m²)",
38483
- industryFieldKey: "portTerminalFacilitiesArea",
38484
- },
38485
- employees: {
38486
- userDataPath: "additionalConfig.erp.shipping.plants.{plantName}.numberOfEmployees",
38487
- transform: (value) => parseFloat(value) || 0,
38488
- required: true,
38489
- fieldLabel: "Number of Employees",
38490
- industryFieldKey: "numberOfEmployees",
38491
- },
38492
- },
38493
- // Food & Beverages Industry Mapping (API expects: production_facility_area + production)
38494
- "Food & Beverages": {
38495
- production_facility_area: {
38496
- userDataPath: "additionalConfig.erp.food & beverages.plants.{plantName}.productionFacilityArea",
38497
- transform: (value) => parseFloat(value) || 0,
38498
- required: true,
38499
- fieldLabel: "Production Facility Area (m²)",
38500
- industryFieldKey: "productionFacilityArea",
38501
- },
38502
- production: {
38503
- userDataPath: "additionalConfig.erp.food & beverages.plants.{plantName}.annualProductionVolume",
38504
- transform: (value) => parseFloat(value) || 0,
38505
- required: true,
38506
- fieldLabel: "Annual Production Volume (tonnes)",
38507
- industryFieldKey: "annualProductionVolume",
38508
- },
38509
- },
38510
- // Hospitality Industry Mapping (API expects: built_up_area only)
38511
- Hospitality: {
38512
- built_up_area: {
38513
- userDataPath: "additionalConfig.erp.hospitality.plants.{plantName}.totalBuiltUpArea",
38514
- transform: (value) => parseFloat(value) || 0,
38515
- required: true,
38516
- fieldLabel: "Total Built Up Area (m²)",
38517
- industryFieldKey: "totalBuiltUpArea",
38518
- },
38519
- },
38520
- // Logistics Industry Mapping (API expects: warehouse_area only)
38521
- Logistics: {
38522
- warehouse_area: {
38523
- userDataPath: "additionalConfig.erp.logistics.plants.{plantName}.warehouseSpaceOperated",
38524
- transform: (value) => parseFloat(value) || 0,
38525
- required: true,
38526
- fieldLabel: "Warehouse Space Operated (m²)",
38527
- industryFieldKey: "warehouseSpaceOperated",
38528
- },
38529
- },
38530
- // Manufacturing Industry Mapping (API expects: manufacturing_facility_area + annual_production)
38531
- Manufacturing: {
38532
- manufacturing_facility_area: {
38533
- userDataPath: "additionalConfig.erp.manufacturing.plants.{plantName}.manufacturingFacilityArea",
38534
- transform: (value) => parseFloat(value) || 0,
38535
- required: true,
38536
- fieldLabel: "Manufacturing Facility Area (m²)",
38537
- industryFieldKey: "manufacturingFacilityArea",
38538
- },
38539
- annual_production: {
38540
- userDataPath: "additionalConfig.erp.manufacturing.plants.{plantName}.annualProductionVolume",
38541
- transform: (value) => parseFloat(value) || 0,
38542
- required: true,
38543
- fieldLabel: "Annual Production Volume (tonnes)",
38544
- industryFieldKey: "annualProductionVolume",
38545
- },
38546
- },
38547
- // Metals & Energy Industry Mapping (API expects: power_generated + annual_production)
38548
- "Metals & Energy": {
38549
- power_generated: {
38550
- userDataPath: "additionalConfig.erp.metals & energy.plants.{plantName}.powerGenerated",
38551
- transform: (value) => parseFloat(value) || 0,
38552
- required: true,
38553
- fieldLabel: "Power Generated (MWH)",
38554
- industryFieldKey: "powerGenerated",
38555
- },
38556
- annual_production: {
38557
- userDataPath: "additionalConfig.erp.metals & energy.plants.{plantName}.annualProductionVolume",
38558
- transform: (value) => parseFloat(value) || 0,
38559
- required: true,
38560
- fieldLabel: "Annual Production Volume (tonnes)",
38561
- industryFieldKey: "annualProductionVolume",
38562
- },
38563
- },
38564
- // Packaging Industry Mapping (API expects: packaging_units only)
38565
- Packaging: {
38566
- packaging_units: {
38567
- userDataPath: "additionalConfig.erp.packaging.plants.{plantName}.packagingUnitsProduced",
38568
- transform: (value) => parseFloat(value) || 0,
38569
- required: true,
38570
- fieldLabel: "Packaging Units Produced",
38571
- industryFieldKey: "packagingUnitsProduced",
38572
- },
38573
- },
38574
- // Petrochemical Industry Mapping (API expects: chemical_production only)
38575
- "Petro Chemical": {
38576
- chemical_production: {
38577
- userDataPath: "additionalConfig.erp.petro chemical.plants.{plantName}.annualProductionVolume",
38578
- transform: (value) => parseFloat(value) || 0,
38579
- required: true,
38580
- fieldLabel: "Chemical Production (tonnes)",
38581
- industryFieldKey: "annualProductionVolume",
38582
- },
38583
- },
38584
- // Real Estate Industry Mapping (API expects: project_site_area only)
38585
- "Real Estate & Construction": {
38586
- project_site_area: {
38587
- userDataPath: "additionalConfig.erp.real estate & construction.plants.{plantName}.projectSiteArea",
38588
- transform: (value) => parseFloat(value) || 0,
38589
- required: true,
38590
- fieldLabel: "Project Site Area (m²)",
38591
- industryFieldKey: "projectSiteArea",
38592
- },
38593
- },
38594
- // Telecommunications Industry Mapping (API expects: project_site_area only)
38595
- Telecommunications: {
38596
- project_site_area: {
38597
- userDataPath: "additionalConfig.erp.telecommunications.plants.{plantName}.projectSiteArea",
38598
- transform: (value) => parseFloat(value) || 0,
38599
- required: true,
38600
- fieldLabel: "Project Site Area (m²)",
38601
- industryFieldKey: "projectSiteArea",
38602
- },
38603
- },
38604
- // Utilities Industry Mapping (API expects: total_area + annual_production)
38605
- Utilities: {
38606
- total_area: {
38607
- userDataPath: "additionalConfig.erp.utilities.plants.{plantName}.plantArea",
38608
- transform: (value) => parseFloat(value) || 0,
38609
- required: true,
38610
- fieldLabel: "Plant Area (m²)",
38611
- industryFieldKey: "plantArea",
38612
- },
38613
- annual_production: {
38614
- userDataPath: "additionalConfig.erp.utilities.plants.{plantName}.annualProductionServiceOutput",
38615
- transform: (value) => parseFloat(value) || 0,
38616
- required: true,
38617
- fieldLabel: "Annual Production/Service Output",
38618
- industryFieldKey: "annualProductionServiceOutput",
38619
- },
38620
- },
38621
- // Cement Industry Mapping (API expects: manufacturing_facility_area + annual_production)
38622
- Cement: {
38623
- manufacturing_facility_area: {
38624
- userDataPath: "additionalConfig.erp.cement.plants.{plantName}.manufacturingFacilityArea",
38625
- transform: (value) => parseFloat(value) || 0,
38626
- required: true,
38627
- fieldLabel: "Manufacturing Facility Area (m²)",
38628
- industryFieldKey: "manufacturingFacilityArea",
38629
- },
38630
- annual_production: {
38631
- userDataPath: "additionalConfig.erp.cement.plants.{plantName}.cementProduced",
38632
- transform: (value) => parseFloat(value) || 0,
38633
- required: true,
38634
- fieldLabel: "Cement Produced (tonnes)",
38635
- industryFieldKey: "cementProduced",
38636
- },
38637
- },
38638
- // Battery & EV Infrastructure (fallback to manufacturing structure)
38639
- "Battery & EV Infra": {
38640
- manufacturing_facility_area: {
38641
- userDataPath: "additionalConfig.erp.battery & ev infra.plants.{plantName}.facilityArea",
38642
- transform: (value) => parseFloat(value) || 0,
38643
- required: true,
38644
- fieldLabel: "Facility Area (m²)",
38645
- industryFieldKey: "facilityArea",
38646
- },
38647
- annual_production: {
38648
- userDataPath: "additionalConfig.erp.battery & ev infra.plants.{plantName}.annualProduction",
38649
- transform: (value) => parseFloat(value) || 0,
38650
- required: true,
38651
- fieldLabel: "Annual Production (units)",
38652
- industryFieldKey: "annualProduction",
38653
- },
38654
- },
38655
- // Default mapping for industries without specific configuration
38656
- default: {
38657
- manufacturing_facility_area: {
38658
- userDataPath: "additionalConfig.erp.{industry}.plants.{plantName}.facilityArea",
38659
- transform: (value) => parseFloat(value) || 0,
38660
- required: true,
38661
- fieldLabel: "Facility Area (m²)",
38662
- industryFieldKey: "facilityArea",
38663
- },
38664
- annual_production: {
38665
- userDataPath: "additionalConfig.erp.{industry}.plants.{plantName}.annualProduction",
38666
- transform: (value) => parseFloat(value) || 0,
38667
- required: true,
38668
- fieldLabel: "Annual Production (tonnes)",
38669
- industryFieldKey: "annualProduction",
38670
- },
38671
- },
38672
- };
38673
- // Helper function to get nested value from object using dot notation
38674
- const getNestedValue = (obj, path) => {
38675
- if (!obj || !path)
38676
- return undefined;
38677
- // Handle array notation like "plants[].plantData.field"
38678
- if (path.includes("[].")) {
38679
- const [arrayPath, ...restPath] = path.split("[].", 2);
38680
- const arrayValue = getNestedValue(obj, arrayPath);
38681
- if (Array.isArray(arrayValue) && arrayValue.length > 0) {
38682
- // For now, take the first item in the array
38683
- return getNestedValue(arrayValue[0], restPath.join("[]."));
38684
- }
38685
- return undefined;
38686
- }
38687
- return path.split(".").reduce((current, key) => {
38688
- return current && current[key] !== undefined ? current[key] : undefined;
38689
- }, obj);
38690
- };
38691
- // Main function to extract carbon intensity data from user data
38692
- const extractCarbonIntensityData = (userData, industry) => {
38693
- var _a, _b;
38694
- let mapping = CARBON_INTENSITY_FIELD_MAPPINGS[industry];
38695
- // If no mapping found, try default mapping
38696
- if (!mapping) {
38697
- mapping = CARBON_INTENSITY_FIELD_MAPPINGS.default;
38698
- console.warn(`No specific carbon intensity mapping found for industry: ${industry}, using default mapping`);
38699
- }
38700
- const extractedData = {};
38701
- // Get the current plant name - use the first available plant or a default
38702
- const industryData = (_b = (_a = userData.additionalConfig) === null || _a === void 0 ? void 0 : _a.erp) === null || _b === void 0 ? void 0 : _b[industry.toLowerCase()];
38703
- const plants = industryData === null || industryData === void 0 ? void 0 : industryData.plants;
38704
- let currentPlantName = "default";
38705
- if (plants && typeof plants === "object") {
38706
- if (Array.isArray(plants)) {
38707
- // Handle array-based plants structure
38708
- if (plants.length > 0) {
38709
- // Use the first plant's id or name
38710
- const firstPlant = plants[0];
38711
- currentPlantName = firstPlant.id || firstPlant.name || "default";
38712
- console.log(`Using plant "${currentPlantName}" from array for carbon intensity data extraction`);
38713
- }
38714
- }
38715
- else {
38716
- // Handle object-based plants structure
38717
- const plantNames = Object.keys(plants);
38718
- if (plantNames.length > 0) {
38719
- currentPlantName = plantNames[0];
38720
- console.log(`Using plant "${currentPlantName}" from object for carbon intensity data extraction`);
38721
- }
38722
- }
38723
- }
38724
- Object.entries(mapping).forEach(([apiField, config]) => {
38725
- // Replace {industry} and {plantName} placeholders
38726
- let userDataPath = config.userDataPath
38727
- .replace("{industry}", industry.toLowerCase())
38728
- .replace("{plantName}", currentPlantName);
38729
- let value = getNestedValue(userData, userDataPath);
38730
- // If value not found and we have array-based plants, try alternative path
38731
- if ((value === undefined || value === null) &&
38732
- plants &&
38733
- Array.isArray(plants) &&
38734
- plants.length > 0) {
38735
- // Try to get the field directly from the first plant's plantData
38736
- const firstPlant = plants[0];
38737
- const fieldKey = config.industryFieldKey;
38738
- if (firstPlant.plantData &&
38739
- fieldKey &&
38740
- firstPlant.plantData[fieldKey] !== undefined) {
38741
- value = firstPlant.plantData[fieldKey];
38742
- console.log(`Found ${apiField} in plantData: ${value}`);
38743
- }
38744
- }
38745
- // Apply transformation if provided
38746
- if (config.transform && value !== undefined) {
38747
- value = config.transform(value);
38748
- }
38749
- // Only use fallback if config explicitly has one and field is not required
38750
- if (value === undefined || value === null || isNaN(Number(value))) {
38751
- if (config.required) {
38752
- // For required fields, set to 0 to indicate missing data (will be caught by validation)
38753
- value = 0;
38754
- }
38755
- else {
38756
- // For non-required fields, use fallback if available
38757
- value = config.fallback || 0;
38758
- }
38759
- }
38760
- extractedData[apiField] = Number(value);
38761
- });
38762
- return extractedData;
38763
- };
38764
- // Helper function to map frontend industry names to API industry types
38765
- const mapIndustryToApiType = (industryName) => {
38766
- const industryMapping = {
38767
- Steel: "steel",
38768
- Pharmaceutical: "pharma",
38769
- Chemical: "chemical",
38770
- Aluminum: "aluminium",
38771
- Alloy: "alloy",
38772
- Textile: "textile",
38773
- Automobiles: "automobile",
38774
- Aviation: "aviation",
38775
- Shipping: "shipping",
38776
- "Food & Beverages": "food_beverages",
38777
- Hospitality: "hospitality",
38778
- Logistics: "logistics",
38779
- Manufacturing: "manufacturing",
38780
- "Metals & Energy": "metal_energy",
38781
- "Battery & EV Infra": "manufacturing", // Falls back to manufacturing
38782
- Packaging: "packaging",
38783
- "Petro Chemical": "petrochemical",
38784
- "Real Estate & Construction": "real_estate",
38785
- Telecommunications: "telecommunication",
38786
- Utilities: "utilities",
38787
- Cement: "manufacturing", // Maps cement to manufacturing API
38788
- };
38789
- return industryMapping[industryName] || "manufacturing";
38790
- };
38791
- // Helper function to get available fields for an industry from user data
38792
- const getAvailableFieldsForIndustry = (userData, industry) => {
38793
- const mapping = CARBON_INTENSITY_FIELD_MAPPINGS[industry];
38794
- if (!mapping)
38795
- return [];
38796
- const availableFields = [];
38797
- Object.entries(mapping).forEach(([apiField, config]) => {
38798
- const value = getNestedValue(userData, config.userDataPath);
38799
- if (value !== undefined && value !== null && value !== "") {
38800
- availableFields.push(apiField);
38801
- }
38802
- });
38803
- return availableFields;
38804
- };
38805
- // Helper function to validate that required data is available
38806
- const validateCarbonIntensityData = (userData, industry) => {
38807
- var _a, _b;
38808
- let mapping = CARBON_INTENSITY_FIELD_MAPPINGS[industry];
38809
- if (!mapping) {
38810
- mapping = CARBON_INTENSITY_FIELD_MAPPINGS.default;
38811
- }
38812
- const extractedData = extractCarbonIntensityData(userData, industry);
38813
- const missingFields = [];
38814
- const errors = [];
38815
- // Get the current plant name for error messages
38816
- const industryData = (_b = (_a = userData.additionalConfig) === null || _a === void 0 ? void 0 : _a.erp) === null || _b === void 0 ? void 0 : _b[industry.toLowerCase()];
38817
- const plants = industryData === null || industryData === void 0 ? void 0 : industryData.plants;
38818
- let currentPlantName = "default";
38819
- if (plants && typeof plants === "object") {
38820
- if (Array.isArray(plants)) {
38821
- // Handle array-based plants structure
38822
- if (plants.length > 0) {
38823
- // Use the first plant's id or name
38824
- const firstPlant = plants[0];
38825
- currentPlantName = firstPlant.id || firstPlant.name || "default";
38826
- }
38827
- }
38828
- else {
38829
- // Handle object-based plants structure
38830
- const plantNames = Object.keys(plants);
38831
- if (plantNames.length > 0) {
38832
- currentPlantName = plantNames[0];
38833
- }
38834
- }
38835
- }
38836
- Object.entries(mapping).forEach(([apiField, config]) => {
38837
- if (config.required) {
38838
- const value = extractedData[apiField];
38839
- if (!value || value === 0) {
38840
- const userDataPath = config.userDataPath
38841
- .replace("{industry}", industry.toLowerCase())
38842
- .replace("{plantName}", currentPlantName);
38843
- missingFields.push({
38844
- apiField,
38845
- fieldLabel: config.fieldLabel || apiField,
38846
- industryFieldKey: config.industryFieldKey || apiField,
38847
- userDataPath,
38848
- });
38849
- errors.push(`Missing required field: "${config.fieldLabel || apiField}" (Key: ${config.industryFieldKey || apiField}) is required for carbon intensity calculations. Please fill this field in the ${industry} industry configuration for plant "${currentPlantName}".`);
38850
- }
38851
- }
38852
- });
38853
- return {
38854
- isValid: missingFields.length === 0,
38855
- missingFields,
38856
- errors,
38857
- };
38858
- };
38859
- // Debug function to see what data is being extracted
38860
- const debugCarbonIntensityMapping = (userData, industry) => {
38861
- CARBON_INTENSITY_FIELD_MAPPINGS[industry] ||
38862
- CARBON_INTENSITY_FIELD_MAPPINGS.default;
38863
- extractCarbonIntensityData(userData, industry);
38864
- };
38865
38366
 
38866
38367
  /**
38867
38368
  * UI Features Configuration System
@@ -40575,5 +40076,5 @@ var index = /*#__PURE__*/Object.freeze({
40575
40076
  getUserNameScope3Config: getUserNameScope3Config
40576
40077
  });
40577
40078
 
40578
- export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CARBON_INTENSITY_FIELD_MAPPINGS, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, debugCarbonIntensityMapping, extractCarbonIntensityData, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getAvailableFieldsForIndustry, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getNestedValue, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, mapIndustryToApiType, sanitizeNumber, supportsIntensityCalculations, validateCarbonIntensityData };
40079
+ export { API_ENDPOINTS, API_SCOPE3_CEMENT_CONFIG, BILL_CALCULATION_CONFIGS, BillManager, CCTS_ALLSCOPES_CEMENT, CCTS_CALCINATION_PRODUCTS, CCTS_ELECTRICITY_PRODUCTS, CCTS_FIRE_EXTINGUISHER_PRODUCTS, CCTS_FUEL_COMBUSTION_PRODUCTS, CCTS_LPG_PRODUCTS, CCTS_MINING_OPERATIONS_PRODUCTS, CCTS_ONSITE_POWER_PRODUCTS, CCTS_PURCHASED_ELECTRICITY, CCTS_REFRIGERANTS, CCTS_SCOPE1_CEMENT, CCTS_SCOPE2_CEMENT, CCTS_SF6_PRODUCTS, CCTS_TABLE_COLUMNS, DEFAULT_BILL_MATCHING_CONFIG, EmissionSourceGenerator, FRONTEND_INDUSTRY_CONFIGS, HTTP_STATUS, INDUSTRIES_CONFIG, INDUSTRY_MAPPING, INDUSTRY_SPECIFIC_FIELDS, INTENSITY_FIELD_LABELS, ISO_CATEGORIES_PACKAGING, index as Industries, UI_FEATURES, WATER_PRODUCTS, calculateCCTSEmission, calculateIntensityMetrics, categorizeApiItem, cleanValue, createBillManager, createCapitalizedMonthMapping, createEmissionSourceGenerator, createMonthMapping, formatEmissionValue, formatIntensityValue, formatKPIEmission, formatMonthlyEmission, formatPercentage, getApiIndustryType, getIndustryConfig, getIndustryFieldConfig, getIntensityFormulas, getPlantNameConfig, getScope3ConfigByName, getUserNameWaterManagementConfig, hasIntensities, isUIFeatureEnabled, sanitizeNumber, supportsIntensityCalculations };
40579
40080
  //# sourceMappingURL=index.esm.js.map