@marteye/studiojs 1.1.36 → 1.1.38
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 +407 -67
- package/dist/index.esm.js +277 -72
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +277 -72
- package/dist/index.js.map +1 -1
- package/dist/net/http.d.ts +1 -0
- package/dist/resources/adjustments.d.ts +2 -0
- package/dist/resources/carts.d.ts +35 -0
- package/dist/resources/contacts.d.ts +28 -0
- package/dist/resources/cph.d.ts +6 -0
- package/dist/resources/customers.d.ts +56 -2
- package/dist/resources/extras.d.ts +32 -0
- package/dist/resources/invoices.d.ts +1 -1
- package/dist/resources/ledger.d.ts +15 -0
- package/dist/resources/payments.d.ts +1 -1
- package/dist/resources/payouts.d.ts +1 -1
- package/dist/resources/productCodes.d.ts +2 -0
- package/dist/resources/saleTemplates.d.ts +30 -0
- package/dist/resources/sales.d.ts +3 -1
- package/dist/resources.d.ts +62 -4
- package/dist/studio.d.ts +63 -5
- package/dist/types.d.ts +119 -26
- package/dist/utils/lots.d.ts +7 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -60,6 +60,9 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
|
|
|
60
60
|
post: async (path, body) => {
|
|
61
61
|
return request("POST", path, body);
|
|
62
62
|
},
|
|
63
|
+
patch: async (path, body) => {
|
|
64
|
+
return request("PATCH", path, body);
|
|
65
|
+
},
|
|
63
66
|
delete: async (path) => {
|
|
64
67
|
return request("DELETE", path);
|
|
65
68
|
},
|
|
@@ -67,7 +70,7 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
|
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
// Path: studiojs/src/resources/markets.ts
|
|
70
|
-
function create$
|
|
73
|
+
function create$m(_) {
|
|
71
74
|
const actions = {
|
|
72
75
|
/***
|
|
73
76
|
* This is used to construct the action from the request body
|
|
@@ -97,7 +100,7 @@ function create$g(_) {
|
|
|
97
100
|
return actions;
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
function create$
|
|
103
|
+
function create$l(httpClient) {
|
|
101
104
|
return {
|
|
102
105
|
list: async (marketId) => {
|
|
103
106
|
return httpClient.get(`/${marketId}/adjustments`);
|
|
@@ -105,13 +108,59 @@ function create$f(httpClient) {
|
|
|
105
108
|
get: async (marketId, id) => {
|
|
106
109
|
return httpClient.get(`/${marketId}/adjustments/${id}`);
|
|
107
110
|
},
|
|
111
|
+
create: async (marketId, data) => {
|
|
112
|
+
return httpClient.post(`/${marketId}/adjustments`, data);
|
|
113
|
+
},
|
|
114
|
+
update: async (marketId, id, data) => {
|
|
115
|
+
return httpClient.post(`/${marketId}/adjustments/${id}`, data);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function create$k(httpClient) {
|
|
121
|
+
return {
|
|
122
|
+
/**
|
|
123
|
+
* Get the full cart for a customer including extras and uninvoiced lots
|
|
124
|
+
*/
|
|
125
|
+
get: async (marketId, customerId) => {
|
|
126
|
+
return httpClient.get(`/${marketId}/carts/${customerId}`);
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Add an extra product to the customer's cart
|
|
130
|
+
*/
|
|
131
|
+
addExtra: async (marketId, customerId, data) => {
|
|
132
|
+
return httpClient.post(`/${marketId}/carts/${customerId}`, data);
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* Remove an extra from the customer's cart
|
|
136
|
+
*/
|
|
137
|
+
removeExtra: async (marketId, customerId, itemId) => {
|
|
138
|
+
return httpClient.delete(`/${marketId}/carts/${customerId}/${itemId}`);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function create$j(httpClient) {
|
|
144
|
+
return {
|
|
145
|
+
list: async (marketId) => {
|
|
146
|
+
return httpClient.get(`/${marketId}/extras`);
|
|
147
|
+
},
|
|
148
|
+
get: async (marketId, id) => {
|
|
149
|
+
return httpClient.get(`/${marketId}/extras/${id}`);
|
|
150
|
+
},
|
|
151
|
+
create: async (marketId, data) => {
|
|
152
|
+
return httpClient.post(`/${marketId}/extras`, data);
|
|
153
|
+
},
|
|
154
|
+
update: async (marketId, id, data) => {
|
|
155
|
+
return httpClient.post(`/${marketId}/extras/${id}`, data);
|
|
156
|
+
},
|
|
108
157
|
};
|
|
109
158
|
}
|
|
110
159
|
|
|
111
160
|
/***
|
|
112
161
|
* Bidder applications
|
|
113
162
|
*/
|
|
114
|
-
function create$
|
|
163
|
+
function create$i(httpClient) {
|
|
115
164
|
let applications = {
|
|
116
165
|
/**
|
|
117
166
|
* List applications for a market with optional filtering
|
|
@@ -178,7 +227,7 @@ function create$e(httpClient) {
|
|
|
178
227
|
}
|
|
179
228
|
|
|
180
229
|
// Path: studiojs/src/resources/markets.ts
|
|
181
|
-
function create$
|
|
230
|
+
function create$h(httpClient) {
|
|
182
231
|
let customers = {
|
|
183
232
|
list: async (marketId, lastId) => {
|
|
184
233
|
let params = {};
|
|
@@ -196,6 +245,9 @@ function create$d(httpClient) {
|
|
|
196
245
|
create: async (marketId, customerData) => {
|
|
197
246
|
return httpClient.post(`/${marketId}/customers`, customerData);
|
|
198
247
|
},
|
|
248
|
+
update: async (marketId, customerId, customerData) => {
|
|
249
|
+
return httpClient.post(`/${marketId}/customers/${customerId}`, customerData);
|
|
250
|
+
},
|
|
199
251
|
/**
|
|
200
252
|
* Get a customer by their account number
|
|
201
253
|
* @param marketId - ID of the market the customer belongs to
|
|
@@ -5012,7 +5064,7 @@ const uploadSingleFile = async (input, token) => {
|
|
|
5012
5064
|
};
|
|
5013
5065
|
|
|
5014
5066
|
// Multipart Upload for Media to the MARTEYE Media Service
|
|
5015
|
-
function create$
|
|
5067
|
+
function create$g() {
|
|
5016
5068
|
const files = {
|
|
5017
5069
|
uploadSingleFile: async (input, token) => {
|
|
5018
5070
|
return await uploadSingleFile(input, token);
|
|
@@ -5027,7 +5079,7 @@ function create$c() {
|
|
|
5027
5079
|
return files;
|
|
5028
5080
|
}
|
|
5029
5081
|
|
|
5030
|
-
function create$
|
|
5082
|
+
function create$f(httpClient) {
|
|
5031
5083
|
const invoices = {
|
|
5032
5084
|
/**
|
|
5033
5085
|
* List all invoices for a market with pagination
|
|
@@ -5055,7 +5107,7 @@ function create$b(httpClient) {
|
|
|
5055
5107
|
return invoices;
|
|
5056
5108
|
}
|
|
5057
5109
|
|
|
5058
|
-
function create$
|
|
5110
|
+
function create$e(httpClient) {
|
|
5059
5111
|
return {
|
|
5060
5112
|
create: async (marketId, saleId, lotId, data) => {
|
|
5061
5113
|
return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
|
|
@@ -5072,7 +5124,7 @@ function create$a(httpClient) {
|
|
|
5072
5124
|
/**
|
|
5073
5125
|
* Defines the possible status values for a lot in a sale
|
|
5074
5126
|
*/
|
|
5075
|
-
function create$
|
|
5127
|
+
function create$d(httpClient) {
|
|
5076
5128
|
return {
|
|
5077
5129
|
get: async (marketId, saleId, lotId) => {
|
|
5078
5130
|
return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
|
|
@@ -5092,7 +5144,7 @@ function create$9(httpClient) {
|
|
|
5092
5144
|
};
|
|
5093
5145
|
}
|
|
5094
5146
|
|
|
5095
|
-
function create$
|
|
5147
|
+
function create$c(httpClient) {
|
|
5096
5148
|
const markets = {
|
|
5097
5149
|
get: async (marketId) => {
|
|
5098
5150
|
return httpClient.get(`/${marketId}`);
|
|
@@ -5114,7 +5166,7 @@ function create$8(httpClient) {
|
|
|
5114
5166
|
return markets;
|
|
5115
5167
|
}
|
|
5116
5168
|
|
|
5117
|
-
function create$
|
|
5169
|
+
function create$b(httpClient) {
|
|
5118
5170
|
const payments = {
|
|
5119
5171
|
/**
|
|
5120
5172
|
* List all payments for a market with pagination
|
|
@@ -5142,7 +5194,7 @@ function create$7(httpClient) {
|
|
|
5142
5194
|
return payments;
|
|
5143
5195
|
}
|
|
5144
5196
|
|
|
5145
|
-
function create$
|
|
5197
|
+
function create$a(httpClient) {
|
|
5146
5198
|
const payouts = {
|
|
5147
5199
|
/**
|
|
5148
5200
|
* List all payouts for a market with pagination
|
|
@@ -5170,18 +5222,24 @@ function create$6(httpClient) {
|
|
|
5170
5222
|
return payouts;
|
|
5171
5223
|
}
|
|
5172
5224
|
|
|
5173
|
-
function create$
|
|
5225
|
+
function create$9(httpClient) {
|
|
5174
5226
|
return {
|
|
5175
5227
|
list: async (marketId) => {
|
|
5176
|
-
return httpClient.get(`/${marketId}/
|
|
5228
|
+
return httpClient.get(`/${marketId}/product-codes`);
|
|
5177
5229
|
},
|
|
5178
5230
|
get: async (marketId, id) => {
|
|
5179
|
-
return httpClient.get(`/${marketId}/
|
|
5231
|
+
return httpClient.get(`/${marketId}/product-codes/${id}`);
|
|
5232
|
+
},
|
|
5233
|
+
create: async (marketId, data) => {
|
|
5234
|
+
return httpClient.post(`/${marketId}/product-codes`, data);
|
|
5235
|
+
},
|
|
5236
|
+
update: async (marketId, id, data) => {
|
|
5237
|
+
return httpClient.post(`/${marketId}/product-codes/${id}`, data);
|
|
5180
5238
|
},
|
|
5181
5239
|
};
|
|
5182
5240
|
}
|
|
5183
5241
|
|
|
5184
|
-
function create$
|
|
5242
|
+
function create$8(httpClient) {
|
|
5185
5243
|
return {
|
|
5186
5244
|
get: async (marketId, saleId) => {
|
|
5187
5245
|
return httpClient.get(`/${marketId}/sales/${saleId}`);
|
|
@@ -5198,7 +5256,27 @@ function create$4(httpClient) {
|
|
|
5198
5256
|
};
|
|
5199
5257
|
}
|
|
5200
5258
|
|
|
5201
|
-
function create$
|
|
5259
|
+
function create$7(httpClient) {
|
|
5260
|
+
return {
|
|
5261
|
+
list: async (marketId) => {
|
|
5262
|
+
return httpClient.get(`/${marketId}/sale-templates`);
|
|
5263
|
+
},
|
|
5264
|
+
get: async (marketId, templateId) => {
|
|
5265
|
+
return httpClient.get(`/${marketId}/sale-templates/${templateId}`);
|
|
5266
|
+
},
|
|
5267
|
+
create: async (marketId, body) => {
|
|
5268
|
+
return httpClient.post(`/${marketId}/sale-templates`, body);
|
|
5269
|
+
},
|
|
5270
|
+
update: async (marketId, templateId, body) => {
|
|
5271
|
+
return httpClient.post(`/${marketId}/sale-templates/${templateId}`, body);
|
|
5272
|
+
},
|
|
5273
|
+
delete: async (marketId, templateId) => {
|
|
5274
|
+
return httpClient.delete(`/${marketId}/sale-templates/${templateId}`);
|
|
5275
|
+
},
|
|
5276
|
+
};
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5279
|
+
function create$6(httpClient) {
|
|
5202
5280
|
let search = {
|
|
5203
5281
|
/**
|
|
5204
5282
|
* Search for documents within a market
|
|
@@ -5213,7 +5291,7 @@ function create$3(httpClient) {
|
|
|
5213
5291
|
return search;
|
|
5214
5292
|
}
|
|
5215
5293
|
|
|
5216
|
-
function create$
|
|
5294
|
+
function create$5(httpClient) {
|
|
5217
5295
|
return {
|
|
5218
5296
|
get: async (marketId) => {
|
|
5219
5297
|
return httpClient.get(`/${marketId}/settings`);
|
|
@@ -5221,7 +5299,7 @@ function create$2(httpClient) {
|
|
|
5221
5299
|
};
|
|
5222
5300
|
}
|
|
5223
5301
|
|
|
5224
|
-
function create$
|
|
5302
|
+
function create$4(httpClient) {
|
|
5225
5303
|
return {
|
|
5226
5304
|
list: async (marketId) => {
|
|
5227
5305
|
return httpClient.get(`/${marketId}/tax_rates`);
|
|
@@ -5233,7 +5311,7 @@ function create$1(httpClient) {
|
|
|
5233
5311
|
}
|
|
5234
5312
|
|
|
5235
5313
|
// Path: studiojs/src/resources/markets.ts
|
|
5236
|
-
function create(_) {
|
|
5314
|
+
function create$3(_) {
|
|
5237
5315
|
const webhooks = {
|
|
5238
5316
|
/***
|
|
5239
5317
|
* This is used to construct the webhook event from the request body
|
|
@@ -5268,25 +5346,78 @@ function create(_) {
|
|
|
5268
5346
|
return webhooks;
|
|
5269
5347
|
}
|
|
5270
5348
|
|
|
5349
|
+
function create$2(httpClient) {
|
|
5350
|
+
return {
|
|
5351
|
+
lookup: async (marketId, cph) => httpClient.get(`/${marketId}/cph`, { cph }),
|
|
5352
|
+
};
|
|
5353
|
+
}
|
|
5354
|
+
|
|
5355
|
+
function create$1(httpClient) {
|
|
5356
|
+
return {
|
|
5357
|
+
list: async (marketId, customerId, params) => {
|
|
5358
|
+
const query = {};
|
|
5359
|
+
if (params === null || params === void 0 ? void 0 : params.lastId)
|
|
5360
|
+
query.lastId = params.lastId;
|
|
5361
|
+
if (params === null || params === void 0 ? void 0 : params.limit)
|
|
5362
|
+
query.limit = params.limit;
|
|
5363
|
+
return httpClient.get(`/${marketId}/customers/${customerId}/contacts`, query);
|
|
5364
|
+
},
|
|
5365
|
+
get: async (marketId, customerId, contactId) => {
|
|
5366
|
+
return httpClient.get(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
|
|
5367
|
+
},
|
|
5368
|
+
create: async (marketId, customerId, payload) => {
|
|
5369
|
+
return httpClient.post(`/${marketId}/customers/${customerId}/contacts`, payload);
|
|
5370
|
+
},
|
|
5371
|
+
update: async (marketId, customerId, contactId, payload) => {
|
|
5372
|
+
return httpClient.post(`/${marketId}/customers/${customerId}/contacts/${contactId}`, payload);
|
|
5373
|
+
},
|
|
5374
|
+
delete: async (marketId, customerId, contactId) => {
|
|
5375
|
+
return httpClient.delete(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
|
|
5376
|
+
},
|
|
5377
|
+
};
|
|
5378
|
+
}
|
|
5379
|
+
|
|
5380
|
+
function create(httpClient) {
|
|
5381
|
+
let ledger = {
|
|
5382
|
+
/**
|
|
5383
|
+
* Get the current balance for a ledger account
|
|
5384
|
+
* @param marketId - ID of the market
|
|
5385
|
+
* @param account - Full account string (format: owner:accountType:accountName)
|
|
5386
|
+
* e.g. "customerId:asset:trade receivable" or "market:liability:trade payable"
|
|
5387
|
+
* @returns The current balance in cents
|
|
5388
|
+
*/
|
|
5389
|
+
getBalance: async (marketId, account) => {
|
|
5390
|
+
return httpClient.get(`/${marketId}/ledger/balance`, { account });
|
|
5391
|
+
},
|
|
5392
|
+
};
|
|
5393
|
+
return ledger;
|
|
5394
|
+
}
|
|
5395
|
+
|
|
5271
5396
|
function resources(httpClient) {
|
|
5272
5397
|
return {
|
|
5273
|
-
markets: create$
|
|
5274
|
-
sales: create$
|
|
5275
|
-
lots: create$
|
|
5276
|
-
lotitems: create$
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5398
|
+
markets: create$c(httpClient),
|
|
5399
|
+
sales: create$8(httpClient),
|
|
5400
|
+
lots: create$d(httpClient),
|
|
5401
|
+
lotitems: create$e(httpClient),
|
|
5402
|
+
carts: create$k(httpClient),
|
|
5403
|
+
cph: create$2(httpClient),
|
|
5404
|
+
webhooks: create$3(),
|
|
5405
|
+
actions: create$m(),
|
|
5406
|
+
bidderApplications: create$i(httpClient),
|
|
5407
|
+
settings: create$5(httpClient),
|
|
5408
|
+
adjustments: create$l(httpClient),
|
|
5409
|
+
extras: create$j(httpClient),
|
|
5410
|
+
productCodes: create$9(httpClient),
|
|
5411
|
+
saleTemplates: create$7(httpClient),
|
|
5412
|
+
taxRates: create$4(httpClient),
|
|
5413
|
+
customers: create$h(httpClient),
|
|
5414
|
+
invoices: create$f(httpClient),
|
|
5415
|
+
payments: create$b(httpClient),
|
|
5416
|
+
payouts: create$a(httpClient),
|
|
5417
|
+
search: create$6(httpClient),
|
|
5418
|
+
files: create$g(),
|
|
5419
|
+
contacts: create$1(httpClient),
|
|
5420
|
+
ledger: create(httpClient),
|
|
5290
5421
|
};
|
|
5291
5422
|
}
|
|
5292
5423
|
|
|
@@ -5597,59 +5728,133 @@ EarTag.countryCodes = {
|
|
|
5597
5728
|
BE: "056",
|
|
5598
5729
|
};
|
|
5599
5730
|
|
|
5731
|
+
/**
|
|
5732
|
+
* Extract the smallest lot number for sorting purposes.
|
|
5733
|
+
* Handles formats:
|
|
5734
|
+
* - Simple: "7" -> 7
|
|
5735
|
+
* - Alpha suffix: "7A" -> 7
|
|
5736
|
+
* - Range: "7-9" -> 7
|
|
5737
|
+
* - Range with alpha: "7A-9A" -> 7
|
|
5738
|
+
* - With gaps: "7-8, 10" -> 7
|
|
5739
|
+
* - Complex: "7A-8A, 10B" -> 7
|
|
5740
|
+
*/
|
|
5741
|
+
function extractMinLotNumber(lotNumber) {
|
|
5742
|
+
// Handle empty/null
|
|
5743
|
+
if (!lotNumber)
|
|
5744
|
+
return { num: null, alpha: "" };
|
|
5745
|
+
// Split by comma first (handles "7-8, 10" format), flexible with whitespace
|
|
5746
|
+
let segments = lotNumber.split(/\s*,\s*/);
|
|
5747
|
+
let minNum = null;
|
|
5748
|
+
let minAlpha = "";
|
|
5749
|
+
for (let segment of segments) {
|
|
5750
|
+
// Split by hyphen (handles "7-9" range format), flexible with whitespace
|
|
5751
|
+
let rangeParts = segment.split(/\s*-\s*/);
|
|
5752
|
+
for (let part of rangeParts) {
|
|
5753
|
+
// Extract number and alpha from each part (e.g., "7A" -> 7, "A")
|
|
5754
|
+
let match = part.trim().match(/^(\d+)(\D*)$/);
|
|
5755
|
+
if (match) {
|
|
5756
|
+
let num = parseInt(match[1], 10);
|
|
5757
|
+
let alpha = match[2] || "";
|
|
5758
|
+
if (minNum === null ||
|
|
5759
|
+
num < minNum ||
|
|
5760
|
+
(num === minNum && alpha < minAlpha)) {
|
|
5761
|
+
minNum = num;
|
|
5762
|
+
minAlpha = alpha;
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
}
|
|
5767
|
+
return { num: minNum, alpha: minAlpha };
|
|
5768
|
+
}
|
|
5600
5769
|
function lotComparator(a, b) {
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
// If neither
|
|
5604
|
-
if (
|
|
5770
|
+
let aMin = extractMinLotNumber(a.lotNumber);
|
|
5771
|
+
let bMin = extractMinLotNumber(b.lotNumber);
|
|
5772
|
+
// If neither has numbers, fall back to string comparison
|
|
5773
|
+
if (aMin.num === null && bMin.num === null) {
|
|
5605
5774
|
return a.lotNumber.localeCompare(b.lotNumber);
|
|
5606
5775
|
}
|
|
5607
|
-
// If only one
|
|
5608
|
-
if (
|
|
5776
|
+
// If only one has numbers, the one without comes first
|
|
5777
|
+
if (aMin.num === null)
|
|
5609
5778
|
return -1;
|
|
5610
|
-
if (
|
|
5779
|
+
if (bMin.num === null)
|
|
5611
5780
|
return 1;
|
|
5612
|
-
//
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
// Compare
|
|
5616
|
-
if (
|
|
5617
|
-
return
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
const bAlpha = (bMatch === null || bMatch === void 0 ? void 0 : bMatch[2]) || "";
|
|
5621
|
-
// Compare by length first (shorter comes first)
|
|
5622
|
-
if (aAlpha.length !== bAlpha.length)
|
|
5623
|
-
return aAlpha.length - bAlpha.length;
|
|
5624
|
-
// Then compare alphabetically
|
|
5625
|
-
return aAlpha.localeCompare(bAlpha);
|
|
5781
|
+
// Compare numeric parts
|
|
5782
|
+
if (aMin.num !== bMin.num)
|
|
5783
|
+
return aMin.num - bMin.num;
|
|
5784
|
+
// Compare alpha suffixes by length then alphabetically
|
|
5785
|
+
if (aMin.alpha.length !== bMin.alpha.length) {
|
|
5786
|
+
return aMin.alpha.length - bMin.alpha.length;
|
|
5787
|
+
}
|
|
5788
|
+
return aMin.alpha.localeCompare(bMin.alpha);
|
|
5626
5789
|
}
|
|
5627
5790
|
function sortByLotNumber(lots) {
|
|
5628
5791
|
return [...lots].sort(lotComparator);
|
|
5629
5792
|
}
|
|
5630
5793
|
/***
|
|
5631
|
-
* Generate the next lot number in a sequence
|
|
5794
|
+
* Generate the next lot number in a sequence.
|
|
5795
|
+
* Handles various formats:
|
|
5796
|
+
* - Simple: "7" -> "8"
|
|
5797
|
+
* - Alphanumeric: "7A" -> "7B"
|
|
5798
|
+
* - Range: "1-3" -> "4", "1 - 3" -> "4" (flexible whitespace)
|
|
5799
|
+
* - Range with alpha: "1-3A" -> "3B"
|
|
5800
|
+
* - Compound: "1-3, 10" -> "11", "1-5, 7-9" -> "10"
|
|
5632
5801
|
*/
|
|
5633
5802
|
function nextLotNumber(previousLotNumber) {
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5803
|
+
// Helper to compare alpha suffixes (longer = greater, then alphabetically)
|
|
5804
|
+
function isGreaterAlpha(a, b) {
|
|
5805
|
+
let aUpper = a.toUpperCase();
|
|
5806
|
+
let bUpper = b.toUpperCase();
|
|
5807
|
+
if (aUpper.length !== bUpper.length) {
|
|
5808
|
+
return aUpper.length > bUpper.length;
|
|
5809
|
+
}
|
|
5810
|
+
return aUpper > bUpper;
|
|
5811
|
+
}
|
|
5812
|
+
// Split by comma (handles "7-8, 10" format), flexible with whitespace
|
|
5813
|
+
let segments = previousLotNumber.split(/\s*,\s*/);
|
|
5814
|
+
let maxNum = null;
|
|
5815
|
+
let maxAlpha = "";
|
|
5816
|
+
for (let segment of segments) {
|
|
5817
|
+
// Check if segment is a range (contains hyphen with numbers on both sides)
|
|
5818
|
+
// Flexible with whitespace: "1-3", "1 - 3", "1- 3", "1 -3", "1 -3"
|
|
5819
|
+
let rangeMatch = segment.trim().match(/^(\d+)\s*-\s*(\d+)(\D*)$/);
|
|
5820
|
+
if (rangeMatch) {
|
|
5821
|
+
// Range format: take the end number
|
|
5822
|
+
let endNum = parseInt(rangeMatch[2], 10);
|
|
5823
|
+
let alphaPart = rangeMatch[3] || "";
|
|
5824
|
+
if (maxNum === null ||
|
|
5825
|
+
endNum > maxNum ||
|
|
5826
|
+
(endNum === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
|
|
5827
|
+
maxNum = endNum;
|
|
5828
|
+
maxAlpha = alphaPart;
|
|
5829
|
+
}
|
|
5642
5830
|
}
|
|
5643
5831
|
else {
|
|
5644
|
-
//
|
|
5645
|
-
|
|
5646
|
-
|
|
5832
|
+
// Single value: "7" or "7A"
|
|
5833
|
+
let singleMatch = segment.trim().match(/^(\d+)(\D*)$/);
|
|
5834
|
+
if (singleMatch) {
|
|
5835
|
+
let num = parseInt(singleMatch[1], 10);
|
|
5836
|
+
let alphaPart = singleMatch[2] || "";
|
|
5837
|
+
if (maxNum === null ||
|
|
5838
|
+
num > maxNum ||
|
|
5839
|
+
(num === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
|
|
5840
|
+
maxNum = num;
|
|
5841
|
+
maxAlpha = alphaPart;
|
|
5842
|
+
}
|
|
5843
|
+
}
|
|
5647
5844
|
}
|
|
5648
5845
|
}
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5846
|
+
// If we found numeric parts, increment
|
|
5847
|
+
if (maxNum !== null) {
|
|
5848
|
+
if (maxAlpha === "") {
|
|
5849
|
+
return (maxNum + 1).toString();
|
|
5850
|
+
}
|
|
5851
|
+
else {
|
|
5852
|
+
let nextAlpha = incrementAlphaSequence(maxAlpha);
|
|
5853
|
+
return maxNum + nextAlpha;
|
|
5854
|
+
}
|
|
5652
5855
|
}
|
|
5856
|
+
// Fallback: treat as pure alphabetic (e.g., "A" -> "B")
|
|
5857
|
+
return incrementAlphaSequence(previousLotNumber);
|
|
5653
5858
|
}
|
|
5654
5859
|
function incrementAlphaSequence(alpha) {
|
|
5655
5860
|
if (alpha === "") {
|