hl-core 0.0.8-beta.2 → 0.0.8-beta.21

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 (43) hide show
  1. package/api/index.ts +42 -14
  2. package/api/interceptors.ts +1 -1
  3. package/components/Dialog/Dialog.vue +6 -3
  4. package/components/Form/FormBlock.vue +63 -28
  5. package/components/Form/FormSection.vue +4 -1
  6. package/components/Form/ManagerAttachment.vue +196 -0
  7. package/components/Form/ProductConditionsBlock.vue +64 -12
  8. package/components/Input/Datepicker.vue +5 -1
  9. package/components/Input/FormInput.vue +20 -4
  10. package/components/Input/PanelInput.vue +5 -0
  11. package/components/Layout/Drawer.vue +1 -0
  12. package/components/Layout/Header.vue +40 -4
  13. package/components/Layout/SettingsPanel.vue +35 -8
  14. package/components/Menu/MenuHover.vue +30 -0
  15. package/components/Menu/MenuNav.vue +28 -11
  16. package/components/Pages/Anketa.vue +19 -15
  17. package/components/Pages/Auth.vue +147 -30
  18. package/components/Pages/InvoiceInfo.vue +30 -0
  19. package/components/Pages/MemberForm.vue +284 -89
  20. package/components/Pages/ProductConditions.vue +291 -7
  21. package/components/Panel/PanelHandler.vue +74 -1
  22. package/components/Utilities/JsonViewer.vue +27 -0
  23. package/composables/classes.ts +128 -23
  24. package/composables/constants.ts +12 -1
  25. package/composables/index.ts +5 -1
  26. package/composables/styles.ts +9 -3
  27. package/configs/i18n.ts +19 -0
  28. package/layouts/default.vue +2 -2
  29. package/locales/en.json +560 -0
  30. package/locales/kz.json +560 -0
  31. package/locales/ru.json +560 -0
  32. package/nuxt.config.ts +8 -0
  33. package/package.json +7 -2
  34. package/pages/500.vue +1 -1
  35. package/pages/Token.vue +51 -0
  36. package/plugins/helperFunctionsPlugins.ts +2 -0
  37. package/plugins/storePlugin.ts +0 -1
  38. package/plugins/vuetifyPlugin.ts +8 -1
  39. package/store/data.store.js +475 -530
  40. package/store/member.store.ts +120 -15
  41. package/store/rules.js +27 -3
  42. package/types/index.ts +34 -0
  43. package/store/messages.ts +0 -434
@@ -1,6 +1,6 @@
1
1
  import { defineStore } from 'pinia';
2
- import { t } from './messages';
3
2
  import { rules } from './rules';
3
+ import { i18n } from '@/configs/i18n';
4
4
  import { Toast, Types, Positions, ToastOptions } from './toast';
5
5
  import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate } from '../composables';
6
6
  import { DataStoreClass, Contragent } from '../composables/classes';
