@zerocarbon/erp-config-sdk 1.0.27 → 1.0.28

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.
@@ -0,0 +1,271 @@
1
+ 'use strict';
2
+
3
+ const normalize = (value) => String(value !== null && value !== void 0 ? value : '')
4
+ .toLowerCase()
5
+ .replace(/co₂/g, 'co2')
6
+ .replace(/[^a-z0-9]+/g, ' ')
7
+ .trim();
8
+ const includesAny = (text, signals) => signals.some((signal) => text.includes(signal));
9
+ const itemText = (item) => normalize([
10
+ item.itemName,
11
+ item.billCategory,
12
+ item.billSubCategory,
13
+ item.billNestedSubCategory,
14
+ item.billType,
15
+ item.unit,
16
+ ].filter(Boolean).join(' '));
17
+ const mappingContextText = (context = {}) => normalize([
18
+ context.scope,
19
+ context.category,
20
+ ...(Array.isArray(context.allowedItems) ? context.allowedItems.map(itemText) : []),
21
+ ].filter(Boolean).join(' '));
22
+ const BULK_BILL_AGENT_PROFILES = {
23
+ electricity: {
24
+ id: 'electricity',
25
+ label: 'Electricity',
26
+ description: 'Grid electricity, renewable electricity, kWh/kVAh/MWh utility bills.',
27
+ documentTypes: ['electricity_bill'],
28
+ itemSignals: ['electric', 'electricity', 'grid', 'renewable', 'solar', 'power', 'kwh', 'kvah', 'mwh', 'location based', 'market based', 'purchased electricity'],
29
+ documentSignals: ['kwh', 'kvah', 'mwh', 'meter', 'discom', 'vidyut', 'billed units', 'net consumption', 'energy charge'],
30
+ preferredUnits: ['kWh', 'kVAh', 'MWh'],
31
+ extractionRules: [
32
+ 'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',
33
+ 'For grid import or purchased electricity, use current-period import/from-grid consumption.',
34
+ 'For solar or renewable electricity, use current-period generation or renewable energy consumption.',
35
+ 'Treat “units” as kWh only for electricity documents.',
36
+ ],
37
+ rejectRules: ['Reject taxes, demand/fixed charges, tariff/rate rows, previous readings, arrears, and currency amounts.'],
38
+ },
39
+ fuel_combustion: {
40
+ id: 'fuel_combustion',
41
+ label: 'Fuel combustion',
42
+ description: 'Diesel, HSD, petrol, furnace oil, coal, coke, CNG and other stationary/mobile combustion fuels.',
43
+ documentTypes: ['fuel_invoice', 'material_invoice'],
44
+ itemSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'furnace oil', 'coal', 'coke', 'cng', 'kerosene', 'ldo', 'mobile combustion', 'stationary combustion', 'operation'],
45
+ documentSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'litre', 'liter', 'kl', 'furnace oil', 'coal', 'petcoke', 'cng'],
46
+ preferredUnits: ['KL', 'Litre', 'Kg', 'Tonnes', 'M3', 'SCM'],
47
+ extractionRules: [
48
+ 'Extract physical fuel quantity, not invoice amount or rate.',
49
+ 'Map vehicle fuel rows to mobile combustion items and generator/boiler/process fuel rows to stationary or operation items when the evidence supports it.',
50
+ 'Preserve the bill unit; unit conversion belongs to validation unless the document states density or conversion explicitly.',
51
+ ],
52
+ rejectRules: ['Reject fuel rates, taxes, HSN/SAC codes, payment totals, and non-fuel services.'],
53
+ },
54
+ refrigerants: {
55
+ id: 'refrigerants',
56
+ label: 'Refrigerants',
57
+ description: 'AC gas and refrigerant purchases/refills such as R-410A, R-32, R-134a, R-22.',
58
+ documentTypes: ['gas_invoice', 'material_invoice'],
59
+ itemSignals: ['refrigerant', 'refrigerants', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'hfc', 'ac gas', 'chiller'],
60
+ documentSignals: ['refrigerant', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'ac gas', 'chiller gas'],
61
+ preferredUnits: ['Kg', 'Tonnes'],
62
+ extractionRules: [
63
+ 'Extract refrigerant top-up, refill, or purchase quantity by refrigerant grade.',
64
+ 'Repair OCR variants like R410, R-410, R 410A, R-410 A to the closest allowed ERP item.',
65
+ 'Do not infer leakage; only extract documented physical quantity.',
66
+ ],
67
+ rejectRules: ['Reject service charges, labour, AC unit model numbers, invoice totals, and taxes.'],
68
+ },
69
+ industrial_gases: {
70
+ id: 'industrial_gases',
71
+ label: 'Industrial gases',
72
+ description: 'Oxygen, CO2, nitrogen, argon, acetylene and cylinder gas invoices.',
73
+ documentTypes: ['gas_invoice', 'material_invoice'],
74
+ itemSignals: ['oxygen', 'o2', 'co2', 'carbon dioxide', 'nitrogen', 'argon', 'acetylene', 'gas cylinder', 'industrial gas', 'welding'],
75
+ documentSignals: ['oxygen', 'o2 gas', 'co2 gas', 'nitrogen', 'argon', 'acetylene', 'cylinder', 'scm', 'nm3', 'm3'],
76
+ preferredUnits: ['M3', 'SCM', 'NM3', 'Kg', 'Cyl'],
77
+ extractionRules: [
78
+ 'Extract gas quantity from row-level item quantity, not cylinder deposit, rental, or amount.',
79
+ 'Keep cylinder count only when the ERP item unit supports count-based activity.',
80
+ 'Repair OCR variants such as 02/O2 and C02/CO2 using allowed ERP items.',
81
+ ],
82
+ rejectRules: ['Reject cylinder deposits, rent, returnable assets, rates, taxes, and empty cylinder rows.'],
83
+ },
84
+ employee_commuting: {
85
+ id: 'employee_commuting',
86
+ label: 'Employee commuting',
87
+ description: 'Employee commute rosters and distance summaries grouped by transport mode.',
88
+ documentTypes: ['transport_roster', 'material_invoice'],
89
+ itemSignals: ['employee commuting', 'commute', 'commuting', 'motorcycle', 'scooter', 'hatchback', 'car', 'rail', 'train', 'metro', 'bus', 'cycle', 'passenger km'],
90
+ documentSignals: ['employee', 'transport', 'mode', 'commute', 'bike', 'scooty', 'car', 'metro', 'bus', 'cycle', 'km'],
91
+ preferredUnits: ['km', 'passenger-km'],
92
+ extractionRules: [
93
+ 'Treat roster files as activity evidence even when they have no invoice number, supplier, or amount.',
94
+ 'Group by transport mode and sum current-period distance into one row per mapped ERP item.',
95
+ 'Use the upload period as the bill period when the roster has no date.',
96
+ ],
97
+ rejectRules: ['Reject employee IDs, names, phone numbers, addresses, and non-distance row counts as activity quantities.'],
98
+ },
99
+ business_travel: {
100
+ id: 'business_travel',
101
+ label: 'Business travel',
102
+ description: 'Flights, rail, hotel stays, and rental vehicle activity.',
103
+ documentTypes: ['travel_invoice', 'material_invoice'],
104
+ itemSignals: ['business travel', 'flight', 'air travel', 'rail', 'train', 'hotel', 'rental car', 'passenger km', 'room night'],
105
+ documentSignals: ['flight', 'airline', 'pnr', 'hotel', 'room night', 'train', 'rail', 'passenger km', 'ticket'],
106
+ preferredUnits: ['km', 'passenger-km', 'night', 'room-night'],
107
+ extractionRules: ['Extract distance, passenger-km, room nights, or trip counts only when the ERP item supports the unit.'],
108
+ rejectRules: ['Reject fares, taxes, booking fees, passenger names, and ticket numbers as activity quantities.'],
109
+ },
110
+ lpg_usage: {
111
+ id: 'lpg_usage',
112
+ label: 'LPG usage',
113
+ description: 'LPG cylinder and bulk LPG invoices.',
114
+ documentTypes: ['fuel_invoice', 'gas_invoice', 'material_invoice'],
115
+ itemSignals: ['lpg', 'liquefied petroleum gas', 'cylinder'],
116
+ documentSignals: ['lpg', 'liquefied petroleum', 'cylinder', 'kg', 'commercial gas'],
117
+ preferredUnits: ['Kg', 'Tonnes', 'KL', 'Cyl'],
118
+ extractionRules: ['Extract filled LPG quantity by kg/tonnes/KL/cylinder size; prefer net fill quantity over cylinder deposit count.'],
119
+ rejectRules: ['Reject cylinder deposits, rental, delivery charges, and taxes.'],
120
+ },
121
+ fire_extinguisher: {
122
+ id: 'fire_extinguisher',
123
+ label: 'Fire extinguisher refilling',
124
+ description: 'CO2 and other extinguisher refill activity.',
125
+ documentTypes: ['material_invoice'],
126
+ itemSignals: ['fire extinguisher', 'extinguisher', 'co2 fire', 'refilling'],
127
+ documentSignals: ['fire extinguisher', 'extinguisher', 'co2', 'refill', 'refilling'],
128
+ preferredUnits: ['Kg', 'Tonnes', 'Cyl'],
129
+ extractionRules: ['Extract refill gas quantity, not extinguisher asset count unless the ERP item is count-based.'],
130
+ rejectRules: ['Reject maintenance service charges, inspection fees, and asset serial numbers.'],
131
+ },
132
+ sf6_usage: {
133
+ id: 'sf6_usage',
134
+ label: 'SF6 usage',
135
+ description: 'SF6 gas purchase, refill, and switchgear top-up activity.',
136
+ documentTypes: ['gas_invoice', 'material_invoice'],
137
+ itemSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride'],
138
+ documentSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride', 'switchgear'],
139
+ preferredUnits: ['Kg', 'Tonnes'],
140
+ extractionRules: ['Extract documented SF6 purchase/refill/top-up quantity only.'],
141
+ rejectRules: ['Reject switchgear model numbers, pressure readings without refill quantity, and service charges.'],
142
+ },
143
+ water: {
144
+ id: 'water',
145
+ label: 'Water',
146
+ description: 'Municipal, borewell, tanker, and wastewater quantities.',
147
+ documentTypes: ['water_bill', 'material_invoice'],
148
+ itemSignals: ['water', 'groundwater', 'municipal', 'tanker', 'wastewater', 'effluent'],
149
+ documentSignals: ['water', 'kl', 'litre', 'liter', 'tanker', 'municipal', 'wastewater', 'effluent'],
150
+ preferredUnits: ['KL', 'Litre', 'M3'],
151
+ extractionRules: ['Extract physical water volume by source/disposal type where possible.'],
152
+ rejectRules: ['Reject water charges, sewerage taxes, arrears, and meter numbers as quantities.'],
153
+ },
154
+ waste: {
155
+ id: 'waste',
156
+ label: 'Waste generated in operations',
157
+ description: 'Waste disposal, recycling, composting, landfill, hazardous/non-hazardous waste.',
158
+ documentTypes: ['waste_invoice', 'material_invoice'],
159
+ itemSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal'],
160
+ documentSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal', 'kg', 'tonne'],
161
+ preferredUnits: ['Kg', 'Tonnes'],
162
+ extractionRules: ['Extract disposed/recycled physical waste mass by waste type and treatment route.'],
163
+ rejectRules: ['Reject disposal fees, GST, container rental, and vehicle numbers.'],
164
+ },
165
+ purchased_goods: {
166
+ id: 'purchased_goods',
167
+ label: 'Purchased goods and services',
168
+ description: 'Raw materials, consumables, and purchased product quantities.',
169
+ documentTypes: ['material_invoice', 'purchase_order'],
170
+ itemSignals: ['purchased goods', 'goods', 'services', 'material', 'raw material', 'consumable', 'packaging'],
171
+ documentSignals: ['invoice', 'tax invoice', 'hsn', 'material', 'goods', 'quantity', 'qty', 'purchase order'],
172
+ preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],
173
+ extractionRules: ['Extract row-level material quantity only when the item maps to an allowed ERP item.'],
174
+ rejectRules: ['Reject rates, taxes, HSN/SAC codes, payment terms, and unmatched non-emission materials.'],
175
+ },
176
+ process_emissions: {
177
+ id: 'process_emissions',
178
+ label: 'Process emissions',
179
+ description: 'Cement clinker calcination, ironmaking/steelmaking, flux calcination and other process quantities.',
180
+ documentTypes: ['production_log', 'material_invoice'],
181
+ itemSignals: ['calcination', 'clinker', 'ironmaking', 'steelmaking', 'flux', 'process emissions', 'hot metal', 'limestone', 'dolomite'],
182
+ documentSignals: ['clinker', 'calcination', 'limestone', 'dolomite', 'hot metal', 'steelmaking', 'production', 'tonne'],
183
+ preferredUnits: ['Tonnes', 'Kg'],
184
+ extractionRules: ['Extract production/process input quantity tied to the selected process item.'],
185
+ rejectRules: ['Reject financial totals, quality percentages, and composition values unless explicitly configured as activity data.'],
186
+ },
187
+ generic_material: {
188
+ id: 'generic_material',
189
+ label: 'Generic material invoice',
190
+ description: 'Fallback for material invoices that do not fit a narrower profile.',
191
+ documentTypes: ['material_invoice', 'purchase_order', 'unknown'],
192
+ itemSignals: ['material', 'goods', 'services', 'quantity', 'qty'],
193
+ documentSignals: ['invoice', 'quantity', 'qty', 'unit', 'hsn', 'sac'],
194
+ preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],
195
+ extractionRules: ['Extract only row-level physical quantities that can be matched to allowed ERP items.'],
196
+ rejectRules: ['Reject invoice metadata, rates, taxes, totals, and unmatched rows.'],
197
+ },
198
+ };
199
+ const ROUTING_PRIORITY = [
200
+ 'electricity',
201
+ 'employee_commuting',
202
+ 'refrigerants',
203
+ 'sf6_usage',
204
+ 'fire_extinguisher',
205
+ 'lpg_usage',
206
+ 'industrial_gases',
207
+ 'fuel_combustion',
208
+ 'business_travel',
209
+ 'water',
210
+ 'waste',
211
+ 'process_emissions',
212
+ 'purchased_goods',
213
+ 'generic_material',
214
+ ];
215
+ const getBulkBillAgentProfile = (profileId) => BULK_BILL_AGENT_PROFILES[profileId];
216
+ const listBulkBillAgentProfiles = () => ROUTING_PRIORITY.map((profileId) => BULK_BILL_AGENT_PROFILES[profileId]);
217
+ const scoreBulkBillAgentProfile = (profile, context = {}, documentText = '') => {
218
+ const contextText = mappingContextText(context);
219
+ const docText = normalize(documentText);
220
+ const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];
221
+ const itemMatches = allowedItems.filter((item) => includesAny(itemText(item), profile.itemSignals)).length;
222
+ const contextMatch = includesAny(contextText, profile.itemSignals) ? 2 : 0;
223
+ const categoryMatch = includesAny(normalize(context.category), profile.itemSignals) ? 3 : 0;
224
+ const documentMatch = docText && includesAny(docText, profile.documentSignals) ? 2 : 0;
225
+ const unitMatch = allowedItems.filter((item) => includesAny(normalize(item.unit), profile.preferredUnits.map(normalize))).length;
226
+ return itemMatches * 3 + unitMatch + contextMatch + categoryMatch + documentMatch;
227
+ };
228
+ const getBulkBillAgentProfilesForMappingContext = (context = {}, documentText = '') => {
229
+ const scored = ROUTING_PRIORITY
230
+ .map((profileId) => {
231
+ const profile = BULK_BILL_AGENT_PROFILES[profileId];
232
+ return { profile, score: scoreBulkBillAgentProfile(profile, context, documentText) };
233
+ })
234
+ .filter((entry) => entry.score > 0)
235
+ .sort((left, right) => right.score - left.score);
236
+ return scored.length ? scored : [{ profile: BULK_BILL_AGENT_PROFILES.generic_material, score: 0 }];
237
+ };
238
+ const getPrimaryBulkBillAgentProfile = (context = {}, documentText = '') => getBulkBillAgentProfilesForMappingContext(context, documentText)[0].profile;
239
+ const formatAllowedItem = (item) => {
240
+ const hierarchy = [item.billCategory, item.billSubCategory, item.billNestedSubCategory]
241
+ .filter(Boolean)
242
+ .join(' > ');
243
+ return `${item.itemName || item.billNestedSubCategory || 'Unnamed item'}${hierarchy ? ` (${hierarchy})` : ''}; expected unit: ${item.unit || 'not specified'}; key: ${item.itemKey || item.sourceId || 'not specified'}`;
244
+ };
245
+ const buildBulkBillAgentPromptConfig = (context = {}, documentText = '') => {
246
+ const profile = getPrimaryBulkBillAgentProfile(context, documentText);
247
+ const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];
248
+ return {
249
+ profile,
250
+ allowedItemCount: allowedItems.length,
251
+ allowedItemSummaries: allowedItems.map(formatAllowedItem),
252
+ uploadContext: {
253
+ scope: String(context.scope || ''),
254
+ category: String(context.category || ''),
255
+ plant: String(context.plant || ''),
256
+ year: String(context.year || ''),
257
+ month: String(context.month || ''),
258
+ yearType: String(context.yearType || ''),
259
+ route: String(context.route || ''),
260
+ },
261
+ };
262
+ };
263
+
264
+ exports.BULK_BILL_AGENT_PROFILES = BULK_BILL_AGENT_PROFILES;
265
+ exports.buildBulkBillAgentPromptConfig = buildBulkBillAgentPromptConfig;
266
+ exports.getBulkBillAgentProfile = getBulkBillAgentProfile;
267
+ exports.getBulkBillAgentProfilesForMappingContext = getBulkBillAgentProfilesForMappingContext;
268
+ exports.getPrimaryBulkBillAgentProfile = getPrimaryBulkBillAgentProfile;
269
+ exports.listBulkBillAgentProfiles = listBulkBillAgentProfiles;
270
+ exports.scoreBulkBillAgentProfile = scoreBulkBillAgentProfile;
271
+ //# sourceMappingURL=bulk-bill-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-bill-agent.js","sources":["../src/config/bulk-bill-agent.ts"],"sourcesContent":["export type BulkBillAgentProfileId =\n | 'electricity'\n | 'fuel_combustion'\n | 'refrigerants'\n | 'industrial_gases'\n | 'employee_commuting'\n | 'business_travel'\n | 'lpg_usage'\n | 'fire_extinguisher'\n | 'sf6_usage'\n | 'water'\n | 'waste'\n | 'purchased_goods'\n | 'process_emissions'\n | 'generic_material';\n\nexport interface BulkBillAgentAllowedItem {\n itemKey?: string;\n sourceId?: string;\n itemName?: string;\n billCategory?: string;\n billSubCategory?: string;\n billNestedSubCategory?: string;\n billType?: string;\n unit?: string;\n emissionFactor?: number;\n requiresMassData?: boolean;\n}\n\nexport interface BulkBillAgentMappingContext {\n locked?: boolean;\n scope?: string;\n category?: string;\n route?: string;\n plant?: string;\n year?: number | string;\n month?: number | string;\n yearType?: string;\n allowedItems?: BulkBillAgentAllowedItem[];\n}\n\nexport interface BulkBillAgentProfile {\n id: BulkBillAgentProfileId;\n label: string;\n description: string;\n documentTypes: string[];\n itemSignals: string[];\n documentSignals: string[];\n preferredUnits: string[];\n extractionRules: string[];\n rejectRules: string[];\n}\n\nexport interface BulkBillAgentPromptConfig {\n profile: BulkBillAgentProfile;\n allowedItemCount: number;\n allowedItemSummaries: string[];\n uploadContext: {\n scope: string;\n category: string;\n plant: string;\n year: string;\n month: string;\n yearType: string;\n route: string;\n };\n}\n\nconst normalize = (value: unknown) =>\n String(value ?? '')\n .toLowerCase()\n .replace(/co₂/g, 'co2')\n .replace(/[^a-z0-9]+/g, ' ')\n .trim();\n\nconst includesAny = (text: string, signals: readonly string[]) =>\n signals.some((signal) => text.includes(signal));\n\nconst itemText = (item: BulkBillAgentAllowedItem) =>\n normalize([\n item.itemName,\n item.billCategory,\n item.billSubCategory,\n item.billNestedSubCategory,\n item.billType,\n item.unit,\n ].filter(Boolean).join(' '));\n\nconst mappingContextText = (context: BulkBillAgentMappingContext = {}) =>\n normalize([\n context.scope,\n context.category,\n ...(Array.isArray(context.allowedItems) ? context.allowedItems.map(itemText) : []),\n ].filter(Boolean).join(' '));\n\nexport const BULK_BILL_AGENT_PROFILES: Record<BulkBillAgentProfileId, BulkBillAgentProfile> = {\n electricity: {\n id: 'electricity',\n label: 'Electricity',\n description: 'Grid electricity, renewable electricity, kWh/kVAh/MWh utility bills.',\n documentTypes: ['electricity_bill'],\n itemSignals: ['electric', 'electricity', 'grid', 'renewable', 'solar', 'power', 'kwh', 'kvah', 'mwh', 'location based', 'market based', 'purchased electricity'],\n documentSignals: ['kwh', 'kvah', 'mwh', 'meter', 'discom', 'vidyut', 'billed units', 'net consumption', 'energy charge'],\n preferredUnits: ['kWh', 'kVAh', 'MWh'],\n extractionRules: [\n 'Prefer current-period bill-level or net billed consumption over charges, rates, TOD/slab rows, arrears, or historical meter rows.',\n 'For grid import or purchased electricity, use current-period import/from-grid consumption.',\n 'For solar or renewable electricity, use current-period generation or renewable energy consumption.',\n 'Treat “units” as kWh only for electricity documents.',\n ],\n rejectRules: ['Reject taxes, demand/fixed charges, tariff/rate rows, previous readings, arrears, and currency amounts.'],\n },\n fuel_combustion: {\n id: 'fuel_combustion',\n label: 'Fuel combustion',\n description: 'Diesel, HSD, petrol, furnace oil, coal, coke, CNG and other stationary/mobile combustion fuels.',\n documentTypes: ['fuel_invoice', 'material_invoice'],\n itemSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'furnace oil', 'coal', 'coke', 'cng', 'kerosene', 'ldo', 'mobile combustion', 'stationary combustion', 'operation'],\n documentSignals: ['diesel', 'hsd', 'petrol', 'fuel', 'litre', 'liter', 'kl', 'furnace oil', 'coal', 'petcoke', 'cng'],\n preferredUnits: ['KL', 'Litre', 'Kg', 'Tonnes', 'M3', 'SCM'],\n extractionRules: [\n 'Extract physical fuel quantity, not invoice amount or rate.',\n 'Map vehicle fuel rows to mobile combustion items and generator/boiler/process fuel rows to stationary or operation items when the evidence supports it.',\n 'Preserve the bill unit; unit conversion belongs to validation unless the document states density or conversion explicitly.',\n ],\n rejectRules: ['Reject fuel rates, taxes, HSN/SAC codes, payment totals, and non-fuel services.'],\n },\n refrigerants: {\n id: 'refrigerants',\n label: 'Refrigerants',\n description: 'AC gas and refrigerant purchases/refills such as R-410A, R-32, R-134a, R-22.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['refrigerant', 'refrigerants', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'hfc', 'ac gas', 'chiller'],\n documentSignals: ['refrigerant', 'r 410', 'r410', 'r 32', 'r32', 'r 134', 'r134', 'r 22', 'r22', 'ac gas', 'chiller gas'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: [\n 'Extract refrigerant top-up, refill, or purchase quantity by refrigerant grade.',\n 'Repair OCR variants like R410, R-410, R 410A, R-410 A to the closest allowed ERP item.',\n 'Do not infer leakage; only extract documented physical quantity.',\n ],\n rejectRules: ['Reject service charges, labour, AC unit model numbers, invoice totals, and taxes.'],\n },\n industrial_gases: {\n id: 'industrial_gases',\n label: 'Industrial gases',\n description: 'Oxygen, CO2, nitrogen, argon, acetylene and cylinder gas invoices.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['oxygen', 'o2', 'co2', 'carbon dioxide', 'nitrogen', 'argon', 'acetylene', 'gas cylinder', 'industrial gas', 'welding'],\n documentSignals: ['oxygen', 'o2 gas', 'co2 gas', 'nitrogen', 'argon', 'acetylene', 'cylinder', 'scm', 'nm3', 'm3'],\n preferredUnits: ['M3', 'SCM', 'NM3', 'Kg', 'Cyl'],\n extractionRules: [\n 'Extract gas quantity from row-level item quantity, not cylinder deposit, rental, or amount.',\n 'Keep cylinder count only when the ERP item unit supports count-based activity.',\n 'Repair OCR variants such as 02/O2 and C02/CO2 using allowed ERP items.',\n ],\n rejectRules: ['Reject cylinder deposits, rent, returnable assets, rates, taxes, and empty cylinder rows.'],\n },\n employee_commuting: {\n id: 'employee_commuting',\n label: 'Employee commuting',\n description: 'Employee commute rosters and distance summaries grouped by transport mode.',\n documentTypes: ['transport_roster', 'material_invoice'],\n itemSignals: ['employee commuting', 'commute', 'commuting', 'motorcycle', 'scooter', 'hatchback', 'car', 'rail', 'train', 'metro', 'bus', 'cycle', 'passenger km'],\n documentSignals: ['employee', 'transport', 'mode', 'commute', 'bike', 'scooty', 'car', 'metro', 'bus', 'cycle', 'km'],\n preferredUnits: ['km', 'passenger-km'],\n extractionRules: [\n 'Treat roster files as activity evidence even when they have no invoice number, supplier, or amount.',\n 'Group by transport mode and sum current-period distance into one row per mapped ERP item.',\n 'Use the upload period as the bill period when the roster has no date.',\n ],\n rejectRules: ['Reject employee IDs, names, phone numbers, addresses, and non-distance row counts as activity quantities.'],\n },\n business_travel: {\n id: 'business_travel',\n label: 'Business travel',\n description: 'Flights, rail, hotel stays, and rental vehicle activity.',\n documentTypes: ['travel_invoice', 'material_invoice'],\n itemSignals: ['business travel', 'flight', 'air travel', 'rail', 'train', 'hotel', 'rental car', 'passenger km', 'room night'],\n documentSignals: ['flight', 'airline', 'pnr', 'hotel', 'room night', 'train', 'rail', 'passenger km', 'ticket'],\n preferredUnits: ['km', 'passenger-km', 'night', 'room-night'],\n extractionRules: ['Extract distance, passenger-km, room nights, or trip counts only when the ERP item supports the unit.'],\n rejectRules: ['Reject fares, taxes, booking fees, passenger names, and ticket numbers as activity quantities.'],\n },\n lpg_usage: {\n id: 'lpg_usage',\n label: 'LPG usage',\n description: 'LPG cylinder and bulk LPG invoices.',\n documentTypes: ['fuel_invoice', 'gas_invoice', 'material_invoice'],\n itemSignals: ['lpg', 'liquefied petroleum gas', 'cylinder'],\n documentSignals: ['lpg', 'liquefied petroleum', 'cylinder', 'kg', 'commercial gas'],\n preferredUnits: ['Kg', 'Tonnes', 'KL', 'Cyl'],\n extractionRules: ['Extract filled LPG quantity by kg/tonnes/KL/cylinder size; prefer net fill quantity over cylinder deposit count.'],\n rejectRules: ['Reject cylinder deposits, rental, delivery charges, and taxes.'],\n },\n fire_extinguisher: {\n id: 'fire_extinguisher',\n label: 'Fire extinguisher refilling',\n description: 'CO2 and other extinguisher refill activity.',\n documentTypes: ['material_invoice'],\n itemSignals: ['fire extinguisher', 'extinguisher', 'co2 fire', 'refilling'],\n documentSignals: ['fire extinguisher', 'extinguisher', 'co2', 'refill', 'refilling'],\n preferredUnits: ['Kg', 'Tonnes', 'Cyl'],\n extractionRules: ['Extract refill gas quantity, not extinguisher asset count unless the ERP item is count-based.'],\n rejectRules: ['Reject maintenance service charges, inspection fees, and asset serial numbers.'],\n },\n sf6_usage: {\n id: 'sf6_usage',\n label: 'SF6 usage',\n description: 'SF6 gas purchase, refill, and switchgear top-up activity.',\n documentTypes: ['gas_invoice', 'material_invoice'],\n itemSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride'],\n documentSignals: ['sf6', 'sulfur hexafluoride', 'sulphur hexafluoride', 'switchgear'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract documented SF6 purchase/refill/top-up quantity only.'],\n rejectRules: ['Reject switchgear model numbers, pressure readings without refill quantity, and service charges.'],\n },\n water: {\n id: 'water',\n label: 'Water',\n description: 'Municipal, borewell, tanker, and wastewater quantities.',\n documentTypes: ['water_bill', 'material_invoice'],\n itemSignals: ['water', 'groundwater', 'municipal', 'tanker', 'wastewater', 'effluent'],\n documentSignals: ['water', 'kl', 'litre', 'liter', 'tanker', 'municipal', 'wastewater', 'effluent'],\n preferredUnits: ['KL', 'Litre', 'M3'],\n extractionRules: ['Extract physical water volume by source/disposal type where possible.'],\n rejectRules: ['Reject water charges, sewerage taxes, arrears, and meter numbers as quantities.'],\n },\n waste: {\n id: 'waste',\n label: 'Waste generated in operations',\n description: 'Waste disposal, recycling, composting, landfill, hazardous/non-hazardous waste.',\n documentTypes: ['waste_invoice', 'material_invoice'],\n itemSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal'],\n documentSignals: ['waste', 'landfill', 'recycl', 'compost', 'hazardous', 'scrap', 'disposal', 'kg', 'tonne'],\n preferredUnits: ['Kg', 'Tonnes'],\n extractionRules: ['Extract disposed/recycled physical waste mass by waste type and treatment route.'],\n rejectRules: ['Reject disposal fees, GST, container rental, and vehicle numbers.'],\n },\n purchased_goods: {\n id: 'purchased_goods',\n label: 'Purchased goods and services',\n description: 'Raw materials, consumables, and purchased product quantities.',\n documentTypes: ['material_invoice', 'purchase_order'],\n itemSignals: ['purchased goods', 'goods', 'services', 'material', 'raw material', 'consumable', 'packaging'],\n documentSignals: ['invoice', 'tax invoice', 'hsn', 'material', 'goods', 'quantity', 'qty', 'purchase order'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract row-level material quantity only when the item maps to an allowed ERP item.'],\n rejectRules: ['Reject rates, taxes, HSN/SAC codes, payment terms, and unmatched non-emission materials.'],\n },\n process_emissions: {\n id: 'process_emissions',\n label: 'Process emissions',\n description: 'Cement clinker calcination, ironmaking/steelmaking, flux calcination and other process quantities.',\n documentTypes: ['production_log', 'material_invoice'],\n itemSignals: ['calcination', 'clinker', 'ironmaking', 'steelmaking', 'flux', 'process emissions', 'hot metal', 'limestone', 'dolomite'],\n documentSignals: ['clinker', 'calcination', 'limestone', 'dolomite', 'hot metal', 'steelmaking', 'production', 'tonne'],\n preferredUnits: ['Tonnes', 'Kg'],\n extractionRules: ['Extract production/process input quantity tied to the selected process item.'],\n rejectRules: ['Reject financial totals, quality percentages, and composition values unless explicitly configured as activity data.'],\n },\n generic_material: {\n id: 'generic_material',\n label: 'Generic material invoice',\n description: 'Fallback for material invoices that do not fit a narrower profile.',\n documentTypes: ['material_invoice', 'purchase_order', 'unknown'],\n itemSignals: ['material', 'goods', 'services', 'quantity', 'qty'],\n documentSignals: ['invoice', 'quantity', 'qty', 'unit', 'hsn', 'sac'],\n preferredUnits: ['Kg', 'Tonnes', 'Litre', 'KL', 'M3', 'Nos'],\n extractionRules: ['Extract only row-level physical quantities that can be matched to allowed ERP items.'],\n rejectRules: ['Reject invoice metadata, rates, taxes, totals, and unmatched rows.'],\n },\n};\n\nconst ROUTING_PRIORITY: BulkBillAgentProfileId[] = [\n 'electricity',\n 'employee_commuting',\n 'refrigerants',\n 'sf6_usage',\n 'fire_extinguisher',\n 'lpg_usage',\n 'industrial_gases',\n 'fuel_combustion',\n 'business_travel',\n 'water',\n 'waste',\n 'process_emissions',\n 'purchased_goods',\n 'generic_material',\n];\n\nexport const getBulkBillAgentProfile = (profileId: BulkBillAgentProfileId) =>\n BULK_BILL_AGENT_PROFILES[profileId];\n\nexport const listBulkBillAgentProfiles = () =>\n ROUTING_PRIORITY.map((profileId) => BULK_BILL_AGENT_PROFILES[profileId]);\n\nexport const scoreBulkBillAgentProfile = (\n profile: BulkBillAgentProfile,\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const contextText = mappingContextText(context);\n const docText = normalize(documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n const itemMatches = allowedItems.filter((item) => includesAny(itemText(item), profile.itemSignals)).length;\n const contextMatch = includesAny(contextText, profile.itemSignals) ? 2 : 0;\n const categoryMatch = includesAny(normalize(context.category), profile.itemSignals) ? 3 : 0;\n const documentMatch = docText && includesAny(docText, profile.documentSignals) ? 2 : 0;\n const unitMatch = allowedItems.filter((item) => includesAny(normalize(item.unit), profile.preferredUnits.map(normalize))).length;\n return itemMatches * 3 + unitMatch + contextMatch + categoryMatch + documentMatch;\n};\n\nexport const getBulkBillAgentProfilesForMappingContext = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => {\n const scored = ROUTING_PRIORITY\n .map((profileId) => {\n const profile = BULK_BILL_AGENT_PROFILES[profileId];\n return { profile, score: scoreBulkBillAgentProfile(profile, context, documentText) };\n })\n .filter((entry) => entry.score > 0)\n .sort((left, right) => right.score - left.score);\n\n return scored.length ? scored : [{ profile: BULK_BILL_AGENT_PROFILES.generic_material, score: 0 }];\n};\n\nexport const getPrimaryBulkBillAgentProfile = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n) => getBulkBillAgentProfilesForMappingContext(context, documentText)[0].profile;\n\nconst formatAllowedItem = (item: BulkBillAgentAllowedItem) => {\n const hierarchy = [item.billCategory, item.billSubCategory, item.billNestedSubCategory]\n .filter(Boolean)\n .join(' > ');\n return `${item.itemName || item.billNestedSubCategory || 'Unnamed item'}${hierarchy ? ` (${hierarchy})` : ''}; expected unit: ${item.unit || 'not specified'}; key: ${item.itemKey || item.sourceId || 'not specified'}`;\n};\n\nexport const buildBulkBillAgentPromptConfig = (\n context: BulkBillAgentMappingContext = {},\n documentText = '',\n): BulkBillAgentPromptConfig => {\n const profile = getPrimaryBulkBillAgentProfile(context, documentText);\n const allowedItems = Array.isArray(context.allowedItems) ? context.allowedItems : [];\n return {\n profile,\n allowedItemCount: allowedItems.length,\n allowedItemSummaries: allowedItems.map(formatAllowedItem),\n uploadContext: {\n scope: String(context.scope || ''),\n category: String(context.category || ''),\n plant: String(context.plant || ''),\n year: String(context.year || ''),\n month: String(context.month || ''),\n yearType: String(context.yearType || ''),\n route: String(context.route || ''),\n },\n };\n};\n"],"names":[],"mappings":";;AAoEA,MAAM,SAAS,GAAG,CAAC,KAAc,KAC/B,MAAM,CAAC,KAAK,aAAL,KAAK,KAAA,MAAA,GAAL,KAAK,GAAI,EAAE;AACf,KAAA,WAAW;AACX,KAAA,OAAO,CAAC,MAAM,EAAE,KAAK;AACrB,KAAA,OAAO,CAAC,aAAa,EAAE,GAAG;AAC1B,KAAA,IAAI,EAAE;AAEX,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAA0B,KAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,QAAQ,GAAG,CAAC,IAA8B,KAC9C,SAAS,CAAC;AACR,IAAA,IAAI,CAAC,QAAQ;AACb,IAAA,IAAI,CAAC,YAAY;AACjB,IAAA,IAAI,CAAC,eAAe;AACpB,IAAA,IAAI,CAAC,qBAAqB;AAC1B,IAAA,IAAI,CAAC,QAAQ;AACb,IAAA,IAAI,CAAC,IAAI;CACV,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE9B,MAAM,kBAAkB,GAAG,CAAC,OAAA,GAAuC,EAAE,KACnE,SAAS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