@zerocarbon/erp-config-sdk 1.0.11 → 1.0.13

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.js CHANGED
@@ -34582,85 +34582,6 @@ const getIndustryConfig = (industry, username) => {
34582
34582
  return defaultConfig;
34583
34583
  };
34584
34584
 
34585
- /**
34586
- * Format emission values to handle small numbers properly while keeping UI clean
34587
- */
34588
- const formatEmissionValue = (value, options) => {
34589
- const { unit = "tonne CO₂e", showUnit = false, forceDecimals, } = options || {};
34590
- if (value === 0)
34591
- return showUnit ? `0 ${unit}` : "0";
34592
- let formatted;
34593
- if (forceDecimals !== undefined) {
34594
- formatted = value.toFixed(forceDecimals);
34595
- }
34596
- else if (value >= 1000) {
34597
- // Large values: show 1 decimal place
34598
- formatted = value.toFixed(1);
34599
- }
34600
- else if (value >= 10) {
34601
- // Medium values: show 1 decimal place
34602
- formatted = value.toFixed(1);
34603
- }
34604
- else if (value >= 1) {
34605
- // Values between 1-10: show 2 decimal places
34606
- formatted = value.toFixed(2);
34607
- }
34608
- else if (value >= 0.01) {
34609
- // Small values: show 3 decimal places
34610
- formatted = value.toFixed(3);
34611
- }
34612
- else if (value >= 0.001) {
34613
- // Very small values: show 5 decimal places to preserve precision
34614
- formatted = value.toFixed(5);
34615
- }
34616
- else {
34617
- // Extremely small values: show 6 decimal places
34618
- formatted = value.toFixed(6);
34619
- }
34620
- // Remove trailing zeros after decimal point
34621
- formatted = formatted.replace(/\.?0+$/, "");
34622
- return showUnit ? `${formatted} ${unit}` : formatted;
34623
- };
34624
- /**
34625
- * Format emission values specifically for monthly display (show small values properly)
34626
- */
34627
- const formatMonthlyEmission = (value) => {
34628
- if (value === 0)
34629
- return "0";
34630
- // Format with maximum 5 decimal places, removing trailing zeros
34631
- const formatted = value.toFixed(5).replace(/\.?0+$/, "");
34632
- return formatted;
34633
- };
34634
- /**
34635
- * Format percentage values
34636
- */
34637
- const formatPercentage = (value) => {
34638
- if (value === 0)
34639
- return "0 %";
34640
- if (Math.abs(value) >= 1) {
34641
- return `${Math.abs(value).toFixed(0)} %`;
34642
- }
34643
- else {
34644
- return `${Math.abs(value).toFixed(1)} %`;
34645
- }
34646
- };
34647
- /**
34648
- * Format large emission values for KPI cards
34649
- */
34650
- const formatKPIEmission = (value) => {
34651
- if (value === 0)
34652
- return "0.0";
34653
- if (value >= 1000) {
34654
- return value.toFixed(1);
34655
- }
34656
- else if (value >= 1) {
34657
- return value.toFixed(1);
34658
- }
34659
- else {
34660
- return formatEmissionValue(value);
34661
- }
34662
- };
34663
-
34664
34585
  // Default calculation configurations
34665
34586
  const BILL_CALCULATION_CONFIGS = [
34666
34587
  {
@@ -34889,6 +34810,85 @@ const createBillManager = (bills, matchingConfig) => {
34889
34810
  return new BillManager(bills, matchingConfig);
34890
34811
  };
34891
34812
 
34813
+ /**
34814
+ * Format emission values to handle small numbers properly while keeping UI clean
34815
+ */
34816
+ const formatEmissionValue = (value, options) => {
34817
+ const { unit = "tonne CO₂e", showUnit = false, forceDecimals, } = options || {};
34818
+ if (value === 0)
34819
+ return showUnit ? `0 ${unit}` : "0";
34820
+ let formatted;
34821
+ if (forceDecimals !== undefined) {
34822
+ formatted = value.toFixed(forceDecimals);
34823
+ }
34824
+ else if (value >= 1000) {
34825
+ // Large values: show 1 decimal place
34826
+ formatted = value.toFixed(1);
34827
+ }
34828
+ else if (value >= 10) {
34829
+ // Medium values: show 1 decimal place
34830
+ formatted = value.toFixed(1);
34831
+ }
34832
+ else if (value >= 1) {
34833
+ // Values between 1-10: show 2 decimal places
34834
+ formatted = value.toFixed(2);
34835
+ }
34836
+ else if (value >= 0.01) {
34837
+ // Small values: show 3 decimal places
34838
+ formatted = value.toFixed(3);
34839
+ }
34840
+ else if (value >= 0.001) {
34841
+ // Very small values: show 5 decimal places to preserve precision
34842
+ formatted = value.toFixed(5);
34843
+ }
34844
+ else {
34845
+ // Extremely small values: show 6 decimal places
34846
+ formatted = value.toFixed(6);
34847
+ }
34848
+ // Remove trailing zeros after decimal point
34849
+ formatted = formatted.replace(/\.?0+$/, "");
34850
+ return showUnit ? `${formatted} ${unit}` : formatted;
34851
+ };
34852
+ /**
34853
+ * Format emission values specifically for monthly display (show small values properly)
34854
+ */
34855
+ const formatMonthlyEmission = (value) => {
34856
+ if (value === 0)
34857
+ return "0";
34858
+ // Format with maximum 5 decimal places, removing trailing zeros
34859
+ const formatted = value.toFixed(5).replace(/\.?0+$/, "");
34860
+ return formatted;
34861
+ };
34862
+ /**
34863
+ * Format percentage values
34864
+ */
34865
+ const formatPercentage = (value) => {
34866
+ if (value === 0)
34867
+ return "0 %";
34868
+ if (Math.abs(value) >= 1) {
34869
+ return `${Math.abs(value).toFixed(0)} %`;
34870
+ }
34871
+ else {
34872
+ return `${Math.abs(value).toFixed(1)} %`;
34873
+ }
34874
+ };
34875
+ /**
34876
+ * Format large emission values for KPI cards
34877
+ */
34878
+ const formatKPIEmission = (value) => {
34879
+ if (value === 0)
34880
+ return "0.0";
34881
+ if (value >= 1000) {
34882
+ return value.toFixed(1);
34883
+ }
34884
+ else if (value >= 1) {
34885
+ return value.toFixed(1);
34886
+ }
34887
+ else {
34888
+ return formatEmissionValue(value);
34889
+ }
34890
+ };
34891
+
34892
34892
  class EmissionSourceGenerator {
34893
34893
  constructor(billManager) {
34894
34894
  this.billManager = billManager;