hl-core 0.0.8 → 0.0.9-beta.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.
Files changed (63) hide show
  1. package/api/index.ts +142 -101
  2. package/api/interceptors.ts +17 -13
  3. package/components/Button/Btn.vue +1 -1
  4. package/components/Button/ScrollButtons.vue +2 -2
  5. package/components/Complex/MessageBlock.vue +26 -0
  6. package/components/Complex/Page.vue +1 -1
  7. package/components/Dialog/Dialog.vue +9 -39
  8. package/components/Dialog/FamilyDialog.vue +7 -4
  9. package/components/Form/FormBlock.vue +90 -42
  10. package/components/Form/FormSection.vue +4 -1
  11. package/components/Form/FormToggle.vue +1 -2
  12. package/components/Form/ManagerAttachment.vue +197 -0
  13. package/components/Form/ProductConditionsBlock.vue +68 -14
  14. package/components/Input/Datepicker.vue +45 -0
  15. package/components/Input/FileInput.vue +2 -3
  16. package/components/Input/FormInput.vue +31 -7
  17. package/components/Input/PanelInput.vue +7 -2
  18. package/components/Input/RoundedInput.vue +2 -2
  19. package/components/Input/RoundedSelect.vue +137 -0
  20. package/components/Layout/Drawer.vue +4 -2
  21. package/components/Layout/Header.vue +40 -4
  22. package/components/Layout/Loader.vue +1 -1
  23. package/components/Layout/SettingsPanel.vue +51 -13
  24. package/components/Menu/MenuHover.vue +30 -0
  25. package/components/Menu/MenuNav.vue +29 -13
  26. package/components/Menu/MenuNavItem.vue +6 -3
  27. package/components/Pages/Anketa.vue +59 -33
  28. package/components/Pages/Auth.vue +139 -46
  29. package/components/Pages/Documents.vue +7 -7
  30. package/components/Pages/InvoiceInfo.vue +30 -0
  31. package/components/Pages/MemberForm.vue +544 -293
  32. package/components/Pages/ProductAgreement.vue +4 -2
  33. package/components/Pages/ProductConditions.vue +673 -75
  34. package/components/Panel/PanelHandler.vue +304 -0
  35. package/components/Panel/PanelSelectItem.vue +1 -1
  36. package/components/Transitions/SlideTransition.vue +5 -0
  37. package/components/Utilities/Chip.vue +27 -0
  38. package/components/Utilities/JsonViewer.vue +27 -0
  39. package/composables/axios.ts +1 -1
  40. package/composables/classes.ts +223 -101
  41. package/composables/constants.ts +26 -51
  42. package/composables/index.ts +80 -2
  43. package/composables/styles.ts +15 -3
  44. package/configs/i18n.ts +17 -0
  45. package/layouts/default.vue +6 -6
  46. package/locales/kz.json +585 -0
  47. package/locales/ru.json +587 -0
  48. package/nuxt.config.ts +13 -1
  49. package/package.json +43 -11
  50. package/pages/500.vue +2 -2
  51. package/pages/Token.vue +51 -0
  52. package/plugins/helperFunctionsPlugins.ts +6 -0
  53. package/plugins/storePlugin.ts +0 -1
  54. package/plugins/vuetifyPlugin.ts +8 -1
  55. package/store/data.store.ts +2649 -0
  56. package/store/form.store.ts +1 -1
  57. package/store/member.store.ts +164 -52
  58. package/store/{rules.js → rules.ts} +65 -34
  59. package/types/enum.ts +83 -0
  60. package/types/env.d.ts +10 -0
  61. package/types/index.ts +262 -5
  62. package/store/data.store.js +0 -2482
  63. package/store/messages.ts +0 -429