@@ -10,7 +10,7 @@ import { useFormStore } from './form.store';
10
10
  export const useDataStore = defineStore('data', {
11
11
  state: () => ({
12
12
  ...new DataStoreClass(),
13
- t: t,
13
+ t: i18n.t,
14
14
  rules: rules,
15
15
  toast: Toast,
16
16
  toastTypes: Types,
@@ -31,6 +31,9 @@ export const useDataStore = defineStore('data', {
31
31
  }),
32
32
  getters: {
33
33
  isEFO: state => state.product === 'efo',
34
+ isAML: state => state.product === 'aml',
35
+ isLKA: state => state.product === 'lka',
36
+ isBridge: state => state.product === 'efo' || state.product === 'aml' || state.product === 'lka',
34
37
  isBaiterek: state => state.product === 'baiterek',
35
38
  isBolashak: state => state.product === 'bolashak',
36
39
  isMycar: state => state.product === 'mycar',
@@ -38,6 +41,8 @@ export const useDataStore = defineStore('data', {
38
41
  isLiferenta: state => state.product === 'liferenta',
39
42
  isPension: state => state.product === 'pension',
40
43
  isGons: state => state.product === 'gons',
44
+ isKazyna: state => state.product === 'halykkazyna',
45
+ isComplianceWindow: state => state.product === 'compliance',
41
46
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
42
47
  },
43
48
  actions: {
@@ -62,7 +67,7 @@ export const useDataStore = defineStore('data', {
62
67
  },
63
68
  copyToClipboard(text) {
64
69
  if (typeof text === 'string' || typeof text === 'number') {
65
- if (this.isEFO) {
70
+ if (this.isBridge) {
66
71
  navigator.clipboard.writeText(text);
67
72
  } else {
68
73
  this.sendToParent(constants.postActions.clipboard, text);
@@ -107,17 +112,30 @@ export const useDataStore = defineStore('data', {
107
112
  this.refreshToken = response.refreshToken;
108
113
  this.getUserRoles();
109
114
  }
115
+ const checkPermission = () => {
116
+ if (this.isAML) {
117
+ return this.isCompliance() || this.isAdmin() || this.isSupport() || this.isAnalyst();
118
+ }
119
+ if (this.isLKA) {
120
+ return this.isAgent() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn();
121
+ }
122
+ if (this.isEFO) {
123
+ return (
124
+ this.isInitiator() ||
125
+ this.isUnderwriter() ||
126
+ this.isAdmin() ||
127
+ this.isCompliance() ||
128
+ this.isAnalyst() ||
129
+ this.isUpk() ||
130
+ this.isFinCenter() ||
131
+ this.isSupervisor() ||
132
+ this.isSupport()
133
+ );
134
+ }
135
+ return false;
136
+ };
110
137
  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();
138
+ const hasPermission = checkPermission();
121
139
  if (hasPermission) {
122
140
  localStorage.setItem('accessToken', this.accessToken);
123
141
  localStorage.setItem('refreshToken', this.refreshToken);
@@ -150,6 +168,9 @@ export const useDataStore = defineStore('data', {
150
168
  }
151
169
  }
152
170
  },
171
+ getUserData() {
172
+ return this.accessToken ? jwtDecode(this.accessToken) : null;
173
+ },
153
174
  isRole(whichRole) {
154
175
  if (this.user.roles.length === 0) {
155
176
  this.getUserRoles();
@@ -196,8 +217,8 @@ export const useDataStore = defineStore('data', {
196
217
  isSupport() {
197
218
  return this.isRole(constants.roles.support);
198
219
  },
199
- isFinanceCenter() {
200
- return this.isRole(constants.roles.financeCenter);
220
+ isFinCenter() {
221
+ return this.isRole(constants.roles.finCenter);
201
222
  },
202
223
  isSupervisor() {
203
224
  return this.isRole(constants.roles.supervisor);
@@ -205,6 +226,20 @@ export const useDataStore = defineStore('data', {
205
226
  isProcessEditable(statusCode) {
206
227
  return !!constants.editableStatuses.find(status => status === statusCode);
207
228
  },
229
+ isProcessReturnable(statusCode) {
230
+ const getReturnableStatuses = () => {
231
+ const defaultStatuses = constants.returnStatementStatuses;
232
+ return defaultStatuses;
233
+ };
234
+ return !!getReturnableStatuses().find(status => status === statusCode);
235
+ },
236
+ isProcessCancel(statusCode) {
237
+ const getCanceleStatuses = () => {
238
+ const defaultStatuses = constants.cancelApplicationStatuses;
239
+ return defaultStatuses;
240
+ };
241
+ return !!getCanceleStatuses().find(status => status === statusCode);
242
+ },
208
243
  isTask() {
209
244
  return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
210
245
  },
@@ -303,7 +338,7 @@ export const useDataStore = defineStore('data', {
303
338
  }
304
339
  }
305
340
  },
306
- async getContragent(member, whichForm, whichIndex, load = true) {
341
+ async getContragent(member, load = true) {
307
342
  if (load) {
308
343
  this.isLoading = true;
309
344
  }
@@ -318,10 +353,10 @@ export const useDataStore = defineStore('data', {
318
353
  response = await this.api.getContragent(queryData);
319
354
  if (response.totalItems > 0) {
320
355
  if (response.totalItems.length === 1) {
321
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
356
+ await this.serializeContragentData(member, response.items[0]);
322
357
  } else {
323
358
  const sortedByRegistrationDate = response.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
324
- await this.serializeContragentData(whichForm, sortedByRegistrationDate[0], whichIndex);
359
+ await this.serializeContragentData(member, sortedByRegistrationDate[0]);
325
360
  }
326
361
  member.gotFromInsis = true;
327
362
  } else {
@@ -339,14 +374,15 @@ export const useDataStore = defineStore('data', {
339
374
  this.isLoading = true;
340
375
  }
341
376
  try {
377
+ const member = whichIndex === null ? this.formStore[whichForm] : this.formStore[whichForm][whichIndex];
342
378
  if (this.isMycar && this.isAgentMycar() && whichForm === this.formStore.beneficiaryFormKey) {
343
- await this.serializeContragentData(whichForm, this.formStore.applicationData.beneficiaryApp[0], whichIndex);
379
+ await this.serializeContragentData(member, this.formStore.applicationData.beneficiaryApp[0]);
344
380
  this.isLoading = false;
345
381
  return;
346
382
  }
347
383
  const response = await this.api.getContragentById(id);
348
384
  if (response.totalItems > 0) {
349
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
385
+ await this.serializeContragentData(member, response.items[0]);
350
386
  } else {
351
387
  this.isLoading = false;
352
388
  return false;
@@ -358,58 +394,35 @@ export const useDataStore = defineStore('data', {
358
394
  this.isLoading = false;
359
395
  }
360
396
  },
361
- async serializeContragentData(whichForm, contragent, whichIndex = null) {
397
+ async serializeContragentData(member, contragent) {
362
398
  const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
363
399
  this.api.getContrAgentData(contragent.id),
364
400
  this.api.getContrAgentContacts(contragent.id),
365
401
  this.api.getContrAgentDocuments(contragent.id),
366
402
  this.api.getContrAgentAddress(contragent.id),
367
403
  ]);
368
- if (whichIndex === null) {
369
- this.formStore[whichForm].response = {
370
- contragent: contragent,
371
- };
372
- if (data && data.length) {
373
- this.formStore[whichForm].response.questionnaires = data;
374
- }
375
- if (contacts && contacts.length) {
376
- this.formStore[whichForm].response.contacts = contacts;
377
- }
378
- if (documents && documents.length) {
379
- this.formStore[whichForm].response.documents = documents;
380
- }
381
- if (address && address.length) {
382
- this.formStore[whichForm].response.addresses = address;
383
- }
404
+ member.response = {
405
+ contragent: contragent,
406
+ };
407
+ if (data && data.length) {
408
+ member.response.questionnaires = data;
384
409
  }
385
- if (whichIndex !== null) {
386
- this.formStore[whichForm][whichIndex].response = {
387
- contragent: contragent,
388
- };
389
- if (data && data.length) {
390
- this.formStore[whichForm][whichIndex].response.questionnaires = data;
391
- }
392
- if (contacts && contacts.length) {
393
- this.formStore[whichForm][whichIndex].response.contacts = contacts;
394
- }
395
- if (documents && documents.length) {
396
- this.formStore[whichForm][whichIndex].response.documents = documents;
397
- }
398
- if (address && address.length) {
399
- this.formStore[whichForm][whichIndex].response.addresses = address;
400
- }
401
- }
402
- this.parseContragent(
403
- whichForm,
404
- {
405
- personalData: contragent,
406
- documents: documents,
407
- contacts: contacts,
408
- data: data,
409
- address: address,
410
- },
411
- whichIndex,
412
- );
410
+ if (contacts && contacts.length) {
411
+ member.response.contacts = contacts;
412
+ }
413
+ if (documents && documents.length) {
414
+ member.response.documents = documents;
415
+ }
416
+ if (address && address.length) {
417
+ member.response.addresses = address;
418
+ }
419
+ this.parseContragent(member, {
420
+ personalData: contragent,
421
+ documents: documents,
422
+ contacts: contacts,
423
+ data: data,
424
+ address: address,
425
+ });
413
426
  },
414
427
  async searchContragent(iin) {
415
428
  this.isLoading = true;
@@ -432,142 +445,80 @@ export const useDataStore = defineStore('data', {
432
445
  }
433
446
  this.isLoading = false;
434
447
  },
435
- parseContragent(whichForm, user, whichIndex = null) {
436
- if (whichIndex === null) {
437
- // Save User Personal Data
438
- this.formStore[whichForm].verifyType = user.personalData.verifyType;
439
- this.formStore[whichForm].verifyDate = user.personalData.verifyDate;
440
- this.formStore[whichForm].iin = reformatIin(user.personalData.iin);
441
- this.formStore[whichForm].age = user.personalData.age;
442
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
443
- this.formStore[whichForm].birthPlace = country && Object.keys(country).length ? country : new Value();
444
- this.formStore[whichForm].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
445
- this.formStore[whichForm].gender.id = user.personalData.gender;
446
- this.formStore[whichForm].birthDate = reformatDate(user.personalData.birthDate);
447
- this.formStore[whichForm].genderName = user.personalData.genderName;
448
- this.formStore[whichForm].lastName = user.personalData.lastName;
449
- this.formStore[whichForm].longName = user.personalData.longName;
450
- this.formStore[whichForm].middleName = user.personalData.middleName ? user.personalData.middleName : '';
451
- this.formStore[whichForm].firstName = user.personalData.firstName;
452
- this.formStore[whichForm].id = user.personalData.id;
453
- this.formStore[whichForm].type = user.personalData.type;
454
- this.formStore[whichForm].registrationDate = user.personalData.registrationDate;
455
- // Save User Documents Data
456
- if ('documents' in user && user.documents.length) {
457
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
458
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
459
- this.formStore[whichForm].documentType = documentType ? documentType : new Value();
460
- this.formStore[whichForm].documentNumber = user.documents[0].number;
461
- this.formStore[whichForm].documentIssuers = documentIssuer ? documentIssuer : new Value();
462
- this.formStore[whichForm].documentDate = reformatDate(user.documents[0].issueDate);
463
- this.formStore[whichForm].documentExpire = reformatDate(user.documents[0].expireDate);
464
- }
465
- // Document detail (residency, economy code, etc..)
466
- if ('data' in user && user.data.length) {
467
- user.data.forEach(dataObject => {
468
- this.searchFromList(whichForm, dataObject);
469
- });
470
- }
471
- if ('address' in user && user.address.length) {
472
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
473
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
474
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
475
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
476
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
477
- this.formStore[whichForm].registrationCountry = country ? country : new Value();
478
- this.formStore[whichForm].registrationStreet = user.address[0].streetName;
479
- this.formStore[whichForm].registrationCity = city ? city : new Value();
480
- this.formStore[whichForm].registrationNumberApartment = user.address[0].apartmentNumber;
481
- this.formStore[whichForm].registrationNumberHouse = user.address[0].blockNumber;
482
- this.formStore[whichForm].registrationProvince = province ? province : new Value();
483
- this.formStore[whichForm].registrationRegionType = localityType ? localityType : new Value();
484
- this.formStore[whichForm].registrationRegion = region ? region : new Value();
485
- this.formStore[whichForm].registrationQuarter = user.address[0].kvartal;
486
- this.formStore[whichForm].registrationMicroDistrict = user.address[0].microRaion;
487
- }
488
- if ('contacts' in user && user.contacts.length) {
489
- user.contacts.forEach(contact => {
490
- if (contact.type === 'EMAIL' && contact.value) {
491
- this.formStore[whichForm].email = contact.value;
492
- }
493
- if (contact.type === 'MOBILE' && contact.value) {
494
- let phoneNumber = contact.value.substring(1);
495
- this.formStore[whichForm].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
496
- }
497
- if (contact.type === 'HOME' && contact.value) {
498
- let homePhone = contact.value.substring(1);
499
- this.formStore[whichForm].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
500
- }
501
- });
502
- }
448
+ parseContragent(member, user) {
449
+ // Save User Personal Data
450
+ member.verifyType = user.personalData.verifyType;
451
+ member.verifyDate = user.personalData.verifyDate;
452
+ member.iin = reformatIin(user.personalData.iin);
453
+ member.age = user.personalData.age;
454
+ const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
455
+ member.birthPlace = country && Object.keys(country).length ? country : new Value();
456
+ member.gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
457
+ member.gender.id = user.personalData.gender;
458
+ member.birthDate = reformatDate(user.personalData.birthDate);
459
+ member.genderName = user.personalData.genderName;
460
+ member.lastName = user.personalData.lastName;
461
+ member.longName = user.personalData.longName;
462
+ member.middleName = user.personalData.middleName ? user.personalData.middleName : '';
463
+ member.firstName = user.personalData.firstName;
464
+ member.id = user.personalData.id;
465
+ member.type = user.personalData.type;
466
+ member.registrationDate = user.personalData.registrationDate;
467
+ // Save User Documents Data
468
+ if ('documents' in user && user.documents.length) {
469
+ member.documentsList = user.documents;
470
+ const documentByPriority = (() => {
471
+ if (this.isLifetrip) {
472
+ return user.documents.find(i => i.type === 'PS');
473
+ }
474
+ return user.documents.find(i => i.type === '1UDL');
475
+ })();
476
+ const userDocument = documentByPriority ? documentByPriority : user.documents[0];
477
+ const documentType = this.documentTypes.find(i => i.ids === userDocument.type);
478
+ const documentIssuer = this.documentIssuers.find(i => i.nameRu === userDocument.issuerNameRu);
479
+ member.documentType = documentType ? documentType : new Value();
480
+ member.documentNumber = userDocument.number;
481
+ member.documentIssuers = documentIssuer ? documentIssuer : new Value();
482
+ member.documentDate = reformatDate(userDocument.issueDate);
483
+ member.documentExpire = reformatDate(userDocument.expireDate);
484
+ }
485
+ // Document detail (residency, economy code, etc..)
486
+ if ('data' in user && user.data.length) {
487
+ user.data.forEach(dataObject => {
488
+ this.searchFromList(member, dataObject);
489
+ });
503
490
  }
504
- if (whichIndex !== null) {
505
- // Save User Personal Data
506
- this.formStore[whichForm][whichIndex].iin = reformatIin(user.personalData.iin);
507
- this.formStore[whichForm][whichIndex].verifyType = user.personalData.verifyType;
508
- this.formStore[whichForm][whichIndex].verifyDate = user.personalData.verifyDate;
509
- this.formStore[whichForm][whichIndex].age = user.personalData.age;
510
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
511
- this.formStore[whichForm][whichIndex].birthPlace = country && Object.keys(country).length ? country : new Value();
512
- this.formStore[whichForm][whichIndex].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
513
- this.formStore[whichForm][whichIndex].gender.id = user.personalData.gender;
514
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(user.personalData.birthDate);
515
- this.formStore[whichForm][whichIndex].genderName = user.personalData.genderName;
516
- this.formStore[whichForm][whichIndex].lastName = user.personalData.lastName;
517
- this.formStore[whichForm][whichIndex].longName = user.personalData.longName;
518
- this.formStore[whichForm][whichIndex].middleName = user.personalData.middleName ? user.personalData.middleName : '';
519
- this.formStore[whichForm][whichIndex].firstName = user.personalData.firstName;
520
- this.formStore[whichForm][whichIndex].id = user.personalData.id;
521
- this.formStore[whichForm][whichIndex].type = user.personalData.type;
522
- this.formStore[whichForm][whichIndex].registrationDate = user.personalData.registrationDate;
523
- // Save User Documents Data
524
- if ('documents' in user && user.documents.length) {
525
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
526
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
527
- this.formStore[whichForm][whichIndex].documentType = documentType ? documentType : new Value();
528
- this.formStore[whichForm][whichIndex].documentNumber = user.documents[0].number;
529
- this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer ? documentIssuer : new Value();
530
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(user.documents[0].issueDate);
531
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(user.documents[0].expireDate);
532
- }
533
- // Document detail (residency, economy code, etc..)
534
- if ('data' in user && user.data.length) {
535
- user.data.forEach(dataObject => {
536
- this.searchFromList(whichForm, dataObject, whichIndex);
537
- });
538
- }
539
- if ('address' in user && user.address.length) {
540
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
541
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
542
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
543
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
544
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
545
- this.formStore[whichForm][whichIndex].registrationCountry = country ? country : new Value();
546
- this.formStore[whichForm][whichIndex].registrationStreet = user.address[0].streetName;
547
- this.formStore[whichForm][whichIndex].registrationCity = city ? city : new Value();
548
- this.formStore[whichForm][whichIndex].registrationNumberApartment = user.address[0].apartmentNumber;
549
- this.formStore[whichForm][whichIndex].registrationNumberHouse = user.address[0].blockNumber;
550
- this.formStore[whichForm][whichIndex].registrationProvince = province ? province : new Value();
551
- this.formStore[whichForm][whichIndex].registrationRegionType = localityType ? localityType : new Value();
552
- this.formStore[whichForm][whichIndex].registrationRegion = region ? region : new Value();
553
- this.formStore[whichForm][whichIndex].registrationQuarter = user.address[0].kvartal;
554
- this.formStore[whichForm][whichIndex].registrationMicroDistrict = user.address[0].microRaion;
555
- }
556
- if ('contacts' in user && user.contacts.length) {
557
- user.contacts.forEach(contact => {
558
- if (contact.type === 'EMAIL' && contact.value) {
559
- this.formStore[whichForm][whichIndex].email = contact.value;
560
- }
561
- if (contact.type === 'MOBILE' && contact.value) {
562
- let phoneNumber = contact.value.substring(1);
563
- this.formStore[whichForm][whichIndex].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
564
- }
565
- if (contact.type === 'HOME' && contact.value) {
566
- let homePhone = contact.value.substring(1);
567
- this.formStore[whichForm][whichIndex].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
568
- }
569
- });
570
- }
491
+ if ('address' in user && user.address.length) {
492
+ const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address[0].countryName, 'i')));
493
+ const province = this.states.find(i => i.ids === user.address[0].stateCode);
494
+ const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
495
+ const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
496
+ const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
497
+ member.registrationCountry = country ? country : new Value();
498
+ member.registrationStreet = user.address[0].streetName;
499
+ member.registrationCity = city ? city : new Value();
500
+ member.registrationNumberApartment = user.address[0].apartmentNumber;
501
+ member.registrationNumberHouse = user.address[0].blockNumber;
502
+ member.registrationProvince = province ? province : new Value();
503
+ member.registrationRegionType = localityType ? localityType : new Value();
504
+ member.registrationRegion = region ? region : new Value();
505
+ member.registrationQuarter = user.address[0].kvartal;
506
+ member.registrationMicroDistrict = user.address[0].microRaion;
507
+ }
508
+ if ('contacts' in user && user.contacts.length) {
509
+ user.contacts.forEach(contact => {
510
+ if (contact.type === 'EMAIL' && contact.value) {
511
+ member.email = contact.value;
512
+ }
513
+ if (contact.type === 'MOBILE' && contact.value) {
514
+ let phoneNumber = contact.value.substring(1);
515
+ member.phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
516
+ }
517
+ if (contact.type === 'HOME' && contact.value) {
518
+ let homePhone = contact.value.substring(1);
519
+ member.homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
520
+ }
521
+ });
571
522
  }
572
523
  },
573
524
  async alreadyInInsis(iin, firstName, lastName, middleName) {
@@ -633,7 +584,7 @@ export const useDataStore = defineStore('data', {
633
584
  gender: user.gender.id,
634
585
  genderName: user.genderName ? user.genderName : user.gender.nameRu,
635
586
  birthPlace: user.birthPlace.nameRu,
636
- age: user.age,
587
+ age: Number(user.age),
637
588
  registrationDate: user.registrationDate,
638
589
  verifyType: user.verifyType,
639
590
  verifyDate: user.verifyDate,
@@ -658,7 +609,7 @@ export const useDataStore = defineStore('data', {
658
609
  questName = 'Страна налогового резиденства';
659
610
  }
660
611
  return {
661
- id: 'response' in user && 'questionnaires' in user.response ? user.response.questionnaires?.find(i => i.questId == questionId).id : question.id,
612
+ id: 'response' in user && user.response && 'questionnaires' in user.response ? user.response.questionnaires?.find(i => i.questId == questionId).id : question.id,
662
613
  contragentId: user.id,
663
614
  questAnswer: question.ids,
664
615
  questId: questionId,
@@ -669,7 +620,7 @@ export const useDataStore = defineStore('data', {
669
620
  if (user.countryOfTaxResidency.ids !== '500014.3') {
670
621
  user.addTaxResidency = new Value();
671
622
  }
672
- const addTaxResidency = 'response' in user && 'questionnaires' in user.response && user.response.questionnaires.find(i => i.questId === '507777');
623
+ const addTaxResidency = 'response' in user && user.response && 'questionnaires' in user.response && user.response.questionnaires.find(i => i.questId === '507777');
673
624
  if (user.addTaxResidency.nameRu !== null) {
674
625
  questionariesData.push({
675
626
  id: addTaxResidency ? addTaxResidency.id : 0,
@@ -697,17 +648,21 @@ export const useDataStore = defineStore('data', {
697
648
  if (user.phoneNumber !== '' && user.phoneNumber !== null) {
698
649
  contactsData.push({
699
650
  contragentId: user.id,
700
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').id : 0,
651
+ id: 'response' in user && user.response && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').id : 0,
701
652
  newValue: '',
702
653
  note: '',
703
654
  primaryFlag: 'Y',
704
655
  type: 'MOBILE',
705
656
  typeName: 'Сотовый телефон',
706
657
  value: formatPhone(user.phoneNumber),
707
- verifyType: user.otpTokenId ? 'BMG' : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType : null,
658
+ verifyType: user.otpTokenId
659
+ ? 'BMG'
660
+ : 'response' in user && user.response && 'contacts' in user.response
661
+ ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType
662
+ : null,
708
663
  verifyDate: user.otpTokenId
709
664
  ? this.currentDate()
710
- : 'response' in user && 'contacts' in user.response
665
+ : 'response' in user && user.response && 'contacts' in user.response
711
666
  ? user.response.contacts.find(i => i.type === 'MOBILE').verifyDate
712
667
  : null,
713
668
  });
@@ -715,19 +670,19 @@ export const useDataStore = defineStore('data', {
715
670
  if (user.email !== '' && user.email !== null) {
716
671
  contactsData.push({
717
672
  contragentId: user.id,
718
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').id : 0,
673
+ id: 'response' in user && user.response && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').id : 0,
719
674
  newValue: '',
720
675
  note: '',
721
676
  primaryFlag: 'N',
722
677
  type: 'EMAIL',
723
678
  typeName: 'E-Mail',
724
- value: user.email ? user.email : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').value : '',
679
+ value: user.email ? user.email : 'response' in user && user.response && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').value : '',
725
680
  });
726
681
  }
727
682
  if (user.homePhone !== '' && user.homePhone !== null) {
728
683
  contactsData.push({
729
684
  contragentId: user.id,
730
- id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'HOME').id : 0,
685
+ id: 'response' in user && user.response && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'HOME').id : 0,
731
686
  newValue: '',
732
687
  note: '',
733
688
  primaryFlag: 'N',
@@ -735,17 +690,18 @@ export const useDataStore = defineStore('data', {
735
690
  typeName: 'Домашний телефон',
736
691
  value: user.homePhone
737
692
  ? formatPhone(user.homePhone)
738
- : 'response' in user && 'contacts' in user.response
693
+ : 'response' in user && user.response && 'contacts' in user.response
739
694
  ? user.response.contacts.find(i => i.type === 'HOME').value
740
695
  : '',
741
696
  });
742
697
  }
743
698
 
744
699
  // ! SaveContragent -> Documents
745
- let documentsData = [];
746
- documentsData.push({
700
+ let documentsData = user.documentsList;
701
+ const hasAlreadyDocument = documentsData.findIndex(i => i.type === user.documentType.ids && i.number === user.documentNumber);
702
+ const userDocument = {
747
703
  contragentId: user.id,
748
- id: 'response' in user && 'documents' in user.response ? user.response.documents[0].id : 0,
704
+ id: hasAlreadyDocument !== -1 ? documentsData[hasAlreadyDocument].id : 0,
749
705
  description: null,
750
706
  expireDate: user.getDateByKey('documentExpire'),
751
707
  issueDate: user.getDateByKey('documentDate'),
@@ -759,15 +715,21 @@ export const useDataStore = defineStore('data', {
759
715
  serial: null,
760
716
  verifyType: user.verifyType,
761
717
  verifyDate: user.verifyDate,
762
- });
718
+ };
719
+ if (hasAlreadyDocument !== -1) {
720
+ documentsData[hasAlreadyDocument] = userDocument;
721
+ } else {
722
+ documentsData.push(userDocument);
723
+ }
763
724
 
764
725
  // ! SaveContragent -> Addresses
726
+ const checkForNull = value => (value ? value : '');
765
727
  let addressData = [];
766
728
  addressData.push({
767
- id: 'response' in user && 'addresses' in user.response ? user.response.addresses[0].id : 0,
729
+ id: 'response' in user && user.response && 'addresses' in user.response ? user.response.addresses[0].id : 0,
768
730
  contragentId: user.id,
769
- countryCode: user.birthPlace.ids,
770
- countryName: user.birthPlace.nameRu,
731
+ countryCode: user.registrationCountry.ids,
732
+ countryName: user.registrationCountry.nameRu,
771
733
  stateCode: user.registrationProvince.ids,
772
734
  stateName: user.registrationProvince.nameRu,
773
735
  cityCode: user.registrationCity.code,
@@ -777,11 +739,13 @@ export const useDataStore = defineStore('data', {
777
739
  streetName: user.registrationStreet,
778
740
  kvartal: user.registrationQuarter,
779
741
  microRaion: user.registrationMicroDistrict,
780
- cityTypeId: Number(user.registrationRegionType.ids),
742
+ cityTypeId: Number(user.registrationRegionType.ids) > 0 ? Number(user.registrationRegionType.ids) : null,
781
743
  cityTypeName: user.registrationRegionType.nameRu,
782
744
  blockNumber: user.registrationNumberHouse,
783
745
  apartmentNumber: user.registrationNumberApartment,
784
- address: `${user.birthPlace.nameRu}, ${user.registrationRegionType.nameRu} ${user.registrationCity.nameRu}, ул. ${user.registrationStreet}, д. ${user.registrationNumberHouse} кв. ${user.registrationNumberApartment}`,
746
+ address: `${checkForNull(user.registrationCountry.nameRu)}, ${checkForNull(user.registrationRegionType.nameRu)} ${checkForNull(
747
+ user.registrationCity.nameRu,
748
+ )}, ул. ${checkForNull(user.registrationStreet)}, д. ${checkForNull(user.registrationNumberHouse)} кв. ${checkForNull(user.registrationNumberApartment)}`,
785
749
  type: 'H',
786
750
  });
787
751
 
@@ -794,9 +758,11 @@ export const useDataStore = defineStore('data', {
794
758
  };
795
759
 
796
760
  const personId = await this.api.saveContragent(data);
797
- if (personId) {
761
+ if (personId > 0) {
798
762
  await this.getContragentById(personId, whichForm, false, whichIndex);
799
763
  user.otpTokenId = null;
764
+ } else {
765
+ return false;
800
766
  }
801
767
  } catch (err) {
802
768
  this.isLoading = false;
@@ -874,6 +840,8 @@ export const useDataStore = defineStore('data', {
874
840
  data.position = member.jobPosition;
875
841
  data.jobName = member.jobPlace;
876
842
  data.familyStatusId = member.familyStatus.id;
843
+ data.relationId = member.relationDegree.ids;
844
+ data.relationName = member.relationDegree.nameRu;
877
845
  }
878
846
  if (whichMember === 'Beneficiary') {
879
847
  if (
@@ -913,7 +881,7 @@ export const useDataStore = defineStore('data', {
913
881
  return ErrorHandler(err, err.response?.data?.errors && Object.values(err.response?.data?.errors).join(' -> '));
914
882
  }
915
883
  },
916
- searchFromList(whichForm, searchIt, whichIndex = null) {
884
+ searchFromList(member, searchIt) {
917
885
  const getQuestionariesData = () => {
918
886
  switch (searchIt.questId) {
919
887
  case '500003':
@@ -936,11 +904,7 @@ export const useDataStore = defineStore('data', {
936
904
  const [searchFrom, whichField] = getQuestionariesData();
937
905
  if (searchFrom && searchFrom.length) {
938
906
  const result = searchFrom.find(i => i.ids === searchIt.questAnswer);
939
- if (whichIndex === null) {
940
- this.formStore[whichForm][whichField] = result ? result : new Value();
941
- } else {
942
- this.formStore[whichForm][whichIndex][whichField] = result ? result : new Value();
943
- }
907
+ member[whichField] = result ? result : new Value();
944
908
  }
945
909
  },
946
910
  async setSurvey(data) {
@@ -958,14 +922,20 @@ export const useDataStore = defineStore('data', {
958
922
  async getFromApi(whichField, whichRequest, parameter, reset = false) {
959
923
  const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
960
924
  const currentHour = new Date().getHours();
925
+ const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / 15);
961
926
 
962
927
  const getDataCondition = () => {
963
928
  if (!storageValue) return true;
964
929
  const hasHourKey = 'hour' in storageValue;
930
+ const hasMiniteKey = 'minute' in storageValue;
965
931
  const hasModeKey = 'mode' in storageValue;
966
932
  const hasValueKey = 'value' in storageValue;
967
- if (storageValue && (hasHourKey === false || hasModeKey === false || hasValueKey === false)) return true;
968
- if (storageValue && (storageValue.hour !== currentHour || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)) return true;
933
+ if (storageValue && (hasHourKey === false || hasMiniteKey === false || hasModeKey === false || hasValueKey === false)) return true;
934
+ if (
935
+ storageValue &&
936
+ (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)
937
+ )
938
+ return true;
969
939
  };
970
940
  if (!!getDataCondition() || reset === true) {
971
941
  this[whichField] = [];
@@ -977,6 +947,7 @@ export const useDataStore = defineStore('data', {
977
947
  JSON.stringify({
978
948
  value: response,
979
949
  hour: currentHour,
950
+ minute: currentMinutePart,
980
951
  mode: import.meta.env.MODE,
981
952
  }),
982
953
  );
@@ -1047,16 +1018,7 @@ export const useDataStore = defineStore('data', {
1047
1018
  });
1048
1019
  },
1049
1020
  async getDicFileTypeList() {
1050
- try {
1051
- if (this.dicFileTypeList.length) {
1052
- return this.dicFileTypeList;
1053
- } else {
1054
- this.dicFileTypeList = await this.api.getDicFileTypeList();
1055
- return this.dicFileTypeList;
1056
- }
1057
- } catch (err) {
1058
- console.log(err.response.data);
1059
- }
1021
+ return await this.getFromApi('dicFileTypeList', 'getDicFileTypeList');
1060
1022
  },
1061
1023
  async getDocumentIssuers() {
1062
1024
  return await this.getFromApi('documentIssuers', 'getDocumentIssuers');
@@ -1094,6 +1056,15 @@ export const useDataStore = defineStore('data', {
1094
1056
  async getProcessTariff() {
1095
1057
  return await this.getFromApi('processTariff', 'getProcessTariff');
1096
1058
  },
1059
+ async getCurrencies() {
1060
+ try {
1061
+ const currencies = await this.api.getCurrencies();
1062
+ this.currencies = currencies;
1063
+ return currencies;
1064
+ } catch (err) {
1065
+ console.log(err);
1066
+ }
1067
+ },
1097
1068
  async getAdditionalInsuranceTermsAnswers(questionId) {
1098
1069
  try {
1099
1070
  const answers = await this.api.getAdditionalInsuranceTermsAnswers(this.processCode, questionId);
@@ -1207,6 +1178,9 @@ export const useDataStore = defineStore('data', {
1207
1178
  this.getProcessIndexRate(),
1208
1179
  this.getProcessTariff(),
1209
1180
  this.getProcessPaymentPeriod(),
1181
+ this.getDicFileTypeList(),
1182
+ this.getDictionaryItems('RegionPolicy'),
1183
+ this.getDictionaryItems('SaleChanellPolicy'),
1210
1184
  ]);
1211
1185
  },
1212
1186
  async getUserGroups() {
@@ -1254,15 +1228,12 @@ export const useDataStore = defineStore('data', {
1254
1228
  },
1255
1229
  async searchAgentByName(name) {
1256
1230
  try {
1257
- this.isLoading = true;
1258
- this.AgentDataList = await this.api.searchAgentByName(name);
1259
- if (!this.AgentDataList.length) {
1231
+ this.AgentData = await this.api.searchAgentByName(name);
1232
+ if (!this.AgentData.length) {
1260
1233
  this.showToaster('error', this.t('toaster.notFound'), 1500);
1261
1234
  }
1262
1235
  } catch (err) {
1263
1236
  console.log(err);
1264
- } finally {
1265
- this.isLoading = false;
1266
1237
  }
1267
1238
  },
1268
1239
  async setINSISWorkData() {
@@ -1291,14 +1262,14 @@ export const useDataStore = defineStore('data', {
1291
1262
  this.isLoading = false;
1292
1263
  }
1293
1264
  },
1294
- async filterManagerByRegion(dictName, filterName) {
1265
+ async getDictionaryItems(dictName) {
1266
+ return await this.getFromApi(dictName, 'getDictionaryItems', dictName);
1267
+ },
1268
+ async filterManagerByRegion(filterName) {
1295
1269
  try {
1296
- this.isLoading = true;
1297
- this[`${dictName}List`] = await this.api.filterManagerByRegion(dictName, filterName);
1270
+ this.ManagerPolicy = await this.api.filterManagerByRegion('ManagerPolicy', filterName);
1298
1271
  } catch (err) {
1299
1272
  console.log(err);
1300
- } finally {
1301
- this.isLoading = false;
1302
1273
  }
1303
1274
  },
1304
1275
  async getUnderwritingCouncilData(id) {
@@ -1324,24 +1295,18 @@ export const useDataStore = defineStore('data', {
1324
1295
  this.showToaster('success', this.t('toaster.successSaved'));
1325
1296
  return true;
1326
1297
  } catch (err) {
1327
- this.showToaster('error', this.t('toaster.error'));
1328
- return false;
1298
+ return ErrorHandler(err);
1329
1299
  } finally {
1330
1300
  this.isLoading = false;
1331
1301
  }
1332
1302
  },
1333
1303
  async sendUnderwritingCouncilTask(data) {
1334
1304
  try {
1335
- this.isLoading = true;
1336
1305
  await this.api.sendUnderwritingCouncilTask(data);
1337
1306
  this.showToaster('success', this.t('toaster.successOperation'), 5000);
1338
1307
  return true;
1339
1308
  } catch (err) {
1340
- console.log(err);
1341
- this.showToaster('error', this.t('toaster.error'), 5000);
1342
- return false;
1343
- } finally {
1344
- this.isLoading = false;
1309
+ return ErrorHandler(err);
1345
1310
  }
1346
1311
  },
1347
1312
  async definedAnswers(filter, whichSurvey, value = null, index = null) {
@@ -1394,10 +1359,19 @@ export const useDataStore = defineStore('data', {
1394
1359
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1395
1360
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1396
1361
  };
1362
+ if (this.isKazyna) {
1363
+ calculationData.premiumInCurrency = getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar);
1364
+ calculationData.amountInCurrency = getNumber(this.formStore.productConditionsForm.requestedSumInsuredInDollar);
1365
+ calculationData.currencyExchangeRate = this.currencies.usd;
1366
+ }
1397
1367
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
1398
1368
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1399
1369
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1400
1370
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1371
+ if (this.isKazyna) {
1372
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(calculationResponse.amountInCurrency);
1373
+ this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1374
+ }
1401
1375
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1402
1376
  } catch (err) {
1403
1377
  ErrorHandler(err);
@@ -1410,7 +1384,6 @@ export const useDataStore = defineStore('data', {
1410
1384
  this.isLoading = true;
1411
1385
  try {
1412
1386
  let form1 = {
1413
- baiterekApp: null,
1414
1387
  policyAppDto: {
1415
1388
  id: this.formStore.applicationData.policyAppDto.id,
1416
1389
  processInstanceId: this.formStore.applicationData.policyAppDto.processInstanceId,
@@ -1440,7 +1413,11 @@ export const useDataStore = defineStore('data', {
1440
1413
  },
1441
1414
  addCoversDto: this.formStore.additionalInsuranceTerms,
1442
1415
  };
1443
-
1416
+ if (this.isKazyna) {
1417
+ form1.policyAppDto.premiumInCurrency = getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar);
1418
+ form1.policyAppDto.amountInCurrency = getNumber(this.formStore.productConditionsForm.requestedSumInsuredInDollar);
1419
+ form1.policyAppDto.currencyExchangeRate = this.currencies.usd;
1420
+ }
1444
1421
  try {
1445
1422
  let id = this.formStore.applicationData.processInstanceId;
1446
1423
 
@@ -1455,6 +1432,9 @@ export const useDataStore = defineStore('data', {
1455
1432
  const applicationData = await this.api.getApplicationData(taskId);
1456
1433
  this.formStore.applicationData = applicationData;
1457
1434
  this.formStore.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
1435
+ if (this.isKazyna) {
1436
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(result / this.currencies.usd);
1437
+ }
1458
1438
  if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
1459
1439
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result);
1460
1440
  } else {
@@ -1524,6 +1504,12 @@ export const useDataStore = defineStore('data', {
1524
1504
  const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
1525
1505
  this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
1526
1506
 
1507
+ if ('finCenterData' in applicationData && !!applicationData.finCenterData) {
1508
+ this.formStore.finCenterData = applicationData.finCenterData;
1509
+ this.formStore.finCenterData.regNumber = applicationData.finCenterData.regNumber;
1510
+ this.formStore.finCenterData.date = reformatDate(applicationData.finCenterData.date);
1511
+ }
1512
+
1527
1513
  if (fetchMembers) {
1528
1514
  let allMembers = [
1529
1515
  {
@@ -1592,6 +1578,8 @@ export const useDataStore = defineStore('data', {
1592
1578
  this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
1593
1579
  if (insuredData && insuredData.length) {
1594
1580
  insuredData.forEach((each, index) => {
1581
+ const relationDegree = this.relations.find(i => i.ids == each.relationId);
1582
+ this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1595
1583
  this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1596
1584
  });
1597
1585
  }
@@ -1654,7 +1642,10 @@ export const useDataStore = defineStore('data', {
1654
1642
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
1655
1643
  applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
1656
1644
  );
1657
-
1645
+ if (this.isKazyna) {
1646
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.amountInCurrency);
1647
+ this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.premiumInCurrency);
1648
+ }
1658
1649
  let riskGroup = this.riskGroup.find(item => {
1659
1650
  if (applicationData.policyAppDto.riskGroup == 0) {
1660
1651
  return true;
@@ -1675,6 +1666,13 @@ export const useDataStore = defineStore('data', {
1675
1666
  this.isLoading = false;
1676
1667
  }
1677
1668
  },
1669
+ async getProcessHistoryLog(taskId) {
1670
+ try {
1671
+ return await this.api.getProcessHistoryLog(taskId);
1672
+ } catch (err) {
1673
+ ErrorHandler(err);
1674
+ }
1675
+ },
1678
1676
  async setApplication() {
1679
1677
  try {
1680
1678
  await this.api.setApplication(this.formStore.applicationData);
@@ -1716,6 +1714,7 @@ export const useDataStore = defineStore('data', {
1716
1714
  },
1717
1715
  async handleTask(action, taskId, comment) {
1718
1716
  if (action && Object.keys(constants.actions).includes(action)) {
1717
+ this.isButtonsLoading = true;
1719
1718
  switch (action) {
1720
1719
  case constants.actions.claim: {
1721
1720
  try {
@@ -1726,6 +1725,7 @@ export const useDataStore = defineStore('data', {
1726
1725
  } catch (err) {
1727
1726
  ErrorHandler(err);
1728
1727
  }
1728
+ break;
1729
1729
  }
1730
1730
  case constants.actions.reject:
1731
1731
  case constants.actions.return:
@@ -1735,7 +1735,22 @@ export const useDataStore = defineStore('data', {
1735
1735
  const sended = await this.sendTask(taskId, action, comment);
1736
1736
  if (!sended) return;
1737
1737
  this.formStore.$reset();
1738
- if (this.isEFO) {
1738
+ if (this.isEFO || this.isAML) {
1739
+ await this.router.push({ name: 'Insurance-Product' });
1740
+ } else {
1741
+ this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
1742
+ }
1743
+ } catch (err) {
1744
+ ErrorHandler(err);
1745
+ }
1746
+ break;
1747
+ }
1748
+ case constants.actions.affiliate: {
1749
+ try {
1750
+ const sended = await this.sendUnderwritingCouncilTask({ taskId: taskId, decision: constants.actions.accept });
1751
+ if (!sended) return;
1752
+ this.formStore.$reset();
1753
+ if (this.isEFO || this.isAML) {
1739
1754
  await this.router.push({ name: 'Insurance-Product' });
1740
1755
  } else {
1741
1756
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1743,8 +1758,10 @@ export const useDataStore = defineStore('data', {
1743
1758
  } catch (err) {
1744
1759
  ErrorHandler(err);
1745
1760
  }
1761
+ break;
1746
1762
  }
1747
1763
  }
1764
+ this.isButtonsLoading = false;
1748
1765
  } else {
1749
1766
  console.error('No handleTask action');
1750
1767
  }
@@ -1753,6 +1770,7 @@ export const useDataStore = defineStore('data', {
1753
1770
  try {
1754
1771
  const response = await this.api.getInvoiceData(processInstanceId);
1755
1772
  if (response) {
1773
+ this.formStore.invoiceData = response;
1756
1774
  return response;
1757
1775
  } else {
1758
1776
  return false;
@@ -1820,10 +1838,18 @@ export const useDataStore = defineStore('data', {
1820
1838
  if (this.formStore.signUrls.length) {
1821
1839
  return this.formStore.signUrls;
1822
1840
  }
1823
- const data = [
1824
- { processInstanceId: this.formStore.applicationData.processInstanceId, name: 'Agreement', format: 'pdf' },
1825
- { processInstanceId: this.formStore.applicationData.processInstanceId, name: 'Statement', format: 'pdf' },
1826
- ];
1841
+ const prepareSignDocuments = () => {
1842
+ switch (this.formStore.applicationData.statusCode) {
1843
+ case 'ContractSignedFrom':
1844
+ return [{ processInstanceId: this.formStore.applicationData.processInstanceId, name: 'Contract', format: 'pdf' }];
1845
+ default:
1846
+ return [
1847
+ { processInstanceId: this.formStore.applicationData.processInstanceId, name: 'Agreement', format: 'pdf' },
1848
+ { processInstanceId: this.formStore.applicationData.processInstanceId, name: 'Statement', format: 'pdf' },
1849
+ ];
1850
+ }
1851
+ };
1852
+ const data = prepareSignDocuments();
1827
1853
  const result = await this.api.signDocument(data);
1828
1854
  this.formStore.signUrls = result;
1829
1855
  return this.formStore.signUrls;
@@ -1831,6 +1857,22 @@ export const useDataStore = defineStore('data', {
1831
1857
  ErrorHandler(err);
1832
1858
  }
1833
1859
  },
1860
+ async registerNumber() {
1861
+ try {
1862
+ this.isLoading = true;
1863
+ const data = {
1864
+ processInstanceId: this.formStore.applicationData.processInstanceId,
1865
+ regNumber: this.formStore.finCenterData.regNumber,
1866
+ date: formatDate(this.formStore.finCenterData.date),
1867
+ };
1868
+ const result = await this.api.registerNumber(data);
1869
+ return result;
1870
+ } catch (err) {
1871
+ return ErrorHandler(err);
1872
+ } finally {
1873
+ this.isLoading = false;
1874
+ }
1875
+ },
1834
1876
  async sendSMS(type, phoneNumber, text) {
1835
1877
  if (!type || !phoneNumber || !text) return;
1836
1878
  const smsData = {
@@ -1911,7 +1953,7 @@ export const useDataStore = defineStore('data', {
1911
1953
  const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
1912
1954
  const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
1913
1955
  if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
1914
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1956
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1915
1957
  return false;
1916
1958
  }
1917
1959
  if (localKey === this.formStore.beneficiaryFormKey) {
@@ -1926,15 +1968,15 @@ export const useDataStore = defineStore('data', {
1926
1968
  }
1927
1969
  } else {
1928
1970
  if (this.formStore[localKey].some(i => i.iin !== null)) {
1929
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1971
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1930
1972
  return false;
1931
1973
  }
1932
1974
  if (this.formStore.applicationData[applicationKey].length !== 0) {
1933
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1975
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1934
1976
  return false;
1935
1977
  } else {
1936
1978
  if (this.formStore[localKey][0].iin !== null) {
1937
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1979
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1938
1980
  return false;
1939
1981
  }
1940
1982
  }
@@ -1947,25 +1989,48 @@ export const useDataStore = defineStore('data', {
1947
1989
  return false;
1948
1990
  }
1949
1991
  if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
1950
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
1992
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
1951
1993
  return false;
1952
1994
  }
1953
- if (!this.isGons) {
1995
+ if (this.members.insuredApp.has) {
1954
1996
  if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
1955
1997
  return false;
1956
1998
  }
1999
+ if (this.members.insuredApp.required) {
2000
+ const inStatement = this.formStore.insuredForm.every(i => i.id > 0);
2001
+ if (inStatement === false) {
2002
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.insured') }));
2003
+ return false;
2004
+ }
2005
+ }
1957
2006
  }
1958
- if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
1959
- return false;
2007
+ if (this.members.beneficiaryApp.has) {
2008
+ if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
2009
+ return false;
2010
+ }
2011
+ if (this.members.beneficiaryApp.required) {
2012
+ const inStatement = this.formStore.beneficiaryForm.every(i => i.id > 0);
2013
+ if (inStatement === false) {
2014
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficiary') }));
2015
+ return false;
2016
+ }
2017
+ }
1960
2018
  }
1961
- if (!this.isGons) {
2019
+ if (this.members.beneficialOwnerApp.has) {
1962
2020
  if (this.formStore.isActOwnBehalf === false) {
1963
2021
  if (this.validateMultipleMembers(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
1964
2022
  return false;
1965
2023
  }
1966
2024
  }
2025
+ if (this.members.beneficialOwnerApp.required) {
2026
+ const inStatement = this.formStore.beneficialOwnerForm.every(i => i.id > 0);
2027
+ if (inStatement === false) {
2028
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficialOwner') }));
2029
+ return false;
2030
+ }
2031
+ }
1967
2032
  }
1968
- if (!this.isGons) {
2033
+ if (this.members.spokesmanApp.has) {
1969
2034
  if (this.formStore.hasRepresentative) {
1970
2035
  if (this.formStore.applicationData.spokesmanApp && this.formStore.policyholdersRepresentativeForm.id !== this.formStore.applicationData.spokesmanApp.insisId) {
1971
2036
  this.showToaster(
@@ -1978,8 +2043,15 @@ export const useDataStore = defineStore('data', {
1978
2043
  return false;
1979
2044
  }
1980
2045
  }
2046
+ if (this.members.spokesmanApp.required) {
2047
+ const inStatement = this.formStore.policyholdersRepresentativeForm.id > 0;
2048
+ if (inStatement === false) {
2049
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.spokesman') }));
2050
+ return false;
2051
+ }
2052
+ }
1981
2053
  }
1982
- if (!this.isGons) {
2054
+ if (this.controls.hasAttachment) {
1983
2055
  const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
1984
2056
  if (areValid) {
1985
2057
  await this.setINSISWorkData();
@@ -2144,313 +2216,180 @@ export const useDataStore = defineStore('data', {
2144
2216
  this.isLoading = false;
2145
2217
  }
2146
2218
  },
2147
- async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
2219
+ async getContragentFromGBDFL(member) {
2220
+ // null - ожидание
2221
+ // false - ошибка или неправильно
2222
+ // true - успешно и данные получены
2148
2223
  this.isLoading = true;
2149
2224
  try {
2150
2225
  const data = {
2151
- iin: iin.replace(/-/g, ''),
2152
- phoneNumber: formatPhone(phoneNumber),
2226
+ iin: member.iin.replace(/-/g, ''),
2227
+ phoneNumber: formatPhone(member.phoneNumber),
2153
2228
  };
2154
2229
  const gbdResponse = await this.api.getContragentFromGBDFL(data);
2155
2230
  if (gbdResponse.status === 'soap:Server') {
2156
2231
  this.showToaster('error', `${gbdResponse.statusName}. Отправьте запрос через некоторое время`, 5000);
2157
2232
  this.isLoading = false;
2158
- return;
2233
+ return false;
2159
2234
  }
2160
2235
  if (gbdResponse.status === 'PENDING') {
2161
- this.showToaster('success', this.t('toaster.waitForClient'), 5000);
2236
+ this.showToaster('info', this.t('toaster.waitForClient'), 5000);
2162
2237
  this.isLoading = false;
2163
- return;
2238
+ return null;
2164
2239
  }
2165
2240
  if (constants.gbdErrors.find(i => i === gbdResponse.status)) {
2166
2241
  if (gbdResponse.status === 'TIMEOUT') {
2167
- this.showToaster('success', `${gbdResponse.statusName}. Отправьте запрос еще раз`, 5000);
2242
+ this.showToaster('error', `${gbdResponse.statusName}. Отправьте запрос еще раз`, 5000);
2243
+ return null;
2168
2244
  } else {
2169
- this.showToaster('success', gbdResponse.statusName, 5000);
2245
+ this.showToaster('error', gbdResponse.statusName, 5000);
2170
2246
  }
2171
2247
  this.isLoading = false;
2172
- return;
2248
+ return false;
2173
2249
  }
2174
2250
  const { person } = parseXML(gbdResponse.content, true, 'person');
2175
2251
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2176
- if (typeof whichIndex !== 'number') {
2177
- if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
2178
- this.formStore[whichForm].resetMember(false);
2179
- }
2180
- this.formStore[whichForm].gosPersonData = person;
2181
- } else {
2182
- if (this.formStore[whichForm][whichIndex].gosPersonData !== null && this.formStore[whichForm][whichIndex].gosPersonData.iin !== iin.replace(/-/g, '')) {
2183
- this.formStore[whichForm][whichIndex].resetMember(false);
2184
- }
2185
- this.formStore[whichForm][whichIndex].gosPersonData = person;
2186
- }
2187
-
2188
- await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
2189
- if (typeof whichIndex !== 'number') {
2190
- this.formStore[whichForm].verifyDate = responseInfo.responseDate;
2191
- this.formStore[whichForm].verifyType = 'GBDFL';
2192
- } else {
2193
- this.formStore[whichForm][whichIndex].verifyDate = responseInfo.responseDate;
2194
- this.formStore[whichForm][whichIndex].verifyType = 'GBDFL';
2195
- }
2196
- await this.saveInStoreUserGBDFL(person, whichForm, whichIndex);
2252
+ if (member.gosPersonData !== null && member.gosPersonData.iin !== iin.replace(/-/g, '')) {
2253
+ member.resetMember(false);
2254
+ }
2255
+ member.gosPersonData = person;
2256
+ await this.getContragent(member, false);
2257
+ member.verifyDate = responseInfo.responseDate;
2258
+ member.verifyType = 'GBDFL';
2259
+ await this.saveInStoreUserGBDFL(person, member);
2260
+ return true;
2197
2261
  } catch (err) {
2198
- ErrorHandler(err);
2262
+ return ErrorHandler(err);
2263
+ } finally {
2264
+ this.isLoading = false;
2199
2265
  }
2200
- this.isLoading = false;
2201
2266
  },
2202
- async saveInStoreUserGBDFL(person, whichForm, whichIndex = null) {
2203
- if (whichIndex === null) {
2204
- this.formStore[whichForm].firstName = person.name;
2205
- this.formStore[whichForm].lastName = person.surname;
2206
- this.formStore[whichForm].middleName = person.patronymic ? person.patronymic : '';
2207
- this.formStore[whichForm].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2208
- this.formStore[whichForm].birthDate = reformatDate(person.birthDate);
2209
- this.formStore[whichForm].genderName = person.gender.nameRu;
2267
+ async saveInStoreUserGBDFL(person, member) {
2268
+ member.firstName = person.name;
2269
+ member.lastName = person.surname;
2270
+ member.middleName = person.patronymic ? person.patronymic : '';
2271
+ member.longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2272
+ member.birthDate = reformatDate(person.birthDate);
2273
+ member.genderName = person.gender.nameRu;
2210
2274
 
2211
- const gender = this.gender.find(i => i.id == person.gender.code);
2212
- if (gender) this.formStore[whichForm].gender = gender;
2275
+ const gender = this.gender.find(i => i.id == person.gender.code);
2276
+ if (gender) member.gender = gender;
2213
2277
 
2214
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2215
- if (birthPlace) this.formStore[whichForm].birthPlace = birthPlace;
2278
+ const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2279
+ if (birthPlace) member.birthPlace = birthPlace;
2216
2280
 
2217
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2218
- if (countryOfCitizenship) this.formStore[whichForm].countryOfCitizenship = countryOfCitizenship;
2281
+ const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2282
+ if (countryOfCitizenship) member.countryOfCitizenship = countryOfCitizenship;
2219
2283
 
2220
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2221
- if (regCountry) this.formStore[whichForm].registrationCountry = regCountry;
2284
+ const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2285
+ if (regCountry) member.registrationCountry = regCountry;
2222
2286
 
2223
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2224
- if (regProvince) this.formStore[whichForm].registrationProvince = regProvince;
2287
+ const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2288
+ if (regProvince) member.registrationProvince = regProvince;
2225
2289
 
2226
- if ('city' in person.regAddress && !!person.regAddress.city) {
2227
- if (person.regAddress.city.includes(', ')) {
2228
- const personCities = person.regAddress.city.split(', ');
2290
+ if ('city' in person.regAddress && !!person.regAddress.city) {
2291
+ if (person.regAddress.city.includes(', ')) {
2292
+ const personCities = person.regAddress.city.split(', ');
2293
+ for (let i = 0; i < personCities.length; ++i) {
2294
+ const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2295
+ if (possibleCity) {
2296
+ member.registrationCity = possibleCity;
2297
+ break;
2298
+ }
2299
+ }
2300
+ if (member.registrationCity.nameRu === null) {
2229
2301
  for (let i = 0; i < personCities.length; ++i) {
2230
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2231
- if (possibleCity) {
2232
- this.formStore[whichForm].registrationCity = possibleCity;
2302
+ const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2303
+ if (possibleRegion) {
2304
+ member.registrationRegion = possibleRegion;
2233
2305
  break;
2234
2306
  }
2235
2307
  }
2236
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2237
- for (let i = 0; i < personCities.length; ++i) {
2238
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2239
- if (possibleRegion) {
2240
- this.formStore[whichForm].registrationRegion = possibleRegion;
2241
- break;
2242
- }
2243
- }
2244
- }
2245
- } else {
2246
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2247
- if (regCity) this.formStore[whichForm].registrationCity = regCity;
2248
-
2249
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2250
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2251
- if (regRegion) this.formStore[whichForm].registrationRegion = regRegion;
2252
- }
2253
2308
  }
2254
- }
2309
+ } else {
2310
+ const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2311
+ if (regCity) member.registrationCity = regCity;
2255
2312
 
2256
- if (this.formStore[whichForm].registrationCity.nameRu === null && this.formStore[whichForm].registrationRegion.nameRu === null) {
2257
- const regCity = this.cities.find(
2258
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2259
- );
2260
- if (regCity) {
2261
- this.formStore[whichForm].registrationCity = regCity;
2262
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2263
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2264
- } else {
2265
- const regRegion = this.regions.find(
2266
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2267
- );
2268
- if (regRegion) {
2269
- this.formStore[whichForm].registrationRegion = regRegion;
2270
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2271
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2272
- }
2313
+ if (member.registrationCity.nameRu === null) {
2314
+ const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2315
+ if (regRegion) member.registrationRegion = regRegion;
2273
2316
  }
2274
2317
  }
2318
+ }
2275
2319
 
2276
- if (person.regAddress.street.includes(', ')) {
2277
- const personAddress = person.regAddress.street.split(', ');
2278
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2279
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2280
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2281
- if (microDistrict) this.formStore[whichForm].registrationMicroDistrict = microDistrict;
2282
- if (quarter) this.formStore[whichForm].registrationQuarter = quarter;
2283
- if (street) this.formStore[whichForm].registrationStreet = street;
2320
+ if (member.registrationCity.nameRu === null && member.registrationRegion.nameRu === null) {
2321
+ const regCity = this.cities.find(
2322
+ i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2323
+ );
2324
+ if (regCity) {
2325
+ member.registrationCity = regCity;
2326
+ const regType = this.localityTypes.find(i => i.nameRu === 'город');
2327
+ if (regType) member.registrationRegionType = regType;
2284
2328
  } else {
2285
- if (person.regAddress.street) this.formStore[whichForm].registrationStreet = person.regAddress.street;
2286
- }
2287
- if (person.regAddress.building) this.formStore[whichForm].registrationNumberHouse = person.regAddress.building;
2288
- if (person.regAddress.flat) this.formStore[whichForm].registrationNumberApartment = person.regAddress.flat;
2289
-
2290
- // TODO Доработать логику и для остальных
2291
- if ('length' in person.documents.document) {
2292
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2293
- if (validDocument) {
2294
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2295
- if (documentType) this.formStore[whichForm].documentType = documentType;
2296
-
2297
- this.formStore[whichForm].documentNumber = validDocument.number;
2298
- this.formStore[whichForm].documentExpire = reformatDate(validDocument.endDate);
2299
- this.formStore[whichForm].documentDate = reformatDate(validDocument.beginDate);
2300
- this.formStore[whichForm].documentNumber = validDocument.number;
2301
-
2302
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2303
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2329
+ const regRegion = this.regions.find(
2330
+ i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2331
+ );
2332
+ if (regRegion) {
2333
+ member.registrationRegion = regRegion;
2334
+ const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2335
+ if (regType) member.registrationRegionType = regType;
2304
2336
  }
2305
- } else {
2306
- const documentType =
2307
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2308
- ? this.documentTypes.find(i => i.ids === '1UDL')
2309
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2310
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2311
- : new Value();
2312
- if (documentType) this.formStore[whichForm].documentType = documentType;
2337
+ }
2338
+ }
2313
2339
 
2314
- const documentNumber = person.documents.document.number;
2315
- if (documentNumber) this.formStore[whichForm].documentNumber = documentNumber;
2340
+ if (person.regAddress.street.includes(', ')) {
2341
+ const personAddress = person.regAddress.street.split(', ');
2342
+ const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2343
+ const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2344
+ const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2345
+ if (microDistrict) member.registrationMicroDistrict = microDistrict;
2346
+ if (quarter) member.registrationQuarter = quarter;
2347
+ if (street) member.registrationStreet = street;
2348
+ } else {
2349
+ if (person.regAddress.street) member.registrationStreet = person.regAddress.street;
2350
+ }
2351
+ if (person.regAddress.building) member.registrationNumberHouse = person.regAddress.building;
2352
+ if (person.regAddress.flat) member.registrationNumberApartment = person.regAddress.flat;
2316
2353
 
2317
- const documentDate = person.documents.document.beginDate;
2318
- if (documentDate) this.formStore[whichForm].documentDate = reformatDate(documentDate);
2354
+ // TODO Доработать логику и для остальных
2355
+ if ('length' in person.documents.document) {
2356
+ const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2357
+ if (validDocument) {
2358
+ const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2359
+ if (documentType) member.documentType = documentType;
2319
2360
 
2320
- const documentExpire = person.documents.document.endDate;
2321
- if (documentExpire) this.formStore[whichForm].documentExpire = reformatDate(documentExpire);
2361
+ member.documentNumber = validDocument.number;
2362
+ member.documentExpire = reformatDate(validDocument.endDate);
2363
+ member.documentDate = reformatDate(validDocument.beginDate);
2364
+ member.documentNumber = validDocument.number;
2322
2365
 
2323
- // TODO уточнить
2324
2366
  const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2325
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2367
+ if (documentIssuer) member.documentIssuers = documentIssuer;
2326
2368
  }
2327
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2328
- if (economySectorCode) this.formStore[whichForm].economySectorCode = economySectorCode;
2329
2369
  } else {
2330
- this.formStore[whichForm][whichIndex].firstName = person.name;
2331
- this.formStore[whichForm][whichIndex].lastName = person.surname;
2332
- this.formStore[whichForm][whichIndex].middleName = person.patronymic ? person.patronymic : '';
2333
- this.formStore[whichForm][whichIndex].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2334
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(person.birthDate);
2335
- this.formStore[whichForm][whichIndex].genderName = person.gender.nameRu;
2336
-
2337
- const gender = this.gender.find(i => i.id == person.gender.code);
2338
- if (gender) this.formStore[whichForm][whichIndex].gender = gender;
2370
+ const documentType =
2371
+ person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2372
+ ? this.documentTypes.find(i => i.ids === '1UDL')
2373
+ : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2374
+ ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2375
+ : new Value();
2376
+ if (documentType) member.documentType = documentType;
2339
2377
 
2340
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2341
- if (birthPlace) this.formStore[whichForm][whichIndex].birthPlace = birthPlace;
2378
+ const documentNumber = person.documents.document.number;
2379
+ if (documentNumber) member.documentNumber = documentNumber;
2342
2380
 
2343
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2344
- if (countryOfCitizenship) this.formStore[whichForm][whichIndex].countryOfCitizenship = countryOfCitizenship;
2381
+ const documentDate = person.documents.document.beginDate;
2382
+ if (documentDate) member.documentDate = reformatDate(documentDate);
2345
2383
 
2346
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2347
- if (regCountry) this.formStore[whichForm][whichIndex].registrationCountry = regCountry;
2384
+ const documentExpire = person.documents.document.endDate;
2385
+ if (documentExpire) member.documentExpire = reformatDate(documentExpire);
2348
2386
 
2349
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2350
- if (regProvince) this.formStore[whichForm][whichIndex].registrationProvince = regProvince;
2351
-
2352
- if ('city' in person.regAddress && !!person.regAddress.city) {
2353
- if (person.regAddress.city.includes(', ')) {
2354
- const personCities = person.regAddress.city.split(', ');
2355
- for (let i = 0; i < personCities.length; ++i) {
2356
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2357
- if (possibleCity) {
2358
- this.formStore[whichForm][whichIndex].registrationCity = possibleCity;
2359
- break;
2360
- }
2361
- }
2362
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2363
- for (let i = 0; i < personCities.length; ++i) {
2364
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2365
- if (possibleRegion) {
2366
- this.formStore[whichForm][whichIndex].registrationRegion = possibleRegion;
2367
- break;
2368
- }
2369
- }
2370
- }
2371
- } else {
2372
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2373
- if (regCity) this.formStore[whichForm][whichIndex].registrationCity = regCity;
2374
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2375
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2376
- if (regRegion) this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2377
- }
2378
- }
2379
- }
2380
-
2381
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null && this.formStore[whichForm][whichIndex].registrationRegion.nameRu === null) {
2382
- const regCity = this.cities.find(
2383
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2384
- );
2385
- if (regCity) {
2386
- this.formStore[whichForm][whichIndex].registrationCity = regCity;
2387
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2388
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2389
- } else {
2390
- const regRegion = this.regions.find(
2391
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2392
- );
2393
- if (regRegion) {
2394
- this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2395
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2396
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2397
- }
2398
- }
2399
- }
2400
-
2401
- if (person.regAddress.street.includes(', ')) {
2402
- const personAddress = person.regAddress.street.split(', ');
2403
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2404
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2405
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2406
- if (microDistrict) this.formStore[whichForm][whichIndex].registrationMicroDistrict = microDistrict;
2407
- if (quarter) this.formStore[whichForm][whichIndex].registrationQuarter = quarter;
2408
- if (street) this.formStore[whichForm][whichIndex].registrationStreet = street;
2409
- } else {
2410
- if (person.regAddress.street) this.formStore[whichForm][whichIndex].registrationStreet = person.regAddress.street;
2411
- }
2412
- if (person.regAddress.building) this.formStore[whichForm][whichIndex].registrationNumberHouse = person.regAddress.building;
2413
- if (person.regAddress.flat) this.formStore[whichForm][whichIndex].registrationNumberApartment = person.regAddress.flat;
2414
-
2415
- // TODO Доработать логику и для остальных
2416
- if ('length' in person.documents.document) {
2417
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2418
- if (validDocument) {
2419
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2420
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2421
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2422
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(validDocument.endDate);
2423
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(validDocument.beginDate);
2424
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2425
-
2426
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2427
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2428
- }
2429
- } else {
2430
- const documentType =
2431
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2432
- ? this.documentTypes.find(i => i.ids === '1UDL')
2433
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2434
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2435
- : new Value();
2436
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2437
-
2438
- const documentNumber = person.documents.document.number;
2439
- if (documentNumber) this.formStore[whichForm][whichIndex].documentNumber = documentNumber;
2440
-
2441
- const documentDate = person.documents.document.beginDate;
2442
- if (documentDate) this.formStore[whichForm][whichIndex].documentDate = reformatDate(documentDate);
2443
-
2444
- const documentExpire = person.documents.document.endDate;
2445
- if (documentExpire) this.formStore[whichForm][whichIndex].documentExpire = reformatDate(documentExpire);
2446
-
2447
- // TODO уточнить
2448
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2449
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2450
- }
2451
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2452
- if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
2387
+ // TODO уточнить
2388
+ const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2389
+ if (documentIssuer) member.documentIssuers = documentIssuer;
2453
2390
  }
2391
+ const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2392
+ if (economySectorCode) member.economySectorCode = economySectorCode;
2454
2393
  },
2455
2394
  hasJobSection(whichForm) {
2456
2395
  switch (whichForm) {
@@ -2490,6 +2429,12 @@ export const useDataStore = defineStore('data', {
2490
2429
  return true;
2491
2430
  }
2492
2431
  },
2432
+ hasPercentageOfPayoutAmount() {
2433
+ return true;
2434
+ },
2435
+ canViewInvoiceInfo() {
2436
+ return this.isAdmin();
2437
+ },
2493
2438
  },
2494
2439
  });
2495
2440