hl-core 0.0.8-beta.1 → 0.0.8-beta.10

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.
@@ -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,7 @@ export const useDataStore = defineStore('data', {
31
31
  }),
32
32
  getters: {
33
33
  isEFO: state => state.product === 'efo',
34
+ isAML: state => state.product === 'aml',
34
35
  isBaiterek: state => state.product === 'baiterek',
35
36
  isBolashak: state => state.product === 'bolashak',
36
37
  isMycar: state => state.product === 'mycar',
@@ -38,6 +39,8 @@ export const useDataStore = defineStore('data', {
38
39
  isLiferenta: state => state.product === 'liferenta',
39
40
  isPension: state => state.product === 'pension',
40
41
  isGons: state => state.product === 'gons',
42
+ isKazyna: state => state.product === 'halykkazyna',
43
+ isComplianceWindow: state => state.product === 'compliance',
41
44
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
42
45
  },
43
46
  actions: {
@@ -62,7 +65,7 @@ export const useDataStore = defineStore('data', {
62
65
  },
63
66
  copyToClipboard(text) {
64
67
  if (typeof text === 'string' || typeof text === 'number') {
65
- if (this.isEFO) {
68
+ if (this.isEFO || this.isAML) {
66
69
  navigator.clipboard.writeText(text);
67
70
  } else {
68
71
  this.sendToParent(constants.postActions.clipboard, text);
@@ -115,7 +118,7 @@ export const useDataStore = defineStore('data', {
115
118
  this.isCompliance() ||
116
119
  this.isAnalyst() ||
117
120
  this.isUpk() ||
118
- this.isFinanceCenter() ||
121
+ this.isFinCenter() ||
119
122
  this.isSupervisor() ||
120
123
  this.isSupport();
121
124
  if (hasPermission) {
@@ -190,11 +193,14 @@ export const useDataStore = defineStore('data', {
190
193
  isUpk() {
191
194
  return this.isRole(constants.roles.upk);
192
195
  },
196
+ isDrn() {
197
+ return this.isRole(constants.roles.drn);
198
+ },
193
199
  isSupport() {
194
200
  return this.isRole(constants.roles.support);
195
201
  },
196
- isFinanceCenter() {
197
- return this.isRole(constants.roles.financeCenter);
202
+ isFinCenter() {
203
+ return this.isRole(constants.roles.finCenter);
198
204
  },
199
205
  isSupervisor() {
200
206
  return this.isRole(constants.roles.supervisor);
@@ -221,6 +227,7 @@ export const useDataStore = defineStore('data', {
221
227
  const token = localStorage.getItem('accessToken') || null;
222
228
  if (token) {
223
229
  this.$reset();
230
+ this.formStore.$reset();
224
231
  localStorage.clear();
225
232
 
226
233
  if (whichProduct === 'efo') {
@@ -299,7 +306,7 @@ export const useDataStore = defineStore('data', {
299
306
  }
300
307
  }
301
308
  },
302
- async getContragent(member, whichForm, whichIndex, load = true) {
309
+ async getContragent(member, load = true) {
303
310
  if (load) {
304
311
  this.isLoading = true;
305
312
  }
@@ -314,10 +321,10 @@ export const useDataStore = defineStore('data', {
314
321
  response = await this.api.getContragent(queryData);
315
322
  if (response.totalItems > 0) {
316
323
  if (response.totalItems.length === 1) {
317
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
324
+ await this.serializeContragentData(member, response.items[0]);
318
325
  } else {
319
326
  const sortedByRegistrationDate = response.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
320
- await this.serializeContragentData(whichForm, sortedByRegistrationDate[0], whichIndex);
327
+ await this.serializeContragentData(member, sortedByRegistrationDate[0]);
321
328
  }
322
329
  member.gotFromInsis = true;
323
330
  } else {
@@ -335,14 +342,15 @@ export const useDataStore = defineStore('data', {
335
342
  this.isLoading = true;
336
343
  }
337
344
  try {
345
+ const member = whichIndex === null ? this.formStore[whichForm] : this.formStore[whichForm][whichIndex];
338
346
  if (this.isMycar && this.isAgentMycar() && whichForm === this.formStore.beneficiaryFormKey) {
339
- await this.serializeContragentData(whichForm, this.formStore.applicationData.beneficiaryApp[0], whichIndex);
347
+ await this.serializeContragentData(member, this.formStore.applicationData.beneficiaryApp[0]);
340
348
  this.isLoading = false;
341
349
  return;
342
350
  }
343
351
  const response = await this.api.getContragentById(id);
344
352
  if (response.totalItems > 0) {
345
- await this.serializeContragentData(whichForm, response.items[0], whichIndex);
353
+ await this.serializeContragentData(member, response.items[0]);
346
354
  } else {
347
355
  this.isLoading = false;
348
356
  return false;
@@ -354,58 +362,35 @@ export const useDataStore = defineStore('data', {
354
362
  this.isLoading = false;
355
363
  }
356
364
  },
357
- async serializeContragentData(whichForm, contragent, whichIndex = null) {
365
+ async serializeContragentData(member, contragent) {
358
366
  const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
359
367
  this.api.getContrAgentData(contragent.id),
360
368
  this.api.getContrAgentContacts(contragent.id),
361
369
  this.api.getContrAgentDocuments(contragent.id),
362
370
  this.api.getContrAgentAddress(contragent.id),
363
371
  ]);
364
- if (whichIndex === null) {
365
- this.formStore[whichForm].response = {
366
- contragent: contragent,
367
- };
368
- if (data && data.length) {
369
- this.formStore[whichForm].response.questionnaires = data;
370
- }
371
- if (contacts && contacts.length) {
372
- this.formStore[whichForm].response.contacts = contacts;
373
- }
374
- if (documents && documents.length) {
375
- this.formStore[whichForm].response.documents = documents;
376
- }
377
- if (address && address.length) {
378
- this.formStore[whichForm].response.addresses = address;
379
- }
372
+ member.response = {
373
+ contragent: contragent,
374
+ };
375
+ if (data && data.length) {
376
+ member.response.questionnaires = data;
380
377
  }
381
- if (whichIndex !== null) {
382
- this.formStore[whichForm][whichIndex].response = {
383
- contragent: contragent,
384
- };
385
- if (data && data.length) {
386
- this.formStore[whichForm][whichIndex].response.questionnaires = data;
387
- }
388
- if (contacts && contacts.length) {
389
- this.formStore[whichForm][whichIndex].response.contacts = contacts;
390
- }
391
- if (documents && documents.length) {
392
- this.formStore[whichForm][whichIndex].response.documents = documents;
393
- }
394
- if (address && address.length) {
395
- this.formStore[whichForm][whichIndex].response.addresses = address;
396
- }
397
- }
398
- this.parseContragent(
399
- whichForm,
400
- {
401
- personalData: contragent,
402
- documents: documents,
403
- contacts: contacts,
404
- data: data,
405
- address: address,
406
- },
407
- whichIndex,
408
- );
378
+ if (contacts && contacts.length) {
379
+ member.response.contacts = contacts;
380
+ }
381
+ if (documents && documents.length) {
382
+ member.response.documents = documents;
383
+ }
384
+ if (address && address.length) {
385
+ member.response.addresses = address;
386
+ }
387
+ this.parseContragent(member, {
388
+ personalData: contragent,
389
+ documents: documents,
390
+ contacts: contacts,
391
+ data: data,
392
+ address: address,
393
+ });
409
394
  },
410
395
  async searchContragent(iin) {
411
396
  this.isLoading = true;
@@ -428,142 +413,72 @@ export const useDataStore = defineStore('data', {
428
413
  }
429
414
  this.isLoading = false;
430
415
  },
431
- parseContragent(whichForm, user, whichIndex = null) {
432
- if (whichIndex === null) {
433
- // Save User Personal Data
434
- this.formStore[whichForm].verifyType = user.personalData.verifyType;
435
- this.formStore[whichForm].verifyDate = user.personalData.verifyDate;
436
- this.formStore[whichForm].iin = reformatIin(user.personalData.iin);
437
- this.formStore[whichForm].age = user.personalData.age;
438
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
439
- this.formStore[whichForm].birthPlace = country && Object.keys(country).length ? country : new Value();
440
- this.formStore[whichForm].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
441
- this.formStore[whichForm].gender.id = user.personalData.gender;
442
- this.formStore[whichForm].birthDate = reformatDate(user.personalData.birthDate);
443
- this.formStore[whichForm].genderName = user.personalData.genderName;
444
- this.formStore[whichForm].lastName = user.personalData.lastName;
445
- this.formStore[whichForm].longName = user.personalData.longName;
446
- this.formStore[whichForm].middleName = user.personalData.middleName ? user.personalData.middleName : '';
447
- this.formStore[whichForm].firstName = user.personalData.firstName;
448
- this.formStore[whichForm].id = user.personalData.id;
449
- this.formStore[whichForm].type = user.personalData.type;
450
- this.formStore[whichForm].registrationDate = user.personalData.registrationDate;
451
- // Save User Documents Data
452
- if ('documents' in user && user.documents.length) {
453
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
454
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
455
- this.formStore[whichForm].documentType = documentType ? documentType : new Value();
456
- this.formStore[whichForm].documentNumber = user.documents[0].number;
457
- this.formStore[whichForm].documentIssuers = documentIssuer ? documentIssuer : new Value();
458
- this.formStore[whichForm].documentDate = reformatDate(user.documents[0].issueDate);
459
- this.formStore[whichForm].documentExpire = reformatDate(user.documents[0].expireDate);
460
- }
461
- // Document detail (residency, economy code, etc..)
462
- if ('data' in user && user.data.length) {
463
- user.data.forEach(dataObject => {
464
- this.searchFromList(whichForm, dataObject);
465
- });
466
- }
467
- if ('address' in user && user.address.length) {
468
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
469
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
470
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
471
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
472
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
473
- this.formStore[whichForm].registrationCountry = country ? country : new Value();
474
- this.formStore[whichForm].registrationStreet = user.address[0].streetName;
475
- this.formStore[whichForm].registrationCity = city ? city : new Value();
476
- this.formStore[whichForm].registrationNumberApartment = user.address[0].apartmentNumber;
477
- this.formStore[whichForm].registrationNumberHouse = user.address[0].blockNumber;
478
- this.formStore[whichForm].registrationProvince = province ? province : new Value();
479
- this.formStore[whichForm].registrationRegionType = localityType ? localityType : new Value();
480
- this.formStore[whichForm].registrationRegion = region ? region : new Value();
481
- this.formStore[whichForm].registrationQuarter = user.address[0].kvartal;
482
- this.formStore[whichForm].registrationMicroDistrict = user.address[0].microRaion;
483
- }
484
- if ('contacts' in user && user.contacts.length) {
485
- user.contacts.forEach(contact => {
486
- if (contact.type === 'EMAIL' && contact.value) {
487
- this.formStore[whichForm].email = contact.value;
488
- }
489
- if (contact.type === 'MOBILE' && contact.value) {
490
- let phoneNumber = contact.value.substring(1);
491
- this.formStore[whichForm].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
492
- }
493
- if (contact.type === 'HOME' && contact.value) {
494
- let homePhone = contact.value.substring(1);
495
- this.formStore[whichForm].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
496
- }
497
- });
498
- }
416
+ parseContragent(member, user) {
417
+ // Save User Personal Data
418
+ member.verifyType = user.personalData.verifyType;
419
+ member.verifyDate = user.personalData.verifyDate;
420
+ member.iin = reformatIin(user.personalData.iin);
421
+ member.age = user.personalData.age;
422
+ const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
423
+ member.birthPlace = country && Object.keys(country).length ? country : new Value();
424
+ member.gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
425
+ member.gender.id = user.personalData.gender;
426
+ member.birthDate = reformatDate(user.personalData.birthDate);
427
+ member.genderName = user.personalData.genderName;
428
+ member.lastName = user.personalData.lastName;
429
+ member.longName = user.personalData.longName;
430
+ member.middleName = user.personalData.middleName ? user.personalData.middleName : '';
431
+ member.firstName = user.personalData.firstName;
432
+ member.id = user.personalData.id;
433
+ member.type = user.personalData.type;
434
+ member.registrationDate = user.personalData.registrationDate;
435
+ // Save User Documents Data
436
+ if ('documents' in user && user.documents.length) {
437
+ const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
438
+ const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
439
+ member.documentType = documentType ? documentType : new Value();
440
+ member.documentNumber = user.documents[0].number;
441
+ member.documentIssuers = documentIssuer ? documentIssuer : new Value();
442
+ member.documentDate = reformatDate(user.documents[0].issueDate);
443
+ member.documentExpire = reformatDate(user.documents[0].expireDate);
444
+ }
445
+ // Document detail (residency, economy code, etc..)
446
+ if ('data' in user && user.data.length) {
447
+ user.data.forEach(dataObject => {
448
+ this.searchFromList(member, dataObject);
449
+ });
499
450
  }
500
- if (whichIndex !== null) {
501
- // Save User Personal Data
502
- this.formStore[whichForm][whichIndex].iin = reformatIin(user.personalData.iin);
503
- this.formStore[whichForm][whichIndex].verifyType = user.personalData.verifyType;
504
- this.formStore[whichForm][whichIndex].verifyDate = user.personalData.verifyDate;
505
- this.formStore[whichForm][whichIndex].age = user.personalData.age;
506
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
507
- this.formStore[whichForm][whichIndex].birthPlace = country && Object.keys(country).length ? country : new Value();
508
- this.formStore[whichForm][whichIndex].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
509
- this.formStore[whichForm][whichIndex].gender.id = user.personalData.gender;
510
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(user.personalData.birthDate);
511
- this.formStore[whichForm][whichIndex].genderName = user.personalData.genderName;
512
- this.formStore[whichForm][whichIndex].lastName = user.personalData.lastName;
513
- this.formStore[whichForm][whichIndex].longName = user.personalData.longName;
514
- this.formStore[whichForm][whichIndex].middleName = user.personalData.middleName ? user.personalData.middleName : '';
515
- this.formStore[whichForm][whichIndex].firstName = user.personalData.firstName;
516
- this.formStore[whichForm][whichIndex].id = user.personalData.id;
517
- this.formStore[whichForm][whichIndex].type = user.personalData.type;
518
- this.formStore[whichForm][whichIndex].registrationDate = user.personalData.registrationDate;
519
- // Save User Documents Data
520
- if ('documents' in user && user.documents.length) {
521
- const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
522
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
523
- this.formStore[whichForm][whichIndex].documentType = documentType ? documentType : new Value();
524
- this.formStore[whichForm][whichIndex].documentNumber = user.documents[0].number;
525
- this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer ? documentIssuer : new Value();
526
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(user.documents[0].issueDate);
527
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(user.documents[0].expireDate);
528
- }
529
- // Document detail (residency, economy code, etc..)
530
- if ('data' in user && user.data.length) {
531
- user.data.forEach(dataObject => {
532
- this.searchFromList(whichForm, dataObject, whichIndex);
533
- });
534
- }
535
- if ('address' in user && user.address.length) {
536
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
537
- const province = this.states.find(i => i.ids === user.address[0].stateCode);
538
- const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
539
- const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
540
- const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
541
- this.formStore[whichForm][whichIndex].registrationCountry = country ? country : new Value();
542
- this.formStore[whichForm][whichIndex].registrationStreet = user.address[0].streetName;
543
- this.formStore[whichForm][whichIndex].registrationCity = city ? city : new Value();
544
- this.formStore[whichForm][whichIndex].registrationNumberApartment = user.address[0].apartmentNumber;
545
- this.formStore[whichForm][whichIndex].registrationNumberHouse = user.address[0].blockNumber;
546
- this.formStore[whichForm][whichIndex].registrationProvince = province ? province : new Value();
547
- this.formStore[whichForm][whichIndex].registrationRegionType = localityType ? localityType : new Value();
548
- this.formStore[whichForm][whichIndex].registrationRegion = region ? region : new Value();
549
- this.formStore[whichForm][whichIndex].registrationQuarter = user.address[0].kvartal;
550
- this.formStore[whichForm][whichIndex].registrationMicroDistrict = user.address[0].microRaion;
551
- }
552
- if ('contacts' in user && user.contacts.length) {
553
- user.contacts.forEach(contact => {
554
- if (contact.type === 'EMAIL' && contact.value) {
555
- this.formStore[whichForm][whichIndex].email = contact.value;
556
- }
557
- if (contact.type === 'MOBILE' && contact.value) {
558
- let phoneNumber = contact.value.substring(1);
559
- this.formStore[whichForm][whichIndex].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
560
- }
561
- if (contact.type === 'HOME' && contact.value) {
562
- let homePhone = contact.value.substring(1);
563
- this.formStore[whichForm][whichIndex].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
564
- }
565
- });
566
- }
451
+ if ('address' in user && user.address.length) {
452
+ const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address[0].countryName, 'i')));
453
+ const province = this.states.find(i => i.ids === user.address[0].stateCode);
454
+ const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
455
+ const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
456
+ const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
457
+ member.registrationCountry = country ? country : new Value();
458
+ member.registrationStreet = user.address[0].streetName;
459
+ member.registrationCity = city ? city : new Value();
460
+ member.registrationNumberApartment = user.address[0].apartmentNumber;
461
+ member.registrationNumberHouse = user.address[0].blockNumber;
462
+ member.registrationProvince = province ? province : new Value();
463
+ member.registrationRegionType = localityType ? localityType : new Value();
464
+ member.registrationRegion = region ? region : new Value();
465
+ member.registrationQuarter = user.address[0].kvartal;
466
+ member.registrationMicroDistrict = user.address[0].microRaion;
467
+ }
468
+ if ('contacts' in user && user.contacts.length) {
469
+ user.contacts.forEach(contact => {
470
+ if (contact.type === 'EMAIL' && contact.value) {
471
+ member.email = contact.value;
472
+ }
473
+ if (contact.type === 'MOBILE' && contact.value) {
474
+ let phoneNumber = contact.value.substring(1);
475
+ member.phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
476
+ }
477
+ if (contact.type === 'HOME' && contact.value) {
478
+ let homePhone = contact.value.substring(1);
479
+ member.homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
480
+ }
481
+ });
567
482
  }
568
483
  },
569
484
  async alreadyInInsis(iin, firstName, lastName, middleName) {
@@ -757,6 +672,8 @@ export const useDataStore = defineStore('data', {
757
672
  verifyDate: user.verifyDate,
758
673
  });
759
674
 
675
+ const checkForNull = value => (value ? value : '');
676
+
760
677
  // ! SaveContragent -> Addresses
761
678
  let addressData = [];
762
679
  addressData.push({
@@ -773,11 +690,14 @@ export const useDataStore = defineStore('data', {
773
690
  streetName: user.registrationStreet,
774
691
  kvartal: user.registrationQuarter,
775
692
  microRaion: user.registrationMicroDistrict,
776
- cityTypeId: Number(user.registrationRegionType.ids),
693
+ cityTypeId: Number(user.registrationRegionType.ids) > 0 ? Number(user.registrationRegionType.ids) : null,
777
694
  cityTypeName: user.registrationRegionType.nameRu,
778
695
  blockNumber: user.registrationNumberHouse,
779
696
  apartmentNumber: user.registrationNumberApartment,
780
- address: `${user.birthPlace.nameRu}, ${user.registrationRegionType.nameRu} ${user.registrationCity.nameRu}, ул. ${user.registrationStreet}, д. ${user.registrationNumberHouse} кв. ${user.registrationNumberApartment}`,
697
+ address: `${checkForNull(user.birthPlace.nameRu)}, ${checkForNull(user.registrationRegionType.nameRu)} ${checkForNull(user.registrationCity.nameRu)}, ул. ${checkForNull(
698
+ user.registrationStreet,
699
+ )}, д. ${checkForNull(user.registrationNumberHouse)} кв. ${checkForNull(user.registrationNumberApartment)}`,
700
+
781
701
  type: 'H',
782
702
  });
783
703
 
@@ -870,6 +790,8 @@ export const useDataStore = defineStore('data', {
870
790
  data.position = member.jobPosition;
871
791
  data.jobName = member.jobPlace;
872
792
  data.familyStatusId = member.familyStatus.id;
793
+ data.relationId = member.relationDegree.ids;
794
+ data.relationName = member.relationDegree.nameRu;
873
795
  }
874
796
  if (whichMember === 'Beneficiary') {
875
797
  if (
@@ -909,7 +831,7 @@ export const useDataStore = defineStore('data', {
909
831
  return ErrorHandler(err, err.response?.data?.errors && Object.values(err.response?.data?.errors).join(' -> '));
910
832
  }
911
833
  },
912
- searchFromList(whichForm, searchIt, whichIndex = null) {
834
+ searchFromList(member, searchIt) {
913
835
  const getQuestionariesData = () => {
914
836
  switch (searchIt.questId) {
915
837
  case '500003':
@@ -932,11 +854,7 @@ export const useDataStore = defineStore('data', {
932
854
  const [searchFrom, whichField] = getQuestionariesData();
933
855
  if (searchFrom && searchFrom.length) {
934
856
  const result = searchFrom.find(i => i.ids === searchIt.questAnswer);
935
- if (whichIndex === null) {
936
- this.formStore[whichForm][whichField] = result ? result : new Value();
937
- } else {
938
- this.formStore[whichForm][whichIndex][whichField] = result ? result : new Value();
939
- }
857
+ member[whichField] = result ? result : new Value();
940
858
  }
941
859
  },
942
860
  async setSurvey(data) {
@@ -954,14 +872,20 @@ export const useDataStore = defineStore('data', {
954
872
  async getFromApi(whichField, whichRequest, parameter, reset = false) {
955
873
  const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
956
874
  const currentHour = new Date().getHours();
875
+ const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / 15);
957
876
 
958
877
  const getDataCondition = () => {
959
878
  if (!storageValue) return true;
960
879
  const hasHourKey = 'hour' in storageValue;
880
+ const hasMiniteKey = 'minute' in storageValue;
961
881
  const hasModeKey = 'mode' in storageValue;
962
882
  const hasValueKey = 'value' in storageValue;
963
- if (storageValue && (hasHourKey === false || hasModeKey === false || hasValueKey === false)) return true;
964
- if (storageValue && (storageValue.hour !== currentHour || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)) return true;
883
+ if (storageValue && (hasHourKey === false || hasMiniteKey === false || hasModeKey === false || hasValueKey === false)) return true;
884
+ if (
885
+ storageValue &&
886
+ (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)
887
+ )
888
+ return true;
965
889
  };
966
890
  if (!!getDataCondition() || reset === true) {
967
891
  this[whichField] = [];
@@ -973,6 +897,7 @@ export const useDataStore = defineStore('data', {
973
897
  JSON.stringify({
974
898
  value: response,
975
899
  hour: currentHour,
900
+ minute: currentMinutePart,
976
901
  mode: import.meta.env.MODE,
977
902
  }),
978
903
  );
@@ -1043,16 +968,7 @@ export const useDataStore = defineStore('data', {
1043
968
  });
1044
969
  },
1045
970
  async getDicFileTypeList() {
1046
- try {
1047
- if (this.dicFileTypeList.length) {
1048
- return this.dicFileTypeList;
1049
- } else {
1050
- this.dicFileTypeList = await this.api.getDicFileTypeList();
1051
- return this.dicFileTypeList;
1052
- }
1053
- } catch (err) {
1054
- console.log(err.response.data);
1055
- }
971
+ return await this.getFromApi('dicFileTypeList', 'getDicFileTypeList');
1056
972
  },
1057
973
  async getDocumentIssuers() {
1058
974
  return await this.getFromApi('documentIssuers', 'getDocumentIssuers');
@@ -1090,6 +1006,15 @@ export const useDataStore = defineStore('data', {
1090
1006
  async getProcessTariff() {
1091
1007
  return await this.getFromApi('processTariff', 'getProcessTariff');
1092
1008
  },
1009
+ async getCurrencies() {
1010
+ try {
1011
+ const currencies = await this.api.getCurrencies();
1012
+ this.currencies = currencies;
1013
+ return currencies;
1014
+ } catch (err) {
1015
+ console.log(err);
1016
+ }
1017
+ },
1093
1018
  async getAdditionalInsuranceTermsAnswers(questionId) {
1094
1019
  try {
1095
1020
  const answers = await this.api.getAdditionalInsuranceTermsAnswers(this.processCode, questionId);
@@ -1203,6 +1128,9 @@ export const useDataStore = defineStore('data', {
1203
1128
  this.getProcessIndexRate(),
1204
1129
  this.getProcessTariff(),
1205
1130
  this.getProcessPaymentPeriod(),
1131
+ this.getDicFileTypeList(),
1132
+ this.getDictionaryItems('RegionPolicy'),
1133
+ this.getDictionaryItems('SaleChanellPolicy'),
1206
1134
  ]);
1207
1135
  },
1208
1136
  async getUserGroups() {
@@ -1250,15 +1178,12 @@ export const useDataStore = defineStore('data', {
1250
1178
  },
1251
1179
  async searchAgentByName(name) {
1252
1180
  try {
1253
- this.isLoading = true;
1254
- this.AgentDataList = await this.api.searchAgentByName(name);
1255
- if (!this.AgentDataList.length) {
1181
+ this.AgentData = await this.api.searchAgentByName(name);
1182
+ if (!this.AgentData.length) {
1256
1183
  this.showToaster('error', this.t('toaster.notFound'), 1500);
1257
1184
  }
1258
1185
  } catch (err) {
1259
1186
  console.log(err);
1260
- } finally {
1261
- this.isLoading = false;
1262
1187
  }
1263
1188
  },
1264
1189
  async setINSISWorkData() {
@@ -1287,14 +1212,14 @@ export const useDataStore = defineStore('data', {
1287
1212
  this.isLoading = false;
1288
1213
  }
1289
1214
  },
1290
- async filterManagerByRegion(dictName, filterName) {
1215
+ async getDictionaryItems(dictName) {
1216
+ return await this.getFromApi(dictName, 'getDictionaryItems', dictName);
1217
+ },
1218
+ async filterManagerByRegion(filterName) {
1291
1219
  try {
1292
- this.isLoading = true;
1293
- this[`${dictName}List`] = await this.api.filterManagerByRegion(dictName, filterName);
1220
+ this.ManagerPolicy = await this.api.filterManagerByRegion('ManagerPolicy', filterName);
1294
1221
  } catch (err) {
1295
1222
  console.log(err);
1296
- } finally {
1297
- this.isLoading = false;
1298
1223
  }
1299
1224
  },
1300
1225
  async getUnderwritingCouncilData(id) {
@@ -1390,11 +1315,18 @@ export const useDataStore = defineStore('data', {
1390
1315
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1391
1316
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1392
1317
  };
1393
- console.log(calculationData);
1318
+ if (this.isKazyna) {
1319
+ calculationData.premiumInCurrency = getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar);
1320
+ calculationData.amountInCurrency = getNumber(this.formStore.productConditionsForm.requestedSumInsuredInDollar);
1321
+ }
1394
1322
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
1395
1323
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1396
1324
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1397
1325
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1326
+ if (this.isKazyna) {
1327
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(calculationResponse.amountInCurrency);
1328
+ this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1329
+ }
1398
1330
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1399
1331
  } catch (err) {
1400
1332
  ErrorHandler(err);
@@ -1437,7 +1369,10 @@ export const useDataStore = defineStore('data', {
1437
1369
  },
1438
1370
  addCoversDto: this.formStore.additionalInsuranceTerms,
1439
1371
  };
1440
-
1372
+ if (this.isKazyna) {
1373
+ form1.policyAppDto.premiumInCurrency = getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar);
1374
+ form1.policyAppDto.amountInCurrency = getNumber(this.formStore.productConditionsForm.requestedSumInsuredInDollar);
1375
+ }
1441
1376
  try {
1442
1377
  let id = this.formStore.applicationData.processInstanceId;
1443
1378
 
@@ -1446,12 +1381,15 @@ export const useDataStore = defineStore('data', {
1446
1381
  try {
1447
1382
  result = await this.api.getCalculation(id);
1448
1383
  } catch (err) {
1449
- this.showToaster('error', err?.response?.data, 5000);
1384
+ ErrorHandler(err);
1450
1385
  }
1451
1386
 
1452
1387
  const applicationData = await this.api.getApplicationData(taskId);
1453
1388
  this.formStore.applicationData = applicationData;
1454
1389
  this.formStore.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
1390
+ if (this.isKazyna) {
1391
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(result / this.currencies.usd);
1392
+ }
1455
1393
  if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
1456
1394
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result);
1457
1395
  } else {
@@ -1459,11 +1397,10 @@ export const useDataStore = defineStore('data', {
1459
1397
  }
1460
1398
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1461
1399
  } catch (err) {
1462
- console.log(err);
1400
+ ErrorHandler(err);
1463
1401
  }
1464
1402
  } catch (err) {
1465
1403
  ErrorHandler(err);
1466
- console.log(err, 'error');
1467
1404
  }
1468
1405
  this.isLoading = false;
1469
1406
  },
@@ -1590,6 +1527,8 @@ export const useDataStore = defineStore('data', {
1590
1527
  this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
1591
1528
  if (insuredData && insuredData.length) {
1592
1529
  insuredData.forEach((each, index) => {
1530
+ const relationDegree = this.relations.find(i => i.ids == each.relationId);
1531
+ this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1593
1532
  this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1594
1533
  });
1595
1534
  }
@@ -1652,7 +1591,10 @@ export const useDataStore = defineStore('data', {
1652
1591
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
1653
1592
  applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
1654
1593
  );
1655
-
1594
+ if (this.isKazyna) {
1595
+ this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.amountInCurrency);
1596
+ this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.premiumInCurrency);
1597
+ }
1656
1598
  let riskGroup = this.riskGroup.find(item => {
1657
1599
  if (applicationData.policyAppDto.riskGroup == 0) {
1658
1600
  return true;
@@ -1714,6 +1656,7 @@ export const useDataStore = defineStore('data', {
1714
1656
  },
1715
1657
  async handleTask(action, taskId, comment) {
1716
1658
  if (action && Object.keys(constants.actions).includes(action)) {
1659
+ this.isButtonsLoading = true;
1717
1660
  switch (action) {
1718
1661
  case constants.actions.claim: {
1719
1662
  try {
@@ -1724,6 +1667,7 @@ export const useDataStore = defineStore('data', {
1724
1667
  } catch (err) {
1725
1668
  ErrorHandler(err);
1726
1669
  }
1670
+ break;
1727
1671
  }
1728
1672
  case constants.actions.reject:
1729
1673
  case constants.actions.return:
@@ -1733,7 +1677,7 @@ export const useDataStore = defineStore('data', {
1733
1677
  const sended = await this.sendTask(taskId, action, comment);
1734
1678
  if (!sended) return;
1735
1679
  this.formStore.$reset();
1736
- if (this.isEFO) {
1680
+ if (this.isEFO || this.isAML) {
1737
1681
  await this.router.push({ name: 'Insurance-Product' });
1738
1682
  } else {
1739
1683
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1741,8 +1685,10 @@ export const useDataStore = defineStore('data', {
1741
1685
  } catch (err) {
1742
1686
  ErrorHandler(err);
1743
1687
  }
1688
+ break;
1744
1689
  }
1745
1690
  }
1691
+ this.isButtonsLoading = false;
1746
1692
  } else {
1747
1693
  console.error('No handleTask action');
1748
1694
  }
@@ -1909,7 +1855,7 @@ export const useDataStore = defineStore('data', {
1909
1855
  const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
1910
1856
  const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
1911
1857
  if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
1912
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1858
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1913
1859
  return false;
1914
1860
  }
1915
1861
  if (localKey === this.formStore.beneficiaryFormKey) {
@@ -1924,15 +1870,15 @@ export const useDataStore = defineStore('data', {
1924
1870
  }
1925
1871
  } else {
1926
1872
  if (this.formStore[localKey].some(i => i.iin !== null)) {
1927
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1873
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1928
1874
  return false;
1929
1875
  }
1930
1876
  if (this.formStore.applicationData[applicationKey].length !== 0) {
1931
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1877
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1932
1878
  return false;
1933
1879
  } else {
1934
1880
  if (this.formStore[localKey][0].iin !== null) {
1935
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1881
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1936
1882
  return false;
1937
1883
  }
1938
1884
  }
@@ -1945,7 +1891,7 @@ export const useDataStore = defineStore('data', {
1945
1891
  return false;
1946
1892
  }
1947
1893
  if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
1948
- this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
1894
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
1949
1895
  return false;
1950
1896
  }
1951
1897
  if (!this.isGons) {
@@ -1977,7 +1923,7 @@ export const useDataStore = defineStore('data', {
1977
1923
  }
1978
1924
  }
1979
1925
  }
1980
- if (!this.isGons) {
1926
+ if (this.controls.hasAttachment) {
1981
1927
  const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
1982
1928
  if (areValid) {
1983
1929
  await this.setINSISWorkData();
@@ -2142,12 +2088,12 @@ export const useDataStore = defineStore('data', {
2142
2088
  this.isLoading = false;
2143
2089
  }
2144
2090
  },
2145
- async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
2091
+ async getContragentFromGBDFL(member) {
2146
2092
  this.isLoading = true;
2147
2093
  try {
2148
2094
  const data = {
2149
- iin: iin.replace(/-/g, ''),
2150
- phoneNumber: formatPhone(phoneNumber),
2095
+ iin: member.iin.replace(/-/g, ''),
2096
+ phoneNumber: formatPhone(member.phoneNumber),
2151
2097
  };
2152
2098
  const gbdResponse = await this.api.getContragentFromGBDFL(data);
2153
2099
  if (gbdResponse.status === 'soap:Server') {
@@ -2171,284 +2117,145 @@ export const useDataStore = defineStore('data', {
2171
2117
  }
2172
2118
  const { person } = parseXML(gbdResponse.content, true, 'person');
2173
2119
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2174
- if (typeof whichIndex !== 'number') {
2175
- if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
2176
- this.formStore[whichForm].resetMember(false);
2177
- }
2178
- this.formStore[whichForm].gosPersonData = person;
2179
- } else {
2180
- if (this.formStore[whichForm][whichIndex].gosPersonData !== null && this.formStore[whichForm][whichIndex].gosPersonData.iin !== iin.replace(/-/g, '')) {
2181
- this.formStore[whichForm][whichIndex].resetMember(false);
2182
- }
2183
- this.formStore[whichForm][whichIndex].gosPersonData = person;
2184
- }
2185
-
2186
- await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
2187
- if (typeof whichIndex !== 'number') {
2188
- this.formStore[whichForm].verifyDate = responseInfo.responseDate;
2189
- this.formStore[whichForm].verifyType = 'GBDFL';
2190
- } else {
2191
- this.formStore[whichForm][whichIndex].verifyDate = responseInfo.responseDate;
2192
- this.formStore[whichForm][whichIndex].verifyType = 'GBDFL';
2193
- }
2194
- await this.saveInStoreUserGBDFL(person, whichForm, whichIndex);
2120
+ if (member.gosPersonData !== null && member.gosPersonData.iin !== iin.replace(/-/g, '')) {
2121
+ member.resetMember(false);
2122
+ }
2123
+ member.gosPersonData = person;
2124
+ await this.getContragent(member, false);
2125
+ member.verifyDate = responseInfo.responseDate;
2126
+ member.verifyType = 'GBDFL';
2127
+ await this.saveInStoreUserGBDFL(person, member);
2195
2128
  } catch (err) {
2196
2129
  ErrorHandler(err);
2197
2130
  }
2198
2131
  this.isLoading = false;
2199
2132
  },
2200
- async saveInStoreUserGBDFL(person, whichForm, whichIndex = null) {
2201
- if (whichIndex === null) {
2202
- this.formStore[whichForm].firstName = person.name;
2203
- this.formStore[whichForm].lastName = person.surname;
2204
- this.formStore[whichForm].middleName = person.patronymic ? person.patronymic : '';
2205
- this.formStore[whichForm].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2206
- this.formStore[whichForm].birthDate = reformatDate(person.birthDate);
2207
- this.formStore[whichForm].genderName = person.gender.nameRu;
2208
-
2209
- const gender = this.gender.find(i => i.id == person.gender.code);
2210
- if (gender) this.formStore[whichForm].gender = gender;
2211
-
2212
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2213
- if (birthPlace) this.formStore[whichForm].birthPlace = birthPlace;
2214
-
2215
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2216
- if (countryOfCitizenship) this.formStore[whichForm].countryOfCitizenship = countryOfCitizenship;
2217
-
2218
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2219
- if (regCountry) this.formStore[whichForm].registrationCountry = regCountry;
2220
-
2221
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2222
- if (regProvince) this.formStore[whichForm].registrationProvince = regProvince;
2223
-
2224
- if ('city' in person.regAddress && !!person.regAddress.city) {
2225
- if (person.regAddress.city.includes(', ')) {
2226
- const personCities = person.regAddress.city.split(', ');
2133
+ async saveInStoreUserGBDFL(person, member) {
2134
+ member.firstName = person.name;
2135
+ member.lastName = person.surname;
2136
+ member.middleName = person.patronymic ? person.patronymic : '';
2137
+ member.longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2138
+ member.birthDate = reformatDate(person.birthDate);
2139
+ member.genderName = person.gender.nameRu;
2140
+
2141
+ const gender = this.gender.find(i => i.id == person.gender.code);
2142
+ if (gender) member.gender = gender;
2143
+
2144
+ const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2145
+ if (birthPlace) member.birthPlace = birthPlace;
2146
+
2147
+ const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2148
+ if (countryOfCitizenship) member.countryOfCitizenship = countryOfCitizenship;
2149
+
2150
+ const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2151
+ if (regCountry) member.registrationCountry = regCountry;
2152
+
2153
+ const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2154
+ if (regProvince) member.registrationProvince = regProvince;
2155
+
2156
+ if ('city' in person.regAddress && !!person.regAddress.city) {
2157
+ if (person.regAddress.city.includes(', ')) {
2158
+ const personCities = person.regAddress.city.split(', ');
2159
+ for (let i = 0; i < personCities.length; ++i) {
2160
+ const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2161
+ if (possibleCity) {
2162
+ member.registrationCity = possibleCity;
2163
+ break;
2164
+ }
2165
+ }
2166
+ if (member.registrationCity.nameRu === null) {
2227
2167
  for (let i = 0; i < personCities.length; ++i) {
2228
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2229
- if (possibleCity) {
2230
- this.formStore[whichForm].registrationCity = possibleCity;
2168
+ const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2169
+ if (possibleRegion) {
2170
+ member.registrationRegion = possibleRegion;
2231
2171
  break;
2232
2172
  }
2233
2173
  }
2234
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2235
- for (let i = 0; i < personCities.length; ++i) {
2236
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2237
- if (possibleRegion) {
2238
- this.formStore[whichForm].registrationRegion = possibleRegion;
2239
- break;
2240
- }
2241
- }
2242
- }
2243
- } else {
2244
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2245
- if (regCity) this.formStore[whichForm].registrationCity = regCity;
2246
-
2247
- if (this.formStore[whichForm].registrationCity.nameRu === null) {
2248
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2249
- if (regRegion) this.formStore[whichForm].registrationRegion = regRegion;
2250
- }
2251
2174
  }
2252
- }
2175
+ } else {
2176
+ const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2177
+ if (regCity) member.registrationCity = regCity;
2253
2178
 
2254
- if (this.formStore[whichForm].registrationCity.nameRu === null && this.formStore[whichForm].registrationRegion.nameRu === null) {
2255
- const regCity = this.cities.find(
2256
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2257
- );
2258
- if (regCity) {
2259
- this.formStore[whichForm].registrationCity = regCity;
2260
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2261
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2262
- } else {
2263
- const regRegion = this.regions.find(
2264
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2265
- );
2266
- if (regRegion) {
2267
- this.formStore[whichForm].registrationRegion = regRegion;
2268
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2269
- if (regType) this.formStore[whichForm].registrationRegionType = regType;
2270
- }
2179
+ if (member.registrationCity.nameRu === null) {
2180
+ const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2181
+ if (regRegion) member.registrationRegion = regRegion;
2271
2182
  }
2272
2183
  }
2184
+ }
2273
2185
 
2274
- if (person.regAddress.street.includes(', ')) {
2275
- const personAddress = person.regAddress.street.split(', ');
2276
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2277
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2278
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2279
- if (microDistrict) this.formStore[whichForm].registrationMicroDistrict = microDistrict;
2280
- if (quarter) this.formStore[whichForm].registrationQuarter = quarter;
2281
- if (street) this.formStore[whichForm].registrationStreet = street;
2186
+ if (member.registrationCity.nameRu === null && member.registrationRegion.nameRu === null) {
2187
+ const regCity = this.cities.find(
2188
+ i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2189
+ );
2190
+ if (regCity) {
2191
+ member.registrationCity = regCity;
2192
+ const regType = this.localityTypes.find(i => i.nameRu === 'город');
2193
+ if (regType) member.registrationRegionType = regType;
2282
2194
  } else {
2283
- if (person.regAddress.street) this.formStore[whichForm].registrationStreet = person.regAddress.street;
2284
- }
2285
- if (person.regAddress.building) this.formStore[whichForm].registrationNumberHouse = person.regAddress.building;
2286
- if (person.regAddress.flat) this.formStore[whichForm].registrationNumberApartment = person.regAddress.flat;
2287
-
2288
- // TODO Доработать логику и для остальных
2289
- if ('length' in person.documents.document) {
2290
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2291
- if (validDocument) {
2292
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2293
- if (documentType) this.formStore[whichForm].documentType = documentType;
2294
-
2295
- this.formStore[whichForm].documentNumber = validDocument.number;
2296
- this.formStore[whichForm].documentExpire = reformatDate(validDocument.endDate);
2297
- this.formStore[whichForm].documentDate = reformatDate(validDocument.beginDate);
2298
- this.formStore[whichForm].documentNumber = validDocument.number;
2299
-
2300
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2301
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2195
+ const regRegion = this.regions.find(
2196
+ i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2197
+ );
2198
+ if (regRegion) {
2199
+ member.registrationRegion = regRegion;
2200
+ const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2201
+ if (regType) member.registrationRegionType = regType;
2302
2202
  }
2303
- } else {
2304
- const documentType =
2305
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2306
- ? this.documentTypes.find(i => i.ids === '1UDL')
2307
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2308
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2309
- : new Value();
2310
- if (documentType) this.formStore[whichForm].documentType = documentType;
2203
+ }
2204
+ }
2311
2205
 
2312
- const documentNumber = person.documents.document.number;
2313
- if (documentNumber) this.formStore[whichForm].documentNumber = documentNumber;
2206
+ if (person.regAddress.street.includes(', ')) {
2207
+ const personAddress = person.regAddress.street.split(', ');
2208
+ const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2209
+ const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2210
+ const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2211
+ if (microDistrict) member.registrationMicroDistrict = microDistrict;
2212
+ if (quarter) member.registrationQuarter = quarter;
2213
+ if (street) member.registrationStreet = street;
2214
+ } else {
2215
+ if (person.regAddress.street) member.registrationStreet = person.regAddress.street;
2216
+ }
2217
+ if (person.regAddress.building) member.registrationNumberHouse = person.regAddress.building;
2218
+ if (person.regAddress.flat) member.registrationNumberApartment = person.regAddress.flat;
2314
2219
 
2315
- const documentDate = person.documents.document.beginDate;
2316
- if (documentDate) this.formStore[whichForm].documentDate = reformatDate(documentDate);
2220
+ // TODO Доработать логику и для остальных
2221
+ if ('length' in person.documents.document) {
2222
+ const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2223
+ if (validDocument) {
2224
+ const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2225
+ if (documentType) member.documentType = documentType;
2317
2226
 
2318
- const documentExpire = person.documents.document.endDate;
2319
- if (documentExpire) this.formStore[whichForm].documentExpire = reformatDate(documentExpire);
2227
+ member.documentNumber = validDocument.number;
2228
+ member.documentExpire = reformatDate(validDocument.endDate);
2229
+ member.documentDate = reformatDate(validDocument.beginDate);
2230
+ member.documentNumber = validDocument.number;
2320
2231
 
2321
- // TODO уточнить
2322
2232
  const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2323
- if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
2233
+ if (documentIssuer) member.documentIssuers = documentIssuer;
2324
2234
  }
2325
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2326
- if (economySectorCode) this.formStore[whichForm].economySectorCode = economySectorCode;
2327
2235
  } else {
2328
- this.formStore[whichForm][whichIndex].firstName = person.name;
2329
- this.formStore[whichForm][whichIndex].lastName = person.surname;
2330
- this.formStore[whichForm][whichIndex].middleName = person.patronymic ? person.patronymic : '';
2331
- this.formStore[whichForm][whichIndex].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2332
- this.formStore[whichForm][whichIndex].birthDate = reformatDate(person.birthDate);
2333
- this.formStore[whichForm][whichIndex].genderName = person.gender.nameRu;
2334
-
2335
- const gender = this.gender.find(i => i.id == person.gender.code);
2336
- if (gender) this.formStore[whichForm][whichIndex].gender = gender;
2236
+ const documentType =
2237
+ person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2238
+ ? this.documentTypes.find(i => i.ids === '1UDL')
2239
+ : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2240
+ ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2241
+ : new Value();
2242
+ if (documentType) member.documentType = documentType;
2337
2243
 
2338
- const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
2339
- if (birthPlace) this.formStore[whichForm][whichIndex].birthPlace = birthPlace;
2244
+ const documentNumber = person.documents.document.number;
2245
+ if (documentNumber) member.documentNumber = documentNumber;
2340
2246
 
2341
- const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
2342
- if (countryOfCitizenship) this.formStore[whichForm][whichIndex].countryOfCitizenship = countryOfCitizenship;
2247
+ const documentDate = person.documents.document.beginDate;
2248
+ if (documentDate) member.documentDate = reformatDate(documentDate);
2343
2249
 
2344
- const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
2345
- if (regCountry) this.formStore[whichForm][whichIndex].registrationCountry = regCountry;
2250
+ const documentExpire = person.documents.document.endDate;
2251
+ if (documentExpire) member.documentExpire = reformatDate(documentExpire);
2346
2252
 
2347
- const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
2348
- if (regProvince) this.formStore[whichForm][whichIndex].registrationProvince = regProvince;
2349
-
2350
- if ('city' in person.regAddress && !!person.regAddress.city) {
2351
- if (person.regAddress.city.includes(', ')) {
2352
- const personCities = person.regAddress.city.split(', ');
2353
- for (let i = 0; i < personCities.length; ++i) {
2354
- const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
2355
- if (possibleCity) {
2356
- this.formStore[whichForm][whichIndex].registrationCity = possibleCity;
2357
- break;
2358
- }
2359
- }
2360
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2361
- for (let i = 0; i < personCities.length; ++i) {
2362
- const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
2363
- if (possibleRegion) {
2364
- this.formStore[whichForm][whichIndex].registrationRegion = possibleRegion;
2365
- break;
2366
- }
2367
- }
2368
- }
2369
- } else {
2370
- const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
2371
- if (regCity) this.formStore[whichForm][whichIndex].registrationCity = regCity;
2372
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
2373
- const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
2374
- if (regRegion) this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2375
- }
2376
- }
2377
- }
2378
-
2379
- if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null && this.formStore[whichForm][whichIndex].registrationRegion.nameRu === null) {
2380
- const regCity = this.cities.find(
2381
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2382
- );
2383
- if (regCity) {
2384
- this.formStore[whichForm][whichIndex].registrationCity = regCity;
2385
- const regType = this.localityTypes.find(i => i.nameRu === 'город');
2386
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2387
- } else {
2388
- const regRegion = this.regions.find(
2389
- i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
2390
- );
2391
- if (regRegion) {
2392
- this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
2393
- const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
2394
- if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
2395
- }
2396
- }
2397
- }
2398
-
2399
- if (person.regAddress.street.includes(', ')) {
2400
- const personAddress = person.regAddress.street.split(', ');
2401
- const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
2402
- const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
2403
- const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
2404
- if (microDistrict) this.formStore[whichForm][whichIndex].registrationMicroDistrict = microDistrict;
2405
- if (quarter) this.formStore[whichForm][whichIndex].registrationQuarter = quarter;
2406
- if (street) this.formStore[whichForm][whichIndex].registrationStreet = street;
2407
- } else {
2408
- if (person.regAddress.street) this.formStore[whichForm][whichIndex].registrationStreet = person.regAddress.street;
2409
- }
2410
- if (person.regAddress.building) this.formStore[whichForm][whichIndex].registrationNumberHouse = person.regAddress.building;
2411
- if (person.regAddress.flat) this.formStore[whichForm][whichIndex].registrationNumberApartment = person.regAddress.flat;
2412
-
2413
- // TODO Доработать логику и для остальных
2414
- if ('length' in person.documents.document) {
2415
- const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2416
- if (validDocument) {
2417
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2418
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2419
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2420
- this.formStore[whichForm][whichIndex].documentExpire = reformatDate(validDocument.endDate);
2421
- this.formStore[whichForm][whichIndex].documentDate = reformatDate(validDocument.beginDate);
2422
- this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
2423
-
2424
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2425
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2426
- }
2427
- } else {
2428
- const documentType =
2429
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2430
- ? this.documentTypes.find(i => i.ids === '1UDL')
2431
- : this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2432
- ? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
2433
- : new Value();
2434
- if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
2435
-
2436
- const documentNumber = person.documents.document.number;
2437
- if (documentNumber) this.formStore[whichForm][whichIndex].documentNumber = documentNumber;
2438
-
2439
- const documentDate = person.documents.document.beginDate;
2440
- if (documentDate) this.formStore[whichForm][whichIndex].documentDate = reformatDate(documentDate);
2441
-
2442
- const documentExpire = person.documents.document.endDate;
2443
- if (documentExpire) this.formStore[whichForm][whichIndex].documentExpire = reformatDate(documentExpire);
2444
-
2445
- // TODO уточнить
2446
- const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2447
- if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
2448
- }
2449
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2450
- if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
2253
+ // TODO уточнить
2254
+ const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
2255
+ if (documentIssuer) member.documentIssuers = documentIssuer;
2451
2256
  }
2257
+ const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2258
+ if (economySectorCode) member.economySectorCode = economySectorCode;
2452
2259
  },
2453
2260
  hasJobSection(whichForm) {
2454
2261
  switch (whichForm) {