@@ -1,2482 +0,0 @@
1
- import { defineStore } from 'pinia';
2
- import { t } from './messages';
3
- import { rules } from './rules';
4
- import { Toast, Types, Positions, ToastOptions } from './toast';
5
- import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate } from '../composables';
6
- import { DataStoreClass, Contragent } from '../composables/classes';
7
- import { ApiClass } from '@/api';
8
- import { useFormStore } from './form.store';
9
-
10
- export const useDataStore = defineStore('data', {
11
- state: () => ({
12
- ...new DataStoreClass(),
13
- t: t,
14
- rules: rules,
15
- toast: Toast,
16
- toastTypes: Types,
17
- toastPositions: Positions,
18
- isValidGUID: isValidGUID,
19
- router: useRouter(),
20
- formStore: useFormStore(),
21
- contragent: useContragentStore(),
22
- api: new ApiClass(),
23
- yearEnding: year => yearEnding(year, constants.yearTitles, constants.yearCases),
24
- currentDate: () => new Date(Date.now() - new Date().getTimezoneOffset() * 60 * 1000).toISOString().slice(0, -1),
25
- showToaster: (type, msg, timeout) =>
26
- Toast.useToast()(msg, {
27
- ...ToastOptions,
28
- type: Types[type.toUpperCase()],
29
- timeout: type === 'error' ? 6000 : typeof timeout === 'number' ? timeout : ToastOptions.timeout,
30
- }),
31
- }),
32
- getters: {
33
- isEFO: state => state.product === 'efo',
34
- isBaiterek: state => state.product === 'baiterek',
35
- isBolashak: state => state.product === 'bolashak',
36
- isMycar: state => state.product === 'mycar',
37
- isLifetrip: state => state.product === 'lifetrip',
38
- isLiferenta: state => state.product === 'liferenta',
39
- isPension: state => state.product === 'pension',
40
- isGons: state => state.product === 'gons',
41
- isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
42
- },
43
- actions: {
44
- isIframe() {
45
- try {
46
- return window.self !== window.top;
47
- } catch (err) {
48
- return true;
49
- }
50
- },
51
- sendToParent(action, value) {
52
- window.parent.postMessage({ action: action, value: value }, '*');
53
- },
54
- getChildIframe() {
55
- return document.getElementById('product-iframe');
56
- },
57
- sendToChild(action, value) {
58
- const childFrame = this.getChildIframe();
59
- if (childFrame && childFrame.contentWindow && childFrame.contentWindow.postMessage) {
60
- childFrame.contentWindow.postMessage({ action: action, value: value }, '*');
61
- }
62
- },
63
- getFilesByIIN(iin) {
64
- return iin ? this.formStore.signedDocumentList.filter(file => file.iin === iin && file.fileTypeName === 'Удостоверение личности') : null;
65
- },
66
- async getNewAccessToken() {
67
- try {
68
- const data = {
69
- accessToken: localStorage.getItem('accessToken'),
70
- refreshToken: localStorage.getItem('refreshToken'),
71
- };
72
- const response = await this.api.getNewAccessToken(data);
73
- this.accessToken = response.accessToken;
74
- this.refreshToken = response.refreshToken;
75
- localStorage.setItem('accessToken', this.accessToken);
76
- localStorage.setItem('refreshToken', this.refreshToken);
77
- } catch (err) {
78
- console.error(err);
79
- }
80
- },
81
- async getDictionaryItems(dictName) {
82
- try {
83
- this.isLoading = true;
84
- if (!this[`${dictName}List`].length) {
85
- this[`${dictName}List`] = await this.api.getDictionaryItems(dictName);
86
- }
87
- } catch (err) {
88
- console.log(err);
89
- } finally {
90
- this.isLoading = false;
91
- }
92
- },
93
- async loginUser(login, password, numAttempt) {
94
- try {
95
- const token = localStorage.getItem('accessToken') || null;
96
- if (token && isValidToken(token)) {
97
- this.accessToken = token;
98
- this.getUserRoles();
99
- } else {
100
- const response = await this.api.loginUser({
101
- login: login,
102
- password: password,
103
- numAttempt: numAttempt,
104
- });
105
-
106
- this.accessToken = response.accessToken;
107
- this.refreshToken = response.refreshToken;
108
- this.getUserRoles();
109
- }
110
- if (this.controls.onAuth) {
111
- const hasPermission =
112
- this.isInitiator() ||
113
- this.isUnderwriter() ||
114
- this.isAdmin() ||
115
- this.isCompliance() ||
116
- this.isAnalyst() ||
117
- this.isUpk() ||
118
- this.isFinanceCenter() ||
119
- this.isSupervisor() ||
120
- this.isSupport();
121
- if (hasPermission) {
122
- localStorage.setItem('accessToken', this.accessToken);
123
- localStorage.setItem('refreshToken', this.refreshToken);
124
- } else {
125
- this.showToaster('error', this.t('toaster.noProductPermission'), 5000);
126
- this.accessToken = null;
127
- this.refreshToken = null;
128
- }
129
- } else {
130
- localStorage.setItem('accessToken', this.accessToken);
131
- localStorage.setItem('refreshToken', this.refreshToken);
132
- }
133
- } catch (err) {
134
- ErrorHandler(err);
135
- }
136
- },
137
- getUserRoles() {
138
- if (this.accessToken && this.user.roles.length === 0) {
139
- const decoded = jwtDecode(this.accessToken);
140
- this.user.id = decoded.sub;
141
- this.user.fullName = `${decoded.lastName} ${decoded.firstName} ${decoded.middleName ? decoded.middleName : ''}`;
142
- const key = getKeyWithPattern(decoded, 'role');
143
- if (key) {
144
- const roles = decoded[key];
145
- if (typeof roles === constants.types.string) {
146
- this.user.roles.push(roles);
147
- } else if (typeof roles === constants.types.array) {
148
- this.user.roles = roles;
149
- }
150
- }
151
- }
152
- },
153
- isRole(whichRole) {
154
- if (this.user.roles.length === 0) {
155
- this.getUserRoles();
156
- }
157
- const isRole = this.user.roles.find(i => i === whichRole);
158
- return !!isRole;
159
- },
160
- isInitiator() {
161
- return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager();
162
- },
163
- isManager() {
164
- return this.isRole(constants.roles.manager);
165
- },
166
- isCompliance() {
167
- return this.isRole(constants.roles.compliance);
168
- },
169
- isAdmin() {
170
- return this.isRole(constants.roles.admin);
171
- },
172
- isAgent() {
173
- return this.isRole(constants.roles.agent);
174
- },
175
- isManagerHalykBank() {
176
- return this.isRole(constants.roles.managerHalykBank);
177
- },
178
- isServiceManager() {
179
- return this.isRole(constants.roles.serviceManager);
180
- },
181
- isUnderwriter() {
182
- return this.isRole(constants.roles.underwriter);
183
- },
184
- isAgentMycar() {
185
- return this.isRole(constants.roles.agentMycar);
186
- },
187
- isAnalyst() {
188
- return this.isRole(constants.roles.analyst);
189
- },
190
- isUpk() {
191
- return this.isRole(constants.roles.upk);
192
- },
193
- isSupport() {
194
- return this.isRole(constants.roles.support);
195
- },
196
- isFinanceCenter() {
197
- return this.isRole(constants.roles.financeCenter);
198
- },
199
- isSupervisor() {
200
- return this.isRole(constants.roles.supervisor);
201
- },
202
- isProcessEditable(statusCode) {
203
- return !!constants.editableStatuses.find(status => status === statusCode);
204
- },
205
- isTask() {
206
- return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
207
- },
208
- async resetSelected(route) {
209
- this.settings.open = false;
210
- this.panel.open = false;
211
- this.panelAction = null;
212
- this.menu.selectedItem = new MenuItem();
213
- if (route && route.name) {
214
- await this.router.replace({ name: route.name });
215
- }
216
- },
217
- async logoutUser() {
218
- this.isLoading = true;
219
- try {
220
- const whichProduct = this.product;
221
- const token = localStorage.getItem('accessToken') || null;
222
- if (token) {
223
- this.$reset();
224
- localStorage.clear();
225
-
226
- if (whichProduct === 'efo') {
227
- await this.router.push({ name: 'Auth' });
228
- } else {
229
- this.sendToParent(constants.postActions.toAuth, null);
230
- }
231
- } else {
232
- this.showToaster('error', this.t('toaster.undefinedError'), 3000);
233
- }
234
- } catch (err) {
235
- console.log(err);
236
- }
237
- this.isLoading = false;
238
- },
239
- async getFile(file, mode = 'view', fileType = 'pdf') {
240
- try {
241
- this.isLoading = true;
242
- await this.api.getFile(file.id).then(response => {
243
- if (!['pdf', 'docx'].includes(fileType)) {
244
- const blob = new Blob([response], { type: `image/${fileType}` });
245
- const url = window.URL.createObjectURL(blob);
246
- const link = document.createElement('a');
247
- link.href = url;
248
- if (mode === 'view') {
249
- setTimeout(() => {
250
- window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
251
- });
252
- } else {
253
- link.setAttribute('download', file.fileName);
254
- document.body.appendChild(link);
255
- link.click();
256
- }
257
- } else {
258
- const blob = new Blob([response], {
259
- type: `application/${fileType}`,
260
- });
261
- const url = window.URL.createObjectURL(blob);
262
- const link = document.createElement('a');
263
- link.href = url;
264
- if (mode === 'view') {
265
- setTimeout(() => {
266
- window.open(url, '_blank', `right=100`);
267
- });
268
- } else {
269
- link.setAttribute('download', file.fileName);
270
- document.body.appendChild(link);
271
- link.click();
272
- }
273
- }
274
- });
275
- } catch (err) {
276
- ErrorHandler(err);
277
- } finally {
278
- this.isLoading = false;
279
- }
280
- },
281
- async deleteFile(data) {
282
- try {
283
- await this.api.deleteFile(data);
284
- this.showToaster('success', this.t('toaster.fileWasDeleted'), 3000);
285
- } catch (err) {
286
- this.showToaster('error', err.response.data, 2000);
287
- }
288
- },
289
- async uploadFiles(data, load = false) {
290
- try {
291
- if (load) {
292
- this.isLoading = true;
293
- }
294
- await this.api.uploadFiles(data);
295
- return true;
296
- } catch (err) {
297
- return ErrorHandler(err);
298
- } finally {
299
- if (load) {
300
- this.isLoading = false;
301
- }
302
- }
303
- },
304
- async getContragent(member, whichForm, whichIndex, load = true) {
305
- if (load) {
306
- this.isLoading = true;
307
- }
308
- try {
309
- let response;
310
- let queryData = {
311
- firstName: '',
312
- lastName: '',
313
- middleName: '',
314
- };
315
- queryData.iin = member.iin.replace(/-/g, '');
316
- response = await this.api.getContragent(queryData);
317
- if (response.totalItems > 0) {
318
- if (response.totalItems.length === 1) {
319
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
320
- } else {
321
- const sortedByRegistrationDate = response.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
322
- await this.serializeContragentData(whichForm, sortedByRegistrationDate[0], whichIndex);
323
- }
324
- member.gotFromInsis = true;
325
- } else {
326
- this.userNotFound = true;
327
- }
328
- } catch (err) {
329
- console.log(err);
330
- }
331
- if (load) {
332
- this.isLoading = false;
333
- }
334
- },
335
- async getContragentById(id, whichForm, onlyGet = true, whichIndex = null) {
336
- if (onlyGet) {
337
- this.isLoading = true;
338
- }
339
- try {
340
- if (this.isMycar && this.isAgentMycar() && whichForm === this.formStore.beneficiaryFormKey) {
341
- await this.serializeContragentData(whichForm, this.formStore.applicationData.beneficiaryApp[0], whichIndex);
342
- this.isLoading = false;
343
- return;
344
- }
345
- const response = await this.api.getContragentById(id);
346
- if (response.totalItems > 0) {
347
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
348
- } else {
349
- this.isLoading = false;
350
- return false;
351
- }
352
- } catch (err) {
353
- console.log(err);
354
- }
355
- if (onlyGet) {
356
- this.isLoading = false;
357
- }
358
- },
359
- async serializeContragentData(whichForm, contragent, whichIndex = null) {
360
- const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
361
- this.api.getContrAgentData(contragent.id),
362
- this.api.getContrAgentContacts(contragent.id),
363
- this.api.getContrAgentDocuments(contragent.id),
364
- this.api.getContrAgentAddress(contragent.id),
365
- ]);
366
- if (whichIndex === null) {
367
- this.formStore[whichForm].response = {
368
- contragent: contragent,
369
- };
370
- if (data && data.length) {
371
- this.formStore[whichForm].response.questionnaires = data;
372
- }
373
- if (contacts && contacts.length) {
374
- this.formStore[whichForm].response.contacts = contacts;
375
- }
376
- if (documents && documents.length) {
377
- this.formStore[whichForm].response.documents = documents;
378
- }
379
- if (address && address.length) {
380
- this.formStore[whichForm].response.addresses = address;
381
- }
382
- }
383
- if (whichIndex !== null) {
384
- this.formStore[whichForm][whichIndex].response = {
385
- contragent: contragent,
386
- };
387
- if (data && data.length) {
388
- this.formStore[whichForm][whichIndex].response.questionnaires = data;
389
- }
390
- if (contacts && contacts.length) {
391
- this.formStore[whichForm][whichIndex].response.contacts = contacts;
392
- }
393
- if (documents && documents.length) {
394
- this.formStore[whichForm][whichIndex].response.documents = documents;
395
- }
396
- if (address && address.length) {
397
- this.formStore[whichForm][whichIndex].response.addresses = address;
398
- }
399
- }
400
- this.parseContragent(
401
- whichForm,
402
- {
403
- personalData: contragent,
404
- documents: documents,
405
- contacts: contacts,
406
- data: data,
407
- address: address,
408
- },
409
- whichIndex,
410
- );
411
- },
412
- async searchContragent(iin) {
413
- this.isLoading = true;
414
- try {
415
- let queryData = {
416
- iin: iin.replace(/-/g, ''),
417
- firstName: '',
418
- lastName: '',
419
- middleName: '',
420
- };
421
- const response = await this.api.getContragent(queryData);
422
- if (response.totalItems > 0) {
423
- this.contragentList = response.items;
424
- } else {
425
- this.contragentList = [];
426
- }
427
- } catch (err) {
428
- console.log(err);
429
- this.contragentList = [];
430
- }
431
- this.isLoading = false;
432
- },
433
- parseContragent(whichForm, user, whichIndex = null) {
434
- if (whichIndex === null) {
435
- // Save User Personal Data
436
- this.formStore[whichForm].verifyType = user.personalData.verifyType;
437
- this.formStore[whichForm].verifyDate = user.personalData.verifyDate;
438
- this.formStore[whichForm].iin = reformatIin(user.personalData.iin);
439
- this.formStore[whichForm].age = user.personalData.age;
440
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
441
- this.formStore[whichForm].birthPlace = country && Object.keys(country).length ? country : new Value();
442
- this.formStore[whichForm].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
443
- this.formStore[whichForm].gender.id = user.personalData.gender;
444
- this.formStore[whichForm].birthDate = reformatDate(user.personalData.birthDate);
445
- this.formStore[whichForm].genderName = user.personalData.genderName;
446
- this.formStore[whichForm].lastName = user.personalData.lastName;
447
- this.formStore[whichForm].longName = user.personalData.longName;
448
- this.formStore[whichForm].middleName = user.personalData.middleName ? user.personalData.middleName : '';
449
- this.formStore[whichForm].firstName = user.personalData.firstName;
450
- this.formStore[whichForm].id = user.personalData.id;
451
- this.formStore[whichForm].type = user.personalData.type;
452
- this.formStore[whichForm].registrationDate = user.personalData.registrationDate;
453
- // Save User Documents Data
454
- if ('documents' in user && user.documents.length) {
455
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
456
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
457
- this.formStore[whichForm].documentType = documentType ? documentType : new Value();
458
- this.formStore[whichForm].documentNumber = user.documents[0].number;
459
- this.formStore[whichForm].documentIssuers = documentIssuer ? documentIssuer : new Value();
460
- this.formStore[whichForm].documentDate = reformatDate(user.documents[0].issueDate);
461
- this.formStore[whichForm].documentExpire = reformatDate(user.documents[0].expireDate);
462
- }
463
- // Document detail (residency, economy code, etc..)
464
- if ('data' in user && user.data.length) {
465
- user.data.forEach(dataObject => {
466
- this.searchFromList(whichForm, dataObject);
467
- });
468
- }
469
- if ('address' in user && user.address.length) {
470
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
471
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
472
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
473
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
474
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
475
- this.formStore[whichForm].registrationCountry = country ? country : new Value();
476
- this.formStore[whichForm].registrationStreet = user.address[0].streetName;
477
- this.formStore[whichForm].registrationCity = city ? city : new Value();
478
- this.formStore[whichForm].registrationNumberApartment = user.address[0].apartmentNumber;
479
- this.formStore[whichForm].registrationNumberHouse = user.address[0].blockNumber;
480
- this.formStore[whichForm].registrationProvince = province ? province : new Value();
481
- this.formStore[whichForm].registrationRegionType = localityType ? localityType : new Value();
482
- this.formStore[whichForm].registrationRegion = region ? region : new Value();
483
- this.formStore[whichForm].registrationQuarter = user.address[0].kvartal;
484
- this.formStore[whichForm].registrationMicroDistrict = user.address[0].microRaion;
485
- }
486
- if ('contacts' in user && user.contacts.length) {
487
- user.contacts.forEach(contact => {
488
- if (contact.type === 'EMAIL' && contact.value) {
489
- this.formStore[whichForm].email = contact.value;
490
- }
491
- if (contact.type === 'MOBILE' && contact.value) {
492
- let phoneNumber = contact.value.substring(1);
493
- this.formStore[whichForm].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
494
- }
495
- if (contact.type === 'HOME' && contact.value) {
496
- let homePhone = contact.value.substring(1);
497
- this.formStore[whichForm].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
498
- }
499
- });
500
- }
501
- }
502
- if (whichIndex !== null) {
503
- // Save User Personal Data
504
- this.formStore[whichForm][whichIndex].iin = reformatIin(user.personalData.iin);
505
- this.formStore[whichForm][whichIndex].verifyType = user.personalData.verifyType;
506
- this.formStore[whichForm][whichIndex].verifyDate = user.personalData.verifyDate;
507
- this.formStore[whichForm][whichIndex].age = user.personalData.age;
508
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
509
- this.formStore[whichForm][whichIndex].birthPlace = country && Object.keys(country).length ? country : new Value();
510
- this.formStore[whichForm][whichIndex].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
511
- this.formStore[whichForm][whichIndex].gender.id = user.personalData.gender;
512
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(user.personalData.birthDate);
513
- this.formStore[whichForm][whichIndex].genderName = user.personalData.genderName;
514
- this.formStore[whichForm][whichIndex].lastName = user.personalData.lastName;
515
- this.formStore[whichForm][whichIndex].longName = user.personalData.longName;
516
- this.formStore[whichForm][whichIndex].middleName = user.personalData.middleName ? user.personalData.middleName : '';
517
- this.formStore[whichForm][whichIndex].firstName = user.personalData.firstName;
518
- this.formStore[whichForm][whichIndex].id = user.personalData.id;
519
- this.formStore[whichForm][whichIndex].type = user.personalData.type;
520
- this.formStore[whichForm][whichIndex].registrationDate = user.personalData.registrationDate;
521
- // Save User Documents Data
522
- if ('documents' in user && user.documents.length) {
523
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
524
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
525
- this.formStore[whichForm][whichIndex].documentType = documentType ? documentType : new Value();
526
- this.formStore[whichForm][whichIndex].documentNumber = user.documents[0].number;
527
- this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer ? documentIssuer : new Value();
528
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(user.documents[0].issueDate);
529
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(user.documents[0].expireDate);
530
- }
531
- // Document detail (residency, economy code, etc..)
532
- if ('data' in user && user.data.length) {
533
- user.data.forEach(dataObject => {
534
- this.searchFromList(whichForm, dataObject, whichIndex);
535
- });
536
- }
537
- if ('address' in user && user.address.length) {
538
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
539
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
540
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
541
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
542
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
543
- this.formStore[whichForm][whichIndex].registrationCountry = country ? country : new Value();
544
- this.formStore[whichForm][whichIndex].registrationStreet = user.address[0].streetName;
545
- this.formStore[whichForm][whichIndex].registrationCity = city ? city : new Value();
546
- this.formStore[whichForm][whichIndex].registrationNumberApartment = user.address[0].apartmentNumber;
547
- this.formStore[whichForm][whichIndex].registrationNumberHouse = user.address[0].blockNumber;
548
- this.formStore[whichForm][whichIndex].registrationProvince = province ? province : new Value();
549
- this.formStore[whichForm][whichIndex].registrationRegionType = localityType ? localityType : new Value();
550
- this.formStore[whichForm][whichIndex].registrationRegion = region ? region : new Value();
551
- this.formStore[whichForm][whichIndex].registrationQuarter = user.address[0].kvartal;
552
- this.formStore[whichForm][whichIndex].registrationMicroDistrict = user.address[0].microRaion;
553
- }
554
- if ('contacts' in user && user.contacts.length) {
555
- user.contacts.forEach(contact => {
556
- if (contact.type === 'EMAIL' && contact.value) {
557
- this.formStore[whichForm][whichIndex].email = contact.value;
558
- }
559
- if (contact.type === 'MOBILE' && contact.value) {
560
- let phoneNumber = contact.value.substring(1);
561
- this.formStore[whichForm][whichIndex].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
562
- }
563
- if (contact.type === 'HOME' && contact.value) {
564
- let homePhone = contact.value.substring(1);
565
- this.formStore[whichForm][whichIndex].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
566
- }
567
- });
568
- }
569
- }
570
- },
571
- async alreadyInInsis(iin, firstName, lastName, middleName) {
572
- try {
573
- const queryData = {
574
- iin: iin.replaceAll('-', ''),
575
- firstName: !!firstName ? firstName : '',
576
- lastName: !!lastName ? lastName : '',
577
- middleName: !!middleName ? middleName : '',
578
- };
579
- const contragent = await this.api.getContragent(queryData);
580
- if (contragent.totalItems > 0) {
581
- if (contragent.totalItems.length === 1) {
582
- return contragent.items[0].id;
583
- } else {
584
- const sortedByRegistrationDate = contragent.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
585
- return sortedByRegistrationDate[0].id;
586
- }
587
- } else {
588
- return false;
589
- }
590
- } catch (err) {
591
- console.log(err);
592
- return false;
593
- }
594
- },
595
- async saveContragent(user, whichForm, whichIndex, onlySaveAction = true) {
596
- this.isLoading = !onlySaveAction;
597
- const hasInsisId = await this.alreadyInInsis(user.iin, user.firstName, user.lastName, user.middleName);
598
- if (hasInsisId !== false) {
599
- user.id = hasInsisId;
600
- const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
601
- this.api.getContrAgentData(user.id),
602
- this.api.getContrAgentContacts(user.id),
603
- this.api.getContrAgentDocuments(user.id),
604
- this.api.getContrAgentAddress(user.id),
605
- ]);
606
- user.response = {};
607
- if (data && data.length) {
608
- user.response.questionnaires = data;
609
- }
610
- if (contacts && contacts.length) {
611
- user.response.contacts = contacts;
612
- }
613
- if (documents && documents.length) {
614
- user.response.documents = documents;
615
- }
616
- if (address && address.length) {
617
- user.response.addresses = address;
618
- }
619
- }
620
- try {
621
- // ! SaveContragent -> Contragent
622
- let contragentData = {
623
- id: user.id,
624
- type: user.type,
625
- iin: user.iin.replace(/-/g, ''),
626
- longName: user.longName !== null ? user.longName : user.lastName + user.firstName + user.middleName ? user.middleName : '',
627
- lastName: user.lastName,
628
- firstName: user.firstName,
629
- middleName: user.middleName ? user.middleName : '',
630
- birthDate: user.getDateByKey('birthDate'),
631
- gender: user.gender.id,
632
- genderName: user.genderName ? user.genderName : user.gender.nameRu,
633
- birthPlace: user.birthPlace.nameRu,
634
- age: user.age,
635
- registrationDate: user.registrationDate,
636
- verifyType: user.verifyType,
637
- verifyDate: user.verifyDate,
638
- };
639
- // ! SaveContragent -> Questionnaires
640
- let questionnaires = (({ economySectorCode, countryOfCitizenship, countryOfTaxResidency, signOfResidency }) => ({
641
- economySectorCode,
642
- countryOfCitizenship,
643
- countryOfTaxResidency,
644
- signOfResidency,
645
- }))(user);
646
- let questionariesData = Object.values(questionnaires).map(question => {
647
- let questName = '';
648
- let questionId = parseInt(question.ids).toString();
649
- if (questionId === '500003') {
650
- questName = 'Код сектора экономики';
651
- } else if (questionId === '500011') {
652
- questName = 'Признак резидентства';
653
- } else if (questionId === '500012') {
654
- questName = 'Страна гражданства';
655
- } else if (questionId === '500014') {
656
- questName = 'Страна налогового резиденства';
657
- }
658
- return {
659
- id: 'response' in user && 'questionnaires' in user.response ? user.response.questionnaires?.find(i => i.questId == questionId).id : question.id,
660
- contragentId: user.id,
661
- questAnswer: question.ids,
662
- questId: questionId,
663
- questAnswerName: question.nameRu,
664
- questName: questName,
665
- };
666
- });
667
- if (user.countryOfTaxResidency.ids !== '500014.3') {
668
- user.addTaxResidency = new Value();
669
- }
670
- const addTaxResidency = 'response' in user && 'questionnaires' in user.response && user.response.questionnaires.find(i => i.questId === '507777');
671
- if (user.addTaxResidency.nameRu !== null) {
672
- questionariesData.push({
673
- id: addTaxResidency ? addTaxResidency.id : 0,
674
- contragentId: user.id,
675
- questAnswer: user.addTaxResidency.ids,
676
- questAnswerName: user.addTaxResidency.nameRu,
677
- questName: 'Указать если налоговое резиденство выбрано другое',
678
- questId: '507777',
679
- });
680
- } else {
681
- if (addTaxResidency && addTaxResidency.questAnswer !== null) {
682
- questionariesData.push({
683
- id: addTaxResidency.id,
684
- contragentId: user.id,
685
- questAnswer: null,
686
- questAnswerName: null,
687
- questName: 'Указать если налоговое резиденство выбрано другое',
688
- questId: '507777',
689
- });
690
- }
691
- }
692
-
693
- // ! SaveContragent -> Contacts
694
- let contactsData = [];
695
- if (user.phoneNumber !== '' && user.phoneNumber !== null) {
696
- contactsData.push({
697
- contragentId: user.id,
698
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').id : 0,
699
- newValue: '',
700
- note: '',
701
- primaryFlag: 'Y',
702
- type: 'MOBILE',
703
- typeName: 'Сотовый телефон',
704
- value: formatPhone(user.phoneNumber),
705
- verifyType: user.otpTokenId ? 'BMG' : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType : null,
706
- verifyDate: user.otpTokenId
707
- ? this.currentDate()
708
- : 'response' in user && 'contacts' in user.response
709
- ? user.response.contacts.find(i => i.type === 'MOBILE').verifyDate
710
- : null,
711
- });
712
- }
713
- if (user.email !== '' && user.email !== null) {
714
- contactsData.push({
715
- contragentId: user.id,
716
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').id : 0,
717
- newValue: '',
718
- note: '',
719
- primaryFlag: 'N',
720
- type: 'EMAIL',
721
- typeName: 'E-Mail',
722
- value: user.email ? user.email : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').value : '',
723
- });
724
- }
725
- if (user.homePhone !== '' && user.homePhone !== null) {
726
- contactsData.push({
727
- contragentId: user.id,
728
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'HOME').id : 0,
729
- newValue: '',
730
- note: '',
731
- primaryFlag: 'N',
732
- type: 'HOME',
733
- typeName: 'Домашний телефон',
734
- value: user.homePhone
735
- ? formatPhone(user.homePhone)
736
- : 'response' in user && 'contacts' in user.response
737
- ? user.response.contacts.find(i => i.type === 'HOME').value
738
- : '',
739
- });
740
- }
741
-
742
- // ! SaveContragent -> Documents
743
- let documentsData = [];
744
- documentsData.push({
745
- contragentId: user.id,
746
- id: 'response' in user && 'documents' in user.response ? user.response.documents[0].id : 0,
747
- description: null,
748
- expireDate: user.getDateByKey('documentExpire'),
749
- issueDate: user.getDateByKey('documentDate'),
750
- issuerId: Number(user.documentIssuers.ids),
751
- issuerName: user.documentIssuers.nameKz,
752
- issuerNameRu: user.documentIssuers.nameRu,
753
- note: null,
754
- number: user.documentNumber,
755
- type: user.documentType.ids,
756
- typeName: user.documentType.nameRu,
757
- serial: null,
758
- verifyType: user.verifyType,
759
- verifyDate: user.verifyDate,
760
- });
761
-
762
- // ! SaveContragent -> Addresses
763
- let addressData = [];
764
- addressData.push({
765
- id: 'response' in user && 'addresses' in user.response ? user.response.addresses[0].id : 0,
766
- contragentId: user.id,
767
- countryCode: user.birthPlace.ids,
768
- countryName: user.birthPlace.nameRu,
769
- stateCode: user.registrationProvince.ids,
770
- stateName: user.registrationProvince.nameRu,
771
- cityCode: user.registrationCity.code,
772
- cityName: user.registrationCity.nameRu,
773
- regionCode: user.registrationRegion.ids,
774
- regionName: user.registrationRegion.nameRu,
775
- streetName: user.registrationStreet,
776
- kvartal: user.registrationQuarter,
777
- microRaion: user.registrationMicroDistrict,
778
- cityTypeId: Number(user.registrationRegionType.ids),
779
- cityTypeName: user.registrationRegionType.nameRu,
780
- blockNumber: user.registrationNumberHouse,
781
- apartmentNumber: user.registrationNumberApartment,
782
- address: `${user.birthPlace.nameRu}, ${user.registrationRegionType.nameRu} ${user.registrationCity.nameRu}, ул. ${user.registrationStreet}, д. ${user.registrationNumberHouse} кв. ${user.registrationNumberApartment}`,
783
- type: 'H',
784
- });
785
-
786
- const data = {
787
- contragent: contragentData,
788
- questionaries: questionariesData,
789
- contacts: contactsData,
790
- documents: documentsData,
791
- addresses: addressData,
792
- };
793
-
794
- const personId = await this.api.saveContragent(data);
795
- if (personId) {
796
- await this.getContragentById(personId, whichForm, false, whichIndex);
797
- user.otpTokenId = null;
798
- }
799
- } catch (err) {
800
- this.isLoading = false;
801
- return ErrorHandler(err);
802
- }
803
- if (onlySaveAction) {
804
- this.isLoading = false;
805
- }
806
- return true;
807
- },
808
- async saveMember(member, whichMember, memberFromApplicaiton) {
809
- let data = {};
810
- try {
811
- data = {
812
- processInstanceId: this.formStore.applicationData.processInstanceId,
813
- insisId: member.id,
814
- iin: member.iin.replace(/-/g, ''),
815
- longName: member.longName,
816
- isIpdl: member.signOfIPDL.nameRu == 'Да' ? true : false,
817
- isTerror: member.isTerror,
818
- isIpdlCompliance: null,
819
- isTerrorCompliance: null,
820
- };
821
- data.id = memberFromApplicaiton && memberFromApplicaiton.id ? memberFromApplicaiton.id : null;
822
- if (whichMember === 'Client') {
823
- data.isInsured = this.formStore.isPolicyholderInsured;
824
- data.isActOwnBehalf = this.formStore.isActOwnBehalf;
825
- data.profession = member.job;
826
- data.position = member.jobPosition;
827
- data.jobName = member.jobPlace;
828
- data.familyStatusId = member.familyStatus.id;
829
- }
830
- if (whichMember === 'Spokesman') {
831
- if (!!memberFromApplicaiton && memberFromApplicaiton.iin !== data.iin) {
832
- delete data.id;
833
- await this.api.deleteMember('Spokesman', this.formStore.applicationData.processInstanceId);
834
- }
835
- data.migrationCard = member.migrationCard;
836
- const migrationCardIssueDate = formatDate(member.migrationCardIssueDate);
837
- if (migrationCardIssueDate) data.migrationCardIssueDate = migrationCardIssueDate.toISOString();
838
- const migrationCardExpireDate = formatDate(member.migrationCardExpireDate);
839
- if (migrationCardExpireDate) data.migrationCardExpireDate = migrationCardExpireDate.toISOString();
840
- data.confirmDocType = member.confirmDocType;
841
- data.confirmDocNumber = member.confirmDocNumber;
842
- const confirmDocIssueDate = formatDate(member.confirmDocIssueDate);
843
- if (confirmDocIssueDate) data.confirmDocIssueDate = confirmDocIssueDate.toISOString();
844
- const confirmDocExpireDate = formatDate(member.confirmDocExpireDate);
845
- if (confirmDocExpireDate) data.confirmDocExpireDate = confirmDocExpireDate.toISOString();
846
- data.clientLongName = this.formStore.applicationData.clientApp.longName;
847
- data.notaryLongName = member.notaryLongName;
848
- data.notaryLicenseNumber = member.notaryLicenseNumber;
849
- const notaryLicenseDate = formatDate(member.notaryLicenseDate);
850
- if (notaryLicenseDate) data.notaryLicenseDate = notaryLicenseDate.toISOString();
851
- data.notaryLicenseIssuer = member.notaryLicenseIssuer;
852
- data.jurLongName = member.jurLongName;
853
- data.fullNameRod = member.fullNameRod;
854
- data.confirmDocTypeKz = member.confirmDocTypeKz;
855
- data.confirmDocTypeRod = member.confirmDocTypeRod;
856
- data.isNotary = member.isNotary;
857
- }
858
- if (whichMember === 'Insured') {
859
- if (
860
- this.formStore.applicationData &&
861
- this.formStore.applicationData.insuredApp &&
862
- this.formStore.applicationData.insuredApp.length &&
863
- this.formStore.applicationData.insuredApp.every(i => i.iin !== data.iin) &&
864
- data.id !== null
865
- ) {
866
- await this.api.deleteMember('Insured', data.id);
867
- delete data.id;
868
- }
869
- data.isDisability = this.formStore.isPolicyholderInsured ? false : member.isDisability.nameRu == 'Да';
870
- data.disabilityGroupId = data.isDisability ? member.disabilityGroupId.id : null;
871
- data.profession = member.job;
872
- data.position = member.jobPosition;
873
- data.jobName = member.jobPlace;
874
- data.familyStatusId = member.familyStatus.id;
875
- }
876
- if (whichMember === 'Beneficiary') {
877
- if (
878
- this.formStore.applicationData &&
879
- this.formStore.applicationData.beneficiaryApp &&
880
- this.formStore.applicationData.beneficiaryApp.length &&
881
- this.formStore.applicationData.beneficiaryApp.every(i => i.iin !== data.iin) &&
882
- data.id !== null
883
- ) {
884
- await this.api.deleteMember('Beneficiary', data.id);
885
- delete data.id;
886
- }
887
- data.familyStatusId = member.familyStatus.id == 0 ? null : member.familyStatus.id;
888
- data.percentage = Number(member.percentageOfPayoutAmount);
889
- data.relationId = member.relationDegree.ids;
890
- data.relationName = member.relationDegree.nameRu;
891
- }
892
- if (whichMember === 'BeneficialOwner') {
893
- if (data.id === 0) {
894
- data.id = null;
895
- }
896
- if (
897
- this.formStore.applicationData &&
898
- this.formStore.applicationData.beneficialOwnerApp &&
899
- this.formStore.applicationData.beneficialOwnerApp.length &&
900
- this.formStore.applicationData.beneficialOwnerApp.every(i => i.iin !== data.iin) &&
901
- data.id !== null
902
- ) {
903
- await this.api.deleteMember('BeneficialOwner', data.id);
904
- delete data.id;
905
- }
906
- data.familyStatusId = member.familyStatus.id;
907
- }
908
- await this.api.setMember(whichMember, data);
909
- return true;
910
- } catch (err) {
911
- return ErrorHandler(err, err.response?.data?.errors && Object.values(err.response?.data?.errors).join(' -> '));
912
- }
913
- },
914
- searchFromList(whichForm, searchIt, whichIndex = null) {
915
- const getQuestionariesData = () => {
916
- switch (searchIt.questId) {
917
- case '500003':
918
- return [this.economySectorCode, 'economySectorCode'];
919
- case '500011':
920
- return [this.residents, 'signOfResidency'];
921
- case '500012':
922
- return [this.citizenshipCountries, 'countryOfCitizenship'];
923
- case '500014':
924
- return [this.taxCountries, 'countryOfTaxResidency'];
925
- case '507777':
926
- return [this.addTaxCountries, 'addTaxResidency'];
927
- case '500147':
928
- return [[]];
929
- case '500148':
930
- return [[]];
931
- }
932
- };
933
-
934
- const [searchFrom, whichField] = getQuestionariesData();
935
- if (searchFrom && searchFrom.length) {
936
- const result = searchFrom.find(i => i.ids === searchIt.questAnswer);
937
- if (whichIndex === null) {
938
- this.formStore[whichForm][whichField] = result ? result : new Value();
939
- } else {
940
- this.formStore[whichForm][whichIndex][whichField] = result ? result : new Value();
941
- }
942
- }
943
- },
944
- async setSurvey(data) {
945
- try {
946
- this.isLoading = true;
947
- const anketaToken = await this.api.setSurvey(data);
948
- this.showToaster('success', this.t('toaster.successSaved'), 2000);
949
- return anketaToken;
950
- } catch (error) {
951
- return ErrorHandler(err);
952
- } finally {
953
- this.isLoading = false;
954
- }
955
- },
956
- async getFromApi(whichField, whichRequest, parameter, reset = false) {
957
- const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
958
- const currentHour = new Date().getHours();
959
-
960
- const getDataCondition = () => {
961
- if (!storageValue) return true;
962
- const hasHourKey = 'hour' in storageValue;
963
- const hasModeKey = 'mode' in storageValue;
964
- const hasValueKey = 'value' in storageValue;
965
- if (storageValue && (hasHourKey === false || hasModeKey === false || hasValueKey === false)) return true;
966
- if (storageValue && (storageValue.hour !== currentHour || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)) return true;
967
- };
968
- if (!!getDataCondition() || reset === true) {
969
- this[whichField] = [];
970
- try {
971
- const response = await this.api[whichRequest](parameter);
972
- if (response) {
973
- localStorage.setItem(
974
- whichField,
975
- JSON.stringify({
976
- value: response,
977
- hour: currentHour,
978
- mode: import.meta.env.MODE,
979
- }),
980
- );
981
- this[whichField] = response;
982
- }
983
- } catch (err) {
984
- console.log(err);
985
- }
986
- } else {
987
- this[whichField] = storageValue.value;
988
- }
989
-
990
- return this[whichField];
991
- },
992
- async getCountries() {
993
- return await this.getFromApi('countries', 'getCountries');
994
- },
995
- async getCitizenshipCountries() {
996
- return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
997
- },
998
- async getTaxCountries() {
999
- return await this.getFromApi('taxCountries', 'getTaxCountries');
1000
- },
1001
- async getAdditionalTaxCountries() {
1002
- return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
1003
- },
1004
- async getStates(key, member) {
1005
- await this.getFromApi('states', 'getStates');
1006
- if (key && member[key] && member[key].ids !== null) {
1007
- return this.states.filter(i => i.code === member[key].ids);
1008
- }
1009
- return this.states;
1010
- },
1011
- async getRegions(key, member) {
1012
- await this.getFromApi('regions', 'getRegions');
1013
- if (key && member[key] && member[key].ids !== null) {
1014
- return this.regions.filter(i => i.code === member[key].ids);
1015
- }
1016
- if (member.registrationProvince.ids !== null) {
1017
- return this.regions.filter(i => i.code === member.registrationProvince.ids);
1018
- } else {
1019
- return this.regions;
1020
- }
1021
- },
1022
- async getCities(key, member) {
1023
- await this.getFromApi('cities', 'getCities');
1024
- if (key && member[key] && member[key].ids !== null) {
1025
- return this.cities.filter(i => i.code === member[key].ids);
1026
- }
1027
- if (member.registrationProvince.ids !== null) {
1028
- return this.cities.filter(i => i.code === member.registrationProvince.ids);
1029
- } else {
1030
- return this.cities;
1031
- }
1032
- },
1033
- async getLocalityTypes() {
1034
- return await this.getFromApi('localityTypes', 'getLocalityTypes');
1035
- },
1036
- async getDocumentTypes() {
1037
- const document_list = await this.getFromApi('documentTypes', 'getDocumentTypes');
1038
- await this.getDicFileTypeList();
1039
- return document_list.filter(doc => {
1040
- for (const dic of this.dicFileTypeList) {
1041
- if (doc.nameRu === dic.nameRu) {
1042
- return doc;
1043
- }
1044
- }
1045
- });
1046
- },
1047
- async getDicFileTypeList() {
1048
- try {
1049
- if (this.dicFileTypeList.length) {
1050
- return this.dicFileTypeList;
1051
- } else {
1052
- this.dicFileTypeList = await this.api.getDicFileTypeList();
1053
- return this.dicFileTypeList;
1054
- }
1055
- } catch (err) {
1056
- console.log(err.response.data);
1057
- }
1058
- },
1059
- async getDocumentIssuers() {
1060
- return await this.getFromApi('documentIssuers', 'getDocumentIssuers');
1061
- },
1062
- async getResidents() {
1063
- return await this.getFromApi('residents', 'getResidents');
1064
- },
1065
- async getSectorCodeList() {
1066
- await this.getFromApi('economySectorCode', 'getSectorCode');
1067
- return this.economySectorCode;
1068
- },
1069
- async getFamilyStatuses() {
1070
- return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
1071
- },
1072
- async getRelationTypes() {
1073
- // TODO Remove this & add filtering in openPanel method
1074
- await this.getFromApi('relations', 'getRelationTypes');
1075
- const filteredRelations = this.relations.filter(i => Number(i.ids) >= 6 && Number(i.ids) <= 15);
1076
- const otherRelations = this.relations.filter(i => Number(i.ids) < 6 || Number(i.ids) > 15);
1077
- return [...filteredRelations, ...otherRelations];
1078
- },
1079
- async getProcessIndexRate() {
1080
- const response = await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
1081
- return response ? response : [];
1082
- },
1083
- async getProcessCoverTypeSum(type) {
1084
- return await this.getFromApi('processCoverTypeSum', 'getProcessCoverTypeSum', type);
1085
- },
1086
- async getProcessPaymentPeriod() {
1087
- return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
1088
- },
1089
- async getQuestionRefs(id) {
1090
- return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
1091
- },
1092
- async getProcessTariff() {
1093
- return await this.getFromApi('processTariff', 'getProcessTariff');
1094
- },
1095
- async getAdditionalInsuranceTermsAnswers(questionId) {
1096
- try {
1097
- const answers = await this.api.getAdditionalInsuranceTermsAnswers(this.processCode, questionId);
1098
- return answers;
1099
- } catch (err) {
1100
- console.log(err);
1101
- }
1102
- },
1103
- async getQuestionList(surveyType, processInstanceId, insuredId, baseField, secondaryField) {
1104
- if (!this.formStore[baseField] || (this.formStore[baseField] && !this.formStore[baseField].length)) {
1105
- try {
1106
- const [{ value: baseQuestions }, { value: secondaryQuestions }] = await Promise.allSettled([
1107
- this.api.getQuestionList(surveyType, processInstanceId, insuredId),
1108
- this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1109
- ]);
1110
- this.formStore[baseField] = baseQuestions;
1111
- this.formStore[secondaryField] = secondaryQuestions;
1112
- } catch (err) {
1113
- console.log(err);
1114
- }
1115
- }
1116
- return this.formStore[baseField];
1117
- },
1118
- getNumberWithSpaces(n) {
1119
- return n === null ? null : Number((typeof n === 'string' ? n : n.toFixed().toString()).replace(/[^0-9]+/g, '')).toLocaleString('ru');
1120
- },
1121
- async getTaskList(search = '', groupCode = 'Work', onlyGet = false, needToReturn = false, key = 'dateCreated', processInstanceId = null, byOneProcess = null) {
1122
- if (onlyGet === false) {
1123
- this.isLoading = true;
1124
- }
1125
- try {
1126
- const column = this.isColumnAsc[key] === null ? 'dateCreated' : key;
1127
- const direction = this.isColumnAsc[key] === null ? 'desc' : this.isColumnAsc[key] === true ? 'asc' : 'desc';
1128
- const query = {
1129
- pageIndex: processInstanceId === null ? this.historyPageIndex - 1 : 0,
1130
- pageSize: this.historyPageSize,
1131
- search: search ? search.replace(/-/g, '') : '',
1132
- column: column,
1133
- direction: direction,
1134
- groupCode: groupCode,
1135
- processCodes: Object.values(constants.products),
1136
- };
1137
- if (byOneProcess !== null) {
1138
- delete query.processCodes;
1139
- query.processCode = byOneProcess;
1140
- }
1141
- const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
1142
- if (needToReturn) {
1143
- this.isLoading = false;
1144
- return taskList.items;
1145
- } else {
1146
- this.taskList = taskList.items;
1147
- this.historyTotalItems = taskList.totalItems;
1148
- }
1149
- } catch (err) {
1150
- this.showToaster('error', err?.response?.data, 2000);
1151
- console.log(err);
1152
- } finally {
1153
- this.isLoading = false;
1154
- }
1155
- if (onlyGet === false) {
1156
- this.isLoading = false;
1157
- }
1158
- },
1159
- async getProcessHistoryList(id) {
1160
- try {
1161
- const processHistory = await this.api.getProcessHistory(id);
1162
- if (processHistory.length > 0) {
1163
- return processHistory;
1164
- } else {
1165
- return [];
1166
- }
1167
- } catch (err) {
1168
- console.log(err);
1169
- }
1170
- },
1171
- async getProcessHistory(id) {
1172
- this.isLoading = true;
1173
- try {
1174
- const processHistory = await this.api.getProcessHistory(id);
1175
- if (processHistory.length > 0) {
1176
- this.processHistory = processHistory.reverse();
1177
- } else {
1178
- this.processHistory = [];
1179
- }
1180
- } catch (err) {
1181
- console.log(err);
1182
- }
1183
- this.isLoading = false;
1184
- },
1185
- findObject(from, key, searchKey) {
1186
- const found = this[from].find(i => i[key] == searchKey);
1187
- return found || new Value();
1188
- },
1189
- async getAllFormsData() {
1190
- await Promise.allSettled([
1191
- this.getCountries(),
1192
- this.getCitizenshipCountries(),
1193
- this.getTaxCountries(),
1194
- this.getAdditionalTaxCountries(),
1195
- this.getStates(),
1196
- this.getRegions(),
1197
- this.getCities(),
1198
- this.getLocalityTypes(),
1199
- this.getDocumentTypes(),
1200
- this.getDocumentIssuers(),
1201
- this.getResidents(),
1202
- this.getSectorCodeList(),
1203
- this.getFamilyStatuses(),
1204
- this.getRelationTypes(),
1205
- this.getProcessIndexRate(),
1206
- this.getProcessTariff(),
1207
- this.getProcessPaymentPeriod(),
1208
- ]);
1209
- },
1210
- async getUserGroups() {
1211
- try {
1212
- this.isLoading = true;
1213
- this.userGroups = await this.api.getUserGroups();
1214
- } catch (err) {
1215
- console.log(err);
1216
- } finally {
1217
- this.isLoading = false;
1218
- }
1219
- },
1220
- async getProcessList() {
1221
- this.isLoading = true;
1222
- try {
1223
- const processList = await this.api.getProcessList();
1224
- if (this.processList === null) {
1225
- this.processList = processList;
1226
- }
1227
- } catch (err) {
1228
- console.log(err);
1229
- }
1230
- this.isLoading = false;
1231
- },
1232
- sortTaskList(key) {
1233
- if (this.taskList.length !== 0) {
1234
- if (key in this.isColumnAsc) {
1235
- if (this.isColumnAsc[key] === true) {
1236
- this.isColumnAsc = { ...InitialColumns() };
1237
- this.isColumnAsc[key] = false;
1238
- return;
1239
- }
1240
- if (this.isColumnAsc[key] === false) {
1241
- this.isColumnAsc = { ...InitialColumns() };
1242
- this.isColumnAsc[key] = null;
1243
- return;
1244
- }
1245
- if (this.isColumnAsc[key] === null) {
1246
- this.isColumnAsc = { ...InitialColumns() };
1247
- this.isColumnAsc[key] = true;
1248
- return;
1249
- }
1250
- }
1251
- }
1252
- },
1253
- async searchAgentByName(name) {
1254
- try {
1255
- this.isLoading = true;
1256
- this.AgentDataList = await this.api.searchAgentByName(name);
1257
- if (!this.AgentDataList.length) {
1258
- this.showToaster('error', this.t('toaster.notFound'), 1500);
1259
- }
1260
- } catch (err) {
1261
- console.log(err);
1262
- } finally {
1263
- this.isLoading = false;
1264
- }
1265
- },
1266
- async setINSISWorkData() {
1267
- const data = {
1268
- id: this.formStore.applicationData.insisWorkDataApp.id,
1269
- processInstanceId: this.formStore.applicationData.processInstanceId,
1270
- agentId: this.formStore.AgentData.agentId,
1271
- agentName: this.formStore.AgentData.fullName,
1272
- salesChannel: this.formStore.applicationData.insisWorkDataApp.salesChannel,
1273
- salesChannelName: this.formStore.applicationData.insisWorkDataApp.salesChannelName,
1274
- insrType: this.formStore.applicationData.insisWorkDataApp.insrType,
1275
- saleChanellPolicy: this.formStore.SaleChanellPolicy.ids,
1276
- saleChanellPolicyName: this.formStore.SaleChanellPolicy.nameRu,
1277
- regionPolicy: this.formStore.RegionPolicy.ids,
1278
- regionPolicyName: this.formStore.RegionPolicy.nameRu,
1279
- managerPolicy: this.formStore.ManagerPolicy.ids,
1280
- managerPolicyName: this.formStore.ManagerPolicy.nameRu,
1281
- insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
1282
- };
1283
- try {
1284
- this.isLoading = true;
1285
- await this.api.setINSISWorkData(data);
1286
- } catch (err) {
1287
- console.log(err);
1288
- } finally {
1289
- this.isLoading = false;
1290
- }
1291
- },
1292
- async filterManagerByRegion(dictName, filterName) {
1293
- try {
1294
- this.isLoading = true;
1295
- this[`${dictName}List`] = await this.api.filterManagerByRegion(dictName, filterName);
1296
- } catch (err) {
1297
- console.log(err);
1298
- } finally {
1299
- this.isLoading = false;
1300
- }
1301
- },
1302
- async getUnderwritingCouncilData(id) {
1303
- try {
1304
- const response = await this.api.getUnderwritingCouncilData(id);
1305
- this.formStore.affilationResolution.id = response.underwritingCouncilAppDto.id;
1306
- this.formStore.affilationResolution.date = response.underwritingCouncilAppDto.date ? reformatDate(response.underwritingCouncilAppDto.date) : null;
1307
- this.formStore.affilationResolution.number = response.underwritingCouncilAppDto.number ? response.underwritingCouncilAppDto.number : null;
1308
- } catch (err) {
1309
- console.log(err);
1310
- }
1311
- },
1312
- async setConfirmation() {
1313
- const data = {
1314
- id: this.formStore.affilationResolution.id,
1315
- processInstanceId: this.formStore.affilationResolution.processInstanceId,
1316
- number: this.formStore.affilationResolution.number,
1317
- date: formatDate(this.formStore.affilationResolution.date)?.toISOString(),
1318
- };
1319
- try {
1320
- this.isLoading = true;
1321
- await this.api.setConfirmation(data);
1322
- this.showToaster('success', this.t('toaster.successSaved'));
1323
- return true;
1324
- } catch (err) {
1325
- this.showToaster('error', this.t('toaster.error'));
1326
- return false;
1327
- } finally {
1328
- this.isLoading = false;
1329
- }
1330
- },
1331
- async sendUnderwritingCouncilTask(data) {
1332
- try {
1333
- this.isLoading = true;
1334
- await this.api.sendUnderwritingCouncilTask(data);
1335
- this.showToaster('success', this.t('toaster.successOperation'), 5000);
1336
- return true;
1337
- } catch (err) {
1338
- console.log(err);
1339
- this.showToaster('error', this.t('toaster.error'), 5000);
1340
- return false;
1341
- } finally {
1342
- this.isLoading = false;
1343
- }
1344
- },
1345
- async definedAnswers(filter, whichSurvey, value = null, index = null) {
1346
- if (!this.formStore.definedAnswersId[whichSurvey].hasOwnProperty(filter)) {
1347
- this.formStore.definedAnswersId[whichSurvey][filter] = await this.api.definedAnswers(filter);
1348
- }
1349
- if (value !== null && this.formStore.definedAnswersId[whichSurvey][filter].length) {
1350
- const answer = this.formStore.definedAnswersId[whichSurvey][filter].find(answer => answer.nameRu === value);
1351
- this.formStore[whichSurvey].body[index].first.answerId = answer.ids;
1352
- }
1353
- return this.formStore.definedAnswersId[whichSurvey];
1354
- },
1355
- async getPaymentTable(id) {
1356
- try {
1357
- const paymentResultTable = await this.api.calculatePremuim(id);
1358
- if (paymentResultTable.length > 0) {
1359
- this.paymentResultTable = paymentResultTable;
1360
- } else {
1361
- this.paymentResultTable = [];
1362
- }
1363
- } catch (err) {
1364
- console.log(err);
1365
- }
1366
- },
1367
- async getDefaultCalculationData(showLoader = false) {
1368
- this.isLoading = showLoader;
1369
- try {
1370
- const calculationData = await this.api.getDefaultCalculationData();
1371
- return calculationData;
1372
- } catch (err) {
1373
- ErrorHandler(err);
1374
- } finally {
1375
- this.isLoading = false;
1376
- }
1377
- },
1378
- async calculateWithoutApplication(showLoader = false) {
1379
- this.isLoading = showLoader;
1380
- try {
1381
- const calculationData = {
1382
- signDate: formatDate(this.formStore.productConditionsForm.signDate)?.toISOString(),
1383
- birthDate: formatDate(this.formStore.productConditionsForm.birthDate)?.toISOString(),
1384
- gender: this.formStore.productConditionsForm.gender.id,
1385
- amount: getNumber(this.formStore.productConditionsForm.requestedSumInsured),
1386
- premium: getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonth),
1387
- coverPeriod: this.formStore.productConditionsForm.coverPeriod,
1388
- payPeriod: this.formStore.productConditionsForm.coverPeriod,
1389
- indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1390
- ? this.formStore.productConditionsForm.processIndexRate.id
1391
- : this.processIndexRate.find(i => i.code === '0')?.id,
1392
- paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1393
- addCovers: this.formStore.additionalInsuranceTermsWithout,
1394
- };
1395
- console.log(calculationData);
1396
- const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
1397
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1398
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1399
- this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1400
- this.showToaster('success', this.t('toaster.calculated'), 1000);
1401
- } catch (err) {
1402
- ErrorHandler(err);
1403
- } finally {
1404
- this.isLoading = false;
1405
- return !!this.formStore.productConditionsForm.requestedSumInsured && !!this.formStore.productConditionsForm.insurancePremiumPerMonth;
1406
- }
1407
- },
1408
- async calculate(taskId) {
1409
- this.isLoading = true;
1410
- try {
1411
- let form1 = {
1412
- baiterekApp: null,
1413
- policyAppDto: {
1414
- id: this.formStore.applicationData.policyAppDto.id,
1415
- processInstanceId: this.formStore.applicationData.policyAppDto.processInstanceId,
1416
- policyId: null,
1417
- policyNumber: null,
1418
- contractDate: this.currentDate(),
1419
- amount: this.formStore.productConditionsForm.requestedSumInsured != null ? Number(this.formStore.productConditionsForm.requestedSumInsured.replace(/\s/g, '')) : null,
1420
- premium:
1421
- this.formStore.productConditionsForm.insurancePremiumPerMonth != null
1422
- ? Number(this.formStore.productConditionsForm.insurancePremiumPerMonth.replace(/\s/g, ''))
1423
- : null,
1424
- isSpokesman: this.formStore.hasRepresentative,
1425
- coverPeriod: this.formStore.productConditionsForm.coverPeriod,
1426
- payPeriod: this.formStore.productConditionsForm.coverPeriod,
1427
- annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
1428
- indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1429
- ? this.formStore.productConditionsForm.processIndexRate.id
1430
- : this.processIndexRate.find(i => i.code === '0')?.id,
1431
- paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1432
- lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply),
1433
- lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive),
1434
- adbMultiply: formatProcents(this.formStore.productConditionsForm.adbMultiply),
1435
- adbAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
1436
- disabilityMultiply: formatProcents(this.formStore.productConditionsForm.disabilityMultiply),
1437
- disabilityAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
1438
- riskGroup: this.formStore.productConditionsForm.riskGroup?.id ? this.formStore.productConditionsForm.riskGroup.id : 1,
1439
- },
1440
- addCoversDto: this.formStore.additionalInsuranceTerms,
1441
- };
1442
-
1443
- try {
1444
- let id = this.formStore.applicationData.processInstanceId;
1445
-
1446
- await this.api.setApplication(form1);
1447
- let result;
1448
- try {
1449
- result = await this.api.getCalculation(id);
1450
- } catch (err) {
1451
- this.showToaster('error', err?.response?.data, 5000);
1452
- }
1453
-
1454
- const applicationData = await this.api.getApplicationData(taskId);
1455
- this.formStore.applicationData = applicationData;
1456
- this.formStore.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
1457
- if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
1458
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result);
1459
- } else {
1460
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result);
1461
- }
1462
- this.showToaster('success', this.t('toaster.calculated'), 1000);
1463
- } catch (err) {
1464
- console.log(err);
1465
- }
1466
- } catch (err) {
1467
- ErrorHandler(err);
1468
- console.log(err, 'error');
1469
- }
1470
- this.isLoading = false;
1471
- },
1472
- async startApplication(member) {
1473
- try {
1474
- const data = {
1475
- clientId: member.id,
1476
- iin: member.iin.replace(/-/g, ''),
1477
- longName: member.longName,
1478
- processCode: this.processCode,
1479
- policyId: 0,
1480
- };
1481
- const response = await this.api.startApplication(data);
1482
- this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
1483
- return response.processInstanceId;
1484
- } catch (err) {
1485
- return ErrorHandler(err);
1486
- }
1487
- },
1488
- async getApplicationData(taskId, onlyGet = true, setMembersField = true, fetchMembers = true, setProductConditions = true) {
1489
- if (onlyGet) {
1490
- this.isLoading = true;
1491
- }
1492
- try {
1493
- const applicationData = await this.api.getApplicationData(taskId);
1494
- if (this.processCode !== applicationData.processCode) {
1495
- this.isLoading = false;
1496
- this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
1497
- return;
1498
- }
1499
- this.formStore.applicationData = applicationData;
1500
- this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
1501
-
1502
- this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
1503
- this.formStore.applicationTaskId = taskId;
1504
- this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
1505
- this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
1506
- this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
1507
- this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
1508
- this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
1509
- this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
1510
-
1511
- this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
1512
- this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
1513
-
1514
- const clientData = applicationData.clientApp;
1515
- const insuredData = applicationData.insuredApp;
1516
- const spokesmanData = applicationData.spokesmanApp;
1517
- const beneficiaryData = applicationData.beneficiaryApp;
1518
- const beneficialOwnerData = applicationData.beneficialOwnerApp;
1519
-
1520
- this.formStore.isPolicyholderInsured = clientData.isInsured;
1521
- this.formStore.isActOwnBehalf = clientData.isActOwnBehalf;
1522
- this.formStore.hasRepresentative = !!applicationData.spokesmanApp;
1523
-
1524
- const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
1525
- this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
1526
-
1527
- if (fetchMembers) {
1528
- let allMembers = [
1529
- {
1530
- ...clientData,
1531
- key: this.formStore.policyholderFormKey,
1532
- index: null,
1533
- },
1534
- ];
1535
-
1536
- if (spokesmanData) {
1537
- allMembers.push({
1538
- ...spokesmanData,
1539
- key: this.formStore.policyholdersRepresentativeFormKey,
1540
- index: null,
1541
- });
1542
- }
1543
-
1544
- if (insuredData && insuredData.length) {
1545
- insuredData.forEach((member, index) => {
1546
- const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
1547
- if (!inStore) {
1548
- member.key = this.formStore.insuredFormKey;
1549
- member.index = index;
1550
- allMembers.push(member);
1551
- if (this.formStore.insuredForm.length - 1 < index) {
1552
- this.formStore.insuredForm.push(new InsuredForm());
1553
- }
1554
- }
1555
- });
1556
- }
1557
- if (beneficiaryData && beneficiaryData.length) {
1558
- beneficiaryData.forEach((member, index) => {
1559
- const inStore = this.formStore.beneficiaryForm.find(each => each.id == member.insisId);
1560
- if (!inStore) {
1561
- member.key = this.formStore.beneficiaryFormKey;
1562
- member.index = index;
1563
- allMembers.push(member);
1564
- if (this.formStore.beneficiaryForm.length - 1 < index) {
1565
- this.formStore.beneficiaryForm.push(new BeneficiaryForm());
1566
- }
1567
- }
1568
- });
1569
- }
1570
- if (beneficialOwnerData && beneficialOwnerData.length) {
1571
- beneficialOwnerData.forEach((member, index) => {
1572
- const inStore = this.formStore.beneficialOwnerForm.find(each => each.id == member.insisId);
1573
- if (!inStore) {
1574
- member.key = this.formStore.beneficialOwnerFormKey;
1575
- member.index = index;
1576
- allMembers.push(member);
1577
- if (this.formStore.beneficialOwnerForm.length - 1 < index) {
1578
- this.formStore.beneficialOwnerForm.push(new BeneficialOwnerForm());
1579
- }
1580
- }
1581
- });
1582
- }
1583
-
1584
- await Promise.allSettled(
1585
- allMembers.map(async member => {
1586
- await this.getContragentById(member.insisId, member.key, false, member.index);
1587
- }),
1588
- );
1589
- }
1590
-
1591
- if (setMembersField) {
1592
- this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
1593
- if (insuredData && insuredData.length) {
1594
- insuredData.forEach((each, index) => {
1595
- this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1596
- });
1597
- }
1598
-
1599
- if (beneficiaryData && beneficiaryData.length) {
1600
- beneficiaryData.forEach((each, index) => {
1601
- this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
1602
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
1603
- this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1604
- this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
1605
- });
1606
- }
1607
-
1608
- if (beneficialOwnerData && beneficialOwnerData.length) {
1609
- beneficialOwnerData.forEach((each, index) => {
1610
- this.setMembersFieldIndex(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', index);
1611
- });
1612
- }
1613
-
1614
- if (!!spokesmanData) {
1615
- this.formStore.policyholdersRepresentativeForm.signOfIPDL = spokesmanData.isIpdl ? this.ipdl[1] : this.ipdl[2];
1616
- this.formStore.policyholdersRepresentativeForm.migrationCard = spokesmanData.migrationCard;
1617
- this.formStore.policyholdersRepresentativeForm.migrationCardIssueDate = reformatDate(spokesmanData.migrationCardIssueDate);
1618
- this.formStore.policyholdersRepresentativeForm.migrationCardExpireDate = reformatDate(spokesmanData.migrationCardExpireDate);
1619
- this.formStore.policyholdersRepresentativeForm.confirmDocType = spokesmanData.confirmDocType;
1620
- this.formStore.policyholdersRepresentativeForm.confirmDocNumber = spokesmanData.confirmDocNumber;
1621
- this.formStore.policyholdersRepresentativeForm.confirmDocIssueDate = reformatDate(spokesmanData.confirmDocIssueDate);
1622
- this.formStore.policyholdersRepresentativeForm.confirmDocExpireDate = reformatDate(spokesmanData.confirmDocExpireDate);
1623
- this.formStore.policyholdersRepresentativeForm.notaryLongName = spokesmanData.notaryLongName;
1624
- this.formStore.policyholdersRepresentativeForm.notaryLicenseNumber = spokesmanData.notaryLicenseNumber;
1625
- this.formStore.policyholdersRepresentativeForm.notaryLicenseDate = reformatDate(spokesmanData.notaryLicenseDate);
1626
- this.formStore.policyholdersRepresentativeForm.notaryLicenseIssuer = spokesmanData.notaryLicenseIssuer;
1627
- this.formStore.policyholdersRepresentativeForm.jurLongName = spokesmanData.jurLongName;
1628
- this.formStore.policyholdersRepresentativeForm.fullNameRod = spokesmanData.fullNameRod;
1629
- this.formStore.policyholdersRepresentativeForm.confirmDocTypeKz = spokesmanData.confirmDocTypeKz;
1630
- this.formStore.policyholdersRepresentativeForm.confirmDocTypeRod = spokesmanData.confirmDocTypeRod;
1631
- this.formStore.policyholdersRepresentativeForm.isNotary = spokesmanData.isNotary;
1632
- }
1633
- }
1634
- if (setProductConditions) {
1635
- this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
1636
- this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
1637
- // this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
1638
- this.formStore.productConditionsForm.lifeMultiply = parseProcents(applicationData.policyAppDto.lifeMultiply);
1639
- this.formStore.productConditionsForm.lifeAdditive = parseProcents(applicationData.policyAppDto.lifeAdditive);
1640
- this.formStore.productConditionsForm.adbMultiply = parseProcents(applicationData.policyAppDto.adbMultiply);
1641
- this.formStore.productConditionsForm.adbAdditive = parseProcents(applicationData.policyAppDto.adbAdditive);
1642
- this.formStore.productConditionsForm.disabilityMultiply = parseProcents(applicationData.policyAppDto.disabilityMultiply);
1643
- this.formStore.productConditionsForm.disabilityAdditive = parseProcents(applicationData.policyAppDto.disabilityAdditive);
1644
-
1645
- let processIndexRate = this.processIndexRate.find(item => item.id == applicationData.policyAppDto.indexRateId);
1646
- this.formStore.productConditionsForm.processIndexRate = processIndexRate ? processIndexRate : this.processIndexRate.find(item => item.code === '0');
1647
-
1648
- let paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
1649
- this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
1650
-
1651
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(
1652
- applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount,
1653
- );
1654
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
1655
- applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
1656
- );
1657
-
1658
- let riskGroup = this.riskGroup.find(item => {
1659
- if (applicationData.policyAppDto.riskGroup == 0) {
1660
- return true;
1661
- }
1662
- return item.id == applicationData.policyAppDto.riskGroup;
1663
- });
1664
- this.formStore.productConditionsForm.riskGroup = riskGroup ? riskGroup : this.riskGroup.find(item => item.id == 1);
1665
- }
1666
- } catch (err) {
1667
- console.log(err);
1668
- if ('response' in err) {
1669
- this.sendToParent(constants.postActions.toHomePage, err.response.data);
1670
- this.isLoading = false;
1671
- return false;
1672
- }
1673
- }
1674
- if (onlyGet) {
1675
- this.isLoading = false;
1676
- }
1677
- },
1678
- async setApplication() {
1679
- try {
1680
- await this.api.setApplication(this.formStore.applicationData);
1681
- } catch (err) {
1682
- console.log(err);
1683
- }
1684
- },
1685
- async deleteTask(taskId) {
1686
- this.isLoading = true;
1687
- try {
1688
- const data = {
1689
- taskId: taskId,
1690
- decision: 'rejectclient',
1691
- comment: 'Клиент отказался',
1692
- };
1693
- await this.api.sendTask(data);
1694
- this.showToaster('success', this.t('toaster.applicationDeleted'), 2000);
1695
- } catch (err) {
1696
- if ('response' in err && err.response.data) {
1697
- this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
1698
- }
1699
- console.log(err);
1700
- }
1701
- this.isLoading = false;
1702
- },
1703
- async sendTask(taskId, decision, comment = null) {
1704
- this.isLoading = true;
1705
- try {
1706
- const data = {
1707
- taskId: taskId,
1708
- decision: decision,
1709
- };
1710
- await this.api.sendTask(comment === null ? data : { ...data, comment: comment });
1711
- this.showToaster('success', this.t('toaster.successOperation'), 3000);
1712
- this.isLoading = false;
1713
- return true;
1714
- } catch (err) {
1715
- console.log(err);
1716
- if ('response' in err && err.response.data) {
1717
- this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
1718
- }
1719
- this.isLoading = false;
1720
- return false;
1721
- }
1722
- },
1723
- async handleTask(action, taskId, comment) {
1724
- if (action && Object.keys(constants.actions).includes(action)) {
1725
- switch (action) {
1726
- case constants.actions.claim: {
1727
- try {
1728
- this.isLoading = true;
1729
- await this.api.claimTask(this.formStore.applicationTaskId);
1730
- await this.getApplicationData(taskId, false, false, false);
1731
- this.showToaster('success', this.t('toaster.successOperation'), 3000);
1732
- } catch (err) {
1733
- console.log(err);
1734
- if ('response' in err && err.response.data) {
1735
- this.showToaster('error', err.response.data, 3000);
1736
- }
1737
- }
1738
- }
1739
- case constants.actions.reject:
1740
- case constants.actions.return:
1741
- case constants.actions.rejectclient:
1742
- case constants.actions.accept: {
1743
- try {
1744
- await this.sendTask(taskId, action, comment);
1745
- this.formStore.$reset();
1746
- if (this.isEFO) {
1747
- await this.router.push({ name: 'Insurance-Product' });
1748
- } else {
1749
- this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
1750
- }
1751
- } catch (err) {
1752
- console.log(err);
1753
- if ('response' in err && err.response.data) {
1754
- this.showToaster('error', err.response.data, 3000);
1755
- }
1756
- }
1757
- }
1758
- }
1759
- } else {
1760
- console.error('No handleTask action');
1761
- }
1762
- },
1763
- async getInvoiceData(processInstanceId) {
1764
- try {
1765
- const response = await this.api.getInvoiceData(processInstanceId);
1766
- if (response) {
1767
- return response;
1768
- } else {
1769
- return false;
1770
- }
1771
- } catch (err) {
1772
- return false;
1773
- }
1774
- },
1775
- async createInvoice() {
1776
- try {
1777
- const created = await this.api.createInvoice(this.formStore.applicationData.processInstanceId, this.formStore.applicationData.policyAppDto.premium);
1778
- return !!created;
1779
- } catch (err) {
1780
- this.isLoading = false;
1781
- }
1782
- },
1783
- async sendToEpay() {
1784
- try {
1785
- const response = await this.api.sendToEpay(this.formStore.applicationData.processInstanceId);
1786
- if (response) {
1787
- return response;
1788
- }
1789
- } catch (err) {
1790
- console.log(err);
1791
- }
1792
- },
1793
- setMembersField(whichForm, whichMember) {
1794
- this.formStore[whichForm].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember].familyStatusId);
1795
- this.formStore[whichForm].signOfIPDL = this.findObject(
1796
- 'ipdl',
1797
- 'nameRu',
1798
- this.formStore.applicationData[whichMember].isIpdl === null ? null : this.formStore.applicationData[whichMember].isIpdl == true ? 'Да' : 'Нет',
1799
- );
1800
- if (!!this.formStore.applicationData[whichMember].profession) this.formStore[whichForm].job = this.formStore.applicationData[whichMember].profession;
1801
- if (!!this.formStore.applicationData[whichMember].position) this.formStore[whichForm].jobPosition = this.formStore.applicationData[whichMember].position;
1802
- if (!!this.formStore.applicationData[whichMember].jobName) this.formStore[whichForm].jobPlace = this.formStore.applicationData[whichMember].jobName;
1803
- },
1804
- setMembersFieldIndex(whichForm, whichMember, index) {
1805
- if ('familyStatus' in this.formStore[whichForm][index]) {
1806
- this.formStore[whichForm][index].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember][index].familyStatusId);
1807
- }
1808
- if ('signOfIPDL' in this.formStore[whichForm][index]) {
1809
- this.formStore[whichForm][index].signOfIPDL = this.findObject(
1810
- 'ipdl',
1811
- 'nameRu',
1812
- this.formStore.applicationData[whichMember][index].isIpdl === null ? null : this.formStore.applicationData[whichMember][index].isIpdl == true ? 'Да' : 'Нет',
1813
- );
1814
- }
1815
- if ('job' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].profession) {
1816
- this.formStore[whichForm][index].job = this.formStore.applicationData[whichMember][index].profession;
1817
- }
1818
- if ('jobPosition' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].position) {
1819
- this.formStore[whichForm][index].jobPosition = this.formStore.applicationData[whichMember][index].position;
1820
- }
1821
- if ('jobPlace' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].jobName) {
1822
- this.formStore[whichForm][index].jobPlace = this.formStore.applicationData[whichMember][index].jobName;
1823
- }
1824
- },
1825
- findObject(from, key, searchKey) {
1826
- const found = this[from].find(i => i[key] == searchKey);
1827
- return found || new Value();
1828
- },
1829
- async signToDocument(data) {
1830
- try {
1831
- if (this.formStore.signUrl) {
1832
- return this.formStore.signUrl;
1833
- }
1834
- const result = await this.api.signToDocument(data);
1835
- this.formStore.signUrl = result.uri;
1836
- return this.formStore.signUrl;
1837
- } catch (error) {
1838
- this.showToaster('error', this.t('toaster.error') + error?.response?.data, 2000);
1839
- }
1840
- },
1841
- sanitize(text) {
1842
- if (text) {
1843
- return text
1844
- .replace(/\r?\n|\r/g, '')
1845
- .replace(/\\/g, '')
1846
- .replace(/"/g, '');
1847
- }
1848
- },
1849
- async getSignedDocList(processInstanceId) {
1850
- if (processInstanceId !== 0) {
1851
- try {
1852
- this.formStore.signedDocumentList = await this.api.getSignedDocList({
1853
- processInstanceId: processInstanceId,
1854
- });
1855
- } catch (err) {
1856
- console.log(err);
1857
- }
1858
- }
1859
- },
1860
- setFormsDisabled(isDisabled) {
1861
- Object.keys(this.formStore.isDisabled).forEach(key => {
1862
- this.formStore.isDisabled[key] = !!isDisabled;
1863
- });
1864
- },
1865
- async reCalculate(processInstanceId, recalculationData, taskId, whichSum) {
1866
- this.isLoading = true;
1867
- try {
1868
- const data = {
1869
- processInstanceId: processInstanceId,
1870
- ...recalculationData,
1871
- };
1872
- const recalculatedValue = await this.api.reCalculate(data);
1873
- if (!!recalculatedValue) {
1874
- await this.getApplicationData(taskId, false, false, false);
1875
- this.showToaster(
1876
- 'success',
1877
- `${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
1878
- recalculatedValue,
1879
- )}₸`,
1880
- 4000,
1881
- );
1882
- }
1883
- } catch (err) {
1884
- console.log(err);
1885
- if ('response' in err) {
1886
- this.showToaster('error', err?.response?.data, 5000);
1887
- } else {
1888
- this.showToaster('error', err, 5000);
1889
- }
1890
- }
1891
- this.isLoading = false;
1892
- },
1893
- async getValidateClientESBD(data) {
1894
- try {
1895
- return await this.api.getValidateClientESBD(data);
1896
- } catch (error) {
1897
- this.isLoading = false;
1898
- if ('response' in error && error.response.data) {
1899
- this.showToaster('error', error.response.data, 5000);
1900
- }
1901
- console.log(error);
1902
- return false;
1903
- }
1904
- },
1905
- validateMultipleMembers(localKey, applicationKey, text) {
1906
- if (this.formStore[localKey].length === this.formStore.applicationData[applicationKey].length) {
1907
- if (this.formStore[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
1908
- const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
1909
- const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
1910
- if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
1911
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1912
- return false;
1913
- }
1914
- if (localKey === this.formStore.beneficiaryFormKey) {
1915
- const sumOfPercentage = localMembers.reduce((sum, member) => {
1916
- return sum + Number(member.percentageOfPayoutAmount);
1917
- }, 0);
1918
- if (sumOfPercentage !== 100) {
1919
- this.showToaster('error', this.t('toaster.errorSumOrPercentage'), 3000);
1920
- return false;
1921
- }
1922
- }
1923
- }
1924
- } else {
1925
- if (this.formStore[localKey].some(i => i.iin !== null)) {
1926
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1927
- return false;
1928
- }
1929
- if (this.formStore.applicationData[applicationKey].length !== 0) {
1930
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1931
- return false;
1932
- } else {
1933
- if (this.formStore[localKey][0].iin !== null) {
1934
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1935
- return false;
1936
- }
1937
- }
1938
- }
1939
- return true;
1940
- },
1941
- async validateAllMembers(taskId, localCheck = false) {
1942
- if (taskId == 0) {
1943
- this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
1944
- return false;
1945
- }
1946
- if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
1947
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
1948
- return false;
1949
- }
1950
- if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
1951
- return false;
1952
- }
1953
- if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
1954
- return false;
1955
- }
1956
- if (this.formStore.isActOwnBehalf === false) {
1957
- if (this.validateMultipleMembers(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
1958
- return false;
1959
- }
1960
- }
1961
- if (this.formStore.hasRepresentative) {
1962
- if (this.formStore.applicationData.spokesmanApp && this.formStore.policyholdersRepresentativeForm.id !== this.formStore.applicationData.spokesmanApp.insisId) {
1963
- this.showToaster(
1964
- 'error',
1965
- this.t('toaster.notSavedMember', {
1966
- text: 'представителя страхователя',
1967
- }),
1968
- 3000,
1969
- );
1970
- return false;
1971
- }
1972
- }
1973
- const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
1974
- if (areValid) {
1975
- await this.setINSISWorkData();
1976
- } else {
1977
- this.isLoading = false;
1978
- this.showToaster('error', this.t('toaster.attachManagerError'), 3000);
1979
- return false;
1980
- }
1981
- if (localCheck === false) {
1982
- try {
1983
- if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
1984
- await Promise.allSettled(
1985
- this.formStore.applicationData.beneficialOwnerApp.map(async member => {
1986
- await this.api.deleteMember('BeneficialOwner', member.id);
1987
- }),
1988
- );
1989
- }
1990
- await this.getApplicationData(taskId, false);
1991
- } catch (err) {
1992
- console.log(err);
1993
- this.showToaster('error', err, 5000);
1994
- return false;
1995
- }
1996
- }
1997
-
1998
- return true;
1999
- },
2000
- validateAnketa(whichSurvey) {
2001
- const list = this.formStore[whichSurvey].body;
2002
- if (!list || (list && list.length === 0)) return false;
2003
- let notAnswered = 0;
2004
- for (let x = 0; x < list.length; x++) {
2005
- if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
2006
- notAnswered = notAnswered + 1;
2007
- }
2008
- }
2009
- return notAnswered === 0;
2010
- },
2011
- async validateAllForms(taskId) {
2012
- this.isLoading = true;
2013
- const areMembersValid = await this.validateAllMembers(taskId);
2014
- if (areMembersValid) {
2015
- if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
2016
- const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
2017
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2018
- await Promise.allSettled([
2019
- this.getQuestionList(
2020
- 'health',
2021
- this.formStore.applicationData.processInstanceId,
2022
- this.formStore.applicationData.insuredApp[0].id,
2023
- 'surveyByHealthBase',
2024
- 'surveyByHealthSecond',
2025
- ),
2026
- this.getQuestionList(
2027
- 'critical',
2028
- this.formStore.applicationData.processInstanceId,
2029
- this.formStore.applicationData.insuredApp[0].id,
2030
- 'surveyByCriticalBase',
2031
- 'surveyByCriticalSecond',
2032
- ),
2033
- ]);
2034
- await Promise.allSettled([
2035
- ...this.formStore.surveyByHealthBase.body.map(async question => {
2036
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2037
- }),
2038
- ...this.formStore.surveyByCriticalBase.body.map(async question => {
2039
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2040
- }),
2041
- ]);
2042
- } else {
2043
- await Promise.allSettled([
2044
- this.getQuestionList(
2045
- 'health',
2046
- this.formStore.applicationData.processInstanceId,
2047
- this.formStore.applicationData.insuredApp[0].id,
2048
- 'surveyByHealthBase',
2049
- 'surveyByHealthSecond',
2050
- ),
2051
- ]);
2052
- await Promise.allSettled(
2053
- this.surveyByHealthBase.body.map(async question => {
2054
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2055
- }),
2056
- );
2057
- }
2058
-
2059
- if (this.validateAnketa('surveyByHealthBase')) {
2060
- let hasCriticalAndItsValid = null;
2061
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2062
- if (this.validateAnketa('surveyByCriticalBase')) {
2063
- hasCriticalAndItsValid = true;
2064
- } else {
2065
- hasCriticalAndItsValid = false;
2066
- this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2067
- }
2068
- } else {
2069
- hasCriticalAndItsValid = null;
2070
- }
2071
- if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2072
- this.isLoading = false;
2073
- return true;
2074
- }
2075
- } else {
2076
- this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2077
- }
2078
- } else {
2079
- this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
2080
- }
2081
- return false;
2082
- }
2083
- this.isLoading = false;
2084
- return false;
2085
- },
2086
- async getFamilyInfo(iin, phoneNumber) {
2087
- this.isLoading = true;
2088
- try {
2089
- const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
2090
- if (familyResponse.status === 'PENDING') {
2091
- this.showToaster('success', this.t('toaster.waitForClient'), 5000);
2092
- this.isLoading = false;
2093
- return;
2094
- }
2095
- if (constants.gbdErrors.find(i => i === familyResponse.status)) {
2096
- if (familyResponse.status === 'TIMEOUT') {
2097
- this.showToaster('success', `${familyResponse.statusName}. Отправьте запрос еще раз`, 5000);
2098
- } else {
2099
- this.showToaster('error', familyResponse.statusName, 5000);
2100
- }
2101
- this.isLoading = false;
2102
- return;
2103
- }
2104
- if (familyResponse.infoList && familyResponse.infoList.birthInfos && familyResponse.infoList.birthInfos.length) {
2105
- const filteredBirthInfos = familyResponse.infoList.birthInfos.filter(
2106
- member => member.childBirthDate && getAgeByBirthDate(member.childBirthDate) <= 15 && typeof member.childLifeStatus === 'number' && member.childLifeStatus === 0,
2107
- );
2108
- if (filteredBirthInfos && filteredBirthInfos.length) {
2109
- this.formStore.birthInfos = filteredBirthInfos;
2110
- this.showToaster('success', this.t('toaster.pickFamilyMember'), 3000);
2111
- } else {
2112
- this.formStore.birthInfos = [];
2113
- this.showToaster('error', this.t('toaster.notFound'), 3000);
2114
- }
2115
- } else {
2116
- this.formStore.birthInfos = [];
2117
- this.showToaster('error', this.t('toaster.notFound'), 3000);
2118
- }
2119
- } catch (err) {
2120
- ErrorHandler(err);
2121
- } finally {
2122
- this.isLoading = false;
2123
- }
2124
- },
2125
- async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
2126
- this.isLoading = true;
2127
- try {
2128
- const data = {
2129
- iin: iin.replace(/-/g, ''),
2130
- phoneNumber: formatPhone(phoneNumber),
2131
- };
2132
- const gbdResponse = await this.api.getContragentFromGBDFL(data);
2133
- if (gbdResponse.status === 'PENDING') {
2134
- this.showToaster('success', this.t('toaster.waitForClient'), 5000);
2135
- this.isLoading = false;
2136
- return;
2137
- }
2138
- if (constants.gbdErrors.find(i => i === gbdResponse.status)) {
2139
- if (gbdResponse.status === 'TIMEOUT') {
2140
- this.showToaster('success', `${gbdResponse.statusName}. Отправьте запрос еще раз`, 5000);
2141
- } else {
2142
- this.showToaster('success', gbdResponse.statusName, 5000);
2143
- }
2144
- this.isLoading = false;
2145
- return;
2146
- }
2147
- const { person } = parseXML(gbdResponse.content, true, 'person');
2148
- const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2149
- if (typeof whichIndex !== 'number') {
2150
- if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
2151
- this.formStore[whichForm].resetMember(false);
2152
- }
2153
- this.formStore[whichForm].gosPersonData = person;
2154
- } else {
2155
- if (this.formStore[whichForm][whichIndex].gosPersonData !== null && this.formStore[whichForm][whichIndex].gosPersonData.iin !== iin.replace(/-/g, '')) {
2156
- this.formStore[whichForm][whichIndex].resetMember(false);
2157
- }
2158
- this.formStore[whichForm][whichIndex].gosPersonData = person;
2159
- }
2160
-
2161
- await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
2162
- if (typeof whichIndex !== 'number') {
2163
- this.formStore[whichForm].verifyDate = responseInfo.responseDate;
2164
- this.formStore[whichForm].verifyType = 'GBDFL';
2165
- } else {
2166
- this.formStore[whichForm][whichIndex].verifyDate = responseInfo.responseDate;
2167
- this.formStore[whichForm][whichIndex].verifyType = 'GBDFL';
2168
- }
2169
- await this.saveInStoreUserGBDFL(person, whichForm, whichIndex);
2170
- } catch (err) {
2171
- console.log(err);
2172
- if ('response' in err) {
2173
- this.showToaster('error', err.response.data, 3000);
2174
- }
2175
- }
2176
- this.isLoading = false;
2177
- },
2178
- async saveInStoreUserGBDFL(person, whichForm, whichIndex = null) {
2179
- if (whichIndex === null) {
2180
- this.formStore[whichForm].firstName = person.name;
2181
- this.formStore[whichForm].lastName = person.surname;
2182
- this.formStore[whichForm].middleName = person.patronymic ? person.patronymic : '';
2183
- this.formStore[whichForm].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2184
- this.formStore[whichForm].birthDate = reformatDate(person.birthDate);
2185
- this.formStore[whichForm].genderName = person.gender.nameRu;
2186
-
2187
- const gender = this.gender.find(i => i.id == person.gender.code);
2188
- if (gender) this.formStore[whichForm].gender = gender;
2189
-
2190
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2191
- if (birthPlace) this.formStore[whichForm].birthPlace = birthPlace;
2192
-
2193
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2194
- if (countryOfCitizenship) this.formStore[whichForm].countryOfCitizenship = countryOfCitizenship;
2195
-
2196
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2197
- if (regCountry) this.formStore[whichForm].registrationCountry = regCountry;
2198
-
2199
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2200
- if (regProvince) this.formStore[whichForm].registrationProvince = regProvince;
2201
-
2202
- if ('city' in person.regAddress && !!person.regAddress.city) {
2203
- if (person.regAddress.city.includes(', ')) {
2204
- const personCities = person.regAddress.city.split(', ');
2205
- for (let i = 0; i < personCities.length; ++i) {
2206
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2207
- if (possibleCity) {
2208
- this.formStore[whichForm].registrationCity = possibleCity;
2209
- break;
2210
- }
2211
- }
2212
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2213
- for (let i = 0; i < personCities.length; ++i) {
2214
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2215
- if (possibleRegion) {
2216
- this.formStore[whichForm].registrationRegion = possibleRegion;
2217
- break;
2218
- }
2219
- }
2220
- }
2221
- } else {
2222
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2223
- if (regCity) this.formStore[whichForm].registrationCity = regCity;
2224
-
2225
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2226
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2227
- if (regRegion) this.formStore[whichForm].registrationRegion = regRegion;
2228
- }
2229
- }
2230
- }
2231
-
2232
- if (this.formStore[whichForm].registrationCity.nameRu === null && this.formStore[whichForm].registrationRegion.nameRu === null) {
2233
- const regCity = this.cities.find(
2234
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2235
- );
2236
- if (regCity) {
2237
- this.formStore[whichForm].registrationCity = regCity;
2238
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2239
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2240
- } else {
2241
- const regRegion = this.regions.find(
2242
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2243
- );
2244
- if (regRegion) {
2245
- this.formStore[whichForm].registrationRegion = regRegion;
2246
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2247
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2248
- }
2249
- }
2250
- }
2251
-
2252
- if (person.regAddress.street.includes(', ')) {
2253
- const personAddress = person.regAddress.street.split(', ');
2254
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2255
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2256
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2257
- if (microDistrict) this.formStore[whichForm].registrationMicroDistrict = microDistrict;
2258
- if (quarter) this.formStore[whichForm].registrationQuarter = quarter;
2259
- if (street) this.formStore[whichForm].registrationStreet = street;
2260
- } else {
2261
- if (person.regAddress.street) this.formStore[whichForm].registrationStreet = person.regAddress.street;
2262
- }
2263
- if (person.regAddress.building) this.formStore[whichForm].registrationNumberHouse = person.regAddress.building;
2264
- if (person.regAddress.flat) this.formStore[whichForm].registrationNumberApartment = person.regAddress.flat;
2265
-
2266
- // TODO Доработать логику и для остальных
2267
- if ('length' in person.documents.document) {
2268
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2269
- if (validDocument) {
2270
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2271
- if (documentType) this.formStore[whichForm].documentType = documentType;
2272
-
2273
- this.formStore[whichForm].documentNumber = validDocument.number;
2274
- this.formStore[whichForm].documentExpire = reformatDate(validDocument.endDate);
2275
- this.formStore[whichForm].documentDate = reformatDate(validDocument.beginDate);
2276
- this.formStore[whichForm].documentNumber = validDocument.number;
2277
-
2278
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2279
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2280
- }
2281
- } else {
2282
- const documentType =
2283
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2284
- ? this.documentTypes.find(i => i.ids === '1UDL')
2285
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2286
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2287
- : new Value();
2288
- if (documentType) this.formStore[whichForm].documentType = documentType;
2289
-
2290
- const documentNumber = person.documents.document.number;
2291
- if (documentNumber) this.formStore[whichForm].documentNumber = documentNumber;
2292
-
2293
- const documentDate = person.documents.document.beginDate;
2294
- if (documentDate) this.formStore[whichForm].documentDate = reformatDate(documentDate);
2295
-
2296
- const documentExpire = person.documents.document.endDate;
2297
- if (documentExpire) this.formStore[whichForm].documentExpire = reformatDate(documentExpire);
2298
-
2299
- // TODO уточнить
2300
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2301
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2302
- }
2303
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2304
- if (economySectorCode) this.formStore[whichForm].economySectorCode = economySectorCode;
2305
- } else {
2306
- this.formStore[whichForm][whichIndex].firstName = person.name;
2307
- this.formStore[whichForm][whichIndex].lastName = person.surname;
2308
- this.formStore[whichForm][whichIndex].middleName = person.patronymic ? person.patronymic : '';
2309
- this.formStore[whichForm][whichIndex].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2310
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(person.birthDate);
2311
- this.formStore[whichForm][whichIndex].genderName = person.gender.nameRu;
2312
-
2313
- const gender = this.gender.find(i => i.id == person.gender.code);
2314
- if (gender) this.formStore[whichForm][whichIndex].gender = gender;
2315
-
2316
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2317
- if (birthPlace) this.formStore[whichForm][whichIndex].birthPlace = birthPlace;
2318
-
2319
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2320
- if (countryOfCitizenship) this.formStore[whichForm][whichIndex].countryOfCitizenship = countryOfCitizenship;
2321
-
2322
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2323
- if (regCountry) this.formStore[whichForm][whichIndex].registrationCountry = regCountry;
2324
-
2325
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2326
- if (regProvince) this.formStore[whichForm][whichIndex].registrationProvince = regProvince;
2327
-
2328
- if ('city' in person.regAddress && !!person.regAddress.city) {
2329
- if (person.regAddress.city.includes(', ')) {
2330
- const personCities = person.regAddress.city.split(', ');
2331
- for (let i = 0; i < personCities.length; ++i) {
2332
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2333
- if (possibleCity) {
2334
- this.formStore[whichForm][whichIndex].registrationCity = possibleCity;
2335
- break;
2336
- }
2337
- }
2338
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2339
- for (let i = 0; i < personCities.length; ++i) {
2340
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2341
- if (possibleRegion) {
2342
- this.formStore[whichForm][whichIndex].registrationRegion = possibleRegion;
2343
- break;
2344
- }
2345
- }
2346
- }
2347
- } else {
2348
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2349
- if (regCity) this.formStore[whichForm][whichIndex].registrationCity = regCity;
2350
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2351
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2352
- if (regRegion) this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2353
- }
2354
- }
2355
- }
2356
-
2357
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null && this.formStore[whichForm][whichIndex].registrationRegion.nameRu === null) {
2358
- const regCity = this.cities.find(
2359
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2360
- );
2361
- if (regCity) {
2362
- this.formStore[whichForm][whichIndex].registrationCity = regCity;
2363
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2364
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2365
- } else {
2366
- const regRegion = this.regions.find(
2367
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2368
- );
2369
- if (regRegion) {
2370
- this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2371
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2372
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2373
- }
2374
- }
2375
- }
2376
-
2377
- if (person.regAddress.street.includes(', ')) {
2378
- const personAddress = person.regAddress.street.split(', ');
2379
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2380
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2381
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2382
- if (microDistrict) this.formStore[whichForm][whichIndex].registrationMicroDistrict = microDistrict;
2383
- if (quarter) this.formStore[whichForm][whichIndex].registrationQuarter = quarter;
2384
- if (street) this.formStore[whichForm][whichIndex].registrationStreet = street;
2385
- } else {
2386
- if (person.regAddress.street) this.formStore[whichForm][whichIndex].registrationStreet = person.regAddress.street;
2387
- }
2388
- if (person.regAddress.building) this.formStore[whichForm][whichIndex].registrationNumberHouse = person.regAddress.building;
2389
- if (person.regAddress.flat) this.formStore[whichForm][whichIndex].registrationNumberApartment = person.regAddress.flat;
2390
-
2391
- // TODO Доработать логику и для остальных
2392
- if ('length' in person.documents.document) {
2393
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2394
- if (validDocument) {
2395
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2396
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2397
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2398
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(validDocument.endDate);
2399
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(validDocument.beginDate);
2400
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2401
-
2402
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2403
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2404
- }
2405
- } else {
2406
- const documentType =
2407
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2408
- ? this.documentTypes.find(i => i.ids === '1UDL')
2409
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2410
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2411
- : new Value();
2412
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2413
-
2414
- const documentNumber = person.documents.document.number;
2415
- if (documentNumber) this.formStore[whichForm][whichIndex].documentNumber = documentNumber;
2416
-
2417
- const documentDate = person.documents.document.beginDate;
2418
- if (documentDate) this.formStore[whichForm][whichIndex].documentDate = reformatDate(documentDate);
2419
-
2420
- const documentExpire = person.documents.document.endDate;
2421
- if (documentExpire) this.formStore[whichForm][whichIndex].documentExpire = reformatDate(documentExpire);
2422
-
2423
- // TODO уточнить
2424
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2425
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2426
- }
2427
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2428
- if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
2429
- }
2430
- },
2431
- hasJobSection(whichForm) {
2432
- switch (whichForm) {
2433
- case this.formStore.beneficiaryFormKey:
2434
- case this.formStore.beneficialOwnerFormKey:
2435
- case this.formStore.policyholdersRepresentativeFormKey:
2436
- return false;
2437
- default:
2438
- return true;
2439
- }
2440
- },
2441
- hasBirthSection(whichForm) {
2442
- if (this.isGons) return false;
2443
- switch (whichForm) {
2444
- case this.formStore.beneficiaryFormKey:
2445
- return false;
2446
- default:
2447
- return true;
2448
- }
2449
- },
2450
- hasPlaceSection(whichForm) {
2451
- switch (whichForm) {
2452
- default:
2453
- return true;
2454
- }
2455
- },
2456
- hasDocumentSection(whichForm) {
2457
- switch (whichForm) {
2458
- default:
2459
- return true;
2460
- }
2461
- },
2462
- hasContactSection(whichForm) {
2463
- if (this.isGons) return false;
2464
- switch (whichForm) {
2465
- default:
2466
- return true;
2467
- }
2468
- },
2469
- },
2470
- });
2471
-
2472
- export const useContragentStore = defineStore('contragent', {
2473
- state: () => ({
2474
- ...new Contragent(),
2475
- formatDate: new Contragent().formatDate,
2476
- getDateByKey: new Contragent().getDateByKey,
2477
- getBirthDate: new Contragent().getBirthDate,
2478
- getDocumentExpireDate: new Contragent().getDocumentExpireDate,
2479
- getDocumentDate: new Contragent().getDocumentDate,
2480
- getAgeByBirthDate: new Contragent().getAgeByBirthDate,
2481
- }),
2482
- });