@catalogicus-international/n8n-nodes-invoice-parser 0.2.0 → 0.2.1
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 +48 -23
- package/dist/nodes/InvoicePdfParser/parse.js +1060 -69
- package/dist/nodes/InvoicePdfParser/parse.js.map +1 -1
- package/dist/nodes/InvoicePdfParser/profiles.d.ts +19 -5
- package/dist/nodes/InvoicePdfParser/profiles.js +865 -3
- package/dist/nodes/InvoicePdfParser/profiles.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -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.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,869 @@ 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);
|
|
78
940
|
}
|
|
79
941
|
});
|
|
80
942
|
|
|
@@ -84819,6 +85681,16 @@ var number = (raw) => {
|
|
|
84819
85681
|
const value = Number.parseFloat(cleaned);
|
|
84820
85682
|
return Number.isFinite(value) ? value : 0;
|
|
84821
85683
|
};
|
|
85684
|
+
var NUMERIC_COLUMNS = /* @__PURE__ */ new Set([
|
|
85685
|
+
"qty",
|
|
85686
|
+
"price",
|
|
85687
|
+
"price2",
|
|
85688
|
+
"sum",
|
|
85689
|
+
"total",
|
|
85690
|
+
"vat",
|
|
85691
|
+
"vatsum"
|
|
85692
|
+
]);
|
|
85693
|
+
var TEXT_COLUMNS = /* @__PURE__ */ new Set(["num", "code", "name", "art", "type"]);
|
|
84822
85694
|
function buildRows(items, yTolerance = 2, page = 1) {
|
|
84823
85695
|
const sorted = [...items].sort((a, b) => b.y - a.y || a.x - b.x);
|
|
84824
85696
|
const rows = [];
|
|
@@ -84848,7 +85720,6 @@ function rowText(row, gap = 1) {
|
|
|
84848
85720
|
return out.replace(/\s+/g, " ").trim();
|
|
84849
85721
|
}
|
|
84850
85722
|
function rowCells(row, profile, gap = 1) {
|
|
84851
|
-
var _a;
|
|
84852
85723
|
const cells = {};
|
|
84853
85724
|
const cellEnd = {};
|
|
84854
85725
|
const pendingSpace = {};
|
|
@@ -84862,12 +85733,17 @@ function rowCells(row, profile, gap = 1) {
|
|
|
84862
85733
|
prevY = item.y;
|
|
84863
85734
|
const width = item.w || item.str.length * 3.2;
|
|
84864
85735
|
const charWidth = width / Math.max(item.str.length, 1);
|
|
85736
|
+
const startColumn = profile.columns.find((column) => item.x + charWidth / 2 >= column.from && item.x + charWidth / 2 < column.to);
|
|
85737
|
+
const startsInText = startColumn !== void 0 && TEXT_COLUMNS.has(startColumn.key);
|
|
84865
85738
|
for (let i = 0; i < item.str.length; i++) {
|
|
84866
85739
|
const char = item.str.charAt(i);
|
|
84867
85740
|
const start = item.x + i * charWidth;
|
|
84868
85741
|
const center = start + charWidth / 2;
|
|
84869
|
-
const
|
|
84870
|
-
if (!
|
|
85742
|
+
const column = profile.columns.find((c) => center >= c.from && center < c.to);
|
|
85743
|
+
if (!column)
|
|
85744
|
+
continue;
|
|
85745
|
+
const key = column.key;
|
|
85746
|
+
if (startsInText && NUMERIC_COLUMNS.has(key))
|
|
84871
85747
|
continue;
|
|
84872
85748
|
if (!char.trim()) {
|
|
84873
85749
|
pendingSpace[key] = true;
|
|
@@ -84969,6 +85845,10 @@ function detectProfile(text) {
|
|
|
84969
85845
|
function detectCandidates(text) {
|
|
84970
85846
|
return profiles_1.PROFILES.filter((profile) => profile.detect.some((re) => re.test(text)));
|
|
84971
85847
|
}
|
|
85848
|
+
function isRepeatedLine(previous, line) {
|
|
85849
|
+
const nameMatches = !previous.name || !line.name || previous.name === line.name;
|
|
85850
|
+
return previous.num === line.num && nameMatches && previous.qty === line.qty && previous.price === line.price && previous.sum === line.sum;
|
|
85851
|
+
}
|
|
84972
85852
|
function isContinuation(prev, row) {
|
|
84973
85853
|
if (prev.page !== row.page)
|
|
84974
85854
|
return false;
|
|
@@ -84976,37 +85856,77 @@ function isContinuation(prev, row) {
|
|
|
84976
85856
|
return prev.y - row.y <= lineHeight * 2.5;
|
|
84977
85857
|
}
|
|
84978
85858
|
function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
84979
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85859
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
84980
85860
|
const lines = [];
|
|
84981
85861
|
const warnings = [];
|
|
84982
85862
|
const unparsedRows = [];
|
|
84983
85863
|
let current;
|
|
84984
85864
|
let currentRow;
|
|
85865
|
+
let pending = [];
|
|
85866
|
+
const flushPending = () => {
|
|
85867
|
+
var _a2, _b2;
|
|
85868
|
+
for (const entry of pending) {
|
|
85869
|
+
const name = (_a2 = entry.cells.name) === null || _a2 === void 0 ? void 0 : _a2.trim();
|
|
85870
|
+
const code = (_b2 = entry.cells.code) === null || _b2 === void 0 ? void 0 : _b2.trim();
|
|
85871
|
+
if (current && currentRow && name && isContinuation(currentRow, entry.row)) {
|
|
85872
|
+
current.name = `${current.name} ${name}`.replace(/\s+/g, " ").trim();
|
|
85873
|
+
if (code)
|
|
85874
|
+
current.code += code;
|
|
85875
|
+
currentRow = entry.row;
|
|
85876
|
+
continue;
|
|
85877
|
+
}
|
|
85878
|
+
unparsedRows.push(rowText(entry.row));
|
|
85879
|
+
}
|
|
85880
|
+
pending = [];
|
|
85881
|
+
};
|
|
84985
85882
|
for (const row of rows) {
|
|
84986
85883
|
const text = rowText(row);
|
|
84987
85884
|
if (!text)
|
|
84988
85885
|
continue;
|
|
84989
85886
|
if (profile.stopPattern.test(text)) {
|
|
85887
|
+
flushPending();
|
|
84990
85888
|
current = void 0;
|
|
84991
85889
|
continue;
|
|
84992
85890
|
}
|
|
84993
85891
|
const cells = rowCells(row, profile);
|
|
84994
85892
|
if (profile.qtyUnitInOneColumn && cells.qty) {
|
|
84995
|
-
const match = /^([\d\s.,]
|
|
85893
|
+
const match = /^([\d\s.,]+)\s*([^\d\s].*)$/.exec(cells.qty.trim());
|
|
84996
85894
|
if ((match === null || match === void 0 ? void 0 : match[1]) && match[2]) {
|
|
84997
85895
|
cells.qty = match[1].replace(/\s+/g, "");
|
|
84998
85896
|
cells.unit = match[2].trim();
|
|
84999
85897
|
}
|
|
85000
85898
|
}
|
|
85001
85899
|
const { num, code } = cells;
|
|
85002
|
-
|
|
85900
|
+
const priceValue = number(cells.price);
|
|
85901
|
+
const hasQuantity = number(cells.qty) > 0;
|
|
85902
|
+
const serviceLike = priceValue > 0 && Math.abs(priceValue - number(cells.sum)) < 5e-3;
|
|
85903
|
+
const codePattern = profile.rowPattern.code;
|
|
85904
|
+
const pendingCode = profile.descriptionAbove ? pending.find((entry) => {
|
|
85905
|
+
var _a2, _b2, _c2;
|
|
85906
|
+
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 : ""));
|
|
85907
|
+
}) : void 0;
|
|
85908
|
+
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);
|
|
85909
|
+
if (isItem) {
|
|
85910
|
+
if (profile.descriptionAbove && pending.length) {
|
|
85911
|
+
const near = pending.filter((entry) => entry.row.page === row.page && entry.row.y - row.y <= 20);
|
|
85912
|
+
for (const entry of [...near].reverse()) {
|
|
85913
|
+
const name = (_b = entry.cells.name) === null || _b === void 0 ? void 0 : _b.trim();
|
|
85914
|
+
const aboveCode = (_c = entry.cells.code) === null || _c === void 0 ? void 0 : _c.trim();
|
|
85915
|
+
if (name)
|
|
85916
|
+
cells.name = `${name} ${(_d = cells.name) !== null && _d !== void 0 ? _d : ""}`.replace(/\s+/g, " ").trim();
|
|
85917
|
+
if (aboveCode && !cells.code)
|
|
85918
|
+
cells.code = aboveCode;
|
|
85919
|
+
}
|
|
85920
|
+
pending = pending.filter((entry) => !near.includes(entry));
|
|
85921
|
+
flushPending();
|
|
85922
|
+
}
|
|
85003
85923
|
const line = {
|
|
85004
|
-
num: Number.parseInt(num, 10),
|
|
85005
|
-
code,
|
|
85006
|
-
name: (
|
|
85007
|
-
article: (profile.articleFromCode ? (
|
|
85008
|
-
productType: ((
|
|
85009
|
-
unit: (
|
|
85924
|
+
num: Number.parseInt(num !== null && num !== void 0 ? num : "", 10),
|
|
85925
|
+
code: (_e = cells.code) !== null && _e !== void 0 ? _e : "",
|
|
85926
|
+
name: (_f = cells.name) !== null && _f !== void 0 ? _f : "",
|
|
85927
|
+
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, "")),
|
|
85928
|
+
productType: ((_j = cells.type) !== null && _j !== void 0 ? _j : "").trim(),
|
|
85929
|
+
unit: (_k = cells.unit) !== null && _k !== void 0 ? _k : "",
|
|
85010
85930
|
vat: number(cells.vat),
|
|
85011
85931
|
qty: number(cells.qty),
|
|
85012
85932
|
price: number(cells.price),
|
|
@@ -85014,11 +85934,21 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85014
85934
|
total: number(cells.total),
|
|
85015
85935
|
raw: cells
|
|
85016
85936
|
};
|
|
85937
|
+
const previous = lines[lines.length - 1];
|
|
85938
|
+
if (previous && isRepeatedLine(previous, line)) {
|
|
85939
|
+
current = previous;
|
|
85940
|
+
currentRow = row;
|
|
85941
|
+
continue;
|
|
85942
|
+
}
|
|
85017
85943
|
lines.push(line);
|
|
85018
85944
|
current = line;
|
|
85019
85945
|
currentRow = row;
|
|
85020
85946
|
continue;
|
|
85021
85947
|
}
|
|
85948
|
+
if (profile.descriptionAbove && !num) {
|
|
85949
|
+
pending.push({ row, cells });
|
|
85950
|
+
continue;
|
|
85951
|
+
}
|
|
85022
85952
|
if (current && currentRow && cells.name && !num && isContinuation(currentRow, row)) {
|
|
85023
85953
|
const prevName = current.name.trimEnd();
|
|
85024
85954
|
const nextName = cells.name.trimStart();
|
|
@@ -85029,68 +85959,98 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85029
85959
|
}
|
|
85030
85960
|
unparsedRows.push(text);
|
|
85031
85961
|
}
|
|
85032
|
-
|
|
85962
|
+
flushPending();
|
|
85963
|
+
if (profile.articleFromCode) {
|
|
85033
85964
|
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;
|
|
85965
|
+
line.article = line.code.replace(/^(?:[\d\s]+)$/, (value) => value.replace(/\s+/g, ""));
|
|
85038
85966
|
}
|
|
85039
85967
|
}
|
|
85040
|
-
|
|
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)}`);
|
|
85045
|
-
}
|
|
85046
|
-
}
|
|
85047
|
-
let totals = lines.reduce((acc, line) => ({
|
|
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 });
|
|
85968
|
+
const documented = {};
|
|
85053
85969
|
if (profile.totalsRow) {
|
|
85054
85970
|
for (const row of rows) {
|
|
85055
85971
|
const text = rowText(row);
|
|
85056
85972
|
if (!profile.totalsRow.test(text))
|
|
85057
85973
|
continue;
|
|
85058
|
-
const numbers = (
|
|
85974
|
+
const numbers = (_l = text.match(/[\d\s]+[.,]\d{2}/g)) !== null && _l !== void 0 ? _l : [];
|
|
85059
85975
|
const first = numbers[0];
|
|
85060
85976
|
const last = numbers[numbers.length - 1];
|
|
85061
85977
|
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
|
-
}
|
|
85978
|
+
documented.sum = number(first);
|
|
85979
|
+
documented.total = number(last);
|
|
85980
|
+
documented.vat = Math.round((documented.total - documented.sum) * 100) / 100;
|
|
85070
85981
|
}
|
|
85071
85982
|
break;
|
|
85072
85983
|
}
|
|
85073
85984
|
}
|
|
85074
85985
|
if (profile.totalsPatterns) {
|
|
85075
|
-
const found = {};
|
|
85076
85986
|
for (const row of rows) {
|
|
85077
85987
|
const text = rowText(row);
|
|
85078
85988
|
for (const key of ["sum", "vat", "total"]) {
|
|
85079
85989
|
const pattern = profile.totalsPatterns[key];
|
|
85080
|
-
if (
|
|
85990
|
+
if (!pattern || documented[key] !== void 0 || !pattern.test(text))
|
|
85081
85991
|
continue;
|
|
85082
|
-
const
|
|
85083
|
-
if (
|
|
85084
|
-
|
|
85992
|
+
const value = valueAfterLabel(text, pattern);
|
|
85993
|
+
if (value !== void 0)
|
|
85994
|
+
documented[key] = value;
|
|
85085
85995
|
}
|
|
85086
85996
|
}
|
|
85087
|
-
|
|
85088
|
-
|
|
85089
|
-
|
|
85090
|
-
|
|
85091
|
-
total
|
|
85092
|
-
}
|
|
85997
|
+
if (documented.sum === void 0 && documented.total !== void 0 && documented.vat !== void 0) {
|
|
85998
|
+
documented.sum = Math.round((documented.total - documented.vat) * 100) / 100;
|
|
85999
|
+
}
|
|
86000
|
+
if (documented.total === void 0 && documented.sum !== void 0 && documented.vat !== void 0) {
|
|
86001
|
+
documented.total = Math.round((documented.sum + documented.vat) * 100) / 100;
|
|
86002
|
+
}
|
|
86003
|
+
}
|
|
86004
|
+
let documentedDiscount = 0;
|
|
86005
|
+
if (profile.discountPattern) {
|
|
86006
|
+
for (const row of rows) {
|
|
86007
|
+
const text = rowText(row);
|
|
86008
|
+
if (!profile.discountPattern.test(text))
|
|
86009
|
+
continue;
|
|
86010
|
+
const value = valueAfterLabel(text, profile.discountPattern);
|
|
86011
|
+
if (value === void 0)
|
|
86012
|
+
continue;
|
|
86013
|
+
documentedDiscount = documented.total && documented.sum ? value * documented.sum / documented.total : value;
|
|
86014
|
+
break;
|
|
86015
|
+
}
|
|
85093
86016
|
}
|
|
86017
|
+
const noVatPrinted = rows.some((row) => /без\s+налога/iu.test(rowText(row)));
|
|
86018
|
+
if (profile.pricesIncludeVat) {
|
|
86019
|
+
const rate = vatRateFor(profile, documented, noVatPrinted);
|
|
86020
|
+
for (const line of lines) {
|
|
86021
|
+
const lineRate = line.vat > 0 ? line.vat : rate;
|
|
86022
|
+
const gross = line.sum;
|
|
86023
|
+
line.total = gross;
|
|
86024
|
+
line.sum = Math.round(gross * 1e4 / (100 + lineRate)) / 100;
|
|
86025
|
+
}
|
|
86026
|
+
}
|
|
86027
|
+
for (const line of lines) {
|
|
86028
|
+
const calc = line.qty * line.price;
|
|
86029
|
+
const expected = line.total > 0 && line.total !== line.sum ? [line.total, line.sum] : [line.sum];
|
|
86030
|
+
if (line.qty && line.price && !expected.some((value) => Math.abs(calc - value) <= Math.max(0.05, value * 2e-3))) {
|
|
86031
|
+
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)}`);
|
|
86032
|
+
}
|
|
86033
|
+
}
|
|
86034
|
+
const summed = lines.reduce((acc, line) => ({
|
|
86035
|
+
qty: acc.qty + line.qty,
|
|
86036
|
+
sum: acc.sum + line.sum,
|
|
86037
|
+
vat: acc.vat + Math.max(0, line.total - line.sum),
|
|
86038
|
+
total: acc.total + line.total
|
|
86039
|
+
}), { qty: 0, sum: 0, vat: 0, total: 0 });
|
|
86040
|
+
if (summed.total === 0 && summed.sum > 0)
|
|
86041
|
+
summed.total = summed.sum;
|
|
86042
|
+
const positionsSum = Math.round(summed.sum * 100) / 100;
|
|
86043
|
+
const sumTolerance = Math.max(0.05, lines.length * 0.02);
|
|
86044
|
+
const positionsGap = documented.sum === void 0 ? 0 : Math.abs(documented.sum - positionsSum);
|
|
86045
|
+
if (lines.length > 0 && documented.sum !== void 0 && positionsGap > sumTolerance && Math.abs(positionsGap - documentedDiscount) > sumTolerance) {
|
|
86046
|
+
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)}`);
|
|
86047
|
+
}
|
|
86048
|
+
const totals = {
|
|
86049
|
+
qty: summed.qty,
|
|
86050
|
+
sum: (_m = documented.sum) !== null && _m !== void 0 ? _m : summed.sum,
|
|
86051
|
+
vat: (_o = documented.vat) !== null && _o !== void 0 ? _o : summed.vat,
|
|
86052
|
+
total: (_p = documented.total) !== null && _p !== void 0 ? _p : summed.total
|
|
86053
|
+
};
|
|
85094
86054
|
if (!isUniversal && layoutScoreValue < 0.85) {
|
|
85095
86055
|
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
86056
|
}
|
|
@@ -85107,31 +86067,62 @@ function parseRows(rows, profile, layoutScoreValue = 1, isUniversal = false) {
|
|
|
85107
86067
|
unparsedRows
|
|
85108
86068
|
};
|
|
85109
86069
|
}
|
|
85110
|
-
|
|
86070
|
+
function valueAfterLabel(text, pattern) {
|
|
86071
|
+
const label = pattern.exec(text);
|
|
86072
|
+
const rest = label ? text.slice(label.index + label[0].length) : text;
|
|
86073
|
+
const match = /([\d\s]*\d[\d\s]*[.,]\d{2})/.exec(rest);
|
|
86074
|
+
return match ? number(match[1]) : void 0;
|
|
86075
|
+
}
|
|
86076
|
+
var KNOWN_VAT_RATES = [0, 5, 7, 10, 20, 22];
|
|
86077
|
+
function vatRateFor(profile, documented, noVatPrinted) {
|
|
85111
86078
|
var _a;
|
|
85112
|
-
|
|
85113
|
-
const
|
|
85114
|
-
|
|
85115
|
-
|
|
86079
|
+
const fallback = (_a = profile.vatRate) !== null && _a !== void 0 ? _a : 22;
|
|
86080
|
+
const net = documented.sum;
|
|
86081
|
+
const vat = documented.vat;
|
|
86082
|
+
if (noVatPrinted)
|
|
86083
|
+
return 0;
|
|
86084
|
+
if (!net || net <= 0 || !vat || vat <= 0)
|
|
86085
|
+
return fallback;
|
|
86086
|
+
const raw = vat / net * 100;
|
|
86087
|
+
const nearest = KNOWN_VAT_RATES.reduce((best, rate) => Math.abs(rate - raw) < Math.abs(best - raw) ? rate : best);
|
|
86088
|
+
return Math.abs(nearest - raw) <= 1.5 ? nearest : Math.round(raw);
|
|
86089
|
+
}
|
|
86090
|
+
async function parseInvoicePdf(data, profileId = "auto", yTolerance = 2) {
|
|
86091
|
+
var _a, _b, _c, _d;
|
|
86092
|
+
const cache = /* @__PURE__ */ new Map();
|
|
86093
|
+
const load = async (tolerance) => {
|
|
86094
|
+
const cached = cache.get(tolerance);
|
|
86095
|
+
if (cached)
|
|
86096
|
+
return cached;
|
|
86097
|
+
const extracted = await readTextItems(data, tolerance);
|
|
86098
|
+
cache.set(tolerance, extracted);
|
|
86099
|
+
return extracted;
|
|
86100
|
+
};
|
|
86101
|
+
const { text } = await load(yTolerance);
|
|
85116
86102
|
let profile;
|
|
85117
86103
|
if (profileId === "auto") {
|
|
85118
86104
|
const candidates = detectCandidates(text);
|
|
85119
|
-
let
|
|
85120
|
-
profile = profiles_1.UNIVERSAL;
|
|
86105
|
+
let best;
|
|
85121
86106
|
for (const candidate of candidates) {
|
|
85122
|
-
const
|
|
85123
|
-
|
|
85124
|
-
|
|
85125
|
-
|
|
86107
|
+
const { rows: rows2 } = await load((_a = candidate.yTolerance) !== null && _a !== void 0 ? _a : yTolerance);
|
|
86108
|
+
const score2 = layoutScore(rows2, candidate);
|
|
86109
|
+
const parsed = parseRows(rows2, candidate, score2);
|
|
86110
|
+
const consistent = parsed.lines.filter((line) => {
|
|
86111
|
+
const expected = candidate.pricesIncludeVat ? line.total : line.sum;
|
|
86112
|
+
return line.qty > 0 && line.price > 0 && Math.abs(line.qty * line.price - expected) <= Math.max(0.05, expected * 2e-3);
|
|
86113
|
+
}).length;
|
|
86114
|
+
const bogus = parsed.lines.length - consistent;
|
|
86115
|
+
const complete = parsed.lines.filter((line) => line.qty > 0 && line.price > 0 && line.sum > 0).length;
|
|
86116
|
+
const better = !best || consistent > best.consistent || consistent === best.consistent && complete > best.complete || consistent === best.consistent && complete === best.complete && bogus < best.bogus;
|
|
86117
|
+
if (better) {
|
|
86118
|
+
best = { profile: candidate, consistent, bogus, score: score2, complete };
|
|
85126
86119
|
}
|
|
85127
86120
|
}
|
|
86121
|
+
profile = (_b = best === null || best === void 0 ? void 0 : best.profile) !== null && _b !== void 0 ? _b : profiles_1.UNIVERSAL;
|
|
85128
86122
|
} else {
|
|
85129
|
-
profile = (
|
|
85130
|
-
}
|
|
85131
|
-
if (profile.yTolerance && profile.yTolerance !== tolerance) {
|
|
85132
|
-
tolerance = profile.yTolerance;
|
|
85133
|
-
({ pages, rows } = await readTextItems(data, tolerance));
|
|
86123
|
+
profile = (_c = profiles_1.PROFILES.find((p) => p.id === profileId)) !== null && _c !== void 0 ? _c : profiles_1.UNIVERSAL;
|
|
85134
86124
|
}
|
|
86125
|
+
const { rows, pages } = await load((_d = profile.yTolerance) !== null && _d !== void 0 ? _d : yTolerance);
|
|
85135
86126
|
const score = profile === profiles_1.UNIVERSAL ? 0 : layoutScore(rows, profile);
|
|
85136
86127
|
const result = parseRows(rows, profile, profile === profiles_1.UNIVERSAL ? 1 : score, profile === profiles_1.UNIVERSAL);
|
|
85137
86128
|
result.pages = pages;
|