hl-core 0.0.9-beta.5 → 0.0.9-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/api/base.api.ts +935 -0
  2. package/api/index.ts +2 -620
  3. package/api/interceptors.ts +53 -14
  4. package/components/Button/Btn.vue +2 -2
  5. package/components/Complex/MessageBlock.vue +2 -2
  6. package/components/Complex/Page.vue +1 -1
  7. package/components/Dialog/Dialog.vue +60 -15
  8. package/components/Form/DynamicForm.vue +100 -0
  9. package/components/Form/FormBlock.vue +12 -3
  10. package/components/Form/FormData.vue +110 -0
  11. package/components/Form/FormSection.vue +3 -3
  12. package/components/Form/FormToggle.vue +25 -5
  13. package/components/Form/ManagerAttachment.vue +150 -86
  14. package/components/Form/ProductConditionsBlock.vue +59 -6
  15. package/components/Input/Datepicker.vue +39 -8
  16. package/components/Input/DynamicInput.vue +23 -0
  17. package/components/Input/FileInput.vue +25 -5
  18. package/components/Input/FormInput.vue +2 -4
  19. package/components/Input/Monthpicker.vue +34 -0
  20. package/components/Input/PanelInput.vue +5 -1
  21. package/components/Input/RoundedEmptyField.vue +5 -0
  22. package/components/Input/RoundedSelect.vue +13 -0
  23. package/components/Input/SwitchInput.vue +64 -0
  24. package/components/Input/TextInput.vue +160 -0
  25. package/components/Layout/Drawer.vue +17 -4
  26. package/components/Layout/Header.vue +23 -2
  27. package/components/Layout/Loader.vue +1 -1
  28. package/components/Layout/SettingsPanel.vue +13 -7
  29. package/components/Menu/InfoMenu.vue +35 -0
  30. package/components/Menu/MenuNav.vue +17 -2
  31. package/components/Pages/Anketa.vue +140 -52
  32. package/components/Pages/Auth.vue +42 -7
  33. package/components/Pages/ContragentForm.vue +124 -50
  34. package/components/Pages/Documents.vue +72 -7
  35. package/components/Pages/InvoiceInfo.vue +1 -1
  36. package/components/Pages/MemberForm.vue +369 -100
  37. package/components/Pages/ProductAgreement.vue +1 -8
  38. package/components/Pages/ProductConditions.vue +888 -181
  39. package/components/Panel/PanelHandler.vue +414 -45
  40. package/components/Panel/PanelSelectItem.vue +17 -2
  41. package/components/Panel/RightPanelCloser.vue +7 -0
  42. package/components/Transitions/Animation.vue +28 -0
  43. package/components/Utilities/Qr.vue +44 -0
  44. package/composables/axios.ts +1 -0
  45. package/composables/classes.ts +433 -8
  46. package/composables/constants.ts +102 -2
  47. package/composables/fields.ts +328 -0
  48. package/composables/index.ts +257 -12
  49. package/composables/styles.ts +29 -16
  50. package/layouts/default.vue +48 -3
  51. package/locales/ru.json +480 -14
  52. package/package.json +27 -24
  53. package/pages/Token.vue +1 -12
  54. package/plugins/vuetifyPlugin.ts +2 -0
  55. package/store/data.store.ts +1190 -248
  56. package/store/extractStore.ts +17 -0
  57. package/store/form.store.ts +13 -1
  58. package/store/member.store.ts +1 -1
  59. package/store/rules.ts +66 -5
  60. package/types/enum.ts +43 -0
  61. package/types/env.d.ts +1 -0
  62. package/types/form.ts +94 -0
  63. package/types/index.ts +254 -21
@@ -3,7 +3,18 @@ import { rules } from './rules';
3
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
- import { DataStoreClass, Contragent, DocumentItem, Member, Value } from '../composables/classes';
6
+ import {
7
+ DataStoreClass,
8
+ Contragent,
9
+ DocumentItem,
10
+ Member,
11
+ Value,
12
+ CountryValue,
13
+ PolicyholderActivity,
14
+ BeneficialOwner,
15
+ GroupMember,
16
+ PolicyholderClass,
17
+ } from '../composables/classes';
7
18
  import { ApiClass } from '../api';
8
19
  import { useFormStore } from './form.store';
9
20
  import { AxiosError } from 'axios';
