@zerocarbon/erp-config-sdk 1.0.31 → 1.0.33

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
@@ -37671,6 +37671,7 @@ const BULK_BILL_AGENT_PROFILES = {
37671
37671
  extractionRules: [
37672
37672
  'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',
37673
37673
  'For grid import or purchased electricity, use current-period import/from-grid consumption.',
37674
+ 'When a purchased grid electricity bill does not explicitly distinguish national vs regional grid, default the ERP mapping to Regional Grid; do not send it to review for that ambiguity alone.',
37674
37675
  'For solar or renewable electricity, use current-period generation or renewable energy consumption.',
37675
37676
  'Treat “units” as kWh only for electricity documents.',
37676
37677
  ],
@@ -38891,7 +38892,7 @@ class BillManager {
38891
38892
  return matchingBills;
38892
38893
  }
38893
38894
  // Create a bill object with proper calculation
38894
- createBill(userId, category, activityData, emissionItem, year, month, scope, industry = "cement", vendorConfig, massData, plantId) {
38895
+ createBill(userId, category, activityData, emissionItem, year, month, scope, industry = "cement", vendorConfig, massData, plantId, options = {}) {
38895
38896
  const calculationConfig = this.getCalculationConfig(industry, scope, category);
38896
38897
  const amountCalculated = this.calculateEmissions(activityData, emissionItem.emissionFactor, calculationConfig, massData);
38897
38898
  const multiplicationFactor = this.getMultiplicationFactor(emissionItem.emissionFactor, calculationConfig);
@@ -38908,8 +38909,12 @@ class BillManager {
38908
38909
  nestedSubCategory: emissionItem.item,
38909
38910
  amountCalculated: amountCalculated,
38910
38911
  multiplicationFactor: multiplicationFactor,
38912
+ billAmount: sanitizeNumber(options.billAmount),
38911
38913
  massData: massData,
38912
- config: vendorConfig || {},
38914
+ config: {
38915
+ ...(vendorConfig || {}),
38916
+ ...(options.config || {}),
38917
+ },
38913
38918
  };
38914
38919
  }
38915
38920
  // Get calculation configuration for specific context
@@ -39086,6 +39091,7 @@ const formatKPIEmission = (value) => {
39086
39091
  }
39087
39092
  };
39088
39093
 
39094
+ const sumBillAmounts = (bills) => bills.reduce((sum, bill) => sum + sanitizeNumber(bill.billAmount), 0);
39089
39095
  class EmissionSourceGenerator {
39090
39096
  constructor(billManager) {
39091
39097
  this.billManager = billManager;
@@ -39109,6 +39115,7 @@ class EmissionSourceGenerator {
39109
39115
  });
39110
39116
  const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
39111
39117
  const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
39118
+ const totalBillAmount = sumBillAmounts(matchingBills);
39112
39119
  sources.push({
39113
39120
  id: sourceId,
39114
39121
  itemName: subProduct.name,
@@ -39119,6 +39126,7 @@ class EmissionSourceGenerator {
39119
39126
  totalEmissions,
39120
39127
  amount: totalActivityData.toString(),
39121
39128
  activityData: totalActivityData,
39129
+ billAmount: totalBillAmount,
39122
39130
  isEditing: false,
39123
39131
  bill: matchingBills[0],
39124
39132
  scope: scopeConfig.scope || "scope1",
@@ -39144,6 +39152,7 @@ class EmissionSourceGenerator {
39144
39152
  const matchingBills = this.billManager.findBillsForEmissionItem(apiItem, scopeConfig.name, year, monthNumber, scopeConfig.scope || "scope3");
39145
39153
  const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
39146
39154
  const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
39155
+ const totalBillAmount = sumBillAmounts(matchingBills);
39147
39156
  sources.push({
39148
39157
  id: sourceId,
39149
39158
  itemName: apiItem.item,
@@ -39154,6 +39163,7 @@ class EmissionSourceGenerator {
39154
39163
  totalEmissions,
39155
39164
  amount: totalActivityData.toString(),
39156
39165
  activityData: totalActivityData,
39166
+ billAmount: totalBillAmount,
39157
39167
  isEditing: false,
39158
39168
  bill: matchingBills[0],
39159
39169
  scope: scopeConfig.scope || "scope3",
@@ -39186,6 +39196,7 @@ class EmissionSourceGenerator {
39186
39196
  });
39187
39197
  const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
39188
39198
  const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
39199
+ const totalBillAmount = sumBillAmounts(matchingBills);
39189
39200
  sources.push({
39190
39201
  id: sourceId,
39191
39202
  itemName: item.item,
@@ -39196,6 +39207,7 @@ class EmissionSourceGenerator {
39196
39207
  totalEmissions,
39197
39208
  amount: totalActivityData.toString(),
39198
39209
  activityData: totalActivityData,
39210
+ billAmount: totalBillAmount,
39199
39211
  isEditing: false,
39200
39212
  bill: matchingBills[0],
39201
39213
  scope: scopeConfig.scope || "scope3",