@zerocarbon/erp-config-sdk 1.0.32 → 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.d.ts +9 -2
- package/dist/index.esm.js +13 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -38892,7 +38892,7 @@ class BillManager {
|
|
|
38892
38892
|
return matchingBills;
|
|
38893
38893
|
}
|
|
38894
38894
|
// Create a bill object with proper calculation
|
|
38895
|
-
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 = {}) {
|
|
38896
38896
|
const calculationConfig = this.getCalculationConfig(industry, scope, category);
|
|
38897
38897
|
const amountCalculated = this.calculateEmissions(activityData, emissionItem.emissionFactor, calculationConfig, massData);
|
|
38898
38898
|
const multiplicationFactor = this.getMultiplicationFactor(emissionItem.emissionFactor, calculationConfig);
|
|
@@ -38909,8 +38909,12 @@ class BillManager {
|
|
|
38909
38909
|
nestedSubCategory: emissionItem.item,
|
|
38910
38910
|
amountCalculated: amountCalculated,
|
|
38911
38911
|
multiplicationFactor: multiplicationFactor,
|
|
38912
|
+
billAmount: sanitizeNumber(options.billAmount),
|
|
38912
38913
|
massData: massData,
|
|
38913
|
-
config:
|
|
38914
|
+
config: {
|
|
38915
|
+
...(vendorConfig || {}),
|
|
38916
|
+
...(options.config || {}),
|
|
38917
|
+
},
|
|
38914
38918
|
};
|
|
38915
38919
|
}
|
|
38916
38920
|
// Get calculation configuration for specific context
|
|
@@ -39087,6 +39091,7 @@ const formatKPIEmission = (value) => {
|
|
|
39087
39091
|
}
|
|
39088
39092
|
};
|
|
39089
39093
|
|
|
39094
|
+
const sumBillAmounts = (bills) => bills.reduce((sum, bill) => sum + sanitizeNumber(bill.billAmount), 0);
|
|
39090
39095
|
class EmissionSourceGenerator {
|
|
39091
39096
|
constructor(billManager) {
|
|
39092
39097
|
this.billManager = billManager;
|
|
@@ -39110,6 +39115,7 @@ class EmissionSourceGenerator {
|
|
|
39110
39115
|
});
|
|
39111
39116
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39112
39117
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39118
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39113
39119
|
sources.push({
|
|
39114
39120
|
id: sourceId,
|
|
39115
39121
|
itemName: subProduct.name,
|
|
@@ -39120,6 +39126,7 @@ class EmissionSourceGenerator {
|
|
|
39120
39126
|
totalEmissions,
|
|
39121
39127
|
amount: totalActivityData.toString(),
|
|
39122
39128
|
activityData: totalActivityData,
|
|
39129
|
+
billAmount: totalBillAmount,
|
|
39123
39130
|
isEditing: false,
|
|
39124
39131
|
bill: matchingBills[0],
|
|
39125
39132
|
scope: scopeConfig.scope || "scope1",
|
|
@@ -39145,6 +39152,7 @@ class EmissionSourceGenerator {
|
|
|
39145
39152
|
const matchingBills = this.billManager.findBillsForEmissionItem(apiItem, scopeConfig.name, year, monthNumber, scopeConfig.scope || "scope3");
|
|
39146
39153
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39147
39154
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39155
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39148
39156
|
sources.push({
|
|
39149
39157
|
id: sourceId,
|
|
39150
39158
|
itemName: apiItem.item,
|
|
@@ -39155,6 +39163,7 @@ class EmissionSourceGenerator {
|
|
|
39155
39163
|
totalEmissions,
|
|
39156
39164
|
amount: totalActivityData.toString(),
|
|
39157
39165
|
activityData: totalActivityData,
|
|
39166
|
+
billAmount: totalBillAmount,
|
|
39158
39167
|
isEditing: false,
|
|
39159
39168
|
bill: matchingBills[0],
|
|
39160
39169
|
scope: scopeConfig.scope || "scope3",
|
|
@@ -39187,6 +39196,7 @@ class EmissionSourceGenerator {
|
|
|
39187
39196
|
});
|
|
39188
39197
|
const totalEmissions = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amountCalculated), 0);
|
|
39189
39198
|
const totalActivityData = matchingBills.reduce((sum, bill) => sum + sanitizeNumber(bill.amount), 0);
|
|
39199
|
+
const totalBillAmount = sumBillAmounts(matchingBills);
|
|
39190
39200
|
sources.push({
|
|
39191
39201
|
id: sourceId,
|
|
39192
39202
|
itemName: item.item,
|
|
@@ -39197,6 +39207,7 @@ class EmissionSourceGenerator {
|
|
|
39197
39207
|
totalEmissions,
|
|
39198
39208
|
amount: totalActivityData.toString(),
|
|
39199
39209
|
activityData: totalActivityData,
|
|
39210
|
+
billAmount: totalBillAmount,
|
|
39200
39211
|
isEditing: false,
|
|
39201
39212
|
bill: matchingBills[0],
|
|
39202
39213
|
scope: scopeConfig.scope || "scope3",
|