@@ -22,6 +33,7 @@ export const useDataStore = defineStore('data', {
22
33
  formStore: useFormStore(),
23
34
  // contragent: useContragentStore(),
24
35
  api: new ApiClass(),
36
+ rController: new AbortController(),
25
37
  yearEnding: (year: number) => yearEnding(year, constants.yearTitles, constants.yearCases),
26
38
  currentDate: () => new Date(Date.now() - new Date().getTimezoneOffset() * 60 * 1000).toISOString().slice(0, -1),
27
39
  showToaster: (type: 'success' | 'error' | 'warning' | 'info', msg: string, timeout?: number) =>
@@ -33,9 +45,12 @@ export const useDataStore = defineStore('data', {
33
45
  }),
34
46
  getters: {
35
47
  isEFO: state => state.product === 'efo',
48
+ isEfoParent: state => state.parentProduct === 'efo',
36
49
  isAML: state => state.product === 'aml',
37
50
  isLKA: state => state.product === 'lka',
38
- isBridge: state => state.product === 'efo' || state.product === 'aml' || state.product === 'lka',
51
+ isAULETTI: state => state.product === 'auletti',
52
+ isAulettiParent: state => state.parentProduct === 'auletti',
53
+ isBridge: state => state.product === 'efo' || state.product === 'aml' || state.product === 'lka' || state.product === 'auletti',
39
54
  isBaiterek: state => state.product === 'baiterek',
40
55
  isBolashak: state => state.product === 'bolashak',
41
56
  isMycar: state => state.product === 'mycar',
@@ -44,9 +59,15 @@ export const useDataStore = defineStore('data', {
44
59
  isLiferenta: state => state.product === 'liferenta',
45
60
  isGons: state => state.product === 'gons',
46
61
  isKazyna: state => state.product === 'halykkazyna',
62
+ isDas: state => state.product === 'daskamkorlyk',
63
+ isPension: state => state.product === 'pensionannuity',
64
+ isAmulet: state => state.product === 'amuletlife',
65
+ isGns: state => state.product === 'gns',
47
66
  isCalculator: state => state.product === 'calculator',
48
67
  isCheckContract: state => state.product === 'checkcontract',
49
68
  isCheckContragent: state => state.product === 'checkcontragent',
69
+ isDSO: state => state.product === 'dso',
70
+ isUU: state => state.product === 'uu',
50
71
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
51
72
  hasClientAnketa: state => state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10),
52
73
  isClientAnketaCondition: state =>
@@ -73,16 +94,41 @@ export const useDataStore = defineStore('data', {
73
94
  childFrame.contentWindow.postMessage({ action: action, value: value }, '*');
74
95
  }
75
96
  },
76
- copyToClipboard(text: any) {
97
+ abortRequests() {
98
+ try {
99
+ this.rController.abort();
100
+ this.rController = new AbortController();
101
+ } catch (err) {
102
+ console.log(err);
103
+ }
104
+ },
105
+ async copyToClipboard(text: unknown, showError: boolean = true) {
77
106
  if (typeof text === 'string' || typeof text === 'number') {
78
- if (this.isBridge) {
79
- navigator.clipboard.writeText(String(text));
107
+ if (navigator.clipboard && window.isSecureContext) {
108
+ if (this.isBridge) {
109
+ await navigator.clipboard.writeText(String(text));
110
+ this.showToaster('success', this.t('toaster.copied'));
111
+ } else {
112
+ this.sendToParent(constants.postActions.clipboard, String(text));
113
+ }
80
114
  } else {
81
- this.sendToParent(constants.postActions.clipboard, String(text));
115
+ const textarea = document.createElement('textarea');
116
+ textarea.value = String(text);
117
+ textarea.style.position = 'absolute';
118
+ textarea.style.left = '-99999999px';
119
+ document.body.prepend(textarea);
120
+ textarea.select();
121
+ try {
122
+ document.execCommand('copy');
123
+ this.showToaster('success', this.t('toaster.copied'));
124
+ } catch (err) {
125
+ console.log(err);
126
+ } finally {
127
+ textarea.remove();
128
+ }
82
129
  }
83
- this.showToaster('success', this.t('toaster.copied'));
84
130
  } else {
85
- this.showToaster('error', this.t('toaster.noUrl'));
131
+ if (showError) this.showToaster('error', this.t('toaster.noUrl'));
86
132
  }
87
133
  },
88
134
  getFilesByIIN(iin: string) {
@@ -141,7 +187,7 @@ export const useDataStore = defineStore('data', {
141
187
  return !!isRole;
142
188
  },
143
189
  isInitiator() {
144
- return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager();
190
+ return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager() || this.isAgentAuletti();
145
191
  },
146
192
  isManager() {
147
193
  return this.isRole(constants.roles.Manager);
@@ -167,6 +213,9 @@ export const useDataStore = defineStore('data', {
167
213
  isAgentMycar() {
168
214
  return this.isRole(constants.roles.AgentMycar);
169
215
  },
216
+ isAgentAuletti() {
217
+ return this.isRole(constants.roles.AgentAuletti);
218
+ },
170
219
  isAnalyst() {
171
220
  return this.isRole(constants.roles.Analyst);
172
221
  },
@@ -185,6 +234,12 @@ export const useDataStore = defineStore('data', {
185
234
  isSupervisor() {
186
235
  return this.isRole(constants.roles.Supervisor);
187
236
  },
237
+ isHeadManager() {
238
+ return this.isRole(constants.roles.HeadManager);
239
+ },
240
+ isBranchDirector() {
241
+ return this.isRole(constants.roles.BranchDirector);
242
+ },
188
243
  isProcessEditable(statusCode?: keyof typeof Statuses) {
189
244
  const getEditibleStatuses = () => {
190
245
  const defaultStatuses = constants.editableStatuses;
@@ -227,25 +282,11 @@ export const useDataStore = defineStore('data', {
227
282
  this.getUserRoles();
228
283
  }
229
284
  const checkPermission = () => {
230
- if (this.isAML) {
231
- return this.isCompliance() || this.isAdmin() || this.isSupport() || this.isAnalyst();
232
- }
233
- if (this.isLKA) {
234
- return this.isAgent() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn();
235
- }
236
- if (this.isEFO) {
237
- return (
238
- this.isInitiator() ||
239
- this.isUnderwriter() ||
240
- this.isAdmin() ||
241
- this.isCompliance() ||
242
- this.isAnalyst() ||
243
- this.isUpk() ||
244
- this.isFinCenter() ||
245
- this.isSupervisor() ||
246
- this.isSupport()
247
- );
248
- }
285
+ const hasAccess = this.hasAccess();
286
+ if (this.isAML) return hasAccess.toAML;
287
+ if (this.isLKA) return hasAccess.toLKA;
288
+ if (this.isEFO) return hasAccess.toEFO;
289
+ if (this.isAULETTI) return hasAccess.toAULETTI;
249
290
  return false;
250
291
  };
251
292
  if (this.controls.onAuth) {
@@ -288,6 +329,7 @@ export const useDataStore = defineStore('data', {
288
329
  },
289
330
  async resetSelected(route: RouteType) {
290
331
  this.settings.open = false;
332
+ this.rightPanel.open = false;
291
333
  this.panel.open = false;
292
334
  this.panelAction = null;
293
335
  this.menu.selectedItem = new MenuItem();
@@ -357,7 +399,7 @@ export const useDataStore = defineStore('data', {
357
399
  this.isLoading = false;
358
400
  }
359
401
  },
360
- async getContragent(member: Member, load: boolean = true) {
402
+ async getContragent(member: Member, load: boolean = true, showToaster: boolean = true) {
361
403
  this.isLoading = load;
362
404
  if (!member.iin) return;
363
405
  try {
@@ -379,7 +421,7 @@ export const useDataStore = defineStore('data', {
379
421
  }
380
422
  member.gotFromInsis = true;
381
423
  } else {
382
- this.showToaster('error', this.t('toaster.notFoundUser'));
424
+ if (showToaster) this.showToaster('error', this.t('toaster.notFoundUser'));
383
425
  }
384
426
  } catch (err) {
385
427
  ErrorHandler(err);
@@ -387,6 +429,7 @@ export const useDataStore = defineStore('data', {
387
429
  this.isLoading = false;
388
430
  },
389
431
  async getContragentById(id: number, whichForm: keyof typeof StoreMembers, load: boolean = true, whichIndex: number | null = null) {
432
+ if (Number(id) === 0) return;
390
433
  this.isLoading = load;
391
434
  try {
392
435
  const member = whichIndex === null ? this.formStore[whichForm as SingleMember] : this.formStore[whichForm as MultipleMember][whichIndex];
@@ -440,9 +483,9 @@ export const useDataStore = defineStore('data', {
440
483
  member.verifyDate = user.personalData.verifyDate;
441
484
  member.iin = reformatIin(user.personalData.iin);
442
485
  member.age = String(user.personalData.age);
443
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
486
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
444
487
  member.birthPlace = country && Object.keys(country).length ? country : new Value();
445
- const gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
488
+ const gender = this.gender.find((i: Value) => i.nameRu === user.personalData.genderName);
446
489
  member.gender = gender ? gender : new Value();
447
490
  member.gender.id = user.personalData.gender;
448
491
  member.birthDate = reformatDate(user.personalData.birthDate);
@@ -464,8 +507,8 @@ export const useDataStore = defineStore('data', {
464
507
  return user.documents.find(i => i.type === '1UDL');
465
508
  })();
466
509
  const userDocument = documentByPriority ? documentByPriority : user.documents[0];
467
- const documentType = this.documentTypes.find(i => i.ids === userDocument.type);
468
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === userDocument.issuerNameRu);
510
+ const documentType = this.documentTypes.find((i: Value) => i.ids === userDocument.type);
511
+ const documentIssuer = this.documentIssuers.find((i: Value) => i.nameRu === userDocument.issuerNameRu);
469
512
  member.documentType = documentType ? documentType : new Value();
470
513
  member.documentNumber = userDocument.number;
471
514
  member.documentIssuers = documentIssuer ? documentIssuer : new Value();
@@ -477,16 +520,22 @@ export const useDataStore = defineStore('data', {
477
520
  user.data.forEach(questData => {
478
521
  this.searchFromList(member, questData);
479
522
  });
523
+ if (this.isLifetrip) {
524
+ const lastNameLat = user.data.find(obj => obj.questId === '500147');
525
+ const firstNameLat = user.data.find(obj => obj.questId === '500148');
526
+ member.lastNameLat = lastNameLat ? (lastNameLat.questAnswer as string) : null;
527
+ member.firstNameLat = firstNameLat ? (firstNameLat.questAnswer as string) : null;
528
+ }
480
529
  }
481
530
  if ('address' in user && user.address && user.address.length) {
482
531
  const userAddress = user.address[0];
483
532
  const countryName = userAddress.countryName;
484
533
  if (countryName) {
485
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(countryName, 'i')));
534
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(countryName, 'i')));
486
535
  member.registrationCountry = country ? country : new Value();
487
536
  }
488
- const province = this.states.find(i => i.ids === userAddress.stateCode);
489
- const localityType = this.localityTypes.find(i => i.nameRu === userAddress.cityTypeName);
537
+ const province = this.states.find((i: Value) => i.ids === userAddress.stateCode);
538
+ const localityType = this.localityTypes.find((i: Value) => i.nameRu === userAddress.cityTypeName);
490
539
  const city = this.cities.find(i => !!userAddress.cityName && i.nameRu === userAddress.cityName.replace('г.', ''));
491
540
  const region = this.regions.find(i => !!userAddress.regionCode && i.ids == userAddress.regionCode);
492
541
  member.registrationStreet = userAddress.streetName;
@@ -536,7 +585,7 @@ export const useDataStore = defineStore('data', {
536
585
  };
537
586
  const qData = getQuestionariesData();
538
587
  if (qData && qData.from && qData.from.length && qData.field) {
539
- const qResult = qData.from.find(i => i.ids === searchIt.questAnswer);
588
+ const qResult = qData.from.find((i: Value) => i.ids === searchIt.questAnswer);
540
589
  //@ts-ignore
541
590
  member[qData.field] = qResult ? qResult : new Value();
542
591
  }
@@ -553,12 +602,12 @@ export const useDataStore = defineStore('data', {
553
602
  const contragent = await this.api.getContragent(queryData);
554
603
  if (contragent.totalItems > 0) {
555
604
  if (contragent.items.length === 1) {
556
- return contragent.items[0].id;
605
+ return contragent.items[0];
557
606
  } else {
558
607
  const sortedByRegistrationDate = contragent.items.sort(
559
608
  (left, right) => new Date(right.registrationDate).getMilliseconds() - new Date(left.registrationDate).getMilliseconds(),
560
609
  );
561
- return sortedByRegistrationDate[0].id;
610
+ return sortedByRegistrationDate[0];
562
611
  }
563
612
  } else {
564
613
  return null;
@@ -588,17 +637,27 @@ export const useDataStore = defineStore('data', {
588
637
  }
589
638
  },
590
639
  async saveContragent(user: Member, whichForm: keyof typeof StoreMembers | 'contragent', whichIndex: number | null, onlySaveAction: boolean = true) {
640
+ if (this.isGons && user.iin && whichForm === 'beneficiaryForm' && useEnv().isProduction) {
641
+ const doesHaveActiveContract = await this.api.checkBeneficiariesInActualPolicy(user.iin.replace(/-/g, ''));
642
+ if (doesHaveActiveContract) {
643
+ this.showToaster('error', this.t('toaster.doesHaveActiveContract'), 6000);
644
+ return false;
645
+ }
646
+ }
591
647
  this.isLoading = !onlySaveAction;
592
- const hasInsisId = await this.alreadyInInsis(user);
593
- if (typeof hasInsisId === 'number') {
594
- user.id = hasInsisId;
648
+ const hasInsis = await this.alreadyInInsis(user);
649
+ if (!!hasInsis) {
650
+ user.id = hasInsis.id;
595
651
  const [questionairesResponse, contactsResponse, documentsResponse, addressResponse] = await Promise.allSettled([
596
652
  this.api.getContrAgentData(user.id),
597
653
  this.api.getContrAgentContacts(user.id),
598
654
  this.api.getContrAgentDocuments(user.id),
599
655
  this.api.getContrAgentAddress(user.id),
600
656
  ]);
601
- user.response = {};
657
+ if (!user.response) {
658
+ user.response = {};
659
+ user.response.contragent = hasInsis;
660
+ }
602
661
  if (questionairesResponse.status === 'fulfilled' && questionairesResponse.value && questionairesResponse.value.length) {
603
662
  user.response.questionnaires = questionairesResponse.value;
604
663
  }
@@ -624,7 +683,11 @@ export const useDataStore = defineStore('data', {
624
683
  birthDate: user.getDateByKey('birthDate')!,
625
684
  gender: Number(user.gender.id),
626
685
  genderName: user.genderName ? user.genderName : user.gender.nameRu ?? '',
627
- birthPlace: user.birthPlace.nameRu ?? '',
686
+ birthPlace: user.birthPlace.nameRu
687
+ ? user.birthPlace.nameRu
688
+ : 'response' in user && user.response && 'contragent' in user.response && user.response.contragent && user.response.contragent.birthPlace
689
+ ? user.response.contragent.birthPlace
690
+ : '',
628
691
  age: Number(user.age),
629
692
  registrationDate: user.registrationDate,
630
693
  verifyType: user.verifyType,
@@ -685,6 +748,26 @@ export const useDataStore = defineStore('data', {
685
748
  });
686
749
  }
687
750
  }
751
+ if (this.isLifetrip) {
752
+ const lastNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500147') : undefined;
753
+ const firstNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500148') : undefined;
754
+ questionariesData.push({
755
+ id: lastNameLat ? lastNameLat.id : 0,
756
+ contragentId: Number(user.id),
757
+ questAnswer: user.lastNameLat ?? '',
758
+ questAnswerName: null,
759
+ questName: 'Фамилия на латинице',
760
+ questId: '500147',
761
+ });
762
+ questionariesData.push({
763
+ id: firstNameLat ? firstNameLat.id : 0,
764
+ contragentId: Number(user.id),
765
+ questAnswer: user.firstNameLat ?? '',
766
+ questAnswerName: null,
767
+ questName: 'Имя на латинице',
768
+ questId: '500148',
769
+ });
770
+ }
688
771
 
689
772
  const userResponseContacts = 'response' in user && user.response && 'contacts' in user.response && user.response.contacts ? user.response.contacts : null;
690
773
  const contactsData: ContragentContacts[] = [];
@@ -952,7 +1035,7 @@ export const useDataStore = defineStore('data', {
952
1035
  annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
953
1036
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
954
1037
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
955
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1038
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
956
1039
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id ?? undefined,
957
1040
  lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply ?? ''),
958
1041
  lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive ?? ''),
@@ -975,6 +1058,13 @@ export const useDataStore = defineStore('data', {
975
1058
  conditionsData.policyAppDto.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
976
1059
  conditionsData.policyAppDto.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
977
1060
  }
1061
+ if (this.isLifeBusiness || this.isGns) {
1062
+ conditionsData.policyAppDto.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1063
+ conditionsData.policyAppDto.fixInsSum = getNumber(String(this.formStore.productConditionsForm.fixInsSum));
1064
+ conditionsData.policyAppDto.mainInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1065
+ conditionsData.policyAppDto.agentCommission = Number(this.formStore.productConditionsForm.agentCommission);
1066
+ conditionsData.policyAppDto.processDefinitionFgotId = (this.formStore.productConditionsForm.processGfot.id as string) ?? undefined;
1067
+ }
978
1068
  return conditionsData;
979
1069
  },
980
1070
  async clearAddCovers(coverCode: number, coverValue: string) {
@@ -993,6 +1083,8 @@ export const useDataStore = defineStore('data', {
993
1083
  }
994
1084
  },
995
1085
  async deleteInsuredLogic() {
1086
+ // TODO Просмотреть
1087
+ if (this.isLifetrip) return;
996
1088
  const applicationData = this.getConditionsData();
997
1089
  const clearCovers = [{ code: 10, value: 'excluded' }];
998
1090
  await Promise.allSettled(
@@ -1023,6 +1115,16 @@ export const useDataStore = defineStore('data', {
1023
1115
  }
1024
1116
  return null;
1025
1117
  },
1118
+ async getProcessCoverTypePeriod(questionId: string) {
1119
+ if (!this.processCode) return null;
1120
+ try {
1121
+ const answers = await this.api.getProcessCoverTypePeriod(this.processCode, questionId);
1122
+ return answers;
1123
+ } catch (err) {
1124
+ console.log(err);
1125
+ }
1126
+ return null;
1127
+ },
1026
1128
  async definedAnswers(
1027
1129
  filter: string,
1028
1130
  whichSurvey: 'surveyByHealthBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBase' | 'surveyByCriticalBasePolicyholder',
@@ -1051,7 +1153,7 @@ export const useDataStore = defineStore('data', {
1051
1153
  this.isLoading = false;
1052
1154
  }
1053
1155
  },
1054
- async setINSISWorkData() {
1156
+ async setINSISWorkData(loading: boolean = true) {
1055
1157
  if (!this.formStore.applicationData.insisWorkDataApp) return;
1056
1158
  const data: InsisWorkDataApp = {
1057
1159
  id: this.formStore.applicationData.insisWorkDataApp.id,
@@ -1070,7 +1172,7 @@ export const useDataStore = defineStore('data', {
1070
1172
  insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
1071
1173
  };
1072
1174
  try {
1073
- this.isLoading = true;
1175
+ this.isLoading = loading;
1074
1176
  await this.api.setINSISWorkData(data);
1075
1177
  } catch (err) {
1076
1178
  ErrorHandler(err);
@@ -1110,7 +1212,7 @@ export const useDataStore = defineStore('data', {
1110
1212
  if (storageValue && (hasHourKey === false || hasMiniteKey === false || hasModeKey === false || hasValueKey === false)) return true;
1111
1213
  if (
1112
1214
  storageValue &&
1113
- (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)
1215
+ (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.VITE_MODE || storageValue.value.length === 0)
1114
1216
  )
1115
1217
  return true;
1116
1218
  };
@@ -1127,7 +1229,7 @@ export const useDataStore = defineStore('data', {
1127
1229
  value: response,
1128
1230
  hour: currentHour,
1129
1231
  minute: currentMinutePart,
1130
- mode: import.meta.env.MODE,
1232
+ mode: import.meta.env.VITE_MODE,
1131
1233
  }),
1132
1234
  );
1133
1235
  //@ts-ignore
@@ -1145,7 +1247,28 @@ export const useDataStore = defineStore('data', {
1145
1247
  return this[whichField];
1146
1248
  },
1147
1249
  async getCountries() {
1148
- return await this.getFromApi('countries', 'getCountries');
1250
+ const response = await this.getFromApi('countries', 'getCountries');
1251
+ const kzIndex = response.findIndex(country => country.ids === 'KZ');
1252
+ if (kzIndex !== -1) {
1253
+ const element = response.splice(kzIndex, 1)[0];
1254
+ response.splice(0, 0, element);
1255
+ }
1256
+ return response;
1257
+ },
1258
+ async getDicCountries() {
1259
+ if (this.isLifetrip) return await this.getFromApi('dicAllCountries', 'getArmDicts', 'DicCountry');
1260
+ },
1261
+ async getDicTripType() {
1262
+ if (this.isLifetrip) return await this.getFromApi('types', 'getArmDicts', 'DicTripType');
1263
+ },
1264
+ async getDicTripPurpose() {
1265
+ if (this.isLifetrip) return await this.getFromApi('purposes', 'getArmDicts', 'DicTripPurpose');
1266
+ },
1267
+ async getDicTripWorkType() {
1268
+ if (this.isLifetrip) return await this.getFromApi('workTypes', 'getArmDicts', 'DicTripWorkType');
1269
+ },
1270
+ async getDicSportsType() {
1271
+ if (this.isLifetrip) return await this.getFromApi('sportsTypes', 'getArmDicts', 'DicSportsType');
1149
1272
  },
1150
1273
  async getCitizenshipCountries() {
1151
1274
  return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
@@ -1156,31 +1279,80 @@ export const useDataStore = defineStore('data', {
1156
1279
  async getAdditionalTaxCountries() {
1157
1280
  return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
1158
1281
  },
1159
- async getStates(key?: string, member?: Member) {
1282
+ async getStates(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1160
1283
  await this.getFromApi('states', 'getStates');
1161
- //@ts-ignore
1162
- if (key && member[key] && member[key].ids !== null) return this.states.filter(i => i.code === member[key].ids);
1284
+ if (!!keys) {
1285
+ if (!!keys.key) {
1286
+ if (!!keys.deepKey) {
1287
+ if (!!keys.subDeepKey) {
1288
+ //@ts-ignore
1289
+ return this.states.filter(i => i.code === member[keys.key][keys.deepKey][keys.subDeepKey].ids || i.code === member[keys.key][keys.deepKey][keys.subDeepKey].id);
1290
+ } else {
1291
+ //@ts-ignore
1292
+ return this.states.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1293
+ }
1294
+ } else {
1295
+ //@ts-ignore
1296
+ return this.states.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1297
+ }
1298
+ }
1299
+ } else {
1300
+ //@ts-ignore
1301
+ if (key && member[key] && member[key].ids !== null) return this.states.filter((i: Value) => i.code === member[key].ids);
1302
+ }
1163
1303
  return this.states;
1164
1304
  },
1165
- async getRegions(key?: string, member?: Member) {
1305
+ async getRegions(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1166
1306
  await this.getFromApi('regions', 'getRegions');
1167
- //@ts-ignore
1168
- if (key && member[key] && member[key].ids !== null) return this.regions.filter(i => i.code === member[key].ids);
1169
- if (member && member.registrationProvince.ids !== null) {
1170
- return this.regions.filter(i => i.code === member.registrationProvince.ids);
1307
+ if (!!keys) {
1308
+ if (!!keys.key) {
1309
+ if (!!keys.deepKey) {
1310
+ if (!!keys.subDeepKey) {
1311
+ //@ts-ignore
1312
+ return this.regions.filter(i => i.code === member[keys.key][keys.deepKey][keys.subDeepKey].ids || i.code === member[keys.key][keys.deepKey][keys.subDeepKey].id);
1313
+ } else {
1314
+ //@ts-ignore
1315
+ return this.regions.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1316
+ }
1317
+ } else {
1318
+ //@ts-ignore
1319
+ return this.regions.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1320
+ }
1321
+ }
1171
1322
  } else {
1172
- return this.regions;
1323
+ //@ts-ignore
1324
+ if (key && member[key] && member[key].ids !== null) return this.regions.filter((i: Value) => i.code === member[key].ids);
1325
+ if (member && member.registrationProvince.ids !== null) {
1326
+ return this.regions.filter((i: Value) => i.code === member.registrationProvince.ids);
1327
+ }
1173
1328
  }
1329
+ return this.regions;
1174
1330
  },
1175
- async getCities(key?: string, member?: Member) {
1331
+ async getCities(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1176
1332
  await this.getFromApi('cities', 'getCities');
1177
- //@ts-ignore
1178
- if (key && member[key] && member[key].ids !== null) return this.cities.filter(i => i.code === member[key].ids);
1179
- if (member && member.registrationProvince.ids !== null) {
1180
- return this.cities.filter(i => i.code === member.registrationProvince.ids);
1333
+ if (!!keys) {
1334
+ if (!!keys.key) {
1335
+ if (!!keys.deepKey) {
1336
+ if (!!keys.subDeepKey) {
1337
+ //@ts-ignore
1338
+ return this.cities.filter(i => i.code === member[keys.key][keys.deepKey][keys.subDeepKey].ids || i.code === member[keys.key][keys.deepKey][keys.subDeepKey].id);
1339
+ } else {
1340
+ //@ts-ignore
1341
+ return this.cities.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1342
+ }
1343
+ } else {
1344
+ //@ts-ignore
1345
+ return this.cities.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1346
+ }
1347
+ }
1181
1348
  } else {
1182
- return this.cities;
1349
+ //@ts-ignore
1350
+ if (key && member[key] && member[key].ids !== null) return this.cities.filter((i: Value) => i.code === member[key].ids);
1351
+ if (member && member.registrationProvince.ids !== null) {
1352
+ return this.cities.filter((i: Value) => i.code === member.registrationProvince.ids);
1353
+ }
1183
1354
  }
1355
+ return this.cities;
1184
1356
  },
1185
1357
  async getLocalityTypes() {
1186
1358
  return await this.getFromApi('localityTypes', 'getLocalityTypes');
@@ -1208,12 +1380,18 @@ export const useDataStore = defineStore('data', {
1208
1380
  async getSectorCodeList() {
1209
1381
  return await this.getFromApi('economySectorCode', 'getSectorCode');
1210
1382
  },
1383
+ async getEconomicActivityType() {
1384
+ if (this.isLifeBusiness || this.isGns || this.isDas || this.isUU) return await this.getFromApi('economicActivityType', 'getEconomicActivityType');
1385
+ },
1211
1386
  async getFamilyStatuses() {
1212
1387
  return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
1213
1388
  },
1214
1389
  async getRelationTypes() {
1215
1390
  return await this.getFromApi('relations', 'getRelationTypes');
1216
1391
  },
1392
+ async getBanks() {
1393
+ if (this.isLifeBusiness || this.isGns || this.isDas || this.isUU) return await this.getFromApi('banks', 'getBanks');
1394
+ },
1217
1395
  async getProcessIndexRate() {
1218
1396
  if (this.processCode) {
1219
1397
  return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
@@ -1228,7 +1406,7 @@ export const useDataStore = defineStore('data', {
1228
1406
  return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
1229
1407
  },
1230
1408
  async getProcessTariff() {
1231
- return await this.getFromApi('processTariff', 'getProcessTariff');
1409
+ if (this.processCode) return await this.getFromApi('processTariff', 'getProcessTariff', this.processCode);
1232
1410
  },
1233
1411
  async getDicAnnuityTypeList() {
1234
1412
  return await this.getFromApi('dicAnnuityTypeList', 'getDicAnnuityTypeList');
@@ -1241,6 +1419,11 @@ export const useDataStore = defineStore('data', {
1241
1419
  async getInsurancePay() {
1242
1420
  return await this.getFromApi('insurancePay', 'getInsurancePay');
1243
1421
  },
1422
+ async getProcessGfot() {
1423
+ if (this.processCode) {
1424
+ return await this.getFromApi('processGfot', 'getProcessGfot', this.processCode);
1425
+ }
1426
+ },
1244
1427
  async getCurrencies() {
1245
1428
  try {
1246
1429
  const currencies = await this.api.getCurrencies();
@@ -1254,6 +1437,12 @@ export const useDataStore = defineStore('data', {
1254
1437
  async getDictionaryItems(dictName: string) {
1255
1438
  return await this.getFromApi(dictName, 'getDictionaryItems', dictName);
1256
1439
  },
1440
+ getGenderList() {
1441
+ return this.gender;
1442
+ },
1443
+ async getAuthorityBasis() {
1444
+ if (this.isDas || this.isLifeBusiness || this.isGns || this.isUU) return await this.getFromApi('authorityBasis', 'getArmDicts', 'DicAuthorityBasis');
1445
+ },
1257
1446
  async getAllFormsData() {
1258
1447
  await Promise.allSettled([
1259
1448
  this.getCountries(),
@@ -1279,59 +1468,68 @@ export const useDataStore = defineStore('data', {
1279
1468
  this.getInsurancePay(),
1280
1469
  this.getDictionaryItems('RegionPolicy'),
1281
1470
  this.getDictionaryItems('SaleChanellPolicy'),
1471
+ this.getDicTripType(),
1472
+ this.getDicCountries(),
1473
+ this.getDicTripWorkType(),
1474
+ this.getDicSportsType(),
1475
+ this.getDicTripPurpose(),
1476
+ this.getCurrencies(),
1477
+ this.getProcessGfot(),
1478
+ this.getBanks(),
1479
+ this.getEconomicActivityType(),
1480
+ this.getAuthorityBasis(),
1282
1481
  ]);
1283
1482
  },
1284
1483
  async getQuestionList(
1285
1484
  surveyType: 'health' | 'critical',
1286
1485
  processInstanceId: string | number,
1287
1486
  insuredId: any,
1288
- baseField: string,
1289
- secondaryField: string,
1487
+ baseField: 'surveyByHealthBase' | 'surveyByCriticalBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBasePolicyholder',
1290
1488
  whichMember: 'insured' | 'policyholder' = 'insured',
1291
1489
  ) {
1292
- //@ts-ignore
1293
- if (!this.formStore[baseField] || (this.formStore[baseField] && !this.formStore[baseField].length)) {
1294
- try {
1295
- if (whichMember === 'insured') {
1296
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1297
- this.api.getQuestionList(surveyType, processInstanceId, insuredId),
1298
- this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1299
- ]);
1300
- if (baseQuestions.status === 'fulfilled') {
1301
- //@ts-ignore
1302
- this.formStore[baseField] = baseQuestions.value;
1303
- }
1304
- if (secondaryQuestions.status === 'fulfilled') {
1305
- //@ts-ignore
1306
- this.formStore[secondaryField] = secondaryQuestions;
1307
- }
1308
- }
1309
- if (whichMember === 'policyholder') {
1310
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1311
- this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1312
- this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1313
- ]);
1314
- if (baseQuestions.status === 'fulfilled') {
1315
- //@ts-ignore
1316
- this.formStore[baseField] = baseQuestions.value;
1317
- }
1318
- if (secondaryQuestions.status === 'fulfilled') {
1319
- //@ts-ignore
1320
- this.formStore[secondaryField] = secondaryQuestions;
1321
- }
1490
+ try {
1491
+ const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1492
+ whichMember === 'insured' ? this.api.getQuestionList(surveyType, processInstanceId, insuredId) : this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1493
+ whichMember === 'insured'
1494
+ ? this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId)
1495
+ : this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1496
+ ,
1497
+ ]);
1498
+ if (baseQuestions.status === 'fulfilled') {
1499
+ this.formStore[baseField] = baseQuestions.value;
1500
+ }
1501
+ if (secondaryQuestions.status === 'fulfilled') {
1502
+ const baseAnketa = this.formStore[baseField];
1503
+ if (baseAnketa && baseAnketa.body && baseAnketa.body.length) {
1504
+ baseAnketa.body.forEach(i => {
1505
+ if (i.first.definedAnswers === 'Y' && i.second === null && secondaryQuestions.value) {
1506
+ i.second = structuredClone(secondaryQuestions.value);
1507
+ }
1508
+ });
1322
1509
  }
1323
- } catch (err) {
1324
- console.log(err);
1325
1510
  }
1511
+ } catch (err) {
1512
+ ErrorHandler(err);
1326
1513
  }
1327
- //@ts-ignore
1328
1514
  return this.formStore[baseField];
1329
1515
  },
1330
1516
  getNumberWithSpaces(n: any) {
1331
1517
  return n === null ? null : Number((typeof n === 'string' ? n : n.toFixed().toString()).replace(/[^0-9]+/g, '')).toLocaleString('ru');
1332
1518
  },
1519
+ getNumberWithSpacesAfterComma(n: number) {
1520
+ let parts = n.toFixed(2).split('.');
1521
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
1522
+ return parts.join(',');
1523
+ },
1333
1524
  getNumberWithDot(n: any) {
1334
- return n === null ? null : n.toLocaleString('ru', { maximumFractionDigits: 2, minimumFractionDigits: 2 }).replace(/,/g, '.');
1525
+ return n === null
1526
+ ? null
1527
+ : n
1528
+ .toLocaleString('ru', {
1529
+ maximumFractionDigits: 2,
1530
+ minimumFractionDigits: 2,
1531
+ })
1532
+ .replace(/,/g, '.');
1335
1533
  },
1336
1534
  async getTaskList(
1337
1535
  search: string = '',
@@ -1371,7 +1569,14 @@ export const useDataStore = defineStore('data', {
1371
1569
  delete query.processCodes;
1372
1570
  query.processCode = byOneProcess;
1373
1571
  }
1374
- const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
1572
+ const taskList = await this.api.getTaskList(
1573
+ processInstanceId === null
1574
+ ? query
1575
+ : {
1576
+ ...query,
1577
+ processInstanceId: processInstanceId,
1578
+ },
1579
+ );
1375
1580
  if (needToReturn) {
1376
1581
  this.isLoading = false;
1377
1582
  return taskList.items;
@@ -1457,7 +1662,7 @@ export const useDataStore = defineStore('data', {
1457
1662
  },
1458
1663
  findObject(from: string, key: string, searchKey: any): any {
1459
1664
  // @ts-ignore
1460
- const found = this[from].find(i => i[key] == searchKey);
1665
+ const found = this[from].find((i: Value) => i[key] == searchKey);
1461
1666
  return found || new Value();
1462
1667
  },
1463
1668
  async searchAgentByName(name: string) {
@@ -1508,18 +1713,69 @@ export const useDataStore = defineStore('data', {
1508
1713
  this.isLoading = false;
1509
1714
  }
1510
1715
  },
1716
+ async getTripInsuredAmount(show: boolean = true) {
1717
+ this.isLoading = true;
1718
+ try {
1719
+ const countryID: string[] = [];
1720
+ for (let country = 0; country < this.formStore.productConditionsForm.calculatorForm.countries!.length; country++) {
1721
+ countryID.push(this.formStore.productConditionsForm.calculatorForm.countries![country].id as string);
1722
+ }
1723
+
1724
+ const form = {
1725
+ tripTypeID: this.formStore.productConditionsForm.calculatorForm.type.id,
1726
+ countryID,
1727
+ };
1728
+
1729
+ const result = await this.api.getTripInsuredAmount(form);
1730
+ const amounts: Value[] = [];
1731
+ result.amounts.forEach(amount => {
1732
+ amounts.push(new Value(amount['id'], amount['nameRu']));
1733
+ });
1734
+
1735
+ this.amountArray = amounts;
1736
+ this.formStore.productConditionsForm.calculatorForm.amount = new Value();
1737
+ this.currency = result.currency;
1738
+
1739
+ if (show) {
1740
+ this.showToaster('success', this.t('toaster.tripInsuredAmountCalculated'), 1000);
1741
+ }
1742
+ } catch (err) {
1743
+ ErrorHandler(err);
1744
+ }
1745
+ this.isLoading = false;
1746
+ },
1747
+ async getPeriod() {
1748
+ if (this.periodArray.length === 0) {
1749
+ try {
1750
+ const response = await this.api.getTripInsuranceDaysOptions();
1751
+ if (response) {
1752
+ const new3 = response.period;
1753
+ const newPeriod: Value[] = [];
1754
+ const newMaxDays: Value[] = [];
1755
+ Object.keys(new3).forEach(key => {
1756
+ newPeriod.push(new Value(key, key, key, key));
1757
+ new3[key as keyof typeof new3].forEach(item => {
1758
+ newMaxDays.push(new Value(item, item, item, key));
1759
+ });
1760
+ });
1761
+ this.periodArray = newPeriod;
1762
+ this.maxDaysAllArray = newMaxDays;
1763
+ }
1764
+ } catch (err) {
1765
+ ErrorHandler(err);
1766
+ }
1767
+ }
1768
+ },
1511
1769
  async calculateWithoutApplication(showLoader: boolean = false, product: string | null = null) {
1512
1770
  this.isLoading = showLoader;
1513
1771
  try {
1514
- if (!this.formStore.productConditionsForm.signDate || !this.formStore.productConditionsForm.birthDate) {
1772
+ if (!this.formStore.productConditionsForm.signDate) {
1515
1773
  return;
1516
1774
  }
1517
1775
  const signDate = formatDate(this.formStore.productConditionsForm.signDate);
1518
- const birthDate = formatDate(this.formStore.productConditionsForm.birthDate);
1519
- if (!signDate || !birthDate) return;
1520
1776
  const calculationData: RecalculationDataType & PolicyAppDto = {
1521
- signDate: signDate.toISOString(),
1522
- birthDate: birthDate.toISOString(),
1777
+ signDate: signDate ? signDate.toISOString() : undefined,
1778
+ birthDate: this.formStore.productConditionsForm.birthDate ? formatDate(this.formStore.productConditionsForm.birthDate)!.toISOString() : undefined,
1523
1779
  gender: Number(this.formStore.productConditionsForm.gender.id),
1524
1780
  amount: getNumber(String(this.formStore.productConditionsForm.requestedSumInsured)),
1525
1781
  premium: getNumber(String(this.formStore.productConditionsForm.insurancePremiumPerMonth)),
@@ -1527,7 +1783,7 @@ export const useDataStore = defineStore('data', {
1527
1783
  payPeriod: Number(this.formStore.productConditionsForm.coverPeriod),
1528
1784
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1529
1785
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
1530
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1786
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
1531
1787
  paymentPeriodId: (this.formStore.productConditionsForm.paymentPeriod.id as string) ?? undefined,
1532
1788
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1533
1789
  };
@@ -1536,15 +1792,24 @@ export const useDataStore = defineStore('data', {
1536
1792
  calculationData.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1537
1793
  calculationData.currencyExchangeRate = this.currencies.usd;
1538
1794
  }
1539
- if (this.isLiferenta) {
1795
+ if (this.isLiferenta || product === 'liferenta') {
1540
1796
  calculationData.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1541
1797
  calculationData.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
1542
1798
  calculationData.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
1543
1799
  calculationData.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
1544
1800
  }
1801
+ if (this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns') {
1802
+ calculationData.clients = this.formStore.lfb.clients;
1803
+ calculationData.insrCount = this.formStore.lfb.clients.length;
1804
+ calculationData.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1805
+ calculationData.fixInsSum = getNumber(String(this.formStore.productConditionsForm.fixInsSum));
1806
+ calculationData.mainInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1807
+ calculationData.agentCommission = Number(this.formStore.productConditionsForm.agentCommission);
1808
+ calculationData.processDefinitionFgotId = this.formStore.productConditionsForm.processGfot.id;
1809
+ }
1545
1810
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1546
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1547
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1811
+ if (calculationResponse.amount) this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1812
+ if (calculationResponse.premium) this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1548
1813
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1549
1814
  if (this.isKazyna || product === 'halykkazyna') {
1550
1815
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
@@ -1553,9 +1818,28 @@ export const useDataStore = defineStore('data', {
1553
1818
  this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1554
1819
  }
1555
1820
  }
1556
- if (this.isLiferenta) {
1821
+ if (this.isLiferenta || product === 'liferenta') {
1557
1822
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(calculationResponse.annuityMonthPay);
1558
1823
  }
1824
+ if (this.isGons || product === 'gons') {
1825
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(calculationResponse.totalAmount5);
1826
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(calculationResponse.totalAmount7);
1827
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(calculationResponse.statePremium5);
1828
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(calculationResponse.statePremium7);
1829
+ }
1830
+ if (this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns') {
1831
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.mainPremiumWithCommission);
1832
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.mainInsSum === 0 ? null : calculationResponse.mainInsSum);
1833
+ this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1834
+ if (calculationResponse.agentCommission) {
1835
+ this.formStore.productConditionsForm.agentCommission = calculationResponse.agentCommission;
1836
+ }
1837
+ if (calculationResponse.clients) {
1838
+ this.formStore.lfb.clients = calculationResponse.clients;
1839
+ }
1840
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1841
+ return calculationResponse;
1842
+ }
1559
1843
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1560
1844
  } catch (err) {
1561
1845
  ErrorHandler(err);
@@ -1591,6 +1875,67 @@ export const useDataStore = defineStore('data', {
1591
1875
  if (this.isLiferenta) {
1592
1876
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(applicationData.policyAppDto.annuityMonthPay);
1593
1877
  }
1878
+ if (this.isGons) {
1879
+ const govPremiums = await this.api.getGovernmentPremiums(String(id));
1880
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(govPremiums.totalAmount5 === null ? null : govPremiums.totalAmount5);
1881
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(govPremiums.totalAmount7 === null ? null : govPremiums.totalAmount7);
1882
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(govPremiums.statePremium5 === null ? null : govPremiums.statePremium5);
1883
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
1884
+ }
1885
+ if (this.isLifeBusiness || this.isGns) {
1886
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
1887
+ if (applicationData.insuredApp && applicationData.insuredApp.length) {
1888
+ const res = await this.newInsuredList(applicationData.insuredApp);
1889
+ this.formStore.lfb.clients = res;
1890
+ }
1891
+ }
1892
+
1893
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1894
+ } catch (err) {
1895
+ ErrorHandler(err);
1896
+ }
1897
+ this.isLoading = false;
1898
+ },
1899
+ async calculatePrice(taskId?: string) {
1900
+ this.isLoading = true;
1901
+ try {
1902
+ const priceForm: SetApplicationRequest = {};
1903
+ priceForm.insuredAmountId = this.formStore.productConditionsForm.calculatorForm.amount.id;
1904
+ priceForm.age = this.formStore.productConditionsForm.calculatorForm.age;
1905
+ priceForm.lifeTripCountries = this.formStore.productConditionsForm.calculatorForm.countries!.map(item => item.id as string);
1906
+ priceForm.tripPurposeId = this.formStore.productConditionsForm.calculatorForm.purpose.id;
1907
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'WorkStudy') {
1908
+ priceForm.workTypeId = this.formStore.productConditionsForm.calculatorForm.workType.id;
1909
+ }
1910
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'Sport') {
1911
+ priceForm.sportsTypeId = this.formStore.productConditionsForm.calculatorForm.sportsType!.id;
1912
+ }
1913
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
1914
+ priceForm.singleTripDays = Number(this.formStore.productConditionsForm.calculatorForm.days);
1915
+ } else {
1916
+ priceForm.multipleTripMaxDays = Number(this.formStore.productConditionsForm.calculatorForm.maxDays.nameRu);
1917
+ priceForm.tripInsurancePeriod = Number(this.formStore.productConditionsForm.calculatorForm.period.nameRu);
1918
+ }
1919
+ if (this.isTask()) {
1920
+ priceForm.processInstanceId = this.formStore.applicationData.processInstanceId!;
1921
+ priceForm.id = taskId!;
1922
+ priceForm.age = Number(this.formStore.policyholderForm.age);
1923
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Multiple') {
1924
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
1925
+ } else {
1926
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
1927
+ priceForm.endDate = formatDate(this.formStore.productConditionsForm.calculatorForm.endDate!)!.toISOString();
1928
+ }
1929
+ }
1930
+ const result = await this.api.getCalculator(priceForm);
1931
+ if (this.isTask() && taskId) {
1932
+ await this.api.setApplication(priceForm);
1933
+ const applicationData = await this.api.getApplicationData(taskId);
1934
+ this.formStore.applicationData = applicationData;
1935
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
1936
+ } else {
1937
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(result)} тг`;
1938
+ }
1594
1939
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1595
1940
  } catch (err) {
1596
1941
  ErrorHandler(err);
@@ -1623,6 +1968,7 @@ export const useDataStore = defineStore('data', {
1623
1968
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
1624
1969
  return;
1625
1970
  }
1971
+ this.formStore.regNumber = applicationData.regNumber;
1626
1972
  this.formStore.applicationData = applicationData;
1627
1973
  this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
1628
1974
 
@@ -1634,7 +1980,6 @@ export const useDataStore = defineStore('data', {
1634
1980
  this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
1635
1981
  this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
1636
1982
  this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
1637
-
1638
1983
  this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
1639
1984
  this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
1640
1985
 
@@ -1656,7 +2001,49 @@ export const useDataStore = defineStore('data', {
1656
2001
  this.formStore.finCenterData.regNumber = applicationData.finCenterData.regNumber;
1657
2002
  this.formStore.finCenterData.date = reformatDate(applicationData.finCenterData.date);
1658
2003
  }
2004
+ if ('lifeTripApp' in applicationData && setProductConditions) {
2005
+ const tripType = this.types.find((i: Value) => i.id === applicationData.lifeTripApp.tripTypeId);
2006
+ this.formStore.productConditionsForm.calculatorForm.type = tripType ? tripType : new Value();
2007
+
2008
+ const countries: CountryValue[] = [];
2009
+ for (let i in applicationData.lifeTripApp.lifeTripCountries) {
2010
+ const tripCountry = this.dicAllCountries.find(country => country.id === applicationData.lifeTripApp.lifeTripCountries[i]);
2011
+ if (tripCountry) {
2012
+ countries.push(tripCountry);
2013
+ }
2014
+ }
2015
+ this.formStore.productConditionsForm.calculatorForm.countries = countries ? countries : [];
2016
+
2017
+ if (this.formStore.productConditionsForm.calculatorForm.countries.length && this.formStore.productConditionsForm.calculatorForm.type.nameRu != null) {
2018
+ await this.getTripInsuredAmount(false);
2019
+ }
2020
+
2021
+ const amount = this.amountArray.find((i: Value) => i.id === applicationData.lifeTripApp.insuredAmountId);
2022
+ this.formStore.productConditionsForm.calculatorForm.amount = amount ? amount : new Value();
2023
+
2024
+ const purpose = this.purposes.find((i: Value) => i.id === applicationData.lifeTripApp.tripPurposeId);
2025
+ this.formStore.productConditionsForm.calculatorForm.purpose = purpose ? purpose : new Value();
2026
+
2027
+ if (applicationData.lifeTripApp.workTypeId != null) {
2028
+ const work = this.workTypes.find((i: Value) => i.id === applicationData.lifeTripApp.workTypeId);
2029
+ this.formStore.productConditionsForm.calculatorForm.workType = work ? work : new Value();
2030
+ }
2031
+ if (applicationData.lifeTripApp.sportsTypeId != null) {
2032
+ const sport = this.sportsTypes.find((i: Value) => i.id === applicationData.lifeTripApp.sportsTypeId);
2033
+ this.formStore.productConditionsForm.calculatorForm.sportsType = sport ? sport : new Value();
2034
+ }
2035
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
2036
+ this.formStore.productConditionsForm.calculatorForm.days = Number(applicationData.lifeTripApp.singleTripDays);
2037
+ } else {
2038
+ await this.getPeriod();
2039
+ this.formStore.productConditionsForm.calculatorForm.maxDays = this.maxDaysAllArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.multipleTripMaxDays)!;
2040
+ this.formStore.productConditionsForm.calculatorForm.period = this.periodArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.tripInsurancePeriod)!;
2041
+ }
2042
+ this.formStore.productConditionsForm.calculatorForm.startDate = reformatDate(applicationData.lifeTripApp.startDate);
2043
+ this.formStore.productConditionsForm.calculatorForm.endDate = reformatDate(applicationData.lifeTripApp.endDate);
1659
2044
 
2045
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
2046
+ }
1660
2047
  if (fetchMembers) {
1661
2048
  let allMembers = [
1662
2049
  {
@@ -1726,7 +2113,7 @@ export const useDataStore = defineStore('data', {
1726
2113
  if (insuredData && insuredData.length) {
1727
2114
  insuredData.forEach((each, index) => {
1728
2115
  this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1729
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2116
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1730
2117
  this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1731
2118
  });
1732
2119
  }
@@ -1734,11 +2121,11 @@ export const useDataStore = defineStore('data', {
1734
2121
  if (beneficiaryData && beneficiaryData.length) {
1735
2122
  beneficiaryData.forEach((each, index) => {
1736
2123
  this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
1737
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2124
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1738
2125
  this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1739
2126
  this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
1740
2127
  if (this.isLiferenta || this.isBolashak) {
1741
- const insurancePay = this.insurancePay.find(i => i.id == each.beneficiaryInsurancePayId);
2128
+ const insurancePay = this.insurancePay.find((i: Value) => i.id == each.beneficiaryInsurancePayId);
1742
2129
  this.formStore.beneficiaryForm[index].insurancePay = insurancePay ? insurancePay : new Value();
1743
2130
  }
1744
2131
  });
@@ -1770,7 +2157,9 @@ export const useDataStore = defineStore('data', {
1770
2157
  this.formStore.policyholdersRepresentativeForm.isNotary = spokesmanData.isNotary;
1771
2158
  }
1772
2159
  }
1773
- if (setProductConditions) {
2160
+ if (setProductConditions && !!applicationData.policyAppDto) {
2161
+ this.formStore.policyNumber = applicationData.policyAppDto.policyNumber;
2162
+ this.formStore.contractDate = reformatDate(applicationData.policyAppDto.contractDate);
1774
2163
  this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
1775
2164
  this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
1776
2165
  // this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
@@ -1858,7 +2247,7 @@ export const useDataStore = defineStore('data', {
1858
2247
  try {
1859
2248
  const data = {
1860
2249
  taskId: taskId,
1861
- decision: decision,
2250
+ decision: decision.replace(/custom/i, '') as keyof typeof constants.actions,
1862
2251
  };
1863
2252
  await this.api.sendTask(comment === null ? data : { ...data, comment: comment });
1864
2253
  this.showToaster('success', this.t('toaster.successOperation'), 3000);
@@ -1866,6 +2255,7 @@ export const useDataStore = defineStore('data', {
1866
2255
  return true;
1867
2256
  } catch (err) {
1868
2257
  this.isLoading = false;
2258
+ this.isButtonsLoading = false;
1869
2259
  return ErrorHandler(err);
1870
2260
  }
1871
2261
  },
@@ -1887,13 +2277,15 @@ export const useDataStore = defineStore('data', {
1887
2277
  }
1888
2278
  case constants.actions.reject:
1889
2279
  case constants.actions.return:
2280
+ case constants.actions.signed:
1890
2281
  case constants.actions.rejectclient:
1891
- case constants.actions.accept: {
2282
+ case constants.actions.accept:
2283
+ case constants.actions.payed: {
1892
2284
  try {
1893
2285
  const sended = await this.sendTask(taskId, action, comment);
1894
2286
  if (!sended) return;
1895
2287
  this.formStore.$reset();
1896
- if (this.isEFO || this.isAML) {
2288
+ if (this.isEFO || this.isAML || this.isAULETTI) {
1897
2289
  await this.router.push({ name: 'Insurance-Product' });
1898
2290
  } else {
1899
2291
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1905,10 +2297,13 @@ export const useDataStore = defineStore('data', {
1905
2297
  }
1906
2298
  case constants.actions.affiliate: {
1907
2299
  try {
1908
- const sended = await this.sendUnderwritingCouncilTask({ taskId: taskId, decision: constants.actions.accept });
2300
+ const sended = await this.sendUnderwritingCouncilTask({
2301
+ taskId: taskId,
2302
+ decision: constants.actions.accept,
2303
+ });
1909
2304
  if (!sended) return;
1910
2305
  this.formStore.$reset();
1911
- if (this.isEFO || this.isAML) {
2306
+ if (this.isEFO || this.isAML || this.isAULETTI) {
1912
2307
  await this.router.push({ name: 'Insurance-Product' });
1913
2308
  } else {
1914
2309
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1988,7 +2383,7 @@ export const useDataStore = defineStore('data', {
1988
2383
  this.formStore[whichForm][index].jobPlace = this.formStore.applicationData[whichMember][index].jobName;
1989
2384
  }
1990
2385
  },
1991
- async signDocument() {
2386
+ async signDocument(type: string = 'electronic') {
1992
2387
  try {
1993
2388
  if (this.formStore.signUrls.length) {
1994
2389
  return this.formStore.signUrls;
@@ -1996,21 +2391,122 @@ export const useDataStore = defineStore('data', {
1996
2391
  const prepareSignDocuments = (): SignDataType[] => {
1997
2392
  switch (this.formStore.applicationData.statusCode) {
1998
2393
  case 'ContractSignedFrom':
1999
- return [{ processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Contract', format: 'pdf' }];
2394
+ return [
2395
+ {
2396
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2397
+ name: 'Contract',
2398
+ format: 'pdf',
2399
+ },
2400
+ ];
2000
2401
  default:
2001
2402
  return [
2002
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Agreement', format: 'pdf' },
2003
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Statement', format: 'pdf' },
2403
+ {
2404
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2405
+ name: 'Agreement',
2406
+ format: 'pdf',
2407
+ },
2408
+ {
2409
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2410
+ name: 'Statement',
2411
+ format: 'pdf',
2412
+ },
2004
2413
  ];
2005
2414
  }
2006
2415
  };
2007
2416
  const data = prepareSignDocuments();
2008
- const result = await this.api.signDocument(data);
2009
- this.formStore.signUrls = result;
2010
- return this.formStore.signUrls;
2417
+ if (type === 'qr') {
2418
+ const groupId = await this.api.signQR(data);
2419
+ return groupId;
2420
+ } else {
2421
+ const result = await this.api.signDocument(data);
2422
+ this.formStore.signUrls = result;
2423
+ return this.formStore.signUrls;
2424
+ }
2425
+ } catch (err) {
2426
+ ErrorHandler(err);
2427
+ }
2428
+ },
2429
+ async downloadTemplate(documentType: number, fileType: string = 'pdf', processInstanceId?: string | number) {
2430
+ try {
2431
+ this.isButtonsLoading = true;
2432
+ const response: any = await this.api.downloadTemplate(documentType, processInstanceId);
2433
+ const blob = new Blob([response], {
2434
+ type: `application/${fileType}`,
2435
+ });
2436
+ const url = window.URL.createObjectURL(blob);
2437
+ const link = document.createElement('a');
2438
+ link.href = url;
2439
+ switch (documentType) {
2440
+ case constants.documentTypes.insuredsList:
2441
+ link.setAttribute('download', 'РФ-ДС-028 Список застрахованных ГССЖ_ГНС, изд.1.xls');
2442
+ break;
2443
+ case constants.documentTypes.statement:
2444
+ link.setAttribute('download', 'Заявление.pdf');
2445
+ break;
2446
+ case constants.documentTypes.contract:
2447
+ link.setAttribute('download', 'Договор страхования.pdf');
2448
+ break;
2449
+ case constants.documentTypes.application1:
2450
+ link.setAttribute('download', 'Приложение №1.xls');
2451
+ break;
2452
+ case constants.documentTypes.questionnaireInsured:
2453
+ link.setAttribute('download', 'Анкета Застрахованного.docx');
2454
+ break;
2455
+ case constants.documentTypes.invoicePayment:
2456
+ link.setAttribute('download', 'Счет на оплату.pdf');
2457
+ break;
2458
+ }
2459
+ document.body.appendChild(link);
2460
+ link.click();
2011
2461
  } catch (err) {
2012
2462
  ErrorHandler(err);
2013
2463
  }
2464
+ this.isButtonsLoading = false;
2465
+ },
2466
+ async sendTemplateToEmail(email: string) {
2467
+ try {
2468
+ this.isButtonsLoading = true;
2469
+ await this.api.sendTemplateToEmail(email);
2470
+ this.showToaster('info', this.t('toaster.successfullyDocSent'), 5000);
2471
+ } catch (err) {
2472
+ ErrorHandler(err);
2473
+ }
2474
+ this.isButtonsLoading = false;
2475
+ },
2476
+ async sendInvoiceToEmail(processInstanceId: string | number, email: string) {
2477
+ try {
2478
+ this.isButtonsLoading = true;
2479
+ await this.api.sendInvoiceToEmail(processInstanceId, email);
2480
+ this.showToaster('info', this.t('toaster.successfullyDocSent'), 5000);
2481
+ } catch (err) {
2482
+ ErrorHandler(err);
2483
+ }
2484
+ this.isButtonsLoading = false;
2485
+ },
2486
+ async generateDocument() {
2487
+ try {
2488
+ this.isButtonsLoading = true;
2489
+ this.formStore.needToScanSignedContract = true;
2490
+ const data: SignDataType = {
2491
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2492
+ name: 'Contract',
2493
+ format: 'pdf',
2494
+ };
2495
+ const response: any = await this.api.generateDocument(data);
2496
+ const blob = new Blob([response], {
2497
+ type: `application/pdf`,
2498
+ });
2499
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2500
+ const url = window.URL.createObjectURL(blob);
2501
+ const link = document.createElement('a');
2502
+ link.href = url;
2503
+ link.setAttribute('download', this.formStore.regNumber + ' Договор страхования');
2504
+ document.body.appendChild(link);
2505
+ link.click();
2506
+ } catch (err) {
2507
+ ErrorHandler(err);
2508
+ }
2509
+ this.isButtonsLoading = false;
2014
2510
  },
2015
2511
  async registerNumber() {
2016
2512
  try {
@@ -2082,6 +2578,9 @@ export const useDataStore = defineStore('data', {
2082
2578
  const recalculatedValue = await this.api.reCalculate(data);
2083
2579
  if (!!recalculatedValue) {
2084
2580
  await this.getApplicationData(taskId, false, false, false, true);
2581
+ if (this.isGons) {
2582
+ this.formStore.productConditionsForm.isRecalculated = true;
2583
+ }
2085
2584
  this.showToaster(
2086
2585
  'success',
2087
2586
  `${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
@@ -2123,7 +2622,7 @@ export const useDataStore = defineStore('data', {
2123
2622
  }
2124
2623
  }
2125
2624
  } else {
2126
- if (this.formStore[localKey].some((i: any) => i.iin !== null)) {
2625
+ if (this.formStore[localKey].some(i => i.iin !== null)) {
2127
2626
  this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
2128
2627
  return false;
2129
2628
  }
@@ -2221,8 +2720,8 @@ export const useDataStore = defineStore('data', {
2221
2720
  }
2222
2721
  if (localCheck === false) {
2223
2722
  try {
2224
- if (this.isInitiator() && !this.isGons) {
2225
- if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
2723
+ if (this.isInitiator() && this.members.beneficialOwnerApp.has) {
2724
+ if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
2226
2725
  await Promise.allSettled(
2227
2726
  this.formStore.applicationData.beneficialOwnerApp.map(async (member: any) => {
2228
2727
  await this.api.deleteMember('BeneficialOwner', member.id);
@@ -2242,124 +2741,127 @@ export const useDataStore = defineStore('data', {
2242
2741
  if (!anketa) return false;
2243
2742
  const list = anketa.body;
2244
2743
  if (!list || (list && list.length === 0)) return false;
2245
- let notAnswered = 0;
2246
- for (let x = 0; x < list.length; x++) {
2247
- if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
2248
- notAnswered = notAnswered + 1;
2744
+ const isAnketaValid = ref<boolean>(true);
2745
+ list.forEach(i => {
2746
+ if (
2747
+ (i.first.definedAnswers === 'N' && !i.first.answerText) ||
2748
+ (i.first.definedAnswers === 'Y' && !i.first.answerName) ||
2749
+ (i.first.definedAnswers === 'D' && !i.first.answerName?.match(new RegExp('Нет', 'i')) && !i.first.answerText)
2750
+ ) {
2751
+ isAnketaValid.value = false;
2752
+ return false;
2249
2753
  }
2250
- }
2251
- return notAnswered === 0;
2754
+ if (this.controls.isSecondAnketaRequired && i.first.definedAnswers === 'Y' && i.first.answerName?.match(new RegExp('Да', 'i'))) {
2755
+ if (i.second && i.second.length) {
2756
+ const isValid = i.second.every(second => (second.definedAnswers === 'N' ? !!second.answerText : !!second.answerName));
2757
+ if (!isValid) {
2758
+ isAnketaValid.value = false;
2759
+ this.showToaster('info', this.t('toaster.emptySecondAnketa', { text: i.first.name }), 5000);
2760
+ return false;
2761
+ }
2762
+ } else {
2763
+ // TODO уточнить
2764
+ }
2765
+ }
2766
+ });
2767
+ return isAnketaValid.value;
2252
2768
  },
2253
2769
  async validateAllForms(taskId: string) {
2254
2770
  this.isLoading = true;
2255
2771
  const areMembersValid = await this.validateAllMembers(taskId);
2256
2772
  if (areMembersValid) {
2257
2773
  if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
2258
- const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
2259
- if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i'))) {
2260
- await Promise.allSettled([
2261
- this.getQuestionList(
2262
- 'health',
2263
- this.formStore.applicationData.processInstanceId,
2264
- this.formStore.applicationData.insuredApp[0].id,
2265
- 'surveyByHealthBase',
2266
- 'surveyByHealthSecond',
2267
- ),
2268
- this.getQuestionList(
2269
- 'critical',
2270
- this.formStore.applicationData.processInstanceId,
2271
- this.formStore.applicationData.insuredApp[0].id,
2272
- 'surveyByCriticalBase',
2273
- 'surveyByCriticalSecond',
2274
- ),
2275
- this.isClientAnketaCondition &&
2276
- this.getQuestionList(
2277
- 'health',
2278
- this.formStore.applicationData.processInstanceId,
2279
- this.formStore.applicationData.clientApp.id,
2280
- 'surveyByHealthBasePolicyholder',
2281
- 'surveyByHealthSecond',
2282
- 'policyholder',
2283
- ),
2284
- ]);
2285
- this.isClientAnketaCondition
2286
- ? await Promise.allSettled([
2287
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2288
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2289
- }),
2290
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2291
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2292
- }),
2293
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2294
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2295
- }),
2296
- ])
2297
- : await Promise.allSettled([
2298
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2299
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2300
- }),
2301
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2302
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2303
- }),
2304
- ]);
2305
- } else {
2306
- await Promise.allSettled([
2307
- this.getQuestionList(
2308
- 'health',
2309
- this.formStore.applicationData.processInstanceId,
2310
- this.formStore.applicationData.insuredApp[0].id,
2311
- 'surveyByHealthBase',
2312
- 'surveyByHealthSecond',
2313
- ),
2314
- this.isClientAnketaCondition &&
2315
- this.getQuestionList(
2316
- 'health',
2317
- this.formStore.applicationData.processInstanceId,
2318
- this.formStore.applicationData.clientApp.id,
2319
- 'surveyByHealthBasePolicyholder',
2320
- 'surveyByHealthSecond',
2321
- 'policyholder',
2322
- ),
2323
- ,
2324
- ]);
2325
- this.isClientAnketaCondition
2326
- ? await Promise.allSettled([
2327
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2328
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2329
- }),
2330
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2331
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2332
- }),
2333
- ])
2334
- : await Promise.allSettled(
2335
- this.formStore.surveyByHealthBase!.body.map(async question => {
2336
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2337
- }),
2338
- );
2339
- }
2340
- if (this.validateAnketa('surveyByHealthBase')) {
2341
- let hasCriticalAndItsValid = null;
2342
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2343
- if (this.validateAnketa('surveyByCriticalBase')) {
2344
- hasCriticalAndItsValid = true;
2345
- } else {
2346
- hasCriticalAndItsValid = false;
2347
- this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2348
- }
2774
+ if (this.controls.hasAnketa) {
2775
+ const hasCritical =
2776
+ this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName.match(new RegExp('Критическое заболевание Застрахованного', 'i'))) ?? null;
2777
+ if (hasCritical === null || (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')))) {
2778
+ await Promise.allSettled([
2779
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2780
+ this.isClientAnketaCondition &&
2781
+ this.getQuestionList(
2782
+ 'health',
2783
+ this.formStore.applicationData.processInstanceId,
2784
+ this.formStore.applicationData.clientApp.id,
2785
+ 'surveyByHealthBasePolicyholder',
2786
+ 'policyholder',
2787
+ ),
2788
+ ,
2789
+ ]);
2790
+ this.isClientAnketaCondition
2791
+ ? await Promise.allSettled([
2792
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2793
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2794
+ }),
2795
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2796
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2797
+ }),
2798
+ ])
2799
+ : await Promise.allSettled(
2800
+ this.formStore.surveyByHealthBase!.body.map(async question => {
2801
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2802
+ }),
2803
+ );
2349
2804
  } else {
2350
- hasCriticalAndItsValid = null;
2805
+ await Promise.allSettled([
2806
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2807
+ this.getQuestionList('critical', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByCriticalBase'),
2808
+ this.isClientAnketaCondition &&
2809
+ this.getQuestionList(
2810
+ 'health',
2811
+ this.formStore.applicationData.processInstanceId,
2812
+ this.formStore.applicationData.clientApp.id,
2813
+ 'surveyByHealthBasePolicyholder',
2814
+ 'policyholder',
2815
+ ),
2816
+ ]);
2817
+ this.isClientAnketaCondition
2818
+ ? await Promise.allSettled([
2819
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2820
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2821
+ }),
2822
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2823
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2824
+ }),
2825
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2826
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2827
+ }),
2828
+ ])
2829
+ : await Promise.allSettled([
2830
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2831
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2832
+ }),
2833
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2834
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2835
+ }),
2836
+ ]);
2351
2837
  }
2352
- if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2353
- if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
2354
- this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
2838
+ if (this.validateAnketa('surveyByHealthBase')) {
2839
+ let hasCriticalAndItsValid = null;
2840
+ if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')) === null) {
2841
+ if (this.validateAnketa('surveyByCriticalBase')) {
2842
+ hasCriticalAndItsValid = true;
2843
+ } else {
2844
+ hasCriticalAndItsValid = false;
2845
+ this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2846
+ }
2847
+ } else {
2848
+ hasCriticalAndItsValid = null;
2849
+ }
2850
+ if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2851
+ if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
2852
+ this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
2853
+ this.isLoading = false;
2854
+ return false;
2855
+ }
2355
2856
  this.isLoading = false;
2356
- return false;
2857
+ return true;
2357
2858
  }
2358
- this.isLoading = false;
2359
- return true;
2859
+ } else {
2860
+ this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2360
2861
  }
2361
2862
  } else {
2362
- this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2863
+ this.isLoading = false;
2864
+ return true;
2363
2865
  }
2364
2866
  } else {
2365
2867
  this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
@@ -2372,7 +2874,10 @@ export const useDataStore = defineStore('data', {
2372
2874
  async getFamilyInfo(iin: string, phoneNumber: string) {
2373
2875
  this.isLoading = true;
2374
2876
  try {
2375
- const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
2877
+ const familyResponse = await this.api.getFamilyInfo({
2878
+ iin: iin.replace(/-/g, ''),
2879
+ phoneNumber: formatPhone(phoneNumber),
2880
+ });
2376
2881
  if (familyResponse.status === 'soap:Server') {
2377
2882
  this.showToaster('error', `${familyResponse.statusName}. Отправьте запрос через некоторое время`, 5000);
2378
2883
  this.isLoading = false;
@@ -2417,6 +2922,32 @@ export const useDataStore = defineStore('data', {
2417
2922
  this.isLoading = false;
2418
2923
  }
2419
2924
  },
2925
+ async getKgd(iin: string) {
2926
+ try {
2927
+ const data = {
2928
+ iinBin: iin.replace(/-/g, ''),
2929
+ };
2930
+ const kgdResponse = await this.api.getKgd(data);
2931
+ return kgdResponse;
2932
+ } catch (err) {
2933
+ return ErrorHandler(err);
2934
+ }
2935
+ },
2936
+ async getGbdUl(bin: string) {
2937
+ if (!this.accessToken) return null;
2938
+ try {
2939
+ const decoded = jwtDecode(this.accessToken);
2940
+ const data = {
2941
+ userName: decoded.code,
2942
+ branchName: decoded.branchCode,
2943
+ bin: bin.replace(/-/g, ''),
2944
+ };
2945
+ const gbdulResponse = await this.api.getGbdUl(data);
2946
+ return gbdulResponse;
2947
+ } catch (err) {
2948
+ return ErrorHandler(err);
2949
+ }
2950
+ },
2420
2951
  async getContragentFromGBDFL(member: Member) {
2421
2952
  // null - ожидание
2422
2953
  // false - ошибка или неправильно
@@ -2448,13 +2979,27 @@ export const useDataStore = defineStore('data', {
2448
2979
  this.isLoading = false;
2449
2980
  return false;
2450
2981
  }
2982
+ if (!gbdResponse.content) {
2983
+ let errMsg: string = '';
2984
+ if (gbdResponse.status) {
2985
+ errMsg += gbdResponse.status;
2986
+ }
2987
+ if (gbdResponse.statusName) {
2988
+ errMsg += gbdResponse.statusName;
2989
+ }
2990
+ if (!!errMsg) {
2991
+ this.showToaster('error', errMsg, 5000);
2992
+ }
2993
+ this.isLoading = false;
2994
+ return false;
2995
+ }
2451
2996
  const { person } = parseXML(gbdResponse.content, true, 'person');
2452
2997
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2453
2998
  if (member.gosPersonData !== null && member.gosPersonData.iin !== member.iin!.replace(/-/g, '')) {
2454
2999
  member.resetMember(false);
2455
3000
  }
2456
3001
  member.gosPersonData = person;
2457
- await this.getContragent(member, false);
3002
+ await this.getContragent(member, false, false);
2458
3003
  member.verifyDate = responseInfo.responseDate;
2459
3004
  member.verifyType = 'GBDFL';
2460
3005
  await this.saveInStoreUserGBDFL(person, member);
@@ -2469,11 +3014,15 @@ export const useDataStore = defineStore('data', {
2469
3014
  member.firstName = person.name;
2470
3015
  member.lastName = person.surname;
2471
3016
  member.middleName = person.patronymic ? person.patronymic : '';
3017
+ if (this.isLifetrip) {
3018
+ member.firstNameLat = person.engFirstName ? person.engFirstName : '';
3019
+ member.lastNameLat = person.engSurname ? person.engSurname : '';
3020
+ }
2472
3021
  member.longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2473
3022
  member.birthDate = reformatDate(person.birthDate);
2474
3023
  member.genderName = person.gender.nameRu;
2475
3024
 
2476
- const gender = this.gender.find(i => i.id == person.gender.code);
3025
+ const gender = this.gender.find((i: Value) => i.id == person.gender.code);
2477
3026
  if (gender) member.gender = gender;
2478
3027
 
2479
3028
  const birthPlace = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.birthPlace.country.nameRu, 'i')));
@@ -2556,7 +3105,7 @@ export const useDataStore = defineStore('data', {
2556
3105
  if ('length' in person.documents.document) {
2557
3106
  const validDocument = person.documents.document.find((i: any) => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2558
3107
  if (validDocument) {
2559
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
3108
+ const documentType = this.documentTypes.find((i: Value) => i.ids === '1UDL');
2560
3109
  if (documentType) member.documentType = documentType;
2561
3110
 
2562
3111
  member.documentNumber = validDocument.number;
@@ -2570,7 +3119,7 @@ export const useDataStore = defineStore('data', {
2570
3119
  } else {
2571
3120
  const documentType =
2572
3121
  person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2573
- ? this.documentTypes.find(i => i.ids === '1UDL')
3122
+ ? this.documentTypes.find((i: Value) => i.ids === '1UDL')
2574
3123
  : this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2575
3124
  ? this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2576
3125
  : new Value();
@@ -2589,9 +3138,368 @@ export const useDataStore = defineStore('data', {
2589
3138
  const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
2590
3139
  if (documentIssuer) member.documentIssuers = documentIssuer;
2591
3140
  }
2592
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
3141
+ const economySectorCode = this.economySectorCode.find((i: Value) => i.ids === '500003.9');
2593
3142
  if (economySectorCode) member.economySectorCode = economySectorCode;
2594
3143
  },
3144
+ preparePersonData(data: any) {
3145
+ if (data) {
3146
+ Object.keys(data).forEach(key => {
3147
+ if (data[key] === Object(data[key]) && !!data[key]) {
3148
+ this.preparePersonData(data[key]);
3149
+ } else {
3150
+ if (data[key] !== null) {
3151
+ if (key === 'iin' || key === 'bin') data[key] = data[key].replace(/-/g, '');
3152
+ if (key === 'phoneNumber') data[key] = formatPhone(data[key]);
3153
+ if (key === 'issuedOn' || key === 'validUntil' || key === 'birthDate') data[key] = formatDate(data[key])?.toISOString() ?? '';
3154
+ if (key === 'nameRu' && data['ids']) data['id'] = data['ids'];
3155
+ }
3156
+ }
3157
+ });
3158
+ }
3159
+ },
3160
+ async startApplicationV2(data: PolicyholderClass) {
3161
+ const policyholder = JSON.parse(JSON.stringify(data)) as any;
3162
+ if (!policyholder.clientData.iin) return false;
3163
+ this.preparePersonData(policyholder);
3164
+ keyDeleter(policyholder as PolicyholderClass, [
3165
+ 'clientData.beneficalOwnerQuest',
3166
+ 'clientData.identityDocument',
3167
+ 'clientData.activityTypes',
3168
+ 'clientData.citizenship',
3169
+ 'clientData.addTaxResidency',
3170
+ 'clientData.gender',
3171
+ 'clientData.placeOfBirth',
3172
+ 'clientData.authoritedPerson.actualAddress',
3173
+ 'clientData.authoritedPerson.bankInfo',
3174
+ 'clientData.authoritedPerson.economySectorCode',
3175
+ 'clientData.authoritedPerson.legalAddress',
3176
+ 'clientData.authoritedPerson.placeOfBirth',
3177
+ 'clientData.authoritedPerson.resident',
3178
+ 'clientData.authoritedPerson.taxResidentCountry',
3179
+ 'clientData.authoritedPerson.addTaxResidency',
3180
+ ]);
3181
+ policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3182
+ try {
3183
+ const response = await this.api.startApplication(policyholder);
3184
+ this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
3185
+ return response.processInstanceId;
3186
+ } catch (err) {
3187
+ return ErrorHandler(err);
3188
+ }
3189
+ },
3190
+ async saveClient(data: PolicyholderClass) {
3191
+ const policyholder = JSON.parse(JSON.stringify(data)) as any;
3192
+ policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3193
+ this.preparePersonData(policyholder);
3194
+ try {
3195
+ await this.api.saveClient(this.formStore.applicationData.processInstanceId, this.formStore.lfb.clientId, policyholder);
3196
+ } catch (err) {
3197
+ return ErrorHandler(err);
3198
+ }
3199
+ },
3200
+ async getApplicationDataV2(taskId: string) {
3201
+ this.isLoading = true;
3202
+ try {
3203
+ const applicationData = await this.api.getApplicationData(taskId);
3204
+ if (this.processCode !== applicationData.processCode) {
3205
+ this.isLoading = false;
3206
+ this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
3207
+ return;
3208
+ }
3209
+
3210
+ this.formStore.applicationData = applicationData;
3211
+ this.formStore.regNumber = applicationData.regNumber;
3212
+ this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
3213
+
3214
+ this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
3215
+ this.formStore.applicationTaskId = taskId;
3216
+ this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
3217
+ this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
3218
+ this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
3219
+ this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
3220
+ this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
3221
+ this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
3222
+
3223
+ this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
3224
+ this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
3225
+
3226
+ const { clientData } = applicationData.clientApp;
3227
+ const beneficialOwnerApp = applicationData.beneficialOwnerApp;
3228
+ const insuredApp = applicationData.insuredApp;
3229
+ const accidentIncidents = applicationData.accidentIncidentDtos;
3230
+ const clientId = applicationData.clientApp.id;
3231
+
3232
+ this.formStore.applicationData.processInstanceId = applicationData.processInstanceId;
3233
+ this.formStore.lfb.policyholder.isIpdl = applicationData.clientApp.isIpdl;
3234
+ this.formStore.lfb.policyholder.clientData = clientData;
3235
+ this.formStore.lfb.policyholder.clientData.authoritedPerson = clientData.authoritedPerson;
3236
+ this.formStore.lfb.policyholder.clientData.iin = reformatIin(clientData.iin);
3237
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.iin = reformatIin(clientData.authoritedPerson.iin);
3238
+ this.formStore.lfb.clientId = clientId;
3239
+ this.formStore.lfb.policyholder.clientData.authorityDetails.date = reformatDate(clientData.authorityDetails.date);
3240
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.birthDate = reformatDate(clientData.authoritedPerson.birthDate) ?? '';
3241
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.issuedOn = reformatDate(clientData.authoritedPerson.identityDocument.issuedOn) ?? '';
3242
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.validUntil = reformatDate(clientData.authoritedPerson.identityDocument.validUntil) ?? '';
3243
+ const gender = this.gender.find((i: Value) => i.id === clientData.authoritedPerson.gender);
3244
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.gender = gender ? gender : new Value();
3245
+
3246
+ if (clientData && clientData.activityTypes !== null) {
3247
+ this.formStore.lfb.policyholderActivities = clientData.activityTypes;
3248
+ }
3249
+
3250
+ if (beneficialOwnerApp && beneficialOwnerApp.length) {
3251
+ this.formStore.lfb.beneficialOwners = beneficialOwnerApp;
3252
+ this.formStore.lfb.isPolicyholderBeneficialOwner = clientData.authoritedPerson.iin.replace(/-/g, '') === beneficialOwnerApp[0].beneficialOwnerData.iin ? true : false;
3253
+ this.formStore.lfb.beneficialOwners.forEach(beneficial => {
3254
+ beneficial.beneficialOwnerData.birthDate = reformatDate(beneficial.beneficialOwnerData.birthDate as string) ?? '';
3255
+ beneficial.beneficialOwnerData.identityDocument.validUntil = reformatDate(beneficial.beneficialOwnerData.identityDocument.validUntil as string) ?? '';
3256
+ beneficial.beneficialOwnerData.iin = reformatIin(beneficial.beneficialOwnerData.iin as string);
3257
+ beneficial.beneficialOwnerData.identityDocument.issuedOn = reformatDate(beneficial.beneficialOwnerData.identityDocument.issuedOn as string) ?? '';
3258
+ //@ts-ignore
3259
+ const gender = this.gender.find((i: Value) => i.id === beneficial.beneficialOwnerData.gender);
3260
+ beneficial.beneficialOwnerData.gender = gender ? gender : new Value();
3261
+ });
3262
+ }
3263
+
3264
+ if (insuredApp && insuredApp.length) {
3265
+ const res = await this.newInsuredList(insuredApp);
3266
+ this.formStore.lfb.clients = res;
3267
+ }
3268
+
3269
+ if (accidentIncidents && accidentIncidents.length) {
3270
+ this.formStore.lfb.accidentIncidents = accidentIncidents;
3271
+ this.formStore.lfb.accidentIncidents.forEach(incident => {
3272
+ incident.amount = incident.amount === 0 ? null : incident.amount;
3273
+ incident.count = incident.count === 0 ? null : incident.count;
3274
+ });
3275
+ }
3276
+
3277
+ this.formStore.productConditionsForm.agentCommission = applicationData.policyAppDto.agentCommission === 0 ? null : applicationData.policyAppDto.agentCommission;
3278
+ this.formStore.productConditionsForm.fixInsSum = this.getNumberWithSpaces(applicationData.policyAppDto.fixInsSum === 0 ? null : applicationData.policyAppDto.fixInsSum);
3279
+ this.formStore.productConditionsForm.coverPeriod = 12;
3280
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(applicationData.policyAppDto.amount === 0 ? null : applicationData.policyAppDto.amount);
3281
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
3282
+ applicationData.policyAppDto.mainPremiumWithCommission === 0 ? null : applicationData.policyAppDto.mainPremiumWithCommission,
3283
+ );
3284
+ const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
3285
+ this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
3286
+ const processGfot = this.processGfot.find(item => item.id == applicationData.policyAppDto.processDefinitionFgotId);
3287
+ this.formStore.productConditionsForm.processGfot = processGfot ? processGfot : new Value();
3288
+ } catch (err) {
3289
+ ErrorHandler(err);
3290
+ if (err instanceof AxiosError) {
3291
+ this.sendToParent(constants.postActions.toHomePage, err.response?.data);
3292
+ this.isLoading = false;
3293
+ return false;
3294
+ }
3295
+ }
3296
+ this.isLoading = false;
3297
+ },
3298
+ async saveAccidentIncidents(data: AccidentIncidents[]) {
3299
+ try {
3300
+ const response = await this.api.saveAccidentIncidents(this.formStore.applicationData.processInstanceId, data);
3301
+ return response;
3302
+ } catch (err) {
3303
+ return ErrorHandler(err);
3304
+ }
3305
+ },
3306
+ async saveClientActivityTypes(data: PolicyholderActivity[]) {
3307
+ try {
3308
+ const response = await this.api.saveClientActivityTypes(this.formStore.applicationData.clientApp.id, data);
3309
+ return response;
3310
+ } catch (err) {
3311
+ return ErrorHandler(err);
3312
+ }
3313
+ },
3314
+ async saveBeneficialOwnerList(data: BeneficialOwner[]) {
3315
+ const beneficialOwnerList = JSON.parse(JSON.stringify(data)) as any;
3316
+ for (const item of beneficialOwnerList) {
3317
+ keyDeleter(item as BeneficialOwner, [
3318
+ 'beneficialOwnerData.activityTypes',
3319
+ 'beneficialOwnerData.actualAddress',
3320
+ 'beneficialOwnerData.addTaxResidency',
3321
+ 'beneficialOwnerData.authoritedPerson',
3322
+ 'beneficialOwnerData.authorityDetails',
3323
+ 'beneficialOwnerData.bankInfo',
3324
+ 'beneficialOwnerData.legalAddress',
3325
+ 'beneficialOwnerData.placeOfBirth',
3326
+ 'beneficialOwnerData.typeOfEconomicActivity',
3327
+ ]);
3328
+ item.processInstanceId = this.formStore.applicationData.processInstanceId;
3329
+ item.beneficialOwnerData.gender = item.beneficialOwnerData.gender.nameRu === 'Мужской' ? 1 : 2;
3330
+ this.preparePersonData(item.beneficialOwnerData);
3331
+ }
3332
+ try {
3333
+ const response = await this.api.saveBeneficialOwnerList(this.formStore.applicationData.processInstanceId, beneficialOwnerList);
3334
+ return response;
3335
+ } catch (err) {
3336
+ return ErrorHandler(err);
3337
+ }
3338
+ },
3339
+ async saveBeneficialOwner(data: BeneficialOwner) {
3340
+ const beneficialOwner = JSON.parse(JSON.stringify(data)) as any;
3341
+ keyDeleter(beneficialOwner as BeneficialOwner, [
3342
+ 'beneficialOwnerData.activityTypes',
3343
+ 'beneficialOwnerData.actualAddress',
3344
+ 'beneficialOwnerData.addTaxResidency',
3345
+ 'beneficialOwnerData.authoritedPerson',
3346
+ 'beneficialOwnerData.authorityDetails',
3347
+ 'beneficialOwnerData.bankInfo',
3348
+ 'beneficialOwnerData.legalAddress',
3349
+ 'beneficialOwnerData.placeOfBirth',
3350
+ 'beneficialOwnerData.typeOfEconomicActivity',
3351
+ ]);
3352
+ beneficialOwner.beneficialOwnerData.gender = beneficialOwner.beneficialOwnerData.gender.nameRu === 'Мужской' ? 1 : 2;
3353
+ this.preparePersonData(beneficialOwner.beneficialOwnerData);
3354
+ try {
3355
+ const response = await this.api.saveBeneficialOwner(this.formStore.applicationData.processInstanceId, String(beneficialOwner.id), beneficialOwner);
3356
+ return response;
3357
+ } catch (err) {
3358
+ return ErrorHandler(err);
3359
+ }
3360
+ },
3361
+ async saveInsuredList(insuredList: any) {
3362
+ try {
3363
+ const response = await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, insuredList);
3364
+ return response;
3365
+ } catch (err) {
3366
+ return ErrorHandler(err);
3367
+ }
3368
+ },
3369
+ async saveInsured(insured: any) {
3370
+ try {
3371
+ const response = await this.api.saveInsured(this.formStore.applicationData.processInstanceId, insured.id, insured);
3372
+ return response;
3373
+ } catch (err) {
3374
+ return ErrorHandler(err);
3375
+ }
3376
+ },
3377
+ newInsuredList(list: any) {
3378
+ const clients = list.map((item: any, index: number) => {
3379
+ const client = item.insuredData;
3380
+ return {
3381
+ id: index,
3382
+ fullName: client.longName,
3383
+ gender: client.gender,
3384
+ position: client.workDetails.position,
3385
+ birthDate: client.birthDate,
3386
+ iin: reformatIin(client.iin),
3387
+ insSum: client.insuredPolicyData.insSum,
3388
+ premium: client.insuredPolicyData.premium,
3389
+ hasAttachedFile: client.hasAttachedFile,
3390
+ };
3391
+ });
3392
+ return clients;
3393
+ },
3394
+ validateMultipleMembersV2(localKey: string, applicationKey: keyof typeof this.formStore.applicationData, text: string) {
3395
+ // @ts-ignore
3396
+ if (this.formStore.lfb[localKey].length === this.formStore.applicationData[applicationKey].length) {
3397
+ // @ts-ignore
3398
+ if (this.formStore.lfb[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
3399
+ // @ts-ignore
3400
+ const localMembers = [...this.formStore.lfb[localKey]].sort((a, b) => Number(a.id) - Number(b.id));
3401
+ const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.id - b.id);
3402
+ if (localMembers.every((each, index) => applicationMembers[index].iin === each.iin?.replace(/-/g, '')) === false) {
3403
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3404
+ return false;
3405
+ }
3406
+ }
3407
+ } else {
3408
+ // @ts-ignore
3409
+ if (this.formStore.lfb[localKey].some(i => i.iin !== null)) {
3410
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3411
+ return false;
3412
+ }
3413
+ if (this.formStore.applicationData[applicationKey].length !== 0) {
3414
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3415
+ return false;
3416
+ } else {
3417
+ // @ts-ignore
3418
+ if (this.formStore.lfb[localKey][0].iin !== null) {
3419
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3420
+ return false;
3421
+ }
3422
+ }
3423
+ }
3424
+ return true;
3425
+ },
3426
+ async validateAllFormsV2(taskId: string) {
3427
+ this.isLoading = true;
3428
+ if (taskId === '0') {
3429
+ this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
3430
+ return false;
3431
+ }
3432
+
3433
+ if (this.formStore.applicationData.clientApp.iin !== this.formStore.applicationData.clientApp.iin) {
3434
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
3435
+ return false;
3436
+ }
3437
+
3438
+ if (this.formStore.lfb.beneficialOwners) {
3439
+ if (this.validateMultipleMembersV2('beneficialOwners', 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
3440
+ return false;
3441
+ }
3442
+ const inStatement = this.formStore.lfb.beneficialOwners.every(i => i.beneficialOwnerData.id !== null);
3443
+ if (inStatement === false) {
3444
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficialOwner') }));
3445
+ return false;
3446
+ }
3447
+ }
3448
+
3449
+ if (this.formStore.applicationData.clientApp.clientData.activityTypes === null) {
3450
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'деятельности Страхователя' }), 3000);
3451
+ return false;
3452
+ }
3453
+
3454
+ if (this.formStore.lfb.clients) {
3455
+ if (this.validateMultipleMembersV2('clients', 'insuredApp', 'застрахованных') === false) {
3456
+ return false;
3457
+ }
3458
+ const inStatement = this.formStore.lfb.clients.every(i => i.id !== null);
3459
+ if (inStatement === false) {
3460
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.insured') }));
3461
+ return false;
3462
+ }
3463
+ }
3464
+
3465
+ if (this.formStore.lfb.clients && this.formStore.lfb.clients.length <= 10) {
3466
+ for (const client of this.formStore.lfb.clients) {
3467
+ if (client.hasAttachedFile === false) {
3468
+ this.showToaster('error', this.t('toaster.needAttachQuestionnaire'), 3000);
3469
+ return false;
3470
+ }
3471
+ }
3472
+ }
3473
+
3474
+ if (this.formStore.productConditionsForm.insurancePremiumPerMonth === null) {
3475
+ this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
3476
+ return false;
3477
+ }
3478
+
3479
+ if (this.formStore.productConditionsForm.insurancePremiumPerMonth === '0') {
3480
+ this.showToaster('error', this.t('toaster.notZeroPremium'), 3000);
3481
+ return false;
3482
+ }
3483
+
3484
+ return true;
3485
+ },
3486
+ async checkIIN(iin: string) {
3487
+ try {
3488
+ const response = await this.api.checkIIN(iin);
3489
+ return response;
3490
+ } catch (err) {
3491
+ ErrorHandler(err);
3492
+ return null;
3493
+ }
3494
+ },
3495
+ async checkAccountNumber(iik: string) {
3496
+ try {
3497
+ const checked = await this.api.checkAccountNumber(iik);
3498
+ return checked;
3499
+ } catch (err) {
3500
+ return ErrorHandler(err);
3501
+ }
3502
+ },
2595
3503
  async isCourseChanged(processInstanceId: string) {
2596
3504
  try {
2597
3505
  const response = await this.api.isCourseChanged(processInstanceId);
@@ -2600,7 +3508,19 @@ export const useDataStore = defineStore('data', {
2600
3508
  return ErrorHandler(err);
2601
3509
  }
2602
3510
  },
3511
+ async generateShortLink(url: string) {
3512
+ try {
3513
+ const response = await this.api.generateShortLink({
3514
+ link: url,
3515
+ priority: 'low',
3516
+ });
3517
+ return response.link;
3518
+ } catch (err) {
3519
+ return ErrorHandler(err);
3520
+ }
3521
+ },
2603
3522
  hasJobSection(whichForm: keyof typeof StoreMembers) {
3523
+ if (this.isLifetrip) return false;
2604
3524
  switch (whichForm) {
2605
3525
  case this.formStore.beneficiaryFormKey:
2606
3526
  case this.formStore.beneficialOwnerFormKey:
@@ -2641,8 +3561,30 @@ export const useDataStore = defineStore('data', {
2641
3561
  hasPercentageOfPayoutAmount() {
2642
3562
  return true;
2643
3563
  },
2644
- canViewInvoiceInfo() {
2645
- return this.isAdmin();
3564
+ hasAccess() {
3565
+ return {
3566
+ invoiceInfo: this.isAdmin(),
3567
+ toLKA: this.isAgent() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn(),
3568
+ toAML: this.isCompliance() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn(),
3569
+ toAULETTI: this.isAgentAuletti() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn(),
3570
+ toEFO:
3571
+ this.isManager() ||
3572
+ this.isAgent() ||
3573
+ this.isAgentMycar() ||
3574
+ this.isManagerHalykBank() ||
3575
+ this.isHeadManager() ||
3576
+ this.isServiceManager() ||
3577
+ this.isUnderwriter() ||
3578
+ this.isAdmin() ||
3579
+ this.isCompliance() ||
3580
+ this.isAnalyst() ||
3581
+ this.isUpk() ||
3582
+ this.isFinCenter() ||
3583
+ this.isSupervisor() ||
3584
+ this.isSupport() ||
3585
+ this.isDrn() ||
3586
+ this.isBranchDirector(),
3587
+ };
2646
3588
  },
2647
3589
  },
2648
3590
  });