@catalogicus-international/n8n-nodes-invoice-parser 0.2.0 → 0.2.2
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/README.md +51 -23
- package/dist/nodes/InvoicePdfParser/parse.d.ts +3 -1
- package/dist/nodes/InvoicePdfParser/parse.js +1236 -71
- package/dist/nodes/InvoicePdfParser/parse.js.map +1 -1
- package/dist/nodes/InvoicePdfParser/profiles.d.ts +26 -5
- package/dist/nodes/InvoicePdfParser/profiles.js +899 -3
- package/dist/nodes/InvoicePdfParser/profiles.js.map +1 -1
- package/dist/package.json +2 -2
- package/package.json +70 -72
|
@@ -13,7 +13,7 @@ var require_profiles = __commonJS({
|
|
|
13
13
|
"dist/nodes/InvoicePdfParser/profiles.js"(exports2) {
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16
|
-
exports2.LEMAN = exports2.PROFILES = exports2.UNIVERSAL = exports2.ETM = void 0;
|
|
16
|
+
exports2.MEGAPOLIS = exports2.LEMAN_SHIFT = exports2.LEMAN_OFFER = exports2.PETROVICH_COMPACT = exports2.PETROVICH_DISCOUNT = exports2.PETROVICH_NARROW = exports2.PETROVICH_MAIN = exports2.PETROVICH_WIDE = exports2.TEREM_NARROW = exports2.TEREM = exports2.NORMALVENT = exports2.LUNDA = exports2.LEMAN = exports2.PROFILES = exports2.UNIVERSAL = exports2.ETM = void 0;
|
|
17
17
|
exports2.ETM = {
|
|
18
18
|
id: "etm",
|
|
19
19
|
layoutId: "etm/main",
|
|
@@ -52,8 +52,8 @@ var require_profiles = __commonJS({
|
|
|
52
52
|
id: "leman",
|
|
53
53
|
layoutId: "leman/main",
|
|
54
54
|
title: "\u041B\u0435\u0440\u0443\u0430 \u041C\u0435\u0440\u043B\u0435\u043D (\u041B\u0415 \u041C\u041E\u041D\u041B\u0418\u0414)",
|
|
55
|
-
detect: [/ЛЕ\s*МОНЛИД/
|
|
56
|
-
yTolerance:
|
|
55
|
+
detect: [/ЛЕ\s*МОНЛИД/iu, /lemanapro\.ru/iu],
|
|
56
|
+
yTolerance: 10,
|
|
57
57
|
pricesIncludeVat: true,
|
|
58
58
|
qtyUnitInOneColumn: true,
|
|
59
59
|
articleFromCode: true,
|
|
@@ -74,7 +74,903 @@ var require_profiles = __commonJS({
|
|
|
74
74
|
total: /^Всего к оплате/i
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
+
exports2.LUNDA = {
|
|
78
|
+
id: "lunda",
|
|
79
|
+
layoutId: "lunda/main",
|
|
80
|
+
title: "\u041B\u0443\u043D\u0434\u0430",
|
|
81
|
+
detect: [/Лунда/iu, /lunda\.ru/iu],
|
|
82
|
+
pricesIncludeVat: true,
|
|
83
|
+
vatRate: 20,
|
|
84
|
+
columns: [
|
|
85
|
+
{ key: "num", from: 0, to: 50 },
|
|
86
|
+
{ key: "code", from: 50, to: 85 },
|
|
87
|
+
{ key: "name", from: 85, to: 258 },
|
|
88
|
+
{ key: "qty", from: 258, to: 294 },
|
|
89
|
+
{ key: "unit", from: 294, to: 312 },
|
|
90
|
+
{ key: "price", from: 378, to: 450 },
|
|
91
|
+
{ key: "sum", from: 450, to: 560 }
|
|
92
|
+
],
|
|
93
|
+
rowPattern: {
|
|
94
|
+
num: /^\d+$/,
|
|
95
|
+
code: new RegExp("^(?:\\p{L}[\\p{L}\\d/*_.?*-]*\\d[\\p{L}\\d/*_.?*-]*|\\d{4,})$", "u")
|
|
96
|
+
},
|
|
97
|
+
stopPattern: /^итого/iu,
|
|
98
|
+
discountPattern: /скидка по программе лояльности/iu,
|
|
99
|
+
totalsPatterns: {
|
|
100
|
+
sum: /Итого без НДС/iu,
|
|
101
|
+
vat: /Сумма НДС/iu,
|
|
102
|
+
total: /Итого к оплате/iu
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports2.PROFILES.push(exports2.LUNDA);
|
|
106
|
+
exports2.NORMALVENT = {
|
|
107
|
+
id: "normalvent",
|
|
108
|
+
layoutId: "normalvent/main",
|
|
109
|
+
title: "\u041D\u043E\u0440\u043C\u0430\u043B-\u0412\u0435\u043D\u0442",
|
|
110
|
+
detect: [/Нормал-?Вент/iu],
|
|
111
|
+
yTolerance: 12,
|
|
112
|
+
pricesIncludeVat: true,
|
|
113
|
+
vatRate: 20,
|
|
114
|
+
columns: [
|
|
115
|
+
{ key: "num", from: 0, to: 45 },
|
|
116
|
+
{ key: "name", from: 45, to: 258 },
|
|
117
|
+
{ key: "unit", from: 258, to: 308 },
|
|
118
|
+
{ key: "qty", from: 308, to: 350 },
|
|
119
|
+
{ key: "price", from: 350, to: 430 },
|
|
120
|
+
{ key: "sum", from: 430, to: 560 }
|
|
121
|
+
],
|
|
122
|
+
rowPattern: { num: /^\d+$/ },
|
|
123
|
+
stopPattern: /^итого/iu,
|
|
124
|
+
totalsPatterns: {
|
|
125
|
+
vat: /^в том числе НДС/iu,
|
|
126
|
+
total: /^Итого:/iu
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
exports2.PROFILES.push(exports2.NORMALVENT);
|
|
130
|
+
exports2.TEREM = {
|
|
131
|
+
id: "terem",
|
|
132
|
+
layoutId: "terem/main",
|
|
133
|
+
title: "\u0422\u0415\u0420\u0415\u041C",
|
|
134
|
+
detect: [/7729646148/, /ООО\s*[«"]?\s*ТЕРЕМ/iu],
|
|
135
|
+
articleFromCode: true,
|
|
136
|
+
columns: [
|
|
137
|
+
{ key: "num", from: 0, to: 60 },
|
|
138
|
+
{ key: "name", from: 60, to: 222 },
|
|
139
|
+
{ key: "code", from: 222, to: 275 },
|
|
140
|
+
{ key: "art", from: 222, to: 275 },
|
|
141
|
+
{ key: "unit", from: 275, to: 300 },
|
|
142
|
+
{ key: "qty", from: 300, to: 345 },
|
|
143
|
+
{ key: "price", from: 345, to: 390 },
|
|
144
|
+
{ key: "price2", from: 390, to: 438 },
|
|
145
|
+
{ key: "sum", from: 438, to: 505 },
|
|
146
|
+
{ key: "total", from: 505, to: 570 }
|
|
147
|
+
],
|
|
148
|
+
rowPattern: { num: /^\d+$/, code: /^[\dA-Za-z.]+$/ },
|
|
149
|
+
stopPattern: /^итого/iu
|
|
150
|
+
};
|
|
151
|
+
exports2.PROFILES.push(exports2.TEREM);
|
|
152
|
+
exports2.TEREM_NARROW = {
|
|
153
|
+
id: "terem-narrow",
|
|
154
|
+
layoutId: "terem/narrow",
|
|
155
|
+
title: "\u0422\u0415\u0420\u0415\u041C (\u0443\u0437\u043A\u0438\u0439 \u043C\u0430\u043A\u0435\u0442)",
|
|
156
|
+
detect: [/7729646148/, /ООО\s*[«"]?\s*ТЕРЕМ/iu],
|
|
157
|
+
articleFromCode: true,
|
|
158
|
+
columns: [
|
|
159
|
+
{ key: "num", from: 0, to: 62 },
|
|
160
|
+
{ key: "name", from: 62, to: 218 },
|
|
161
|
+
{ key: "code", from: 218, to: 265 },
|
|
162
|
+
{ key: "art", from: 218, to: 265 },
|
|
163
|
+
{ key: "unit", from: 265, to: 290 },
|
|
164
|
+
{ key: "qty", from: 290, to: 330 },
|
|
165
|
+
{ key: "price", from: 330, to: 368 },
|
|
166
|
+
{ key: "price2", from: 368, to: 412 },
|
|
167
|
+
{ key: "sum", from: 412, to: 470 },
|
|
168
|
+
{ key: "total", from: 470, to: 570 }
|
|
169
|
+
],
|
|
170
|
+
rowPattern: { num: /^\d+$/, code: /^[\dA-Za-z.]+$/ },
|
|
171
|
+
stopPattern: /^итого/iu
|
|
172
|
+
};
|
|
173
|
+
exports2.PROFILES.push(exports2.TEREM_NARROW);
|
|
174
|
+
exports2.PETROVICH_WIDE = {
|
|
175
|
+
id: "petrovich-wide",
|
|
176
|
+
layoutId: "petrovich/wide",
|
|
177
|
+
title: "\u0421\u0422\u0414 \xAB\u041F\u0435\u0442\u0440\u043E\u0432\u0438\u0447\xBB (\u0448\u0438\u0440\u043E\u043A\u0438\u0439 \u043C\u0430\u043A\u0435\u0442)",
|
|
178
|
+
detect: [/7802348846/],
|
|
179
|
+
descriptionAbove: true,
|
|
180
|
+
pricesIncludeVat: true,
|
|
181
|
+
vatRate: 20,
|
|
182
|
+
articleFromCode: true,
|
|
183
|
+
columns: [
|
|
184
|
+
{ key: "num", from: 0, to: 45 },
|
|
185
|
+
{ key: "code", from: 45, to: 80 },
|
|
186
|
+
{ key: "name", from: 80, to: 190 },
|
|
187
|
+
{ key: "qty", from: 190, to: 205 },
|
|
188
|
+
{ key: "unit", from: 205, to: 232 },
|
|
189
|
+
{ key: "art", from: 232, to: 296 },
|
|
190
|
+
{ key: "vat", from: 296, to: 320 },
|
|
191
|
+
{ key: "vatsum", from: 320, to: 360 },
|
|
192
|
+
{ key: "price2", from: 360, to: 425 },
|
|
193
|
+
{ key: "price", from: 425, to: 478 },
|
|
194
|
+
{ key: "vatflag", from: 478, to: 515 },
|
|
195
|
+
{ key: "sum", from: 515, to: 700 }
|
|
196
|
+
],
|
|
197
|
+
rowPattern: { num: /^\d+$/, code: /^[\d\s]{6,}$/ },
|
|
198
|
+
stopPattern: /^Всего наименований/iu,
|
|
199
|
+
totalsPatterns: {
|
|
200
|
+
vat: /В том числе НДС/iu,
|
|
201
|
+
total: /Итого:/iu
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
exports2.PROFILES.push(exports2.PETROVICH_WIDE);
|
|
205
|
+
exports2.PETROVICH_MAIN = {
|
|
206
|
+
id: "petrovich-main",
|
|
207
|
+
layoutId: "petrovich/main",
|
|
208
|
+
title: "\u0421\u0422\u0414 \xAB\u041F\u0435\u0442\u0440\u043E\u0432\u0438\u0447\xBB",
|
|
209
|
+
detect: [/7802348846/],
|
|
210
|
+
pricesIncludeVat: true,
|
|
211
|
+
vatRate: 20,
|
|
212
|
+
articleFromCode: true,
|
|
213
|
+
columns: [
|
|
214
|
+
{ key: "num", from: 0, to: 60 },
|
|
215
|
+
{ key: "code", from: 60, to: 100 },
|
|
216
|
+
{ key: "name", from: 100, to: 330 },
|
|
217
|
+
{ key: "qty", from: 330, to: 360 },
|
|
218
|
+
{ key: "unit", from: 360, to: 400 },
|
|
219
|
+
{ key: "art", from: 400, to: 465 },
|
|
220
|
+
{ key: "price", from: 465, to: 520 },
|
|
221
|
+
{ key: "sum", from: 520, to: 600 }
|
|
222
|
+
],
|
|
223
|
+
rowPattern: { num: /^\d+$/, code: /^\d{6,}$/ },
|
|
224
|
+
stopPattern: /^Всего наименований/iu,
|
|
225
|
+
totalsPatterns: {
|
|
226
|
+
vat: /В том числе НДС/iu,
|
|
227
|
+
total: /Итого:/iu
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
exports2.PROFILES.push(exports2.PETROVICH_MAIN);
|
|
231
|
+
exports2.PETROVICH_NARROW = {
|
|
232
|
+
id: "petrovich-narrow",
|
|
233
|
+
layoutId: "petrovich/narrow",
|
|
234
|
+
title: "\u0421\u0422\u0414 \xAB\u041F\u0435\u0442\u0440\u043E\u0432\u0438\u0447\xBB (\u0441\u0447\u0435\u0442\u0430 2026)",
|
|
235
|
+
detect: [/7802348846/],
|
|
236
|
+
pricesIncludeVat: true,
|
|
237
|
+
vatRate: 22,
|
|
238
|
+
columns: [
|
|
239
|
+
{ key: "num", from: 0, to: 60 },
|
|
240
|
+
{ key: "name", from: 60, to: 330 },
|
|
241
|
+
{ key: "qty", from: 330, to: 360 },
|
|
242
|
+
{ key: "unit", from: 360, to: 400 },
|
|
243
|
+
{ key: "art", from: 400, to: 465 },
|
|
244
|
+
{ key: "price", from: 465, to: 520 },
|
|
245
|
+
{ key: "sum", from: 520, to: 600 }
|
|
246
|
+
],
|
|
247
|
+
rowPattern: { num: /^\d+$/ },
|
|
248
|
+
stopPattern: /^Всего наименований/iu,
|
|
249
|
+
totalsPatterns: {
|
|
250
|
+
vat: /В том числе НДС/iu,
|
|
251
|
+
total: /Итого:/iu
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
exports2.PROFILES.push(exports2.PETROVICH_NARROW);
|
|
255
|
+
exports2.PETROVICH_DISCOUNT = {
|
|
256
|
+
id: "petrovich-discount",
|
|
257
|
+
layoutId: "petrovich/discount",
|
|
258
|
+
title: "\u0421\u0422\u0414 \xAB\u041F\u0435\u0442\u0440\u043E\u0432\u0438\u0447\xBB (\u0441\u043E \u0441\u043A\u0438\u0434\u043A\u043E\u0439)",
|
|
259
|
+
detect: [/7802348846/],
|
|
260
|
+
pricesIncludeVat: true,
|
|
261
|
+
vatRate: 20,
|
|
262
|
+
articleFromCode: true,
|
|
263
|
+
columns: [
|
|
264
|
+
{ key: "num", from: 0, to: 55 },
|
|
265
|
+
{ key: "code", from: 55, to: 100 },
|
|
266
|
+
{ key: "name", from: 100, to: 230 },
|
|
267
|
+
{ key: "qty", from: 230, to: 262 },
|
|
268
|
+
{ key: "unit", from: 262, to: 300 },
|
|
269
|
+
{ key: "art", from: 300, to: 345 },
|
|
270
|
+
{ key: "price2", from: 345, to: 408 },
|
|
271
|
+
{ key: "price", from: 408, to: 465 },
|
|
272
|
+
{ key: "vatflag", from: 465, to: 500 },
|
|
273
|
+
{ key: "sum", from: 500, to: 600 }
|
|
274
|
+
],
|
|
275
|
+
rowPattern: { num: /^\d+$/, code: /^\d{6,}$/ },
|
|
276
|
+
stopPattern: /^Всего наименований/iu,
|
|
277
|
+
totalsPatterns: {
|
|
278
|
+
vat: /В том числе НДС/iu,
|
|
279
|
+
total: /Итого:/iu
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
exports2.PROFILES.push(exports2.PETROVICH_DISCOUNT);
|
|
283
|
+
exports2.PETROVICH_COMPACT = {
|
|
284
|
+
id: "petrovich-compact",
|
|
285
|
+
layoutId: "petrovich/compact",
|
|
286
|
+
title: "\u0421\u0422\u0414 \xAB\u041F\u0435\u0442\u0440\u043E\u0432\u0438\u0447\xBB (\u043A\u043E\u043C\u043F\u0430\u043A\u0442\u043D\u044B\u0439)",
|
|
287
|
+
detect: [/7802348846/],
|
|
288
|
+
pricesIncludeVat: true,
|
|
289
|
+
vatRate: 20,
|
|
290
|
+
articleFromCode: true,
|
|
291
|
+
columns: [
|
|
292
|
+
{ key: "num", from: 0, to: 55 },
|
|
293
|
+
{ key: "code", from: 55, to: 90 },
|
|
294
|
+
{ key: "name", from: 90, to: 205 },
|
|
295
|
+
{ key: "qty", from: 205, to: 232 },
|
|
296
|
+
{ key: "unit", from: 232, to: 262 },
|
|
297
|
+
{ key: "price2", from: 262, to: 350 },
|
|
298
|
+
{ key: "price", from: 350, to: 400 },
|
|
299
|
+
{ key: "vatflag", from: 400, to: 445 },
|
|
300
|
+
{ key: "sum", from: 450, to: 520 }
|
|
301
|
+
],
|
|
302
|
+
rowPattern: { num: /^\d+$/, code: /^\d{6,}$/ },
|
|
303
|
+
stopPattern: /^Всего наименований/iu,
|
|
304
|
+
totalsPatterns: {
|
|
305
|
+
vat: /В том числе НДС/iu,
|
|
306
|
+
total: /Итого:/iu
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
exports2.PROFILES.push(exports2.PETROVICH_COMPACT);
|
|
310
|
+
var ONEC_ARTICLE = [
|
|
311
|
+
{ key: "num", from: 0, to: 58 },
|
|
312
|
+
{ key: "art", from: 56, to: 100 },
|
|
313
|
+
{ key: "name", from: 100, to: 290 },
|
|
314
|
+
{ key: "qty", from: 290, to: 333 },
|
|
315
|
+
{ key: "unit", from: 333, to: 355 },
|
|
316
|
+
{ key: "price", from: 355, to: 430 },
|
|
317
|
+
{ key: "vat", from: 430, to: 455 },
|
|
318
|
+
{ key: "vatsum", from: 455, to: 510 },
|
|
319
|
+
{ key: "sum", from: 510, to: 610 }
|
|
320
|
+
];
|
|
321
|
+
var ONEC_CODE_ARTICLE = [
|
|
322
|
+
{ key: "num", from: 0, to: 58 },
|
|
323
|
+
{ key: "code", from: 58, to: 100 },
|
|
324
|
+
{ key: "art", from: 100, to: 135 },
|
|
325
|
+
{ key: "name", from: 135, to: 290 },
|
|
326
|
+
{ key: "qty", from: 290, to: 333 },
|
|
327
|
+
{ key: "unit", from: 333, to: 355 },
|
|
328
|
+
{ key: "price", from: 355, to: 430 },
|
|
329
|
+
{ key: "vat", from: 430, to: 455 },
|
|
330
|
+
{ key: "vatsum", from: 455, to: 510 },
|
|
331
|
+
{ key: "sum", from: 510, to: 610 }
|
|
332
|
+
];
|
|
333
|
+
var ONEC_PLAIN = [
|
|
334
|
+
{ key: "num", from: 0, to: 58 },
|
|
335
|
+
{ key: "name", from: 58, to: 395 },
|
|
336
|
+
{ key: "qty", from: 395, to: 440 },
|
|
337
|
+
{ key: "unit", from: 440, to: 460 },
|
|
338
|
+
{ key: "price", from: 460, to: 510 },
|
|
339
|
+
{ key: "sum", from: 510, to: 620 }
|
|
340
|
+
];
|
|
341
|
+
var ONEC_CODE = [
|
|
342
|
+
{ key: "num", from: 0, to: 58 },
|
|
343
|
+
{ key: "code", from: 58, to: 100 },
|
|
344
|
+
{ key: "name", from: 100, to: 290 },
|
|
345
|
+
{ key: "qty", from: 290, to: 333 },
|
|
346
|
+
{ key: "unit", from: 333, to: 355 },
|
|
347
|
+
{ key: "price", from: 355, to: 430 },
|
|
348
|
+
{ key: "vat", from: 430, to: 455 },
|
|
349
|
+
{ key: "vatsum", from: 455, to: 510 },
|
|
350
|
+
{ key: "sum", from: 510, to: 610 }
|
|
351
|
+
];
|
|
352
|
+
var ONEC_PLAIN_CODE = [
|
|
353
|
+
{ key: "num", from: 0, to: 58 },
|
|
354
|
+
{ key: "code", from: 58, to: 100 },
|
|
355
|
+
{ key: "name", from: 100, to: 395 },
|
|
356
|
+
{ key: "qty", from: 395, to: 440 },
|
|
357
|
+
{ key: "unit", from: 440, to: 460 },
|
|
358
|
+
{ key: "price", from: 460, to: 510 },
|
|
359
|
+
{ key: "sum", from: 510, to: 620 }
|
|
360
|
+
];
|
|
361
|
+
var SHORT_TABLE = [
|
|
362
|
+
{ key: "num", from: 0, to: 56 },
|
|
363
|
+
{ key: "name", from: 56, to: 330 },
|
|
364
|
+
{ key: "qty", from: 330, to: 344 },
|
|
365
|
+
{ key: "unit", from: 344, to: 378 },
|
|
366
|
+
{ key: "price", from: 378, to: 460 },
|
|
367
|
+
{ key: "sum", from: 460, to: 610 }
|
|
368
|
+
];
|
|
369
|
+
var OFFER_TABLE = [
|
|
370
|
+
{ key: "num", from: 0, to: 56 },
|
|
371
|
+
{ key: "name", from: 56, to: 370 },
|
|
372
|
+
{ key: "qty", from: 370, to: 386 },
|
|
373
|
+
{ key: "unit", from: 386, to: 420 },
|
|
374
|
+
{ key: "price", from: 420, to: 500 },
|
|
375
|
+
{ key: "sum", from: 500, to: 610 }
|
|
376
|
+
];
|
|
377
|
+
var CODE_RIGHT_TABLE = [
|
|
378
|
+
{ key: "num", from: 0, to: 60 },
|
|
379
|
+
{ key: "name", from: 60, to: 235 },
|
|
380
|
+
{ key: "code", from: 235, to: 330 },
|
|
381
|
+
{ key: "qty", from: 330, to: 350 },
|
|
382
|
+
{ key: "unit", from: 350, to: 400 },
|
|
383
|
+
{ key: "price", from: 400, to: 470 },
|
|
384
|
+
{ key: "sum", from: 470, to: 610 }
|
|
385
|
+
];
|
|
386
|
+
var IP_TABLE = [
|
|
387
|
+
{ key: "num", from: 0, to: 80 },
|
|
388
|
+
{ key: "name", from: 80, to: 240 },
|
|
389
|
+
{ key: "code", from: 240, to: 290 },
|
|
390
|
+
{ key: "qty", from: 290, to: 302 },
|
|
391
|
+
{ key: "unit", from: 302, to: 330 },
|
|
392
|
+
{ key: "price", from: 330, to: 370 },
|
|
393
|
+
{ key: "sum", from: 420, to: 610 }
|
|
394
|
+
];
|
|
395
|
+
var TUBE_TABLE = [
|
|
396
|
+
{ key: "num", from: 0, to: 70 },
|
|
397
|
+
{ key: "name", from: 70, to: 300 },
|
|
398
|
+
{ key: "code", from: 300, to: 345 },
|
|
399
|
+
{ key: "price", from: 345, to: 415 },
|
|
400
|
+
{ key: "qty", from: 415, to: 440 },
|
|
401
|
+
{ key: "unit", from: 440, to: 485 },
|
|
402
|
+
{ key: "sum", from: 485, to: 610 }
|
|
403
|
+
];
|
|
404
|
+
var BOILER_TABLE = [
|
|
405
|
+
{ key: "num", from: 0, to: 80 },
|
|
406
|
+
{ key: "name", from: 80, to: 370 },
|
|
407
|
+
{ key: "qty", from: 370, to: 384 },
|
|
408
|
+
{ key: "unit", from: 384, to: 430 },
|
|
409
|
+
{ key: "price", from: 430, to: 510 },
|
|
410
|
+
{ key: "sum", from: 510, to: 610 }
|
|
411
|
+
];
|
|
412
|
+
var CATALOG_TABLE = [
|
|
413
|
+
{ key: "num", from: 0, to: 56 },
|
|
414
|
+
{ key: "code", from: 56, to: 100 },
|
|
415
|
+
{ key: "name", from: 100, to: 275 },
|
|
416
|
+
{ key: "qty", from: 390, to: 430 },
|
|
417
|
+
{ key: "unit", from: 430, to: 460 },
|
|
418
|
+
{ key: "price", from: 460, to: 510 },
|
|
419
|
+
{ key: "sum", from: 510, to: 610 }
|
|
420
|
+
];
|
|
421
|
+
var WA_TABLE = [
|
|
422
|
+
{ key: "num", from: 0, to: 56 },
|
|
423
|
+
{ key: "name", from: 56, to: 260 },
|
|
424
|
+
{ key: "qty", from: 260, to: 300 },
|
|
425
|
+
{ key: "unit", from: 300, to: 340 },
|
|
426
|
+
{ key: "price", from: 340, to: 420 },
|
|
427
|
+
{ key: "sum", from: 500, to: 610 }
|
|
428
|
+
];
|
|
429
|
+
var PLUMB_TABLE = [
|
|
430
|
+
{ key: "num", from: 0, to: 56 },
|
|
431
|
+
{ key: "code", from: 56, to: 110 },
|
|
432
|
+
{ key: "name", from: 110, to: 265 },
|
|
433
|
+
{ key: "qty", from: 265, to: 300 },
|
|
434
|
+
{ key: "unit", from: 300, to: 335 },
|
|
435
|
+
{ key: "price", from: 335, to: 380 },
|
|
436
|
+
{ key: "price2", from: 380, to: 420 },
|
|
437
|
+
{ key: "sum", from: 420, to: 475 },
|
|
438
|
+
{ key: "vatflag", from: 475, to: 610 }
|
|
439
|
+
];
|
|
440
|
+
var SATURN_TABLE = [
|
|
441
|
+
{ key: "num", from: 0, to: 60 },
|
|
442
|
+
{ key: "name", from: 60, to: 350 },
|
|
443
|
+
{ key: "qty", from: 350, to: 378 },
|
|
444
|
+
{ key: "unit", from: 378, to: 400 },
|
|
445
|
+
{ key: "price", from: 400, to: 470 },
|
|
446
|
+
{ key: "sum", from: 470, to: 525 }
|
|
447
|
+
];
|
|
448
|
+
var DECOR_TABLE = [
|
|
449
|
+
{ key: "num", from: 0, to: 48 },
|
|
450
|
+
{ key: "name", from: 48, to: 235 },
|
|
451
|
+
{ key: "qty", from: 330, to: 400 },
|
|
452
|
+
{ key: "price", from: 455, to: 517 },
|
|
453
|
+
{ key: "sum", from: 517, to: 620 }
|
|
454
|
+
];
|
|
455
|
+
var ORDER_TABLE = [
|
|
456
|
+
{ key: "num", from: 0, to: 35 },
|
|
457
|
+
{ key: "name", from: 35, to: 180 },
|
|
458
|
+
{ key: "qty", from: 180, to: 190 },
|
|
459
|
+
{ key: "unit", from: 190, to: 230 },
|
|
460
|
+
{ key: "price", from: 255, to: 300 },
|
|
461
|
+
{ key: "sum", from: 400, to: 610 }
|
|
462
|
+
];
|
|
463
|
+
var CONTRACT_TABLE = [
|
|
464
|
+
{ key: "num", from: 0, to: 58 },
|
|
465
|
+
{ key: "name", from: 58, to: 385 },
|
|
466
|
+
{ key: "price", from: 385, to: 450 },
|
|
467
|
+
{ key: "qty", from: 450, to: 480 },
|
|
468
|
+
{ key: "unit", from: 480, to: 505 },
|
|
469
|
+
{ key: "sum", from: 505, to: 610 }
|
|
470
|
+
];
|
|
471
|
+
var TERMOKIT_TABLE = [
|
|
472
|
+
{ key: "num", from: 0, to: 30 },
|
|
473
|
+
{ key: "code", from: 30, to: 90 },
|
|
474
|
+
{ key: "name", from: 90, to: 300 },
|
|
475
|
+
{ key: "qty", from: 300, to: 310 },
|
|
476
|
+
{ key: "unit", from: 310, to: 340 },
|
|
477
|
+
{ key: "price", from: 340, to: 400 },
|
|
478
|
+
{ key: "total", from: 400, to: 455 },
|
|
479
|
+
{ key: "vatsum", from: 455, to: 505 },
|
|
480
|
+
{ key: "sum", from: 505, to: 610 }
|
|
481
|
+
];
|
|
482
|
+
var STEEL_TABLE = [
|
|
483
|
+
{ key: "num", from: 0, to: 60 },
|
|
484
|
+
{ key: "name", from: 60, to: 330 },
|
|
485
|
+
{ key: "qty", from: 330, to: 352 },
|
|
486
|
+
{ key: "unit", from: 352, to: 380 },
|
|
487
|
+
{ key: "price", from: 380, to: 480 },
|
|
488
|
+
{ key: "sum", from: 480, to: 610 }
|
|
489
|
+
];
|
|
490
|
+
var TOTALS_WITH_VAT = {
|
|
491
|
+
vat: /В т\.ч\. НДС|Сумма НДС/iu,
|
|
492
|
+
total: /Итого с НДС/iu
|
|
493
|
+
};
|
|
494
|
+
var TOTALS_PAYABLE = {
|
|
495
|
+
vat: /В том числе НДС/iu,
|
|
496
|
+
total: /Всего к оплате/iu
|
|
497
|
+
};
|
|
498
|
+
var TOTALS_TOTAL = {
|
|
499
|
+
vat: /В том числе НДС/iu,
|
|
500
|
+
total: /Итого:/iu
|
|
501
|
+
};
|
|
502
|
+
var TOTALS_PAY = {
|
|
503
|
+
total: /Итог к оплате/iu
|
|
504
|
+
};
|
|
505
|
+
var TOTALS_PLUMB = {
|
|
506
|
+
sum: /Итого без НДС/iu,
|
|
507
|
+
vat: /Кроме того НДС/iu,
|
|
508
|
+
total: /Итого\s*[cс]\s*НДС/iu
|
|
509
|
+
};
|
|
510
|
+
var TOTALS_SUM = {
|
|
511
|
+
vat: /В том числе НДС/iu,
|
|
512
|
+
total: /на сумму/iu
|
|
513
|
+
};
|
|
514
|
+
var PROFILE_ALTUS_KRASNODAR = {
|
|
515
|
+
id: "altus-krasnodar",
|
|
516
|
+
layoutId: "onec-article",
|
|
517
|
+
title: "\u041E\u041E\u041E \xAB\u0410\u041B\u042C\u0422\u0423\u0421 \u041A\u0420\u0410\u0421\u041D\u041E\u0414\u0410\u0420\xBB",
|
|
518
|
+
detect: [/2312309655/],
|
|
519
|
+
pricesIncludeVat: true,
|
|
520
|
+
vatRate: 22,
|
|
521
|
+
columns: ONEC_ARTICLE,
|
|
522
|
+
rowPattern: { num: /^\d+$/ },
|
|
523
|
+
stopPattern: /^итог/iu,
|
|
524
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
525
|
+
};
|
|
526
|
+
exports2.PROFILES.push(PROFILE_ALTUS_KRASNODAR);
|
|
527
|
+
var PROFILE_KRASKA_1001 = {
|
|
528
|
+
id: "kraska-1001",
|
|
529
|
+
layoutId: "onec-article",
|
|
530
|
+
title: "\u041E\u041E\u041E \xAB1001 \u041A\u0420\u0410\u0421\u041A\u0410\xBB",
|
|
531
|
+
detect: [/7729682876/],
|
|
532
|
+
pricesIncludeVat: true,
|
|
533
|
+
vatRate: 22,
|
|
534
|
+
columns: ONEC_CODE,
|
|
535
|
+
rowPattern: { num: /^\d+$/ },
|
|
536
|
+
stopPattern: /^итог/iu,
|
|
537
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
538
|
+
};
|
|
539
|
+
exports2.PROFILES.push(PROFILE_KRASKA_1001);
|
|
540
|
+
var PROFILE_ROZMET = {
|
|
541
|
+
id: "rozmet",
|
|
542
|
+
layoutId: "onec-article",
|
|
543
|
+
title: "\u041E\u041E\u041E \xAB\u0420\u043E\u0437\u043C\u0435\u0442\xBB",
|
|
544
|
+
detect: [/5003099533/],
|
|
545
|
+
pricesIncludeVat: true,
|
|
546
|
+
vatRate: 22,
|
|
547
|
+
columns: ONEC_ARTICLE,
|
|
548
|
+
rowPattern: { num: /^\d+$/ },
|
|
549
|
+
stopPattern: /^итог/iu,
|
|
550
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
551
|
+
};
|
|
552
|
+
exports2.PROFILES.push(PROFILE_ROZMET);
|
|
553
|
+
var PROFILE_R_KLIMAT = {
|
|
554
|
+
id: "r-klimat",
|
|
555
|
+
layoutId: "onec-code-article",
|
|
556
|
+
title: "\u041E\u041E\u041E \xAB\u0420-\u041A\u041B\u0418\u041C\u0410\u0422\xBB",
|
|
557
|
+
detect: [/7706739893/],
|
|
558
|
+
pricesIncludeVat: true,
|
|
559
|
+
vatRate: 22,
|
|
560
|
+
columns: ONEC_CODE_ARTICLE,
|
|
561
|
+
rowPattern: { num: /^\d+$/ },
|
|
562
|
+
stopPattern: /^итог/iu,
|
|
563
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
564
|
+
};
|
|
565
|
+
exports2.PROFILES.push(PROFILE_R_KLIMAT);
|
|
566
|
+
var PROFILE_OBEDINENNY_METALIST = {
|
|
567
|
+
id: "obedinenny-metalist",
|
|
568
|
+
layoutId: "onec-plain",
|
|
569
|
+
title: "\u041E\u041E\u041E \xAB\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0451\u043D\u043D\u044B\u0439 \u043C\u0435\u0442\u0430\u043B\u043B\u0438\u0441\u0442\xBB",
|
|
570
|
+
detect: [/2315123592/],
|
|
571
|
+
pricesIncludeVat: true,
|
|
572
|
+
vatRate: 22,
|
|
573
|
+
columns: ONEC_PLAIN,
|
|
574
|
+
rowPattern: { num: /^\d+$/ },
|
|
575
|
+
stopPattern: /^итог/iu,
|
|
576
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
577
|
+
};
|
|
578
|
+
exports2.PROFILES.push(PROFILE_OBEDINENNY_METALIST);
|
|
579
|
+
var PROFILE_PROFILSTAR = {
|
|
580
|
+
id: "profilstar",
|
|
581
|
+
layoutId: "onec-plain",
|
|
582
|
+
title: "\u041E\u041E\u041E \xAB\u041F\u0420\u041E\u0424\u0418\u041B\u042C\u0421\u0422\u0410\u0420\xBB",
|
|
583
|
+
detect: [/7702401126/],
|
|
584
|
+
pricesIncludeVat: true,
|
|
585
|
+
vatRate: 22,
|
|
586
|
+
columns: ONEC_PLAIN,
|
|
587
|
+
rowPattern: { num: /^\d+$/ },
|
|
588
|
+
stopPattern: /^итог/iu,
|
|
589
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
590
|
+
};
|
|
591
|
+
exports2.PROFILES.push(PROFILE_PROFILSTAR);
|
|
592
|
+
var PROFILE_FORWARD_S = {
|
|
593
|
+
id: "forward-s",
|
|
594
|
+
layoutId: "onec-plain",
|
|
595
|
+
title: "\u041E\u041E\u041E \xAB\u0424\u041E\u0420\u0412\u0410\u0420\u0414-\u0421\xBB",
|
|
596
|
+
detect: [/7743224469/],
|
|
597
|
+
pricesIncludeVat: true,
|
|
598
|
+
vatRate: 22,
|
|
599
|
+
columns: ONEC_PLAIN,
|
|
600
|
+
rowPattern: { num: /^\d+$/ },
|
|
601
|
+
stopPattern: /^итог/iu,
|
|
602
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
603
|
+
};
|
|
604
|
+
exports2.PROFILES.push(PROFILE_FORWARD_S);
|
|
605
|
+
var PROFILE_GK_ATLANT = {
|
|
606
|
+
id: "gk-atlant",
|
|
607
|
+
layoutId: "onec-plain",
|
|
608
|
+
title: "\u041E\u041E\u041E \xAB\u0413\u041A \u0410\u0422\u041B\u0410\u041D\u0422\xBB",
|
|
609
|
+
detect: [/7811214101/],
|
|
610
|
+
columns: ONEC_PLAIN,
|
|
611
|
+
rowPattern: { num: /^\d+$/ },
|
|
612
|
+
stopPattern: /^итог/iu,
|
|
613
|
+
totalsPatterns: {
|
|
614
|
+
sum: /Итого:/iu,
|
|
615
|
+
vat: /Сумма НДС/iu,
|
|
616
|
+
total: /Итого с НДС/iu
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
exports2.PROFILES.push(PROFILE_GK_ATLANT);
|
|
620
|
+
var PROFILE_MAMAZHANOV = {
|
|
621
|
+
id: "mamazhanov",
|
|
622
|
+
layoutId: "onec-plain-article",
|
|
623
|
+
title: "\u0418\u041F \u041C\u0430\u043C\u0430\u0436\u0430\u043D\u043E\u0432 \u0420. \u041E.",
|
|
624
|
+
detect: [/582102754005/],
|
|
625
|
+
pricesIncludeVat: true,
|
|
626
|
+
vatRate: 22,
|
|
627
|
+
columns: ONEC_PLAIN_CODE,
|
|
628
|
+
rowPattern: { num: /^\d+$/ },
|
|
629
|
+
stopPattern: /^итог/iu,
|
|
630
|
+
totalsPatterns: TOTALS_WITH_VAT
|
|
631
|
+
};
|
|
632
|
+
exports2.PROFILES.push(PROFILE_MAMAZHANOV);
|
|
633
|
+
var PROFILE_SHAROV = {
|
|
634
|
+
id: "sharov",
|
|
635
|
+
layoutId: "short-table",
|
|
636
|
+
title: "\u0418\u041F \u0428\u0430\u0440\u043E\u0432 \u041C. \u0418.",
|
|
637
|
+
detect: [/772883149760/],
|
|
638
|
+
pricesIncludeVat: true,
|
|
639
|
+
vatRate: 22,
|
|
640
|
+
columns: SHORT_TABLE,
|
|
641
|
+
rowPattern: { num: /^\d+$/ },
|
|
642
|
+
stopPattern: /^итог/iu,
|
|
643
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
644
|
+
};
|
|
645
|
+
exports2.PROFILES.push(PROFILE_SHAROV);
|
|
646
|
+
var PROFILE_BOYKO = {
|
|
647
|
+
id: "boyko",
|
|
648
|
+
layoutId: "short-table",
|
|
649
|
+
title: "\u0418\u041F \u0411\u043E\u0439\u043A\u043E \u0421. \u0421.",
|
|
650
|
+
detect: [/772797351740/],
|
|
651
|
+
pricesIncludeVat: true,
|
|
652
|
+
vatRate: 22,
|
|
653
|
+
columns: SHORT_TABLE,
|
|
654
|
+
rowPattern: { num: /^\d+$/ },
|
|
655
|
+
stopPattern: /^итог/iu,
|
|
656
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
657
|
+
};
|
|
658
|
+
exports2.PROFILES.push(PROFILE_BOYKO);
|
|
659
|
+
var PROFILE_SGK_TEHSTROY = {
|
|
660
|
+
id: "sgk-tehstroy",
|
|
661
|
+
layoutId: "short-table",
|
|
662
|
+
title: "\u041E\u041E\u041E \xAB\u0421\u0413\u041A-\u0422\u0415\u0425\u0421\u0422\u0420\u041E\u0419\xBB",
|
|
663
|
+
detect: [/7724615523/],
|
|
664
|
+
pricesIncludeVat: true,
|
|
665
|
+
vatRate: 22,
|
|
666
|
+
columns: SHORT_TABLE,
|
|
667
|
+
rowPattern: { num: /^\d+$/ },
|
|
668
|
+
stopPattern: /^итог/iu,
|
|
669
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
670
|
+
};
|
|
671
|
+
exports2.PROFILES.push(PROFILE_SGK_TEHSTROY);
|
|
672
|
+
var PROFILE_STROY_DIALOG = {
|
|
673
|
+
id: "stroy-dialog",
|
|
674
|
+
layoutId: "short-table",
|
|
675
|
+
title: "\u041E\u041E\u041E \xAB\u0421\u0442\u0440\u043E\u0439-\u0414\u0438\u0430\u043B\u043E\u0433\xBB",
|
|
676
|
+
detect: [/7719742692/],
|
|
677
|
+
pricesIncludeVat: true,
|
|
678
|
+
vatRate: 22,
|
|
679
|
+
columns: SHORT_TABLE,
|
|
680
|
+
rowPattern: { num: /^\d+$/ },
|
|
681
|
+
stopPattern: /^итог/iu,
|
|
682
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
683
|
+
};
|
|
684
|
+
exports2.PROFILES.push(PROFILE_STROY_DIALOG);
|
|
685
|
+
var PROFILE_M5_GROUP = {
|
|
686
|
+
id: "m5-group",
|
|
687
|
+
layoutId: "short-table",
|
|
688
|
+
title: "\u041E\u041E\u041E \xAB\u041C5 \u0413\u0420\u0423\u041F\u041F\xBB",
|
|
689
|
+
detect: [/7751259296/],
|
|
690
|
+
pricesIncludeVat: true,
|
|
691
|
+
vatRate: 22,
|
|
692
|
+
columns: SHORT_TABLE,
|
|
693
|
+
rowPattern: { num: /^\d+$/ },
|
|
694
|
+
stopPattern: /^итог/iu,
|
|
695
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
696
|
+
};
|
|
697
|
+
exports2.PROFILES.push(PROFILE_M5_GROUP);
|
|
698
|
+
var PROFILE_VIKVENT = {
|
|
699
|
+
id: "vikvent",
|
|
700
|
+
layoutId: "offer-table",
|
|
701
|
+
title: "\u041E\u041E\u041E \xAB\u0412\u0418\u041A\u0412\u0415\u041D\u0422\xBB",
|
|
702
|
+
detect: [/5040151735/],
|
|
703
|
+
pricesIncludeVat: true,
|
|
704
|
+
vatRate: 22,
|
|
705
|
+
columns: OFFER_TABLE,
|
|
706
|
+
rowPattern: { num: /^\d+$/ },
|
|
707
|
+
stopPattern: /^итог/iu,
|
|
708
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
709
|
+
};
|
|
710
|
+
exports2.PROFILES.push(PROFILE_VIKVENT);
|
|
711
|
+
var PROFILE_AGAFONKIN = {
|
|
712
|
+
id: "agafonkin",
|
|
713
|
+
layoutId: "offer-table",
|
|
714
|
+
title: "\u0418\u041F \u0410\u0433\u0430\u0444\u043E\u043D\u043A\u0438\u043D \u0410. \u041C.",
|
|
715
|
+
detect: [/501304967839/],
|
|
716
|
+
pricesIncludeVat: true,
|
|
717
|
+
vatRate: 22,
|
|
718
|
+
columns: OFFER_TABLE,
|
|
719
|
+
rowPattern: { num: /^\d+$/ },
|
|
720
|
+
stopPattern: /^итог/iu,
|
|
721
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
722
|
+
};
|
|
723
|
+
exports2.PROFILES.push(PROFILE_AGAFONKIN);
|
|
724
|
+
var PROFILE_INTERIER_UYUT = {
|
|
725
|
+
id: "interier-uyut",
|
|
726
|
+
layoutId: "code-right-table",
|
|
727
|
+
title: "\u041E\u041E\u041E \xAB\u0418\u043D\u0442\u0435\u0440\u044C\u0435\u0440 \u0423\u044E\u0442\xBB",
|
|
728
|
+
detect: [/5029209244/],
|
|
729
|
+
pricesIncludeVat: true,
|
|
730
|
+
vatRate: 22,
|
|
731
|
+
columns: CODE_RIGHT_TABLE,
|
|
732
|
+
rowPattern: { num: /^\d+$/ },
|
|
733
|
+
stopPattern: /^итог/iu,
|
|
734
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
735
|
+
};
|
|
736
|
+
exports2.PROFILES.push(PROFILE_INTERIER_UYUT);
|
|
737
|
+
var PROFILE_VSEINSTRUMENTI = {
|
|
738
|
+
id: "vseinstrumenti",
|
|
739
|
+
layoutId: "catalog-table",
|
|
740
|
+
title: "\u041E\u041E\u041E \xAB\u0412\u0441\u0435\u0418\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u044B.\u0440\u0443\xBB",
|
|
741
|
+
detect: [/7722753969/],
|
|
742
|
+
pricesIncludeVat: true,
|
|
743
|
+
vatRate: 22,
|
|
744
|
+
columns: CATALOG_TABLE,
|
|
745
|
+
rowPattern: { num: /^\d+$/ },
|
|
746
|
+
stopPattern: /^итог/iu,
|
|
747
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
748
|
+
};
|
|
749
|
+
exports2.PROFILES.push(PROFILE_VSEINSTRUMENTI);
|
|
750
|
+
var PROFILE_KOLODIY = {
|
|
751
|
+
id: "kolodiy",
|
|
752
|
+
layoutId: "ip-table",
|
|
753
|
+
title: "\u0418\u041F \u041A\u043E\u043B\u043E\u0434\u0438\u0439 \u0412. \u0412.",
|
|
754
|
+
detect: [/732771536701/],
|
|
755
|
+
columns: IP_TABLE,
|
|
756
|
+
rowPattern: { num: /^\d+$/ },
|
|
757
|
+
stopPattern: /^итог/iu,
|
|
758
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
759
|
+
};
|
|
760
|
+
exports2.PROFILES.push(PROFILE_KOLODIY);
|
|
761
|
+
var PROFILE_TRUBY_SOVKOM = {
|
|
762
|
+
id: "truby-sovkom",
|
|
763
|
+
layoutId: "tube-table",
|
|
764
|
+
yTolerance: 9,
|
|
765
|
+
title: "\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A 7743778097",
|
|
766
|
+
detect: [/7743778097/],
|
|
767
|
+
pricesIncludeVat: true,
|
|
768
|
+
vatRate: 22,
|
|
769
|
+
columns: TUBE_TABLE,
|
|
770
|
+
rowPattern: { num: /^\d+$/ },
|
|
771
|
+
stopPattern: /^итог/iu,
|
|
772
|
+
totalsPatterns: TOTALS_TOTAL
|
|
773
|
+
};
|
|
774
|
+
exports2.PROFILES.push(PROFILE_TRUBY_SOVKOM);
|
|
775
|
+
var PROFILE_KOPICHNIKOVA = {
|
|
776
|
+
id: "kopichnikova",
|
|
777
|
+
layoutId: "boiler-table",
|
|
778
|
+
title: "\u0418\u041F \u041A\u043E\u043F\u0438\u0447\u043D\u0438\u043A\u043E\u0432\u0430 \u0415. \u0421.",
|
|
779
|
+
detect: [/770201555461/],
|
|
780
|
+
pricesIncludeVat: true,
|
|
781
|
+
vatRate: 22,
|
|
782
|
+
columns: BOILER_TABLE,
|
|
783
|
+
rowPattern: { num: /^\d+$/ },
|
|
784
|
+
stopPattern: /^итог/iu,
|
|
785
|
+
totalsPatterns: TOTALS_TOTAL
|
|
786
|
+
};
|
|
787
|
+
exports2.PROFILES.push(PROFILE_KOPICHNIKOVA);
|
|
788
|
+
var PROFILE_BABAYAN = {
|
|
789
|
+
id: "babayan",
|
|
790
|
+
layoutId: "wa-table",
|
|
791
|
+
title: "\u0418\u041F \u0411\u0430\u0431\u0430\u044F\u043D \u041C. \u041C.",
|
|
792
|
+
detect: [/772793005900/],
|
|
793
|
+
columns: WA_TABLE,
|
|
794
|
+
rowPattern: { num: /^\d+$/ },
|
|
795
|
+
stopPattern: /^итог/iu,
|
|
796
|
+
totalsPatterns: TOTALS_PAY
|
|
797
|
+
};
|
|
798
|
+
exports2.PROFILES.push(PROFILE_BABAYAN);
|
|
799
|
+
var PROFILE_SANTEHKOMPLEKT = {
|
|
800
|
+
id: "santehkomplekt",
|
|
801
|
+
layoutId: "plumb-table",
|
|
802
|
+
title: "\u041E\u041E\u041E \xAB\u0421\u0430\u043D\u0442\u0435\u0445\u043A\u043E\u043C\u043F\u043B\u0435\u043A\u0442\xBB",
|
|
803
|
+
detect: [/7736192449/],
|
|
804
|
+
pricesIncludeVat: true,
|
|
805
|
+
vatRate: 22,
|
|
806
|
+
columns: PLUMB_TABLE,
|
|
807
|
+
rowPattern: { num: /^\d+$/ },
|
|
808
|
+
stopPattern: /^итог/iu,
|
|
809
|
+
totalsPatterns: TOTALS_PLUMB
|
|
810
|
+
};
|
|
811
|
+
exports2.PROFILES.push(PROFILE_SANTEHKOMPLEKT);
|
|
812
|
+
var PROFILE_SATURN_CENTR = {
|
|
813
|
+
id: "saturn-centr",
|
|
814
|
+
layoutId: "saturn-table",
|
|
815
|
+
title: "\u041E\u041E\u041E \xAB\u0421\u0410\u0422\u0423\u0420\u041D \u0426\u0415\u041D\u0422\u0420\xBB",
|
|
816
|
+
detect: [/9717052425/],
|
|
817
|
+
pricesIncludeVat: true,
|
|
818
|
+
vatRate: 22,
|
|
819
|
+
columns: SATURN_TABLE,
|
|
820
|
+
rowPattern: { num: /^\d+$/ },
|
|
821
|
+
stopPattern: /^итог/iu,
|
|
822
|
+
totalsPatterns: TOTALS_TOTAL
|
|
823
|
+
};
|
|
824
|
+
exports2.PROFILES.push(PROFILE_SATURN_CENTR);
|
|
825
|
+
var PROFILE_VLADIMIROVA = {
|
|
826
|
+
id: "vladimirova",
|
|
827
|
+
layoutId: "decor-table",
|
|
828
|
+
title: "\u0418\u041F \u0412\u043B\u0430\u0434\u0438\u043C\u0438\u0440\u043E\u0432\u0430 \u041C. \u041D.",
|
|
829
|
+
detect: [/502771785894/],
|
|
830
|
+
columns: DECOR_TABLE,
|
|
831
|
+
rowPattern: { num: /^\d+$/ },
|
|
832
|
+
stopPattern: /^итог/iu,
|
|
833
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
834
|
+
};
|
|
835
|
+
exports2.PROFILES.push(PROFILE_VLADIMIROVA);
|
|
836
|
+
var PROFILE_ROVEN_M = {
|
|
837
|
+
id: "roven-m",
|
|
838
|
+
layoutId: "order-table",
|
|
839
|
+
title: "\u041E\u041E\u041E \xAB\u0420\u041E\u0412\u0415\u041D-\u041C\xBB",
|
|
840
|
+
detect: [/7723812078/],
|
|
841
|
+
pricesIncludeVat: true,
|
|
842
|
+
vatRate: 22,
|
|
843
|
+
columns: ORDER_TABLE,
|
|
844
|
+
rowPattern: { num: /^\d+$/ },
|
|
845
|
+
stopPattern: /^итог/iu,
|
|
846
|
+
totalsPatterns: TOTALS_SUM
|
|
847
|
+
};
|
|
848
|
+
exports2.PROFILES.push(PROFILE_ROVEN_M);
|
|
849
|
+
var PROFILE_SCHET_DOGOVOR = {
|
|
850
|
+
id: "schet-dogovor",
|
|
851
|
+
layoutId: "contract-table",
|
|
852
|
+
title: "\u0421\u0447\u0451\u0442-\u0434\u043E\u0433\u043E\u0432\u043E\u0440 (\u0418\u041D\u041D 7707743243)",
|
|
853
|
+
detect: [/7707743243/],
|
|
854
|
+
pricesIncludeVat: true,
|
|
855
|
+
vatRate: 22,
|
|
856
|
+
columns: CONTRACT_TABLE,
|
|
857
|
+
rowPattern: { num: /^\d+$/ },
|
|
858
|
+
stopPattern: /^итог/iu,
|
|
859
|
+
totalsPatterns: TOTALS_TOTAL
|
|
860
|
+
};
|
|
861
|
+
exports2.PROFILES.push(PROFILE_SCHET_DOGOVOR);
|
|
862
|
+
var PROFILE_TERMOKIT = {
|
|
863
|
+
id: "termokit",
|
|
864
|
+
layoutId: "termokit-table",
|
|
865
|
+
title: "\u041E\u041E\u041E \xAB\u0422\u0415\u0420\u041C\u041E\u041A\u0418\u0422-\u0421\u0415\u0420\u0412\u0418\u0421\xBB",
|
|
866
|
+
detect: [/9715287781/],
|
|
867
|
+
columns: TERMOKIT_TABLE,
|
|
868
|
+
rowPattern: { num: /^\d+$/ },
|
|
869
|
+
stopPattern: /^итог/iu
|
|
870
|
+
};
|
|
871
|
+
exports2.PROFILES.push(PROFILE_TERMOKIT);
|
|
872
|
+
var PROFILE_REGION_STAL_SPB = {
|
|
873
|
+
id: "region-stal-spb",
|
|
874
|
+
layoutId: "steel-table",
|
|
875
|
+
title: "\u041E\u041E\u041E \xAB\u0420\u0415\u0413\u0418\u041E\u041D \u0421\u0422\u0410\u041B\u042C \u0421\u041F\u0411\xBB",
|
|
876
|
+
detect: [/7814712017/],
|
|
877
|
+
pricesIncludeVat: true,
|
|
878
|
+
vatRate: 22,
|
|
879
|
+
columns: STEEL_TABLE,
|
|
880
|
+
rowPattern: { num: /^\d+$/ },
|
|
881
|
+
stopPattern: /^итог/iu,
|
|
882
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
883
|
+
};
|
|
884
|
+
exports2.PROFILES.push(PROFILE_REGION_STAL_SPB);
|
|
77
885
|
exports2.PROFILES.push(exports2.LEMAN);
|
|
886
|
+
exports2.LEMAN_OFFER = {
|
|
887
|
+
id: "leman-offer",
|
|
888
|
+
layoutId: "leman/offer",
|
|
889
|
+
title: "\u041B\u0435\u0440\u0443\u0430 \u041C\u0435\u0440\u043B\u0435\u043D (\u0441\u0447\u0451\u0442-\u043E\u0444\u0435\u0440\u0442\u0430)",
|
|
890
|
+
detect: [/ЛЕ\s*МОНЛИД/iu, /lemanapro\.ru/iu],
|
|
891
|
+
descriptionAbove: true,
|
|
892
|
+
pricesIncludeVat: true,
|
|
893
|
+
vatRate: 20,
|
|
894
|
+
columns: [
|
|
895
|
+
{ key: "num", from: 0, to: 60 },
|
|
896
|
+
{ key: "code", from: 60, to: 120 },
|
|
897
|
+
{ key: "art", from: 60, to: 120 },
|
|
898
|
+
{ key: "name", from: 120, to: 280 },
|
|
899
|
+
{ key: "qty", from: 280, to: 300 },
|
|
900
|
+
{ key: "unit", from: 300, to: 340 },
|
|
901
|
+
{ key: "price", from: 340, to: 430 },
|
|
902
|
+
{ key: "sum", from: 430, to: 500 }
|
|
903
|
+
],
|
|
904
|
+
rowPattern: { num: /^\d+$/, code: /^[\d\s]{6,}$/ },
|
|
905
|
+
stopPattern: /^Итого:/i,
|
|
906
|
+
discountPattern: /^Скидка:/i,
|
|
907
|
+
totalsPatterns: {
|
|
908
|
+
vat: /В том числе НДС/i,
|
|
909
|
+
total: /Всего к оплате/i
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
exports2.PROFILES.push(exports2.LEMAN_OFFER);
|
|
913
|
+
exports2.LEMAN_SHIFT = {
|
|
914
|
+
id: "leman-shift",
|
|
915
|
+
layoutId: "leman/shift",
|
|
916
|
+
title: "\u041B\u0435\u0440\u0443\u0430 \u041C\u0435\u0440\u043B\u0435\u043D (\u0441\u0434\u0432\u0438\u043D\u0443\u0442\u044B\u0439 \u043C\u0430\u043A\u0435\u0442)",
|
|
917
|
+
detect: [/ЛЕ\s*МОНЛИД/iu, /lemanapro\.ru/iu],
|
|
918
|
+
descriptionAbove: true,
|
|
919
|
+
pricesIncludeVat: true,
|
|
920
|
+
vatRate: 22,
|
|
921
|
+
qtyUnitInOneColumn: true,
|
|
922
|
+
articleFromCode: true,
|
|
923
|
+
columns: [
|
|
924
|
+
{ key: "num", from: 0, to: 85 },
|
|
925
|
+
{ key: "code", from: 85, to: 132 },
|
|
926
|
+
{ key: "name", from: 132, to: 315 },
|
|
927
|
+
{ key: "qty", from: 315, to: 385 },
|
|
928
|
+
{ key: "price", from: 386, to: 470 },
|
|
929
|
+
{ key: "vat", from: 470, to: 508 },
|
|
930
|
+
{ key: "sum", from: 508, to: 600 }
|
|
931
|
+
],
|
|
932
|
+
rowPattern: { num: /^\d+$/, code: /^[\d\s]{5,}$/ },
|
|
933
|
+
stopPattern: /^Сумма без НДС/i,
|
|
934
|
+
totalsPatterns: {
|
|
935
|
+
sum: /^Сумма без НДС/i,
|
|
936
|
+
vat: /^Итого НДС/i
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
exports2.PROFILES.push(exports2.LEMAN_SHIFT);
|
|
940
|
+
var ONEC_RENT = [
|
|
941
|
+
{ key: "num", from: 0, to: 60 },
|
|
942
|
+
{ key: "name", from: 60, to: 390 },
|
|
943
|
+
{ key: "qty", from: 390, to: 424.7 },
|
|
944
|
+
{ key: "unit", from: 424.7, to: 455 },
|
|
945
|
+
{ key: "price", from: 455, to: 521 },
|
|
946
|
+
{ key: "sum", from: 521, to: 620 }
|
|
947
|
+
];
|
|
948
|
+
exports2.MEGAPOLIS = {
|
|
949
|
+
id: "megapolis",
|
|
950
|
+
layoutId: "onec-rent",
|
|
951
|
+
title: "\u041E\u041E\u041E \xAB\u041C\u0415\u0413\u0410\u041F\u041E\u041B\u0418\u0421\xBB",
|
|
952
|
+
detect: [/(?<!\d)7731283974(?!\d)/u],
|
|
953
|
+
pricesIncludeVat: true,
|
|
954
|
+
vatRate: 22,
|
|
955
|
+
columns: ONEC_RENT,
|
|
956
|
+
headerColumns: {
|
|
957
|
+
labels: {
|
|
958
|
+
num: /^(?:№|N|No)$/u,
|
|
959
|
+
name: /^Наименование(?:\s+товара)?$/iu,
|
|
960
|
+
qty: /^(?:Кол-?во|Количество)$/iu,
|
|
961
|
+
unit: /^Ед\.?(?:\s*изм\.?)?$/iu,
|
|
962
|
+
price: /^Цена(?:,?\s*руб\.?)?(?:\s+с\s+НДС)?$/iu,
|
|
963
|
+
sum: /^Сумма(?:,?\s*руб\.?)?(?:\s+с\s+НДС)?$/iu
|
|
964
|
+
},
|
|
965
|
+
exclude: {
|
|
966
|
+
sum: /^Сумма(?:,?\s*руб\.?)?\s+(?:НДС|без)(?:\s|$)/iu
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
rowPattern: { num: /^\d+$/ },
|
|
970
|
+
stopPattern: /^итог/iu,
|
|
971
|
+
totalsPatterns: TOTALS_PAYABLE
|
|
972
|
+
};
|
|
973
|
+
exports2.PROFILES.push(exports2.MEGAPOLIS);
|
|
78
974
|
}
|
|
79
975
|
});
|
|
80
976
|
|
|
@@ -84808,6 +85704,8 @@ exports.rowCells = rowCells;
|
|
|
84808
85704
|
exports.layoutScore = layoutScore;
|
|
84809
85705
|
exports.detectProfile = detectProfile;
|
|
84810
85706
|
exports.detectCandidates = detectCandidates;
|
|
85707
|
+
exports.headerColumns = headerColumns;
|
|
85708
|
+
exports.resolveProfileColumns = resolveProfileColumns;
|
|
84811
85709
|
exports.parseRows = parseRows;
|
|
84812
85710
|
exports.parseInvoicePdf = parseInvoicePdf;
|
|
84813
85711
|
var node_path_1 = __importDefault(require("node:path"));
|
|
@@ -84819,6 +85717,16 @@ var number = (raw) => {
|
|
|
84819
85717
|
const value = Number.parseFloat(cleaned);
|
|
84820
85718
|
return Number.isFinite(value) ? value : 0;
|
|
84821
85719
|
};
|
|
85720
|
+
var NUMERIC_COLUMNS = /* @__PURE__ */ new Set([
|
|
85721
|
+
"qty",
|
|
85722
|
+
"price",
|
|
85723
|
+
"price2",
|
|
85724
|
+
"sum",
|
|
85725
|
+
"total",
|
|
85726
|
+
"vat",
|
|
85727
|
+
"vatsum"
|
|
85728
|
+
]);
|
|
85729
|
+
var TEXT_COLUMNS = /* @__PURE__ */ new Set(["num", "code", "name", "art", "type"]);
|
|
84822
85730
|
function buildRows(items, yTolerance = 2, page = 1) {
|
|
84823
85731
|
const sorted = [...items].sort((a, b) => b.y - a.y || a.x - b.x);
|
|
84824
85732
|
const rows = [];
|
|
@@ -84848,7 +85756,6 @@ function rowText(row, gap = 1) {
|
|
|
84848
85756
|
return out.replace(/\s+/g, " ").trim();
|
|
84849
85757
|
}
|
|
84850
85758
|
function rowCells(row, profile, gap = 1) {
|
|
84851
|
-
var _a;
|
|
84852
85759
|
const cells = {};
|
|
84853
85760
|
const cellEnd = {};
|
|
84854
85761
|
const pendingSpace = {};
|
|
@@ -84862,12 +85769,17 @@ function rowCells(row, profile, gap = 1) {
|
|
|
84862
85769
|
prevY = item.y;
|
|
84863
85770
|
const width = item.w || item.str.length * 3.2;
|
|
84864
85771
|
const charWidth = width / Math.max(item.str.length, 1);
|
|
85772
|
+
const startColumn = profile.columns.find((column) => item.x + charWidth / 2 >= column.from && item.x + charWidth / 2 < column.to);
|
|
85773
|
+
const startsInText = startColumn !== void 0 && TEXT_COLUMNS.has(startColumn.key);
|
|
84865
85774
|
for (let i = 0; i < item.str.length; i++) {
|
|
84866
85775
|
const char = item.str.charAt(i);
|
|
84867
85776
|
const start = item.x + i * charWidth;
|
|
84868
85777
|
const center = start + charWidth / 2;
|
|
84869
|
-
const
|
|
84870
|
-
if (!
|
|
85778
|
+
const column = profile.columns.find((c) => center >= c.from && center < c.to);
|
|
85779
|
+
if (!column)
|
|
85780
|
+
continue;
|
|
85781
|
+
const key = column.key;
|
|
85782
|
+
if (startsInText && NUMERIC_COLUMNS.has(key))
|
|
84871
85783
|
continue;
|
|
84872
85784
|
if (!char.trim()) {
|
|
84873
85785
|
pendingSpace[key] = true;
|
|
@@ -84969,6 +85881,141 @@ function detectProfile(text) {
|
|
|
84969
85881
|
function detectCandidates(text) {
|
|
84970
85882
|
return profiles_1.PROFILES.filter((profile) => profile.detect.some((re) => re.test(text)));
|
|
84971
85883
|
}
|
|
85884
|
+
var HEADER_REQUIRED = ["name", "qty", "price", "sum"];
|
|
85885
|
+
var roundCoordinate = (value) => Math.round(value * 100) / 100;
|
|
85886
|
+
var HEADER_CELL_GAP = 1.5;
|
|
85887
|
+
var HEADER_CONTEXT_GAP = 8;
|
|
85888
|
+
var HEADER_WINDOW = 4;
|
|
85889
|
+
function headerCells(row) {
|
|
85890
|
+
const cells = [];
|
|
85891
|
+
for (const item of row.items) {
|
|
85892
|
+
const text = item.str.trim();
|
|
85893
|
+
if (!text)
|
|
85894
|
+
continue;
|
|
85895
|
+
const previous = cells[cells.length - 1];
|
|
85896
|
+
const gap = previous ? item.x - (previous.x + previous.w) : Number.POSITIVE_INFINITY;
|
|
85897
|
+
if (previous && gap <= HEADER_CELL_GAP) {
|
|
85898
|
+
previous.text += `${gap > 1 ? " " : ""}${text}`;
|
|
85899
|
+
previous.w = item.x + (item.w || 0) - previous.x;
|
|
85900
|
+
continue;
|
|
85901
|
+
}
|
|
85902
|
+
cells.push({ x: item.x, w: item.w || 0, text });
|
|
85903
|
+
}
|
|
85904
|
+
return cells;
|
|
85905
|
+
}
|
|
85906
|
+
function windowText(cells, start, end) {
|
|
85907
|
+
const parts = [];
|
|
85908
|
+
for (let index = start; index <= end; index += 1) {
|
|
85909
|
+
const cell = cells[index];
|
|
85910
|
+
if (!cell)
|
|
85911
|
+
return void 0;
|
|
85912
|
+
if (index > start) {
|
|
85913
|
+
const previous = cells[index - 1];
|
|
85914
|
+
if (!previous || cell.x - (previous.x + previous.w) > HEADER_CONTEXT_GAP)
|
|
85915
|
+
return void 0;
|
|
85916
|
+
}
|
|
85917
|
+
parts.push(cell.text);
|
|
85918
|
+
}
|
|
85919
|
+
return parts.join(" ");
|
|
85920
|
+
}
|
|
85921
|
+
function findLabel(cells, pattern, exclude) {
|
|
85922
|
+
for (let start = cells.length - 1; start >= 0; start -= 1) {
|
|
85923
|
+
for (let end = Math.min(start + HEADER_WINDOW - 1, cells.length - 1); end >= start; end -= 1) {
|
|
85924
|
+
const text = windowText(cells, start, end);
|
|
85925
|
+
const first = cells[start];
|
|
85926
|
+
const last = cells[end];
|
|
85927
|
+
if (text === void 0 || !first || !last || !pattern.test(text))
|
|
85928
|
+
continue;
|
|
85929
|
+
const extended = windowText(cells, start, end + 1);
|
|
85930
|
+
if (exclude && extended !== void 0 && exclude.test(extended))
|
|
85931
|
+
continue;
|
|
85932
|
+
return { x: first.x, w: last.x + last.w - first.x };
|
|
85933
|
+
}
|
|
85934
|
+
}
|
|
85935
|
+
return void 0;
|
|
85936
|
+
}
|
|
85937
|
+
function headerColumns(rows, spec) {
|
|
85938
|
+
var _a, _b;
|
|
85939
|
+
const labels = Object.entries(spec.labels).filter(([, pattern]) => Boolean(pattern));
|
|
85940
|
+
for (const row of rows) {
|
|
85941
|
+
const cells = headerCells(row);
|
|
85942
|
+
const found = /* @__PURE__ */ new Map();
|
|
85943
|
+
for (const [key, pattern] of labels) {
|
|
85944
|
+
const span = findLabel(cells, pattern, (_a = spec.exclude) === null || _a === void 0 ? void 0 : _a[key]);
|
|
85945
|
+
if (span)
|
|
85946
|
+
found.set(key, span);
|
|
85947
|
+
}
|
|
85948
|
+
if (!HEADER_REQUIRED.every((key) => found.has(key)))
|
|
85949
|
+
continue;
|
|
85950
|
+
const ordered = [...found.entries()].sort((a, b) => a[1].x - b[1].x);
|
|
85951
|
+
let overlapped = false;
|
|
85952
|
+
for (let index = 1; index < ordered.length; index += 1) {
|
|
85953
|
+
const previous = ordered[index - 1];
|
|
85954
|
+
const current = ordered[index];
|
|
85955
|
+
if (previous && current && current[1].x < previous[1].x + previous[1].w - 1e-3) {
|
|
85956
|
+
overlapped = true;
|
|
85957
|
+
break;
|
|
85958
|
+
}
|
|
85959
|
+
}
|
|
85960
|
+
if (overlapped)
|
|
85961
|
+
continue;
|
|
85962
|
+
const insideSpan = (cell) => ordered.some(([, span]) => cell.x >= span.x - 0.01 && cell.x + cell.w <= span.x + span.w + 0.01);
|
|
85963
|
+
const segments = [];
|
|
85964
|
+
for (const [key, span] of ordered)
|
|
85965
|
+
segments.push({ key, x: span.x, w: span.w });
|
|
85966
|
+
for (const cell of cells)
|
|
85967
|
+
if (!insideSpan(cell))
|
|
85968
|
+
segments.push({ x: cell.x, w: cell.w });
|
|
85969
|
+
segments.sort((a, b) => a.x - b.x);
|
|
85970
|
+
const boundaryBetween = (left, right) => {
|
|
85971
|
+
if (left.key === "num")
|
|
85972
|
+
return left.x + left.w + 8;
|
|
85973
|
+
if (left.key === "name")
|
|
85974
|
+
return right.x - 2;
|
|
85975
|
+
return (left.x + left.w + right.x) / 2;
|
|
85976
|
+
};
|
|
85977
|
+
const columns = [];
|
|
85978
|
+
for (let index = 0; index < segments.length; index += 1) {
|
|
85979
|
+
const segment = segments[index];
|
|
85980
|
+
if (!(segment === null || segment === void 0 ? void 0 : segment.key))
|
|
85981
|
+
continue;
|
|
85982
|
+
const previous = segments[index - 1];
|
|
85983
|
+
const next = segments[index + 1];
|
|
85984
|
+
const from = previous ? boundaryBetween(previous, segment) : 0;
|
|
85985
|
+
const to = next ? boundaryBetween(segment, next) : (_b = spec.endX) !== null && _b !== void 0 ? _b : 620;
|
|
85986
|
+
if (to > from)
|
|
85987
|
+
columns.push({ key: segment.key, from: roundCoordinate(from), to: roundCoordinate(to) });
|
|
85988
|
+
}
|
|
85989
|
+
let columnsOverlap = false;
|
|
85990
|
+
for (let index = 1; index < columns.length; index += 1) {
|
|
85991
|
+
const previous = columns[index - 1];
|
|
85992
|
+
const current = columns[index];
|
|
85993
|
+
if (previous && current && current.from < previous.to - 1e-3) {
|
|
85994
|
+
columnsOverlap = true;
|
|
85995
|
+
break;
|
|
85996
|
+
}
|
|
85997
|
+
}
|
|
85998
|
+
if (columnsOverlap)
|
|
85999
|
+
continue;
|
|
86000
|
+
if (columns.length === ordered.length)
|
|
86001
|
+
return columns;
|
|
86002
|
+
}
|
|
86003
|
+
return void 0;
|
|
86004
|
+
}
|
|
86005
|
+
function resolveProfileColumns(rows, profile) {
|
|
86006
|
+
if (!profile.headerColumns)
|
|
86007
|
+
return profile;
|
|
86008
|
+
const columns = headerColumns(rows, profile.headerColumns);
|
|
86009
|
+
if (!columns)
|
|
86010
|
+
return profile;
|
|
86011
|
+
const resolved = { ...profile, columns };
|
|
86012
|
+
delete resolved.headerColumns;
|
|
86013
|
+
return resolved;
|
|
86014
|
+
}
|
|
86015
|
+
function isRepeatedLine(previous, line) {
|
|
86016
|
+
const nameMatches = !previous.name || !line.name || previous.name === line.name;
|
|
86017
|
+
return previous.num === line.num && nameMatches && previous.qty === line.qty && previous.price === line.price && previous.sum === line.sum;
|
|
86018
|
+
}
|
|
84972
86019
|
function isContinuation(prev, row) {
|
|
84973
86020
|
if (prev.page !== row.page)
|
|
84974
86021
|
return false;
|
|
@@ -84976,37 +86023,82 @@ function isContinuation(prev, row) {
|
|
|
84976
86023
|
return prev.y - row.y <= lineHeight * 2.5;
|
|
84977
86024
|
}
|
|
84978
86025
|
function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
84979
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
86026
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
84980
86027
|
const lines = [];
|
|
84981
86028
|
const warnings = [];
|
|
84982
86029
|
const unparsedRows = [];
|
|
86030
|
+
const headerExpected = Boolean(profile.headerColumns);
|
|
86031
|
+
profile = resolveProfileColumns(rows, profile);
|
|
86032
|
+
if (headerExpected && profile.headerColumns) {
|
|
86033
|
+
warnings.push(`\u0428\u0430\u043F\u043A\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430: \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044E\u0442\u0441\u044F \u0437\u0430\u043F\u0430\u0441\u043D\u044B\u0435 \u0433\u0440\u0430\u043D\u0438\u0446\u044B \u043F\u0440\u043E\u0444\u0438\u043B\u044F ${profile.layoutId}`);
|
|
86034
|
+
}
|
|
84983
86035
|
let current;
|
|
84984
86036
|
let currentRow;
|
|
86037
|
+
let pending = [];
|
|
86038
|
+
const flushPending = () => {
|
|
86039
|
+
var _a2, _b2;
|
|
86040
|
+
for (const entry of pending) {
|
|
86041
|
+
const name = (_a2 = entry.cells.name) === null || _a2 === void 0 ? void 0 : _a2.trim();
|
|
86042
|
+
const code = (_b2 = entry.cells.code) === null || _b2 === void 0 ? void 0 : _b2.trim();
|
|
86043
|
+
if (current && currentRow && name && isContinuation(currentRow, entry.row)) {
|
|
86044
|
+
current.name = `${current.name} ${name}`.replace(/\s+/g, " ").trim();
|
|
86045
|
+
if (code)
|
|
86046
|
+
current.code += code;
|
|
86047
|
+
currentRow = entry.row;
|
|
86048
|
+
continue;
|
|
86049
|
+
}
|
|
86050
|
+
unparsedRows.push(rowText(entry.row));
|
|
86051
|
+
}
|
|
86052
|
+
pending = [];
|
|
86053
|
+
};
|
|
84985
86054
|
for (const row of rows) {
|
|
84986
86055
|
const text = rowText(row);
|
|
84987
86056
|
if (!text)
|
|
84988
86057
|
continue;
|
|
84989
86058
|
if (profile.stopPattern.test(text)) {
|
|
86059
|
+
flushPending();
|
|
84990
86060
|
current = void 0;
|
|
84991
86061
|
continue;
|
|
84992
86062
|
}
|
|
84993
86063
|
const cells = rowCells(row, profile);
|
|
84994
86064
|
if (profile.qtyUnitInOneColumn && cells.qty) {
|
|
84995
|
-
const match = /^([\d\s.,]
|
|
86065
|
+
const match = /^([\d\s.,]+)\s*([^\d\s].*)$/.exec(cells.qty.trim());
|
|
84996
86066
|
if ((match === null || match === void 0 ? void 0 : match[1]) && match[2]) {
|
|
84997
86067
|
cells.qty = match[1].replace(/\s+/g, "");
|
|
84998
86068
|
cells.unit = match[2].trim();
|
|
84999
86069
|
}
|
|
85000
86070
|
}
|
|
85001
86071
|
const { num, code } = cells;
|
|
85002
|
-
|
|
86072
|
+
const priceValue = number(cells.price);
|
|
86073
|
+
const hasQuantity = number(cells.qty) > 0;
|
|
86074
|
+
const serviceLike = priceValue > 0 && Math.abs(priceValue - number(cells.sum)) < 5e-3;
|
|
86075
|
+
const codePattern = profile.rowPattern.code;
|
|
86076
|
+
const pendingCode = profile.descriptionAbove ? pending.find((entry) => {
|
|
86077
|
+
var _a2, _b2, _c2;
|
|
86078
|
+
return entry.row.page === row.page && entry.row.y - row.y <= 20 && Boolean((_a2 = entry.cells.code) === null || _a2 === void 0 ? void 0 : _a2.trim()) && (!codePattern || codePattern.test((_c2 = (_b2 = entry.cells.code) === null || _b2 === void 0 ? void 0 : _b2.trim()) !== null && _c2 !== void 0 ? _c2 : ""));
|
|
86079
|
+
}) : void 0;
|
|
86080
|
+
const isItem = Boolean(num) && Number.parseInt(num !== null && num !== void 0 ? num : "", 10) > 0 && profile.rowPattern.num.test(num !== null && num !== void 0 ? num : "") && (!codePattern || Boolean(code) && codePattern.test(code !== null && code !== void 0 ? code : "") || pendingCode !== void 0) && (Boolean(codePattern) || Boolean((_a = cells.name) === null || _a === void 0 ? void 0 : _a.trim()) || hasQuantity) && (Boolean(codePattern) || hasQuantity || serviceLike);
|
|
86081
|
+
if (isItem) {
|
|
86082
|
+
if (profile.descriptionAbove && pending.length) {
|
|
86083
|
+
const near = pending.filter((entry) => entry.row.page === row.page && entry.row.y - row.y <= 20);
|
|
86084
|
+
for (const entry of [...near].reverse()) {
|
|
86085
|
+
const name = (_b = entry.cells.name) === null || _b === void 0 ? void 0 : _b.trim();
|
|
86086
|
+
const aboveCode = (_c = entry.cells.code) === null || _c === void 0 ? void 0 : _c.trim();
|
|
86087
|
+
if (name)
|
|
86088
|
+
cells.name = `${name} ${(_d = cells.name) !== null && _d !== void 0 ? _d : ""}`.replace(/\s+/g, " ").trim();
|
|
86089
|
+
if (aboveCode && !cells.code)
|
|
86090
|
+
cells.code = aboveCode;
|
|
86091
|
+
}
|
|
86092
|
+
pending = pending.filter((entry) => !near.includes(entry));
|
|
86093
|
+
flushPending();
|
|
86094
|
+
}
|
|
85003
86095
|
const line = {
|
|
85004
|
-
num: Number.parseInt(num, 10),
|
|
85005
|
-
code,
|
|
85006
|
-
name: (
|
|
85007
|
-
article: (profile.articleFromCode ? (
|
|
85008
|
-
productType: ((
|
|
85009
|
-
unit: (
|
|
86096
|
+
num: Number.parseInt(num !== null && num !== void 0 ? num : "", 10),
|
|
86097
|
+
code: (_e = cells.code) !== null && _e !== void 0 ? _e : "",
|
|
86098
|
+
name: (_f = cells.name) !== null && _f !== void 0 ? _f : "",
|
|
86099
|
+
article: (profile.articleFromCode ? (_g = cells.code) !== null && _g !== void 0 ? _g : "" : (_h = cells.art) !== null && _h !== void 0 ? _h : "").replace(/^(?:[\d\s]+)$/, (value) => value.replace(/\s+/g, "")),
|
|
86100
|
+
productType: ((_j = cells.type) !== null && _j !== void 0 ? _j : "").trim(),
|
|
86101
|
+
unit: (_k = cells.unit) !== null && _k !== void 0 ? _k : "",
|
|
85010
86102
|
vat: number(cells.vat),
|
|
85011
86103
|
qty: number(cells.qty),
|
|
85012
86104
|
price: number(cells.price),
|
|
@@ -85014,11 +86106,21 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85014
86106
|
total: number(cells.total),
|
|
85015
86107
|
raw: cells
|
|
85016
86108
|
};
|
|
86109
|
+
const previous = lines[lines.length - 1];
|
|
86110
|
+
if (previous && isRepeatedLine(previous, line)) {
|
|
86111
|
+
current = previous;
|
|
86112
|
+
currentRow = row;
|
|
86113
|
+
continue;
|
|
86114
|
+
}
|
|
85017
86115
|
lines.push(line);
|
|
85018
86116
|
current = line;
|
|
85019
86117
|
currentRow = row;
|
|
85020
86118
|
continue;
|
|
85021
86119
|
}
|
|
86120
|
+
if (profile.descriptionAbove && !num) {
|
|
86121
|
+
pending.push({ row, cells });
|
|
86122
|
+
continue;
|
|
86123
|
+
}
|
|
85022
86124
|
if (current && currentRow && cells.name && !num && isContinuation(currentRow, row)) {
|
|
85023
86125
|
const prevName = current.name.trimEnd();
|
|
85024
86126
|
const nextName = cells.name.trimStart();
|
|
@@ -85029,68 +86131,98 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85029
86131
|
}
|
|
85030
86132
|
unparsedRows.push(text);
|
|
85031
86133
|
}
|
|
85032
|
-
|
|
86134
|
+
flushPending();
|
|
86135
|
+
if (profile.articleFromCode) {
|
|
85033
86136
|
for (const line of lines) {
|
|
85034
|
-
|
|
85035
|
-
const gross = line.sum;
|
|
85036
|
-
line.total = gross;
|
|
85037
|
-
line.sum = Math.round(gross * 1e4 / (100 + rate)) / 100;
|
|
85038
|
-
}
|
|
85039
|
-
}
|
|
85040
|
-
for (const line of lines) {
|
|
85041
|
-
const calc = line.qty * line.price;
|
|
85042
|
-
const expected = profile.pricesIncludeVat ? line.total : line.sum;
|
|
85043
|
-
if (line.qty && line.price && Math.abs(calc - expected) > Math.max(0.05, expected * 2e-3)) {
|
|
85044
|
-
warnings.push(`\u0421\u0442\u0440\u043E\u043A\u0430 ${line.num} (${line.code}): ${line.qty} \xD7 ${line.price} = ${calc.toFixed(2)}, \u0432 \u0441\u0447\u0451\u0442\u0435 ${line.sum.toFixed(2)}`);
|
|
86137
|
+
line.article = line.code.replace(/^(?:[\d\s]+)$/, (value) => value.replace(/\s+/g, ""));
|
|
85045
86138
|
}
|
|
85046
86139
|
}
|
|
85047
|
-
|
|
85048
|
-
qty: acc.qty + line.qty,
|
|
85049
|
-
sum: acc.sum + line.sum,
|
|
85050
|
-
vat: acc.vat + Math.max(0, line.total - line.sum),
|
|
85051
|
-
total: acc.total + line.total
|
|
85052
|
-
}), { qty: 0, sum: 0, vat: 0, total: 0 });
|
|
86140
|
+
const documented = {};
|
|
85053
86141
|
if (profile.totalsRow) {
|
|
85054
86142
|
for (const row of rows) {
|
|
85055
86143
|
const text = rowText(row);
|
|
85056
86144
|
if (!profile.totalsRow.test(text))
|
|
85057
86145
|
continue;
|
|
85058
|
-
const numbers = (
|
|
86146
|
+
const numbers = (_l = text.match(/[\d\s]+[.,]\d{2}/g)) !== null && _l !== void 0 ? _l : [];
|
|
85059
86147
|
const first = numbers[0];
|
|
85060
86148
|
const last = numbers[numbers.length - 1];
|
|
85061
86149
|
if (first && last) {
|
|
85062
|
-
|
|
85063
|
-
|
|
85064
|
-
|
|
85065
|
-
totals = { qty: totals.qty, sum: net, vat: Math.round((gross - net) * 100) / 100, total: gross };
|
|
85066
|
-
if (Math.abs(totals.sum - lines.reduce((acc, line) => acc + line.sum, 0)) > 0.05) {
|
|
85067
|
-
warnings.push(`\u0421\u0443\u043C\u043C\u0430 \u043F\u043E\u0437\u0438\u0446\u0438\u0439 ${lines.reduce((acc, line) => acc + line.sum, 0).toFixed(2)} \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0438\u0442\u043E\u0433\u043E\u043C \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430 ${net.toFixed(2)}`);
|
|
85068
|
-
}
|
|
85069
|
-
}
|
|
86150
|
+
documented.sum = number(first);
|
|
86151
|
+
documented.total = number(last);
|
|
86152
|
+
documented.vat = Math.round((documented.total - documented.sum) * 100) / 100;
|
|
85070
86153
|
}
|
|
85071
86154
|
break;
|
|
85072
86155
|
}
|
|
85073
86156
|
}
|
|
85074
86157
|
if (profile.totalsPatterns) {
|
|
85075
|
-
const found = {};
|
|
85076
86158
|
for (const row of rows) {
|
|
85077
86159
|
const text = rowText(row);
|
|
85078
86160
|
for (const key of ["sum", "vat", "total"]) {
|
|
85079
86161
|
const pattern = profile.totalsPatterns[key];
|
|
85080
|
-
if (
|
|
86162
|
+
if (!pattern || documented[key] !== void 0 || !pattern.test(text))
|
|
85081
86163
|
continue;
|
|
85082
|
-
const
|
|
85083
|
-
if (
|
|
85084
|
-
|
|
86164
|
+
const value = valueAfterLabel(text, pattern);
|
|
86165
|
+
if (value !== void 0)
|
|
86166
|
+
documented[key] = value;
|
|
85085
86167
|
}
|
|
85086
86168
|
}
|
|
85087
|
-
|
|
85088
|
-
|
|
85089
|
-
|
|
85090
|
-
|
|
85091
|
-
total
|
|
85092
|
-
}
|
|
86169
|
+
if (documented.sum === void 0 && documented.total !== void 0 && documented.vat !== void 0) {
|
|
86170
|
+
documented.sum = Math.round((documented.total - documented.vat) * 100) / 100;
|
|
86171
|
+
}
|
|
86172
|
+
if (documented.total === void 0 && documented.sum !== void 0 && documented.vat !== void 0) {
|
|
86173
|
+
documented.total = Math.round((documented.sum + documented.vat) * 100) / 100;
|
|
86174
|
+
}
|
|
86175
|
+
}
|
|
86176
|
+
let documentedDiscount = 0;
|
|
86177
|
+
if (profile.discountPattern) {
|
|
86178
|
+
for (const row of rows) {
|
|
86179
|
+
const text = rowText(row);
|
|
86180
|
+
if (!profile.discountPattern.test(text))
|
|
86181
|
+
continue;
|
|
86182
|
+
const value = valueAfterLabel(text, profile.discountPattern);
|
|
86183
|
+
if (value === void 0)
|
|
86184
|
+
continue;
|
|
86185
|
+
documentedDiscount = documented.total && documented.sum ? value * documented.sum / documented.total : value;
|
|
86186
|
+
break;
|
|
86187
|
+
}
|
|
85093
86188
|
}
|
|
86189
|
+
const noVatPrinted = rows.some((row) => /без\s+налога/iu.test(rowText(row)));
|
|
86190
|
+
if (profile.pricesIncludeVat) {
|
|
86191
|
+
const rate = vatRateFor(profile, documented, noVatPrinted);
|
|
86192
|
+
for (const line of lines) {
|
|
86193
|
+
const lineRate = line.vat > 0 ? line.vat : rate;
|
|
86194
|
+
const gross = line.sum;
|
|
86195
|
+
line.total = gross;
|
|
86196
|
+
line.sum = Math.round(gross * 1e4 / (100 + lineRate)) / 100;
|
|
86197
|
+
}
|
|
86198
|
+
}
|
|
86199
|
+
for (const line of lines) {
|
|
86200
|
+
const calc = line.qty * line.price;
|
|
86201
|
+
const expected = line.total > 0 && line.total !== line.sum ? [line.total, line.sum] : [line.sum];
|
|
86202
|
+
if (line.qty && line.price && !expected.some((value) => Math.abs(calc - value) <= Math.max(0.05, value * 2e-3))) {
|
|
86203
|
+
warnings.push(`\u0421\u0442\u0440\u043E\u043A\u0430 ${line.num} (${line.code}): ${line.qty} \xD7 ${line.price} = ${calc.toFixed(2)}, \u0432 \u0441\u0447\u0451\u0442\u0435 ${line.sum.toFixed(2)}`);
|
|
86204
|
+
}
|
|
86205
|
+
}
|
|
86206
|
+
const summed = lines.reduce((acc, line) => ({
|
|
86207
|
+
qty: acc.qty + line.qty,
|
|
86208
|
+
sum: acc.sum + line.sum,
|
|
86209
|
+
vat: acc.vat + Math.max(0, line.total - line.sum),
|
|
86210
|
+
total: acc.total + line.total
|
|
86211
|
+
}), { qty: 0, sum: 0, vat: 0, total: 0 });
|
|
86212
|
+
if (summed.total === 0 && summed.sum > 0)
|
|
86213
|
+
summed.total = summed.sum;
|
|
86214
|
+
const positionsSum = Math.round(summed.sum * 100) / 100;
|
|
86215
|
+
const sumTolerance = Math.max(0.05, lines.length * 0.02);
|
|
86216
|
+
const positionsGap = documented.sum === void 0 ? 0 : Math.abs(documented.sum - positionsSum);
|
|
86217
|
+
if (lines.length > 0 && documented.sum !== void 0 && positionsGap > sumTolerance && Math.abs(positionsGap - documentedDiscount) > sumTolerance) {
|
|
86218
|
+
warnings.push(`\u0421\u0443\u043C\u043C\u0430 \u043F\u043E\u0437\u0438\u0446\u0438\u0439 ${positionsSum.toFixed(2)} \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0438\u0442\u043E\u0433\u043E\u043C \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430 ${documented.sum.toFixed(2)}`);
|
|
86219
|
+
}
|
|
86220
|
+
const totals = {
|
|
86221
|
+
qty: summed.qty,
|
|
86222
|
+
sum: (_m = documented.sum) !== null && _m !== void 0 ? _m : summed.sum,
|
|
86223
|
+
vat: (_o = documented.vat) !== null && _o !== void 0 ? _o : summed.vat,
|
|
86224
|
+
total: (_p = documented.total) !== null && _p !== void 0 ? _p : summed.total
|
|
86225
|
+
};
|
|
85094
86226
|
if (!isUniversal && layoutScoreValue < 0.85) {
|
|
85095
86227
|
warnings.push(`\u041C\u0430\u043A\u0435\u0442 \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u043B \u0441 \u043F\u0440\u043E\u0444\u0438\u043B\u0435\u043C ${profile.layoutId}: \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435 ${(layoutScoreValue * 100).toFixed(1)}%, \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0432\u0451\u0440\u0441\u0442\u043A\u0443 \u0441\u0447\u0451\u0442\u0430`);
|
|
85096
86228
|
}
|
|
@@ -85107,33 +86239,66 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85107
86239
|
unparsedRows
|
|
85108
86240
|
};
|
|
85109
86241
|
}
|
|
85110
|
-
|
|
86242
|
+
function valueAfterLabel(text, pattern) {
|
|
86243
|
+
const label = pattern.exec(text);
|
|
86244
|
+
const rest = label ? text.slice(label.index + label[0].length) : text;
|
|
86245
|
+
const match = /([\d\s]*\d[\d\s]*[.,]\d{2})/.exec(rest);
|
|
86246
|
+
return match ? number(match[1]) : void 0;
|
|
86247
|
+
}
|
|
86248
|
+
var KNOWN_VAT_RATES = [0, 5, 7, 10, 20, 22];
|
|
86249
|
+
function vatRateFor(profile, documented, noVatPrinted) {
|
|
85111
86250
|
var _a;
|
|
85112
|
-
|
|
85113
|
-
const
|
|
85114
|
-
|
|
85115
|
-
|
|
86251
|
+
const fallback = (_a = profile.vatRate) !== null && _a !== void 0 ? _a : 22;
|
|
86252
|
+
const net = documented.sum;
|
|
86253
|
+
const vat = documented.vat;
|
|
86254
|
+
if (noVatPrinted)
|
|
86255
|
+
return 0;
|
|
86256
|
+
if (!net || net <= 0 || !vat || vat <= 0)
|
|
86257
|
+
return fallback;
|
|
86258
|
+
const raw = vat / net * 100;
|
|
86259
|
+
const nearest = KNOWN_VAT_RATES.reduce((best, rate) => Math.abs(rate - raw) < Math.abs(best - raw) ? rate : best);
|
|
86260
|
+
return Math.abs(nearest - raw) <= 1.5 ? nearest : Math.round(raw);
|
|
86261
|
+
}
|
|
86262
|
+
async function parseInvoicePdf(data, profileId = "auto", yTolerance = 2) {
|
|
86263
|
+
var _a, _b, _c, _d;
|
|
86264
|
+
const cache = /* @__PURE__ */ new Map();
|
|
86265
|
+
const load = async (tolerance) => {
|
|
86266
|
+
const cached = cache.get(tolerance);
|
|
86267
|
+
if (cached)
|
|
86268
|
+
return cached;
|
|
86269
|
+
const extracted = await readTextItems(data, tolerance);
|
|
86270
|
+
cache.set(tolerance, extracted);
|
|
86271
|
+
return extracted;
|
|
86272
|
+
};
|
|
86273
|
+
const { text } = await load(yTolerance);
|
|
85116
86274
|
let profile;
|
|
85117
86275
|
if (profileId === "auto") {
|
|
85118
86276
|
const candidates = detectCandidates(text);
|
|
85119
|
-
let
|
|
85120
|
-
profile = profiles_1.UNIVERSAL;
|
|
86277
|
+
let best;
|
|
85121
86278
|
for (const candidate of candidates) {
|
|
85122
|
-
const
|
|
85123
|
-
|
|
85124
|
-
|
|
85125
|
-
|
|
86279
|
+
const { rows: rows2 } = await load((_a = candidate.yTolerance) !== null && _a !== void 0 ? _a : yTolerance);
|
|
86280
|
+
const resolved2 = resolveProfileColumns(rows2, candidate);
|
|
86281
|
+
const score2 = layoutScore(rows2, resolved2);
|
|
86282
|
+
const parsed = parseRows(rows2, resolved2, score2);
|
|
86283
|
+
const consistent = parsed.lines.filter((line) => {
|
|
86284
|
+
const expected = candidate.pricesIncludeVat ? line.total : line.sum;
|
|
86285
|
+
return line.qty > 0 && line.price > 0 && Math.abs(line.qty * line.price - expected) <= Math.max(0.05, expected * 2e-3);
|
|
86286
|
+
}).length;
|
|
86287
|
+
const bogus = parsed.lines.length - consistent;
|
|
86288
|
+
const complete = parsed.lines.filter((line) => line.qty > 0 && line.price > 0 && line.sum > 0).length;
|
|
86289
|
+
const better = !best || consistent > best.consistent || consistent === best.consistent && complete > best.complete || consistent === best.consistent && complete === best.complete && bogus < best.bogus;
|
|
86290
|
+
if (better) {
|
|
86291
|
+
best = { profile: candidate, consistent, bogus, score: score2, complete };
|
|
85126
86292
|
}
|
|
85127
86293
|
}
|
|
86294
|
+
profile = (_b = best === null || best === void 0 ? void 0 : best.profile) !== null && _b !== void 0 ? _b : profiles_1.UNIVERSAL;
|
|
85128
86295
|
} else {
|
|
85129
|
-
profile = (
|
|
85130
|
-
}
|
|
85131
|
-
if (profile.yTolerance && profile.yTolerance !== tolerance) {
|
|
85132
|
-
tolerance = profile.yTolerance;
|
|
85133
|
-
({ pages, rows } = await readTextItems(data, tolerance));
|
|
86296
|
+
profile = (_c = profiles_1.PROFILES.find((p) => p.id === profileId)) !== null && _c !== void 0 ? _c : profiles_1.UNIVERSAL;
|
|
85134
86297
|
}
|
|
85135
|
-
const
|
|
85136
|
-
const
|
|
86298
|
+
const { rows, pages } = await load((_d = profile.yTolerance) !== null && _d !== void 0 ? _d : yTolerance);
|
|
86299
|
+
const resolved = resolveProfileColumns(rows, profile);
|
|
86300
|
+
const score = profile === profiles_1.UNIVERSAL ? 0 : layoutScore(rows, resolved);
|
|
86301
|
+
const result = parseRows(rows, resolved, profile === profiles_1.UNIVERSAL ? 1 : score, profile === profiles_1.UNIVERSAL);
|
|
85137
86302
|
result.pages = pages;
|
|
85138
86303
|
return { ...result, text };
|
|
85139
86304
|
}
|