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

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