hl-core 0.0.9-beta.8 → 0.0.10-beta.1

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 (72) hide show
  1. package/api/base.api.ts +1109 -0
  2. package/api/index.ts +2 -620
  3. package/api/interceptors.ts +38 -1
  4. package/components/Button/Btn.vue +1 -6
  5. package/components/Complex/MessageBlock.vue +1 -1
  6. package/components/Complex/Page.vue +1 -1
  7. package/components/Complex/TextBlock.vue +23 -0
  8. package/components/Dialog/Dialog.vue +70 -16
  9. package/components/Dialog/FamilyDialog.vue +1 -1
  10. package/components/Form/DynamicForm.vue +100 -0
  11. package/components/Form/FormBlock.vue +12 -3
  12. package/components/Form/FormData.vue +110 -0
  13. package/components/Form/FormSection.vue +3 -3
  14. package/components/Form/FormTextSection.vue +11 -3
  15. package/components/Form/FormToggle.vue +25 -5
  16. package/components/Form/ManagerAttachment.vue +177 -89
  17. package/components/Form/ProductConditionsBlock.vue +59 -6
  18. package/components/Input/Datepicker.vue +43 -7
  19. package/components/Input/DynamicInput.vue +23 -0
  20. package/components/Input/FileInput.vue +25 -5
  21. package/components/Input/FormInput.vue +7 -4
  22. package/components/Input/Monthpicker.vue +34 -0
  23. package/components/Input/PanelInput.vue +5 -1
  24. package/components/Input/RoundedSelect.vue +7 -2
  25. package/components/Input/SwitchInput.vue +64 -0
  26. package/components/Input/TextInput.vue +160 -0
  27. package/components/Layout/Drawer.vue +17 -4
  28. package/components/Layout/Header.vue +23 -2
  29. package/components/Layout/Loader.vue +2 -1
  30. package/components/Layout/SettingsPanel.vue +24 -11
  31. package/components/Menu/InfoMenu.vue +35 -0
  32. package/components/Menu/MenuNav.vue +25 -3
  33. package/components/Pages/Anketa.vue +254 -65
  34. package/components/Pages/Auth.vue +56 -9
  35. package/components/Pages/ContragentForm.vue +9 -9
  36. package/components/Pages/Documents.vue +266 -30
  37. package/components/Pages/InvoiceInfo.vue +1 -1
  38. package/components/Pages/MemberForm.vue +774 -102
  39. package/components/Pages/ProductAgreement.vue +1 -8
  40. package/components/Pages/ProductConditions.vue +1132 -180
  41. package/components/Panel/PanelHandler.vue +632 -50
  42. package/components/Panel/PanelSelectItem.vue +17 -2
  43. package/components/Panel/RightPanelCloser.vue +7 -0
  44. package/components/Transitions/Animation.vue +28 -0
  45. package/components/Utilities/JsonViewer.vue +3 -2
  46. package/components/Utilities/Qr.vue +44 -0
  47. package/composables/axios.ts +1 -0
  48. package/composables/classes.ts +501 -14
  49. package/composables/constants.ts +126 -6
  50. package/composables/fields.ts +328 -0
  51. package/composables/index.ts +355 -20
  52. package/composables/styles.ts +23 -6
  53. package/configs/pwa.ts +63 -0
  54. package/layouts/clear.vue +21 -0
  55. package/layouts/default.vue +62 -3
  56. package/layouts/full.vue +21 -0
  57. package/locales/ru.json +559 -16
  58. package/nuxt.config.ts +11 -15
  59. package/package.json +36 -39
  60. package/pages/Token.vue +0 -13
  61. package/plugins/head.ts +26 -0
  62. package/plugins/vuetifyPlugin.ts +1 -5
  63. package/store/data.store.ts +1610 -321
  64. package/store/extractStore.ts +17 -0
  65. package/store/form.store.ts +13 -1
  66. package/store/member.store.ts +1 -1
  67. package/store/rules.ts +97 -3
  68. package/store/toast.ts +1 -1
  69. package/types/enum.ts +81 -0
  70. package/types/env.d.ts +2 -0
  71. package/types/form.ts +94 -0
  72. package/types/index.ts +419 -24
@@ -3,11 +3,13 @@ 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 { DataStoreClass, DocumentItem, Member, Value, CountryValue, PolicyholderActivity, BeneficialOwner, PolicyholderClass } from '../composables/classes';
7
7
  import { ApiClass } from '../api';
8
8
  import { useFormStore } from './form.store';
9
9
  import { AxiosError } from 'axios';
10
- import { PostActions, StoreMembers, Roles, Statuses, MemberCodes, MemberAppCodes } from '../types/enum';
10
+ import { PostActions, StoreMembers, Roles, Statuses, MemberCodes, MemberAppCodes, Enums } from '../types/enum';
11
+ //@ts-ignore
12
+ import { NCALayerClient } from 'ncalayer-js-client';
11
13
 
12
14
  export const useDataStore = defineStore('data', {
13
15
  state: () => ({
@@ -22,6 +24,7 @@ export const useDataStore = defineStore('data', {
22
24
  formStore: useFormStore(),
23
25
  // contragent: useContragentStore(),
24
26
  api: new ApiClass(),
27
+ rController: new AbortController(),
25
28
  yearEnding: (year: number) => yearEnding(year, constants.yearTitles, constants.yearCases),
26
29
  currentDate: () => new Date(Date.now() - new Date().getTimezoneOffset() * 60 * 1000).toISOString().slice(0, -1),
27
30
  showToaster: (type: 'success' | 'error' | 'warning' | 'info', msg: string, timeout?: number) =>
@@ -33,9 +36,13 @@ export const useDataStore = defineStore('data', {
33
36
  }),
34
37
  getters: {
35
38
  isEFO: state => state.product === 'efo',
39
+ isEfoParent: state => state.parentProduct === 'efo',
36
40
  isAML: state => state.product === 'aml',
37
41
  isLKA: state => state.product === 'lka',
38
- isBridge: state => state.product === 'efo' || state.product === 'aml' || state.product === 'lka',
42
+ isAULETTI: state => state.product === 'auletti',
43
+ isLKA_A: state => state.product === 'lka-auletti',
44
+ isAulettiParent: state => state.parentProduct === 'auletti',
45
+ isBridge: state => state.product === 'efo' || state.product === 'aml' || state.product === 'lka' || state.product === 'auletti',
39
46
  isBaiterek: state => state.product === 'baiterek',
40
47
  isBolashak: state => state.product === 'bolashak',
41
48
  isMycar: state => state.product === 'mycar',
@@ -44,16 +51,36 @@ export const useDataStore = defineStore('data', {
44
51
  isLiferenta: state => state.product === 'liferenta',
45
52
  isGons: state => state.product === 'gons',
46
53
  isKazyna: state => state.product === 'halykkazyna',
54
+ isDas: state => state.product === 'daskamkorlyk',
55
+ isPension: state => state.product === 'pensionannuitynew',
56
+ isAmulet: state => state.product === 'amuletlife',
57
+ isGns: state => state.product === 'gns',
47
58
  isCalculator: state => state.product === 'calculator',
48
59
  isCheckContract: state => state.product === 'checkcontract',
49
60
  isCheckContragent: state => state.product === 'checkcontragent',
50
- isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
61
+ isPrePension: state => state.product === 'prepensionannuity',
62
+ isDSO: state => state.product === 'dso',
63
+ isUU: state => state.product === 'uu',
51
64
  hasClientAnketa: state => state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10),
52
65
  isClientAnketaCondition: state =>
53
66
  !state.formStore.insuredForm.find(member => member.iin === state.formStore.policyholderForm.iin) &&
54
67
  !!state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10 && i.coverSumCode === 'included'),
55
68
  },
56
69
  actions: {
70
+ async getProjectConfig() {
71
+ try {
72
+ const projectConfig = await this.api.getProjectConfig();
73
+ if (projectConfig) {
74
+ this.projectConfig = projectConfig;
75
+ return true;
76
+ } else {
77
+ return false;
78
+ }
79
+ } catch (err) {
80
+ this.projectConfig = null;
81
+ return false;
82
+ }
83
+ },
57
84
  isIframe() {
58
85
  try {
59
86
  return window.self !== window.top;
@@ -73,16 +100,41 @@ export const useDataStore = defineStore('data', {
73
100
  childFrame.contentWindow.postMessage({ action: action, value: value }, '*');
74
101
  }
75
102
  },
76
- copyToClipboard(text: any) {
103
+ abortRequests() {
104
+ try {
105
+ this.rController.abort();
106
+ this.rController = new AbortController();
107
+ } catch (err) {
108
+ console.log(err);
109
+ }
110
+ },
111
+ async copyToClipboard(text: unknown, showError: boolean = true) {
77
112
  if (typeof text === 'string' || typeof text === 'number') {
78
- if (this.isBridge) {
79
- navigator.clipboard.writeText(String(text));
113
+ if (navigator.clipboard && window.isSecureContext) {
114
+ if (this.isBridge) {
115
+ await navigator.clipboard.writeText(String(text));
116
+ this.showToaster('success', this.t('toaster.copied'));
117
+ } else {
118
+ this.sendToParent(constants.postActions.clipboard, String(text));
119
+ }
80
120
  } else {
81
- this.sendToParent(constants.postActions.clipboard, String(text));
121
+ const textarea = document.createElement('textarea');
122
+ textarea.value = String(text);
123
+ textarea.style.position = 'absolute';
124
+ textarea.style.left = '-99999999px';
125
+ document.body.prepend(textarea);
126
+ textarea.select();
127
+ try {
128
+ document.execCommand('copy');
129
+ this.showToaster('success', this.t('toaster.copied'));
130
+ } catch (err) {
131
+ console.log(err);
132
+ } finally {
133
+ textarea.remove();
134
+ }
82
135
  }
83
- this.showToaster('success', this.t('toaster.copied'));
84
136
  } else {
85
- this.showToaster('error', this.t('toaster.noUrl'));
137
+ if (showError) this.showToaster('error', this.t('toaster.noUrl'));
86
138
  }
87
139
  },
88
140
  getFilesByIIN(iin: string) {
@@ -141,7 +193,7 @@ export const useDataStore = defineStore('data', {
141
193
  return !!isRole;
142
194
  },
143
195
  isInitiator() {
144
- return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager();
196
+ return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager() || this.isAgentAuletti();
145
197
  },
146
198
  isManager() {
147
199
  return this.isRole(constants.roles.Manager);
@@ -152,6 +204,9 @@ export const useDataStore = defineStore('data', {
152
204
  isAdmin() {
153
205
  return this.isRole(constants.roles.Admin);
154
206
  },
207
+ isJurist() {
208
+ return this.isRole(constants.roles.Jurist);
209
+ },
155
210
  isAgent() {
156
211
  return this.isRole(constants.roles.Agent);
157
212
  },
@@ -164,15 +219,30 @@ export const useDataStore = defineStore('data', {
164
219
  isUnderwriter() {
165
220
  return this.isRole(constants.roles.Underwriter);
166
221
  },
222
+ isActuary() {
223
+ return this.isRole(constants.roles.Actuary);
224
+ },
167
225
  isAgentMycar() {
168
226
  return this.isRole(constants.roles.AgentMycar);
169
227
  },
228
+ isAgentAuletti() {
229
+ return this.isRole(constants.roles.AgentAuletti);
230
+ },
170
231
  isAnalyst() {
171
232
  return this.isRole(constants.roles.Analyst);
172
233
  },
173
234
  isUpk() {
174
235
  return this.isRole(constants.roles.UPK);
175
236
  },
237
+ isUrp() {
238
+ return this.isRole(constants.roles.URP);
239
+ },
240
+ isUsns() {
241
+ return this.isRole(constants.roles.USNS);
242
+ },
243
+ isAccountant() {
244
+ return this.isRole(constants.roles.Accountant);
245
+ },
176
246
  isDrn() {
177
247
  return this.isRole(constants.roles.DRNSJ);
178
248
  },
@@ -185,6 +255,27 @@ export const useDataStore = defineStore('data', {
185
255
  isSupervisor() {
186
256
  return this.isRole(constants.roles.Supervisor);
187
257
  },
258
+ isHeadManager() {
259
+ return this.isRole(constants.roles.HeadManager);
260
+ },
261
+ isBranchDirector() {
262
+ return this.isRole(constants.roles.BranchDirector);
263
+ },
264
+ isUSNSACCINS() {
265
+ return this.isRole(constants.roles.USNSACCINS);
266
+ },
267
+ isDsuio() {
268
+ return this.isRole(constants.roles.Dsuio);
269
+ },
270
+ isAdjuster() {
271
+ return this.isRole(constants.roles.Adjuster);
272
+ },
273
+ isDsoDirector() {
274
+ return this.isRole(constants.roles.DsoDirector);
275
+ },
276
+ isAccountantDirector() {
277
+ return this.isRole(constants.roles.AccountantDirector);
278
+ },
188
279
  isProcessEditable(statusCode?: keyof typeof Statuses) {
189
280
  const getEditibleStatuses = () => {
190
281
  const defaultStatuses = constants.editableStatuses;
@@ -206,9 +297,29 @@ export const useDataStore = defineStore('data', {
206
297
  };
207
298
  return !!getCanceleStatuses().find(status => status === statusCode);
208
299
  },
300
+ isProcessReject(statusCode?: keyof typeof Statuses) {
301
+ const getRejectStatuses = () => {
302
+ const defaultStatuses = constants.rejectApplicationStatuses;
303
+ return defaultStatuses;
304
+ };
305
+ return !!getRejectStatuses().find(status => status === statusCode);
306
+ },
209
307
  isTask() {
210
308
  return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
211
309
  },
310
+ validateAccess() {
311
+ try {
312
+ const hasAccess = this.hasAccess();
313
+ if (this.isAML) return hasAccess.toAML;
314
+ if (this.isLKA) return hasAccess.toLKA;
315
+ if (this.isEFO) return hasAccess.toEFO;
316
+ if (this.isAULETTI) return hasAccess.toAULETTI;
317
+ if (this.isLKA_A) return hasAccess.toLKA_A;
318
+ return false;
319
+ } catch (err) {
320
+ return ErrorHandler(err);
321
+ }
322
+ },
212
323
  async loginUser(login: string, password: string, numAttempt: number) {
213
324
  try {
214
325
  const token = localStorage.getItem('accessToken') || null;
@@ -221,35 +332,12 @@ export const useDataStore = defineStore('data', {
221
332
  password: password,
222
333
  numAttempt: numAttempt,
223
334
  });
224
-
225
335
  this.accessToken = loginResponse.accessToken;
226
336
  this.refreshToken = loginResponse.refreshToken;
227
337
  this.getUserRoles();
228
338
  }
229
- 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
- }
249
- return false;
250
- };
251
339
  if (this.controls.onAuth) {
252
- const hasPermission = checkPermission();
340
+ const hasPermission = this.validateAccess();
253
341
  if (hasPermission) {
254
342
  localStorage.setItem('accessToken', this.accessToken);
255
343
  localStorage.setItem('refreshToken', String(this.refreshToken));
@@ -286,8 +374,18 @@ export const useDataStore = defineStore('data', {
286
374
  }
287
375
  this.isLoading = false;
288
376
  },
377
+ async checkToken() {
378
+ try {
379
+ await this.api.checkToken();
380
+ return true;
381
+ } catch (err) {
382
+ ErrorHandler(err);
383
+ return false;
384
+ }
385
+ },
289
386
  async resetSelected(route: RouteType) {
290
387
  this.settings.open = false;
388
+ this.rightPanel.open = false;
291
389
  this.panel.open = false;
292
390
  this.panelAction = null;
293
391
  this.menu.selectedItem = new MenuItem();
@@ -357,7 +455,7 @@ export const useDataStore = defineStore('data', {
357
455
  this.isLoading = false;
358
456
  }
359
457
  },
360
- async getContragent(member: Member, load: boolean = true) {
458
+ async getContragent(member: Member, load: boolean = true, showToaster: boolean = true) {
361
459
  this.isLoading = load;
362
460
  if (!member.iin) return;
363
461
  try {
@@ -379,7 +477,7 @@ export const useDataStore = defineStore('data', {
379
477
  }
380
478
  member.gotFromInsis = true;
381
479
  } else {
382
- this.showToaster('error', this.t('toaster.notFoundUser'));
480
+ if (showToaster) this.showToaster('error', this.t('toaster.notFoundUser'));
383
481
  }
384
482
  } catch (err) {
385
483
  ErrorHandler(err);
@@ -387,6 +485,7 @@ export const useDataStore = defineStore('data', {
387
485
  this.isLoading = false;
388
486
  },
389
487
  async getContragentById(id: number, whichForm: keyof typeof StoreMembers, load: boolean = true, whichIndex: number | null = null) {
488
+ if (Number(id) === 0) return;
390
489
  this.isLoading = load;
391
490
  try {
392
491
  const member = whichIndex === null ? this.formStore[whichForm as SingleMember] : this.formStore[whichForm as MultipleMember][whichIndex];
@@ -440,9 +539,9 @@ export const useDataStore = defineStore('data', {
440
539
  member.verifyDate = user.personalData.verifyDate;
441
540
  member.iin = reformatIin(user.personalData.iin);
442
541
  member.age = String(user.personalData.age);
443
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
542
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
444
543
  member.birthPlace = country && Object.keys(country).length ? country : new Value();
445
- const gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
544
+ const gender = this.gender.find((i: Value) => i.nameRu === user.personalData.genderName);
446
545
  member.gender = gender ? gender : new Value();
447
546
  member.gender.id = user.personalData.gender;
448
547
  member.birthDate = reformatDate(user.personalData.birthDate);
@@ -457,15 +556,10 @@ export const useDataStore = defineStore('data', {
457
556
 
458
557
  if ('documents' in user && user.documents && user.documents.length) {
459
558
  member.documentsList = user.documents;
460
- const documentByPriority = (() => {
461
- if (this.isLifetrip) {
462
- return user.documents.find(i => i.type === 'PS');
463
- }
464
- return user.documents.find(i => i.type === '1UDL');
465
- })();
559
+ const documentByPriority = user.documents.find(i => i.type === Enums.Insis.DocTypes['1UDL']);
466
560
  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);
561
+ const documentType = this.documentTypes.find((i: Value) => i.ids === userDocument.type);
562
+ const documentIssuer = this.documentIssuers.find((i: Value) => i.nameRu === userDocument.issuerNameRu);
469
563
  member.documentType = documentType ? documentType : new Value();
470
564
  member.documentNumber = userDocument.number;
471
565
  member.documentIssuers = documentIssuer ? documentIssuer : new Value();
@@ -477,16 +571,22 @@ export const useDataStore = defineStore('data', {
477
571
  user.data.forEach(questData => {
478
572
  this.searchFromList(member, questData);
479
573
  });
574
+ if (this.isLifetrip) {
575
+ const lastNameLat = user.data.find(obj => obj.questId === '500147');
576
+ const firstNameLat = user.data.find(obj => obj.questId === '500148');
577
+ member.lastNameLat = lastNameLat ? (lastNameLat.questAnswer as string) : null;
578
+ member.firstNameLat = firstNameLat ? (firstNameLat.questAnswer as string) : null;
579
+ }
480
580
  }
481
581
  if ('address' in user && user.address && user.address.length) {
482
582
  const userAddress = user.address[0];
483
583
  const countryName = userAddress.countryName;
484
584
  if (countryName) {
485
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(countryName, 'i')));
585
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(countryName, 'i')));
486
586
  member.registrationCountry = country ? country : new Value();
487
587
  }
488
- const province = this.states.find(i => i.ids === userAddress.stateCode);
489
- const localityType = this.localityTypes.find(i => i.nameRu === userAddress.cityTypeName);
588
+ const province = this.states.find((i: Value) => i.ids === userAddress.stateCode);
589
+ const localityType = this.localityTypes.find((i: Value) => i.nameRu === userAddress.cityTypeName);
490
590
  const city = this.cities.find(i => !!userAddress.cityName && i.nameRu === userAddress.cityName.replace('г.', ''));
491
591
  const region = this.regions.find(i => !!userAddress.regionCode && i.ids == userAddress.regionCode);
492
592
  member.registrationStreet = userAddress.streetName;
@@ -536,7 +636,7 @@ export const useDataStore = defineStore('data', {
536
636
  };
537
637
  const qData = getQuestionariesData();
538
638
  if (qData && qData.from && qData.from.length && qData.field) {
539
- const qResult = qData.from.find(i => i.ids === searchIt.questAnswer);
639
+ const qResult = qData.from.find((i: Value) => i.ids === searchIt.questAnswer);
540
640
  //@ts-ignore
541
641
  member[qData.field] = qResult ? qResult : new Value();
542
642
  }
@@ -553,12 +653,12 @@ export const useDataStore = defineStore('data', {
553
653
  const contragent = await this.api.getContragent(queryData);
554
654
  if (contragent.totalItems > 0) {
555
655
  if (contragent.items.length === 1) {
556
- return contragent.items[0].id;
656
+ return contragent.items[0];
557
657
  } else {
558
658
  const sortedByRegistrationDate = contragent.items.sort(
559
659
  (left, right) => new Date(right.registrationDate).getMilliseconds() - new Date(left.registrationDate).getMilliseconds(),
560
660
  );
561
- return sortedByRegistrationDate[0].id;
661
+ return sortedByRegistrationDate[0];
562
662
  }
563
663
  } else {
564
664
  return null;
@@ -588,17 +688,27 @@ export const useDataStore = defineStore('data', {
588
688
  }
589
689
  },
590
690
  async saveContragent(user: Member, whichForm: keyof typeof StoreMembers | 'contragent', whichIndex: number | null, onlySaveAction: boolean = true) {
691
+ if (this.isGons && user.iin && whichForm === 'beneficiaryForm' && useEnv().isProduction) {
692
+ const doesHaveActiveContract = await this.api.checkBeneficiariesInActualPolicy(user.iin.replace(/-/g, ''));
693
+ if (doesHaveActiveContract) {
694
+ this.showToaster('error', this.t('toaster.doesHaveActiveContract'), 6000);
695
+ return false;
696
+ }
697
+ }
591
698
  this.isLoading = !onlySaveAction;
592
- const hasInsisId = await this.alreadyInInsis(user);
593
- if (typeof hasInsisId === 'number') {
594
- user.id = hasInsisId;
699
+ const hasInsis = await this.alreadyInInsis(user);
700
+ if (!!hasInsis) {
701
+ user.id = hasInsis.id;
595
702
  const [questionairesResponse, contactsResponse, documentsResponse, addressResponse] = await Promise.allSettled([
596
703
  this.api.getContrAgentData(user.id),
597
704
  this.api.getContrAgentContacts(user.id),
598
705
  this.api.getContrAgentDocuments(user.id),
599
706
  this.api.getContrAgentAddress(user.id),
600
707
  ]);
601
- user.response = {};
708
+ if (!user.response) {
709
+ user.response = {};
710
+ user.response.contragent = hasInsis;
711
+ }
602
712
  if (questionairesResponse.status === 'fulfilled' && questionairesResponse.value && questionairesResponse.value.length) {
603
713
  user.response.questionnaires = questionairesResponse.value;
604
714
  }
@@ -624,7 +734,11 @@ export const useDataStore = defineStore('data', {
624
734
  birthDate: user.getDateByKey('birthDate')!,
625
735
  gender: Number(user.gender.id),
626
736
  genderName: user.genderName ? user.genderName : user.gender.nameRu ?? '',
627
- birthPlace: user.birthPlace.nameRu ?? '',
737
+ birthPlace: user.birthPlace.nameRu
738
+ ? user.birthPlace.nameRu
739
+ : 'response' in user && user.response && 'contragent' in user.response && user.response.contragent && user.response.contragent.birthPlace
740
+ ? user.response.contragent.birthPlace
741
+ : '',
628
742
  age: Number(user.age),
629
743
  registrationDate: user.registrationDate,
630
744
  verifyType: user.verifyType,
@@ -685,6 +799,26 @@ export const useDataStore = defineStore('data', {
685
799
  });
686
800
  }
687
801
  }
802
+ if (this.isLifetrip) {
803
+ const lastNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500147') : undefined;
804
+ const firstNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500148') : undefined;
805
+ questionariesData.push({
806
+ id: lastNameLat ? lastNameLat.id : 0,
807
+ contragentId: Number(user.id),
808
+ questAnswer: user.lastNameLat ?? '',
809
+ questAnswerName: null,
810
+ questName: 'Фамилия на латинице',
811
+ questId: '500147',
812
+ });
813
+ questionariesData.push({
814
+ id: firstNameLat ? firstNameLat.id : 0,
815
+ contragentId: Number(user.id),
816
+ questAnswer: user.firstNameLat ?? '',
817
+ questAnswerName: null,
818
+ questName: 'Имя на латинице',
819
+ questId: '500148',
820
+ });
821
+ }
688
822
 
689
823
  const userResponseContacts = 'response' in user && user.response && 'contacts' in user.response && user.response.contacts ? user.response.contacts : null;
690
824
  const contactsData: ContragentContacts[] = [];
@@ -789,7 +923,7 @@ export const useDataStore = defineStore('data', {
789
923
 
790
924
  const personId = await this.api.saveContragent(data);
791
925
  if (personId > 0) {
792
- if (this.isLKA || whichForm === 'contragent') {
926
+ if (this.isLKA || this.isLKA_A || whichForm === 'contragent') {
793
927
  return personId;
794
928
  } else {
795
929
  await this.getContragentById(personId, whichForm, false, whichIndex);
@@ -827,6 +961,7 @@ export const useDataStore = defineStore('data', {
827
961
  data.profession = member.job;
828
962
  data.position = member.jobPosition;
829
963
  data.jobName = member.jobPlace;
964
+ data.positionCode = member.positionCode;
830
965
  data.familyStatusId = member.familyStatus.id;
831
966
  }
832
967
  if (whichMember === 'Spokesman') {
@@ -868,7 +1003,7 @@ export const useDataStore = defineStore('data', {
868
1003
  data.isNotary = member.isNotary;
869
1004
  }
870
1005
  if (whichMember === 'Insured') {
871
- if (this.formStore.applicationData && this.formStore.applicationData.insuredApp && this.formStore.applicationData.insuredApp.length) {
1006
+ if (this.formStore.applicationData && this.formStore.applicationData.insuredApp && this.formStore.applicationData.insuredApp.length && !this.isPension) {
872
1007
  if (this.members.insuredApp.has) {
873
1008
  await this.deleteInsuredLogic();
874
1009
  }
@@ -877,11 +1012,12 @@ export const useDataStore = defineStore('data', {
877
1012
  delete data.id;
878
1013
  }
879
1014
  }
880
- data.isDisability = this.formStore.isPolicyholderInsured ? false : member.isDisability.nameRu == 'Да';
1015
+ data.isDisability = this.formStore.isPolicyholderInsured && !this.isPension ? false : !!member.isDisability;
881
1016
  data.disabilityGroupId = data.isDisability && member.disabilityGroup ? member.disabilityGroup.id : null;
882
1017
  data.profession = member.job;
883
1018
  data.position = member.jobPosition;
884
1019
  data.jobName = member.jobPlace;
1020
+ data.positionCode = member.positionCode;
885
1021
  data.familyStatusId = member.familyStatus.id;
886
1022
  data.relationId = member.relationDegree.ids;
887
1023
  data.relationName = member.relationDegree.nameRu;
@@ -929,6 +1065,24 @@ export const useDataStore = defineStore('data', {
929
1065
  }
930
1066
  }
931
1067
  },
1068
+ async setApplication(applicationData: object, calculate: boolean = false) {
1069
+ try {
1070
+ this.isLoading = true;
1071
+ this.isButtonsLoading = true;
1072
+ await this.api.setApplication(applicationData);
1073
+ if (calculate) {
1074
+ await this.api.calculatePension(String(this.formStore.applicationData.processInstanceId));
1075
+ this.showToaster('success', this.t('toaster.successSaved'), 2000);
1076
+ }
1077
+ this.isLoading = false;
1078
+ this.isButtonsLoading = false;
1079
+ return true;
1080
+ } catch (err) {
1081
+ this.isLoading = false;
1082
+ this.isButtonsLoading = false;
1083
+ return ErrorHandler(err);
1084
+ }
1085
+ },
932
1086
  getConditionsData() {
933
1087
  const conditionsData: {
934
1088
  policyAppDto: PolicyAppDto;
@@ -952,7 +1106,7 @@ export const useDataStore = defineStore('data', {
952
1106
  annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
953
1107
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
954
1108
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
955
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1109
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
956
1110
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id ?? undefined,
957
1111
  lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply ?? ''),
958
1112
  lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive ?? ''),
@@ -975,6 +1129,15 @@ export const useDataStore = defineStore('data', {
975
1129
  conditionsData.policyAppDto.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
976
1130
  conditionsData.policyAppDto.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
977
1131
  }
1132
+ if (this.isLifeBusiness || this.isGns) {
1133
+ conditionsData.policyAppDto.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1134
+ conditionsData.policyAppDto.fixInsSum = getNumber(String(this.formStore.productConditionsForm.fixInsSum));
1135
+ conditionsData.policyAppDto.mainInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1136
+ conditionsData.policyAppDto.agentCommission = Number(this.formStore.productConditionsForm.agentCommission);
1137
+ conditionsData.policyAppDto.processDefinitionFgotId = (this.formStore.productConditionsForm.processGfot.id as string) ?? undefined;
1138
+ conditionsData.policyAppDto.contractEndDate = formatDate(this.formStore.productConditionsForm.contractEndDate as string)!.toISOString();
1139
+ conditionsData.policyAppDto.calcDate = formatDate(this.formStore.productConditionsForm.calcDate as string)!.toISOString();
1140
+ }
978
1141
  return conditionsData;
979
1142
  },
980
1143
  async clearAddCovers(coverCode: number, coverValue: string) {
@@ -993,6 +1156,8 @@ export const useDataStore = defineStore('data', {
993
1156
  }
994
1157
  },
995
1158
  async deleteInsuredLogic() {
1159
+ // TODO Просмотреть
1160
+ if (this.isLifetrip || this.isPension) return;
996
1161
  const applicationData = this.getConditionsData();
997
1162
  const clearCovers = [{ code: 10, value: 'excluded' }];
998
1163
  await Promise.allSettled(
@@ -1023,6 +1188,16 @@ export const useDataStore = defineStore('data', {
1023
1188
  }
1024
1189
  return null;
1025
1190
  },
1191
+ async getProcessCoverTypePeriod(questionId: string) {
1192
+ if (!this.processCode) return null;
1193
+ try {
1194
+ const answers = await this.api.getProcessCoverTypePeriod(this.processCode, questionId);
1195
+ return answers;
1196
+ } catch (err) {
1197
+ console.log(err);
1198
+ }
1199
+ return null;
1200
+ },
1026
1201
  async definedAnswers(
1027
1202
  filter: string,
1028
1203
  whichSurvey: 'surveyByHealthBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBase' | 'surveyByCriticalBasePolicyholder',
@@ -1051,7 +1226,7 @@ export const useDataStore = defineStore('data', {
1051
1226
  this.isLoading = false;
1052
1227
  }
1053
1228
  },
1054
- async setINSISWorkData() {
1229
+ async setINSISWorkData(loading: boolean = true) {
1055
1230
  if (!this.formStore.applicationData.insisWorkDataApp) return;
1056
1231
  const data: InsisWorkDataApp = {
1057
1232
  id: this.formStore.applicationData.insisWorkDataApp.id,
@@ -1070,7 +1245,7 @@ export const useDataStore = defineStore('data', {
1070
1245
  insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
1071
1246
  };
1072
1247
  try {
1073
- this.isLoading = true;
1248
+ this.isLoading = loading;
1074
1249
  await this.api.setINSISWorkData(data);
1075
1250
  } catch (err) {
1076
1251
  ErrorHandler(err);
@@ -1099,7 +1274,7 @@ export const useDataStore = defineStore('data', {
1099
1274
  async getFromApi(whichField: string, whichRequest: string, parameter?: any, reset: boolean = false): Promise<Value[]> {
1100
1275
  const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
1101
1276
  const currentHour = new Date().getHours();
1102
- const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / (this.isLKA ? 60 : 15));
1277
+ const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / (this.isLKA || this.isLKA_A ? 60 : 15));
1103
1278
 
1104
1279
  const getDataCondition = () => {
1105
1280
  if (!storageValue) return true;
@@ -1110,7 +1285,7 @@ export const useDataStore = defineStore('data', {
1110
1285
  if (storageValue && (hasHourKey === false || hasMiniteKey === false || hasModeKey === false || hasValueKey === false)) return true;
1111
1286
  if (
1112
1287
  storageValue &&
1113
- (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)
1288
+ (storageValue.hour !== currentHour || storageValue.minute !== currentMinutePart || storageValue.mode !== import.meta.env.VITE_MODE || storageValue.value.length === 0)
1114
1289
  )
1115
1290
  return true;
1116
1291
  };
@@ -1127,7 +1302,7 @@ export const useDataStore = defineStore('data', {
1127
1302
  value: response,
1128
1303
  hour: currentHour,
1129
1304
  minute: currentMinutePart,
1130
- mode: import.meta.env.MODE,
1305
+ mode: import.meta.env.VITE_MODE,
1131
1306
  }),
1132
1307
  );
1133
1308
  //@ts-ignore
@@ -1145,7 +1320,28 @@ export const useDataStore = defineStore('data', {
1145
1320
  return this[whichField];
1146
1321
  },
1147
1322
  async getCountries() {
1148
- return await this.getFromApi('countries', 'getCountries');
1323
+ const response = await this.getFromApi('countries', 'getCountries');
1324
+ const kzIndex = response.findIndex(country => country.ids === 'KZ');
1325
+ if (kzIndex !== -1) {
1326
+ const element = response.splice(kzIndex, 1)[0];
1327
+ response.splice(0, 0, element);
1328
+ }
1329
+ return response;
1330
+ },
1331
+ async getDicCountries() {
1332
+ if (this.isLifetrip) return await this.getFromApi('dicAllCountries', 'getArmDicts', 'DicCountry');
1333
+ },
1334
+ async getDicTripType() {
1335
+ if (this.isLifetrip) return await this.getFromApi('types', 'getArmDicts', 'DicTripType');
1336
+ },
1337
+ async getDicTripPurpose() {
1338
+ if (this.isLifetrip) return await this.getFromApi('purposes', 'getArmDicts', 'DicTripPurpose');
1339
+ },
1340
+ async getDicTripWorkType() {
1341
+ if (this.isLifetrip) return await this.getFromApi('workTypes', 'getArmDicts', 'DicTripWorkType');
1342
+ },
1343
+ async getDicSportsType() {
1344
+ if (this.isLifetrip) return await this.getFromApi('sportsTypes', 'getArmDicts', 'DicSportsType');
1149
1345
  },
1150
1346
  async getCitizenshipCountries() {
1151
1347
  return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
@@ -1156,31 +1352,80 @@ export const useDataStore = defineStore('data', {
1156
1352
  async getAdditionalTaxCountries() {
1157
1353
  return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
1158
1354
  },
1159
- async getStates(key?: string, member?: Member) {
1355
+ async getStates(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1160
1356
  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);
1357
+ if (!!keys) {
1358
+ if (!!keys.key) {
1359
+ if (!!keys.deepKey) {
1360
+ if (!!keys.subDeepKey) {
1361
+ //@ts-ignore
1362
+ 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);
1363
+ } else {
1364
+ //@ts-ignore
1365
+ return this.states.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1366
+ }
1367
+ } else {
1368
+ //@ts-ignore
1369
+ return this.states.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1370
+ }
1371
+ }
1372
+ } else {
1373
+ //@ts-ignore
1374
+ if (key && member[key] && member[key].ids !== null) return this.states.filter((i: Value) => i.code === member[key].ids);
1375
+ }
1163
1376
  return this.states;
1164
1377
  },
1165
- async getRegions(key?: string, member?: Member) {
1378
+ async getRegions(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1166
1379
  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);
1380
+ if (!!keys) {
1381
+ if (!!keys.key) {
1382
+ if (!!keys.deepKey) {
1383
+ if (!!keys.subDeepKey) {
1384
+ //@ts-ignore
1385
+ 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);
1386
+ } else {
1387
+ //@ts-ignore
1388
+ return this.regions.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1389
+ }
1390
+ } else {
1391
+ //@ts-ignore
1392
+ return this.regions.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1393
+ }
1394
+ }
1171
1395
  } else {
1172
- return this.regions;
1396
+ //@ts-ignore
1397
+ if (key && member[key] && member[key].ids !== null) return this.regions.filter((i: Value) => i.code === member[key].ids);
1398
+ if (member && member.registrationProvince.ids !== null) {
1399
+ return this.regions.filter((i: Value) => i.code === member.registrationProvince.ids);
1400
+ }
1173
1401
  }
1402
+ return this.regions;
1174
1403
  },
1175
- async getCities(key?: string, member?: Member) {
1404
+ async getCities(key?: string, member?: Member, keys?: { key?: string; deepKey?: string; subDeepKey?: string }) {
1176
1405
  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);
1406
+ if (!!keys) {
1407
+ if (!!keys.key) {
1408
+ if (!!keys.deepKey) {
1409
+ if (!!keys.subDeepKey) {
1410
+ //@ts-ignore
1411
+ 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);
1412
+ } else {
1413
+ //@ts-ignore
1414
+ return this.cities.filter(i => i.code === member[keys.key][keys.deepKey].ids || i.code === member[keys.key][keys.deepKey].id);
1415
+ }
1416
+ } else {
1417
+ //@ts-ignore
1418
+ return this.cities.filter(i => i.code === member[keys.key].ids || i.code === member[keys.key].id);
1419
+ }
1420
+ }
1181
1421
  } else {
1182
- return this.cities;
1422
+ //@ts-ignore
1423
+ if (key && member[key] && member[key].ids !== null) return this.cities.filter((i: Value) => i.code === member[key].ids);
1424
+ if (member && member.registrationProvince.ids !== null) {
1425
+ return this.cities.filter((i: Value) => i.code === member.registrationProvince.ids);
1426
+ }
1183
1427
  }
1428
+ return this.cities;
1184
1429
  },
1185
1430
  async getLocalityTypes() {
1186
1431
  return await this.getFromApi('localityTypes', 'getLocalityTypes');
@@ -1208,12 +1453,24 @@ export const useDataStore = defineStore('data', {
1208
1453
  async getSectorCodeList() {
1209
1454
  return await this.getFromApi('economySectorCode', 'getSectorCode');
1210
1455
  },
1456
+ async getEconomicActivityType() {
1457
+ if (this.isLifeBusiness || this.isGns || this.isDas || this.isUU || this.isPrePension) return await this.getFromApi('economicActivityType', 'getEconomicActivityType');
1458
+ },
1211
1459
  async getFamilyStatuses() {
1212
1460
  return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
1213
1461
  },
1462
+ async getDisabilityGroups() {
1463
+ return await this.getFromApi('disabilityGroups', 'getArmDicts', 'DicDisabilityGroup');
1464
+ },
1214
1465
  async getRelationTypes() {
1215
1466
  return await this.getFromApi('relations', 'getRelationTypes');
1216
1467
  },
1468
+ async getBanks() {
1469
+ if (this.isLifeBusiness || this.isDas || this.isUU || this.isPension || this.isGns || this.isPrePension || this.isDSO) return await this.getFromApi('banks', 'getBanks');
1470
+ },
1471
+ async getInsuranceCompanies() {
1472
+ if (this.isPension) return await this.getFromApi('transferContractCompanies', 'getInsuranceCompanies');
1473
+ },
1217
1474
  async getProcessIndexRate() {
1218
1475
  if (this.processCode) {
1219
1476
  return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
@@ -1228,7 +1485,7 @@ export const useDataStore = defineStore('data', {
1228
1485
  return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
1229
1486
  },
1230
1487
  async getProcessTariff() {
1231
- return await this.getFromApi('processTariff', 'getProcessTariff');
1488
+ if (this.processCode) return await this.getFromApi('processTariff', 'getProcessTariff', this.processCode);
1232
1489
  },
1233
1490
  async getDicAnnuityTypeList() {
1234
1491
  return await this.getFromApi('dicAnnuityTypeList', 'getDicAnnuityTypeList');
@@ -1241,6 +1498,11 @@ export const useDataStore = defineStore('data', {
1241
1498
  async getInsurancePay() {
1242
1499
  return await this.getFromApi('insurancePay', 'getInsurancePay');
1243
1500
  },
1501
+ async getProcessGfot() {
1502
+ if (this.processCode) {
1503
+ return await this.getFromApi('processGfot', 'getProcessGfot', this.processCode);
1504
+ }
1505
+ },
1244
1506
  async getCurrencies() {
1245
1507
  try {
1246
1508
  const currencies = await this.api.getCurrencies();
@@ -1254,6 +1516,21 @@ export const useDataStore = defineStore('data', {
1254
1516
  async getDictionaryItems(dictName: string) {
1255
1517
  return await this.getFromApi(dictName, 'getDictionaryItems', dictName);
1256
1518
  },
1519
+ getGenderList() {
1520
+ return this.gender;
1521
+ },
1522
+ async getAuthorityBasis() {
1523
+ if (this.isDas || this.isLifeBusiness || this.isGns || this.isUU || this.isPrePension) return await this.getFromApi('authorityBasis', 'getArmDicts', 'DicAuthorityBasis');
1524
+ },
1525
+ async getWorkPosition(search: string) {
1526
+ try {
1527
+ const workPositions = await this.api.getWorkPosition(search);
1528
+ return workPositions;
1529
+ } catch (err) {
1530
+ ErrorHandler(err);
1531
+ return [];
1532
+ }
1533
+ },
1257
1534
  async getAllFormsData() {
1258
1535
  await Promise.allSettled([
1259
1536
  this.getCountries(),
@@ -1279,52 +1556,56 @@ export const useDataStore = defineStore('data', {
1279
1556
  this.getInsurancePay(),
1280
1557
  this.getDictionaryItems('RegionPolicy'),
1281
1558
  this.getDictionaryItems('SaleChanellPolicy'),
1559
+ this.getDicTripType(),
1560
+ this.getDicCountries(),
1561
+ this.getDicTripWorkType(),
1562
+ this.getDicSportsType(),
1563
+ this.getDicTripPurpose(),
1564
+ this.getCurrencies(),
1565
+ this.getProcessGfot(),
1566
+ this.getBanks(),
1567
+ this.getInsuranceCompanies(),
1568
+ this.getEconomicActivityType(),
1569
+ this.getAuthorityBasis(),
1570
+ this.getDisabilityGroups(),
1282
1571
  ]);
1283
1572
  },
1284
1573
  async getQuestionList(
1285
1574
  surveyType: 'health' | 'critical',
1286
1575
  processInstanceId: string | number,
1287
1576
  insuredId: any,
1288
- baseField: string,
1289
- secondaryField: string,
1577
+ baseField: 'surveyByHealthBase' | 'surveyByCriticalBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBasePolicyholder',
1290
1578
  whichMember: 'insured' | 'policyholder' = 'insured',
1291
1579
  ) {
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
- }
1580
+ try {
1581
+ const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1582
+ whichMember === 'insured' ? this.api.getQuestionList(surveyType, processInstanceId, insuredId) : this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1583
+ whichMember === 'insured'
1584
+ ? this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId)
1585
+ : this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1586
+ ,
1587
+ ]);
1588
+ if (baseQuestions.status === 'fulfilled') {
1589
+ this.formStore[baseField] = baseQuestions.value;
1590
+ }
1591
+ if (secondaryQuestions.status === 'fulfilled') {
1592
+ const baseAnketa = this.formStore[baseField];
1593
+ if (baseAnketa && baseAnketa.body && baseAnketa.body.length) {
1594
+ baseAnketa.body.forEach(i => {
1595
+ if (i.first.definedAnswers === 'Y' && i.second === null && secondaryQuestions.value) {
1596
+ i.second = structuredClone(secondaryQuestions.value);
1597
+ }
1598
+ if (i.first.definedAnswers === 'Y' && i.second && i.second.length) {
1599
+ i.second.forEach(second => {
1600
+ if (second.answerType === 'D') second.answerText = reformatDate(String(second.answerText));
1601
+ });
1602
+ }
1603
+ });
1322
1604
  }
1323
- } catch (err) {
1324
- console.log(err);
1325
1605
  }
1606
+ } catch (err) {
1607
+ ErrorHandler(err);
1326
1608
  }
1327
- //@ts-ignore
1328
1609
  return this.formStore[baseField];
1329
1610
  },
1330
1611
  getNumberWithSpaces(n: any) {
@@ -1336,7 +1617,14 @@ export const useDataStore = defineStore('data', {
1336
1617
  return parts.join(',');
1337
1618
  },
1338
1619
  getNumberWithDot(n: any) {
1339
- return n === null ? null : n.toLocaleString('ru', { maximumFractionDigits: 2, minimumFractionDigits: 2 }).replace(/,/g, '.');
1620
+ return n === null
1621
+ ? null
1622
+ : n
1623
+ .toLocaleString('ru', {
1624
+ maximumFractionDigits: 2,
1625
+ minimumFractionDigits: 2,
1626
+ })
1627
+ .replace(/,/g, '.');
1340
1628
  },
1341
1629
  async getTaskList(
1342
1630
  search: string = '',
@@ -1376,7 +1664,18 @@ export const useDataStore = defineStore('data', {
1376
1664
  delete query.processCodes;
1377
1665
  query.processCode = byOneProcess;
1378
1666
  }
1379
- const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
1667
+ if (byOneProcess === 19 && !useEnv().isProduction) {
1668
+ query.processCodes = [19, 2];
1669
+ delete query.processCode;
1670
+ }
1671
+ const taskList = await this.api.getTaskList(
1672
+ processInstanceId === null
1673
+ ? query
1674
+ : {
1675
+ ...query,
1676
+ processInstanceId: processInstanceId,
1677
+ },
1678
+ );
1380
1679
  if (needToReturn) {
1381
1680
  this.isLoading = false;
1382
1681
  return taskList.items;
@@ -1462,12 +1761,12 @@ export const useDataStore = defineStore('data', {
1462
1761
  },
1463
1762
  findObject(from: string, key: string, searchKey: any): any {
1464
1763
  // @ts-ignore
1465
- const found = this[from].find(i => i[key] == searchKey);
1764
+ const found = this[from].find((i: Value) => i[key] == searchKey);
1466
1765
  return found || new Value();
1467
1766
  },
1468
- async searchAgentByName(name: string) {
1767
+ async searchAgentByName(name: string, branchCode?: string) {
1469
1768
  try {
1470
- this.AgentData = await this.api.searchAgentByName(name);
1769
+ this.AgentData = await this.api.searchAgentByName(name, branchCode);
1471
1770
  if (!this.AgentData.length) {
1472
1771
  this.showToaster('error', this.t('toaster.notFound'), 1500);
1473
1772
  }
@@ -1513,18 +1812,69 @@ export const useDataStore = defineStore('data', {
1513
1812
  this.isLoading = false;
1514
1813
  }
1515
1814
  },
1815
+ async getTripInsuredAmount(show: boolean = true) {
1816
+ this.isLoading = true;
1817
+ try {
1818
+ const countryID: string[] = [];
1819
+ for (let country = 0; country < this.formStore.productConditionsForm.calculatorForm.countries!.length; country++) {
1820
+ countryID.push(this.formStore.productConditionsForm.calculatorForm.countries![country].id as string);
1821
+ }
1822
+
1823
+ const form = {
1824
+ tripTypeID: this.formStore.productConditionsForm.calculatorForm.type.id,
1825
+ countryID,
1826
+ };
1827
+
1828
+ const result = await this.api.getTripInsuredAmount(form);
1829
+ const amounts: Value[] = [];
1830
+ result.amounts.forEach(amount => {
1831
+ amounts.push(new Value(amount['id'], amount['nameRu']));
1832
+ });
1833
+
1834
+ this.amountArray = amounts;
1835
+ this.formStore.productConditionsForm.calculatorForm.amount = new Value();
1836
+ this.currency = result.currency;
1837
+
1838
+ if (show) {
1839
+ this.showToaster('success', this.t('toaster.tripInsuredAmountCalculated'), 1000);
1840
+ }
1841
+ } catch (err) {
1842
+ ErrorHandler(err);
1843
+ }
1844
+ this.isLoading = false;
1845
+ },
1846
+ async getPeriod() {
1847
+ if (this.periodArray.length === 0) {
1848
+ try {
1849
+ const response = await this.api.getTripInsuranceDaysOptions();
1850
+ if (response) {
1851
+ const new3 = response.period;
1852
+ const newPeriod: Value[] = [];
1853
+ const newMaxDays: Value[] = [];
1854
+ Object.keys(new3).forEach(key => {
1855
+ newPeriod.push(new Value(key, key, key, key));
1856
+ new3[key as keyof typeof new3].forEach(item => {
1857
+ newMaxDays.push(new Value(item, item, item, key));
1858
+ });
1859
+ });
1860
+ this.periodArray = newPeriod;
1861
+ this.maxDaysAllArray = newMaxDays;
1862
+ }
1863
+ } catch (err) {
1864
+ ErrorHandler(err);
1865
+ }
1866
+ }
1867
+ },
1516
1868
  async calculateWithoutApplication(showLoader: boolean = false, product: string | null = null) {
1517
1869
  this.isLoading = showLoader;
1518
1870
  try {
1519
- if (!this.formStore.productConditionsForm.signDate || !this.formStore.productConditionsForm.birthDate) {
1871
+ if (!this.formStore.productConditionsForm.signDate) {
1520
1872
  return;
1521
1873
  }
1522
1874
  const signDate = formatDate(this.formStore.productConditionsForm.signDate);
1523
- const birthDate = formatDate(this.formStore.productConditionsForm.birthDate);
1524
- if (!signDate || !birthDate) return;
1525
1875
  const calculationData: RecalculationDataType & PolicyAppDto = {
1526
- signDate: signDate.toISOString(),
1527
- birthDate: birthDate.toISOString(),
1876
+ signDate: signDate ? signDate.toISOString() : undefined,
1877
+ birthDate: this.formStore.productConditionsForm.birthDate ? formatDate(this.formStore.productConditionsForm.birthDate)!.toISOString() : undefined,
1528
1878
  gender: Number(this.formStore.productConditionsForm.gender.id),
1529
1879
  amount: getNumber(String(this.formStore.productConditionsForm.requestedSumInsured)),
1530
1880
  premium: getNumber(String(this.formStore.productConditionsForm.insurancePremiumPerMonth)),
@@ -1532,7 +1882,7 @@ export const useDataStore = defineStore('data', {
1532
1882
  payPeriod: Number(this.formStore.productConditionsForm.coverPeriod),
1533
1883
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1534
1884
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
1535
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1885
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
1536
1886
  paymentPeriodId: (this.formStore.productConditionsForm.paymentPeriod.id as string) ?? undefined,
1537
1887
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1538
1888
  };
@@ -1541,15 +1891,26 @@ export const useDataStore = defineStore('data', {
1541
1891
  calculationData.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1542
1892
  calculationData.currencyExchangeRate = this.currencies.usd;
1543
1893
  }
1544
- if (this.isLiferenta) {
1894
+ if (this.isLiferenta || product === 'liferenta') {
1545
1895
  calculationData.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1546
1896
  calculationData.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
1547
1897
  calculationData.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
1548
1898
  calculationData.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
1549
1899
  }
1900
+ if (this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns') {
1901
+ calculationData.clients = this.formStore.lfb.clients;
1902
+ calculationData.insrCount = this.formStore.lfb.clients.length;
1903
+ calculationData.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1904
+ calculationData.fixInsSum = getNumber(String(this.formStore.productConditionsForm.fixInsSum));
1905
+ calculationData.mainInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1906
+ calculationData.agentCommission = Number(this.formStore.productConditionsForm.agentCommission);
1907
+ calculationData.processDefinitionFgotId = this.formStore.productConditionsForm.processGfot.id;
1908
+ calculationData.contractEndDate = formatDate(this.formStore.productConditionsForm.contractEndDate as string)!.toISOString();
1909
+ calculationData.calcDate = formatDate(this.formStore.productConditionsForm.calcDate as string)!.toISOString();
1910
+ }
1550
1911
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1551
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1552
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1912
+ if (calculationResponse.amount) this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1913
+ if (calculationResponse.premium) this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1553
1914
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1554
1915
  if (this.isKazyna || product === 'halykkazyna') {
1555
1916
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
@@ -1558,9 +1919,28 @@ export const useDataStore = defineStore('data', {
1558
1919
  this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1559
1920
  }
1560
1921
  }
1561
- if (this.isLiferenta) {
1922
+ if (this.isLiferenta || product === 'liferenta') {
1562
1923
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(calculationResponse.annuityMonthPay);
1563
1924
  }
1925
+ if (this.isGons || product === 'gons') {
1926
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(calculationResponse.totalAmount5);
1927
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(calculationResponse.totalAmount7);
1928
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(calculationResponse.statePremium5);
1929
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(calculationResponse.statePremium7);
1930
+ }
1931
+ if (this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns') {
1932
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.mainPremiumWithCommission);
1933
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.mainInsSum === 0 ? null : calculationResponse.mainInsSum);
1934
+ this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1935
+ if (calculationResponse.agentCommission) {
1936
+ this.formStore.productConditionsForm.agentCommission = calculationResponse.agentCommission;
1937
+ }
1938
+ if (calculationResponse.clients) {
1939
+ this.formStore.lfb.clients = calculationResponse.clients;
1940
+ }
1941
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1942
+ return calculationResponse;
1943
+ }
1564
1944
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1565
1945
  } catch (err) {
1566
1946
  ErrorHandler(err);
@@ -1573,7 +1953,7 @@ export const useDataStore = defineStore('data', {
1573
1953
  this.isLoading = true;
1574
1954
  try {
1575
1955
  const id = this.formStore.applicationData.processInstanceId;
1576
- await this.api.setApplication(this.getConditionsData());
1956
+ if (!this.isPension) await this.api.setApplication(this.getConditionsData());
1577
1957
  const result = ref();
1578
1958
  result.value = await this.api.getCalculation(String(id));
1579
1959
  const applicationData = await this.api.getApplicationData(taskId);
@@ -1596,20 +1976,100 @@ export const useDataStore = defineStore('data', {
1596
1976
  if (this.isLiferenta) {
1597
1977
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(applicationData.policyAppDto.annuityMonthPay);
1598
1978
  }
1979
+ if (this.isGons) {
1980
+ const govPremiums = await this.api.getGovernmentPremiums(String(id));
1981
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(govPremiums.totalAmount5 === null ? null : govPremiums.totalAmount5);
1982
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(govPremiums.totalAmount7 === null ? null : govPremiums.totalAmount7);
1983
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(govPremiums.statePremium5 === null ? null : govPremiums.statePremium5);
1984
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
1985
+ }
1986
+ if (this.isLifeBusiness || this.isGns) {
1987
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
1988
+ if (applicationData.insuredApp && applicationData.insuredApp.length) {
1989
+ const res = await this.newInsuredList(applicationData.insuredApp);
1990
+ this.formStore.lfb.clients = res;
1991
+ }
1992
+ }
1993
+
1994
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1995
+ } catch (err) {
1996
+ ErrorHandler(err);
1997
+ }
1998
+ this.isLoading = false;
1999
+ },
2000
+ async calculatePremium(data: any) {
2001
+ this.isLoading = true;
2002
+ try {
2003
+ const response = await this.api.calculatePremium(data);
2004
+ // @ts-ignore
2005
+ if (response && response.errMsg) {
2006
+ // @ts-ignore
2007
+ this.showToaster('error', response.errMsg, 1000);
2008
+ } else {
2009
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
2010
+ }
2011
+ this.isLoading = false;
2012
+ return response;
2013
+ } catch (err) {
2014
+ ErrorHandler(err);
2015
+ }
2016
+ this.isLoading = false;
2017
+ },
2018
+ async calculatePrice(taskId?: string) {
2019
+ this.isLoading = true;
2020
+ try {
2021
+ const priceForm: SetApplicationRequest = {};
2022
+ priceForm.insuredAmountId = this.formStore.productConditionsForm.calculatorForm.amount.id;
2023
+ priceForm.age = this.formStore.productConditionsForm.calculatorForm.age;
2024
+ priceForm.lifeTripCountries = this.formStore.productConditionsForm.calculatorForm.countries!.map(item => item.id as string);
2025
+ priceForm.tripPurposeId = this.formStore.productConditionsForm.calculatorForm.purpose.id;
2026
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'WorkStudy') {
2027
+ priceForm.workTypeId = this.formStore.productConditionsForm.calculatorForm.workType.id;
2028
+ }
2029
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'Sport') {
2030
+ priceForm.sportsTypeId = this.formStore.productConditionsForm.calculatorForm.sportsType!.id;
2031
+ }
2032
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
2033
+ priceForm.singleTripDays = Number(this.formStore.productConditionsForm.calculatorForm.days);
2034
+ } else {
2035
+ priceForm.multipleTripMaxDays = Number(this.formStore.productConditionsForm.calculatorForm.maxDays.nameRu);
2036
+ priceForm.tripInsurancePeriod = Number(this.formStore.productConditionsForm.calculatorForm.period.nameRu);
2037
+ }
2038
+ if (this.isTask()) {
2039
+ priceForm.processInstanceId = this.formStore.applicationData.processInstanceId!;
2040
+ priceForm.id = taskId!;
2041
+ priceForm.age = Number(this.formStore.policyholderForm.age);
2042
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Multiple') {
2043
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
2044
+ } else {
2045
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
2046
+ priceForm.endDate = formatDate(this.formStore.productConditionsForm.calculatorForm.endDate!)!.toISOString();
2047
+ }
2048
+ }
2049
+ if (this.isTask() && taskId) {
2050
+ await this.api.setApplication(priceForm);
2051
+ await this.api.getCalculator(priceForm);
2052
+ const applicationData = await this.api.getApplicationData(taskId);
2053
+ this.formStore.applicationData = applicationData;
2054
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
2055
+ } else {
2056
+ const result = await this.api.getCalculator(priceForm);
2057
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(result)} тг`;
2058
+ }
1599
2059
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1600
2060
  } catch (err) {
1601
2061
  ErrorHandler(err);
1602
2062
  }
1603
2063
  this.isLoading = false;
1604
2064
  },
1605
- async startApplication(member: Member) {
2065
+ async startApplication(member: Member, processCode?: number) {
1606
2066
  if (!member.iin) return false;
1607
2067
  try {
1608
2068
  const data: StartApplicationType = {
1609
2069
  clientId: member.id,
1610
2070
  iin: member.iin.replace(/-/g, ''),
1611
2071
  longName: member.longName ?? '',
1612
- processCode: Number(this.processCode),
2072
+ processCode: processCode ?? Number(this.processCode),
1613
2073
  policyId: 0,
1614
2074
  };
1615
2075
  const response = await this.api.startApplication(data);
@@ -1623,11 +2083,12 @@ export const useDataStore = defineStore('data', {
1623
2083
  this.isLoading = onlyGet;
1624
2084
  try {
1625
2085
  const applicationData = await this.api.getApplicationData(taskId);
1626
- if (this.processCode !== applicationData.processCode) {
2086
+ if (this.processCode !== applicationData.processCode && !this.isPension) {
1627
2087
  this.isLoading = false;
1628
2088
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
1629
2089
  return;
1630
2090
  }
2091
+ this.formStore.regNumber = applicationData.regNumber;
1631
2092
  this.formStore.applicationData = applicationData;
1632
2093
  this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
1633
2094
 
@@ -1639,7 +2100,6 @@ export const useDataStore = defineStore('data', {
1639
2100
  this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
1640
2101
  this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
1641
2102
  this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
1642
-
1643
2103
  this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
1644
2104
  this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
1645
2105
 
@@ -1653,15 +2113,59 @@ export const useDataStore = defineStore('data', {
1653
2113
  this.formStore.isActOwnBehalf = clientData.isActOwnBehalf;
1654
2114
  this.formStore.hasRepresentative = !!applicationData.spokesmanApp;
1655
2115
 
1656
- const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
1657
- this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
2116
+ if (beneficiaryData) {
2117
+ const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
2118
+ this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
2119
+ }
1658
2120
 
1659
2121
  if ('finCenterData' in applicationData && !!applicationData.finCenterData) {
1660
2122
  this.formStore.finCenterData = applicationData.finCenterData;
1661
2123
  this.formStore.finCenterData.regNumber = applicationData.finCenterData.regNumber;
1662
2124
  this.formStore.finCenterData.date = reformatDate(applicationData.finCenterData.date);
1663
2125
  }
2126
+ if ('lifeTripApp' in applicationData && setProductConditions) {
2127
+ const tripType = this.types.find((i: Value) => i.id === applicationData.lifeTripApp.tripTypeId);
2128
+ this.formStore.productConditionsForm.calculatorForm.type = tripType ? tripType : new Value();
2129
+
2130
+ const countries: CountryValue[] = [];
2131
+ for (let i in applicationData.lifeTripApp.lifeTripCountries) {
2132
+ const tripCountry = this.dicAllCountries.find(country => country.id === applicationData.lifeTripApp.lifeTripCountries[i]);
2133
+ if (tripCountry) {
2134
+ countries.push(tripCountry);
2135
+ }
2136
+ }
2137
+ this.formStore.productConditionsForm.calculatorForm.countries = countries ? countries : [];
2138
+
2139
+ if (this.formStore.productConditionsForm.calculatorForm.countries.length && this.formStore.productConditionsForm.calculatorForm.type.nameRu != null) {
2140
+ await this.getTripInsuredAmount(false);
2141
+ }
2142
+
2143
+ const amount = this.amountArray.find((i: Value) => i.id === applicationData.lifeTripApp.insuredAmountId);
2144
+ this.formStore.productConditionsForm.calculatorForm.amount = amount ? amount : new Value();
2145
+
2146
+ const purpose = this.purposes.find((i: Value) => i.id === applicationData.lifeTripApp.tripPurposeId);
2147
+ this.formStore.productConditionsForm.calculatorForm.purpose = purpose ? purpose : new Value();
2148
+
2149
+ if (applicationData.lifeTripApp.workTypeId != null) {
2150
+ const work = this.workTypes.find((i: Value) => i.id === applicationData.lifeTripApp.workTypeId);
2151
+ this.formStore.productConditionsForm.calculatorForm.workType = work ? work : new Value();
2152
+ }
2153
+ if (applicationData.lifeTripApp.sportsTypeId != null) {
2154
+ const sport = this.sportsTypes.find((i: Value) => i.id === applicationData.lifeTripApp.sportsTypeId);
2155
+ this.formStore.productConditionsForm.calculatorForm.sportsType = sport ? sport : new Value();
2156
+ }
2157
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
2158
+ this.formStore.productConditionsForm.calculatorForm.days = Number(applicationData.lifeTripApp.singleTripDays);
2159
+ } else {
2160
+ await this.getPeriod();
2161
+ this.formStore.productConditionsForm.calculatorForm.maxDays = this.maxDaysAllArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.multipleTripMaxDays)!;
2162
+ this.formStore.productConditionsForm.calculatorForm.period = this.periodArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.tripInsurancePeriod)!;
2163
+ }
2164
+ this.formStore.productConditionsForm.calculatorForm.startDate = reformatDate(applicationData.lifeTripApp.startDate);
2165
+ this.formStore.productConditionsForm.calculatorForm.endDate = reformatDate(applicationData.lifeTripApp.endDate);
1664
2166
 
2167
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
2168
+ }
1665
2169
  if (fetchMembers) {
1666
2170
  let allMembers = [
1667
2171
  {
@@ -1679,6 +2183,10 @@ export const useDataStore = defineStore('data', {
1679
2183
  });
1680
2184
  }
1681
2185
 
2186
+ if (applicationData.slave) {
2187
+ insuredData.push(applicationData.slave.insuredApp[0]);
2188
+ }
2189
+
1682
2190
  if (insuredData && insuredData.length) {
1683
2191
  insuredData.forEach((member, index) => {
1684
2192
  const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
@@ -1718,7 +2226,6 @@ export const useDataStore = defineStore('data', {
1718
2226
  }
1719
2227
  });
1720
2228
  }
1721
-
1722
2229
  await Promise.allSettled(
1723
2230
  allMembers.map(async member => {
1724
2231
  await this.getContragentById(member.insisId, member.key, false, member.index);
@@ -1731,7 +2238,7 @@ export const useDataStore = defineStore('data', {
1731
2238
  if (insuredData && insuredData.length) {
1732
2239
  insuredData.forEach((each, index) => {
1733
2240
  this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1734
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2241
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1735
2242
  this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1736
2243
  });
1737
2244
  }
@@ -1739,11 +2246,11 @@ export const useDataStore = defineStore('data', {
1739
2246
  if (beneficiaryData && beneficiaryData.length) {
1740
2247
  beneficiaryData.forEach((each, index) => {
1741
2248
  this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
1742
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2249
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1743
2250
  this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1744
2251
  this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
1745
2252
  if (this.isLiferenta || this.isBolashak) {
1746
- const insurancePay = this.insurancePay.find(i => i.id == each.beneficiaryInsurancePayId);
2253
+ const insurancePay = this.insurancePay.find((i: Value) => i.id == each.beneficiaryInsurancePayId);
1747
2254
  this.formStore.beneficiaryForm[index].insurancePay = insurancePay ? insurancePay : new Value();
1748
2255
  }
1749
2256
  });
@@ -1775,7 +2282,9 @@ export const useDataStore = defineStore('data', {
1775
2282
  this.formStore.policyholdersRepresentativeForm.isNotary = spokesmanData.isNotary;
1776
2283
  }
1777
2284
  }
1778
- if (setProductConditions) {
2285
+ if (setProductConditions && !!applicationData.policyAppDto) {
2286
+ this.formStore.policyNumber = applicationData.policyAppDto.policyNumber;
2287
+ this.formStore.contractDate = reformatDate(applicationData.policyAppDto.contractDate);
1779
2288
  this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
1780
2289
  this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
1781
2290
  // this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
@@ -1829,6 +2338,9 @@ export const useDataStore = defineStore('data', {
1829
2338
  });
1830
2339
  this.formStore.productConditionsForm.riskGroup = riskGroup ? riskGroup : this.riskGroup.find(item => item.id == 1) ?? new Value();
1831
2340
  }
2341
+ if (this.isPension && this.formStore.policyholderForm.bankInfo && this.formStore.policyholderForm.bankInfo.bik) {
2342
+ this.formStore.insuredForm[0].bankInfo = this.formStore.policyholderForm.bankInfo;
2343
+ }
1832
2344
  } catch (err) {
1833
2345
  ErrorHandler(err);
1834
2346
  if (err instanceof AxiosError) {
@@ -1863,7 +2375,7 @@ export const useDataStore = defineStore('data', {
1863
2375
  try {
1864
2376
  const data = {
1865
2377
  taskId: taskId,
1866
- decision: decision,
2378
+ decision: decision.replace(/custom/i, '') as keyof typeof constants.actions,
1867
2379
  };
1868
2380
  await this.api.sendTask(comment === null ? data : { ...data, comment: comment });
1869
2381
  this.showToaster('success', this.t('toaster.successOperation'), 3000);
@@ -1871,6 +2383,7 @@ export const useDataStore = defineStore('data', {
1871
2383
  return true;
1872
2384
  } catch (err) {
1873
2385
  this.isLoading = false;
2386
+ this.isButtonsLoading = false;
1874
2387
  return ErrorHandler(err);
1875
2388
  }
1876
2389
  },
@@ -1891,14 +2404,17 @@ export const useDataStore = defineStore('data', {
1891
2404
  break;
1892
2405
  }
1893
2406
  case constants.actions.reject:
2407
+ case constants.actions.cancel:
1894
2408
  case constants.actions.return:
2409
+ case constants.actions.signed:
1895
2410
  case constants.actions.rejectclient:
1896
- case constants.actions.accept: {
2411
+ case constants.actions.accept:
2412
+ case constants.actions.payed: {
1897
2413
  try {
1898
2414
  const sended = await this.sendTask(taskId, action, comment);
1899
2415
  if (!sended) return;
1900
2416
  this.formStore.$reset();
1901
- if (this.isEFO || this.isAML) {
2417
+ if (this.isEFO || this.isAML || this.isAULETTI) {
1902
2418
  await this.router.push({ name: 'Insurance-Product' });
1903
2419
  } else {
1904
2420
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1910,10 +2426,13 @@ export const useDataStore = defineStore('data', {
1910
2426
  }
1911
2427
  case constants.actions.affiliate: {
1912
2428
  try {
1913
- const sended = await this.sendUnderwritingCouncilTask({ taskId: taskId, decision: constants.actions.accept });
2429
+ const sended = await this.sendUnderwritingCouncilTask({
2430
+ taskId: taskId,
2431
+ decision: constants.actions.accept,
2432
+ });
1914
2433
  if (!sended) return;
1915
2434
  this.formStore.$reset();
1916
- if (this.isEFO || this.isAML) {
2435
+ if (this.isEFO || this.isAML || this.isAULETTI) {
1917
2436
  await this.router.push({ name: 'Insurance-Product' });
1918
2437
  } else {
1919
2438
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
@@ -1971,6 +2490,22 @@ export const useDataStore = defineStore('data', {
1971
2490
  if (!!this.formStore.applicationData[whichMember].profession) this.formStore[whichForm].job = this.formStore.applicationData[whichMember].profession;
1972
2491
  if (!!this.formStore.applicationData[whichMember].position) this.formStore[whichForm].jobPosition = this.formStore.applicationData[whichMember].position;
1973
2492
  if (!!this.formStore.applicationData[whichMember].jobName) this.formStore[whichForm].jobPlace = this.formStore.applicationData[whichMember].jobName;
2493
+ if (!!this.formStore.applicationData[whichMember].positionCode) this.formStore[whichForm].positionCode = this.formStore.applicationData[whichMember].positionCode;
2494
+ if (typeof this.formStore.applicationData[whichMember].isDisability === 'boolean')
2495
+ this.formStore[whichForm].isDisability = this.formStore.applicationData[whichMember].isDisability;
2496
+ if (!!this.formStore.applicationData[whichMember].disabilityGroupId) {
2497
+ const disabilityGroup = this.disabilityGroups.find(i => i.id === this.formStore.applicationData[whichMember].disabilityGroupId);
2498
+ this.formStore[whichForm].disabilityGroup = disabilityGroup ? disabilityGroup : new Value();
2499
+ }
2500
+ if (whichForm === this.formStore.policyholderFormKey && this.isPension && 'pensionApp' in this.formStore.applicationData && !!this.formStore.applicationData.pensionApp) {
2501
+ this.formStore[whichForm].bankInfo.iik = this.formStore.applicationData.pensionApp.account;
2502
+ this.formStore[whichForm].bankInfo.bik = this.formStore.applicationData.pensionApp.bankBik;
2503
+ const bank = this.banks.find(i => i.ids === this.formStore.applicationData.pensionApp.bankBin);
2504
+ const transferCompany = this.transferContractCompanies.find(i => i.nameRu === this.formStore.applicationData.pensionApp.transferContractCompany);
2505
+ this.formStore[whichForm].bankInfo.bankName = bank ? bank : new Value();
2506
+ this.formStore[whichForm].bankInfo.bin = bank ? String(bank.ids) : '';
2507
+ this.formStore.applicationData.pensionApp.transferContractCompany = transferCompany ? transferCompany : new Value();
2508
+ }
1974
2509
  },
1975
2510
  setMembersFieldIndex(whichForm: MultipleMember, whichMember: keyof typeof MemberAppCodes, index: number) {
1976
2511
  if ('familyStatus' in this.formStore[whichForm][index]) {
@@ -1992,8 +2527,18 @@ export const useDataStore = defineStore('data', {
1992
2527
  if ('jobPlace' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].jobName) {
1993
2528
  this.formStore[whichForm][index].jobPlace = this.formStore.applicationData[whichMember][index].jobName;
1994
2529
  }
2530
+ if ('positionCode' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].positionCode) {
2531
+ this.formStore[whichForm][index].positionCode = this.formStore.applicationData[whichMember][index].positionCode;
2532
+ }
2533
+ if (typeof this.formStore.applicationData[whichMember][index].isDisability === 'boolean') {
2534
+ this.formStore[whichForm][index].isDisability = this.formStore.applicationData[whichMember][index].isDisability;
2535
+ }
2536
+ if (!!this.formStore.applicationData[whichMember][index].disabilityGroupId) {
2537
+ const disabilityGroup = this.disabilityGroups.find(i => i.id === this.formStore.applicationData[whichMember][index].disabilityGroupId);
2538
+ this.formStore[whichForm][index].disabilityGroup = disabilityGroup ? disabilityGroup : new Value();
2539
+ }
1995
2540
  },
1996
- async signDocument() {
2541
+ async signDocument(type: string = 'electronic') {
1997
2542
  try {
1998
2543
  if (this.formStore.signUrls.length) {
1999
2544
  return this.formStore.signUrls;
@@ -2001,21 +2546,267 @@ export const useDataStore = defineStore('data', {
2001
2546
  const prepareSignDocuments = (): SignDataType[] => {
2002
2547
  switch (this.formStore.applicationData.statusCode) {
2003
2548
  case 'ContractSignedFrom':
2004
- return [{ processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Contract', format: 'pdf' }];
2005
- default:
2006
2549
  return [
2007
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Agreement', format: 'pdf' },
2008
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Statement', format: 'pdf' },
2550
+ {
2551
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2552
+ name: 'Contract',
2553
+ format: 'pdf',
2554
+ },
2009
2555
  ];
2010
- }
2011
- };
2012
- const data = prepareSignDocuments();
2013
- const result = await this.api.signDocument(data);
2014
- this.formStore.signUrls = result;
2015
- return this.formStore.signUrls;
2556
+ case 'AttachAppContractForm':
2557
+ if (type === 'qrXml') {
2558
+ return [
2559
+ {
2560
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2561
+ name: 'PAEnpf_Agreement',
2562
+ format: 'xml',
2563
+ },
2564
+ ];
2565
+ } else {
2566
+ return [
2567
+ {
2568
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2569
+ name: this.processCode == 19 ? 'PA_Statement' : 'PA_RefundStatement',
2570
+ format: 'pdf',
2571
+ },
2572
+ {
2573
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2574
+ name: 'Agreement',
2575
+ format: 'pdf',
2576
+ },
2577
+ ];
2578
+ }
2579
+ case 'HeadManagerForm':
2580
+ return [
2581
+ {
2582
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2583
+ name: 'PA_Contract',
2584
+ format: 'pdf',
2585
+ },
2586
+ ];
2587
+ default:
2588
+ return [
2589
+ {
2590
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2591
+ name: 'Agreement',
2592
+ format: 'pdf',
2593
+ },
2594
+ {
2595
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2596
+ name: 'Statement',
2597
+ format: 'pdf',
2598
+ },
2599
+ ];
2600
+ }
2601
+ };
2602
+ const data = prepareSignDocuments();
2603
+ if (type === 'qr') {
2604
+ const groupId = await this.api.signQR(data);
2605
+ return groupId;
2606
+ } else if (type === 'qrXml') {
2607
+ const signData = await this.api.signXml(data);
2608
+ return signData;
2609
+ } else if (type === 'signature') {
2610
+ const ncaLayerClient = new NCALayerClient();
2611
+ const formTemplate = new FormData();
2612
+ formTemplate.append('format', 'pdf');
2613
+ formTemplate.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2614
+ let activeTokens;
2615
+ try {
2616
+ await ncaLayerClient.connect();
2617
+ activeTokens = await ncaLayerClient.getActiveTokens();
2618
+ const storageType = activeTokens[0] || NCALayerClient.fileStorageType;
2619
+ if (this.formStore.applicationData.statusCode === 'ContractSignedFrom') {
2620
+ const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2621
+ const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2622
+ const formData = formTemplate;
2623
+ formData.append('base64EncodedSignature', base64EncodedSignature);
2624
+ formData.append('name', 'PA_Contract');
2625
+ try {
2626
+ await this.api.uploadDigitalCertifijcate(formData);
2627
+ await this.handleTask('accept', String(this.formStore.applicationTaskId));
2628
+ } catch (e) {
2629
+ this.showToaster('error', String(e));
2630
+ return;
2631
+ }
2632
+ } else if (this.formStore.applicationData.statusCode === 'HeadManagerForm') {
2633
+ const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2634
+ const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2635
+ const formData = formTemplate;
2636
+ formData.append('base64EncodedSignature', base64EncodedSignature);
2637
+ formData.append('name', 'PA_Contract');
2638
+ try {
2639
+ await this.api.uploadDigitalCertificatePensionAnnuityNew(formData);
2640
+ await this.handleTask('accept', String(this.formStore.applicationTaskId));
2641
+ } catch (e) {
2642
+ this.showToaster('error', String(e));
2643
+ return;
2644
+ }
2645
+ } else {
2646
+ if (!!this.formStore.signedDocumentList.find(i => i.fileTypeCode === '43')?.signed) {
2647
+ const statement = await this.generatePDFDocument('PA_Statement', '37', 'pdf');
2648
+ const statementSignature = await ncaLayerClient.basicsSignCMS(storageType, statement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2649
+ const statementData = formTemplate;
2650
+ statementData.append('base64EncodedSignature', statementSignature);
2651
+ statementData.append('name', 'PA_Statement');
2652
+ await this.api.uploadDigitalCertifijcate(statementData);
2653
+ const agreement = await this.generatePDFDocument('Agreement', '19', 'pdf');
2654
+ const agreementSignature = await ncaLayerClient.basicsSignCMS(storageType, agreement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2655
+ const agreementData = formTemplate;
2656
+ agreementData.append('base64EncodedSignature', agreementSignature);
2657
+ agreementData.append('name', 'Agreement');
2658
+ await this.api.uploadDigitalCertifijcate(agreementData);
2659
+ await this.handleTask('accept', String(this.formStore.applicationTaskId));
2660
+ } else {
2661
+ const document = {
2662
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2663
+ name: 'PAEnpf_Agreement',
2664
+ format: 'xml',
2665
+ };
2666
+ const signData = await this.api.signXml([document]);
2667
+ const agreementXml = await this.api.getDocumentsByEdsXmlId(signData.data);
2668
+ const wnd = window.open('about:blank', '', '_blank');
2669
+ wnd?.document.write(agreementXml.data.document.documentXml);
2670
+ const signedAgreement = await ncaLayerClient.signXml(storageType, agreementXml.data.document.documentXml, 'SIGNATURE', '');
2671
+ const data = new FormData();
2672
+ data.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2673
+ data.append('xmlData', signedAgreement);
2674
+ data.append('name', 'PAEnpf_Agreement');
2675
+ data.append('format', 'xml');
2676
+ data.append('EdsXmlId', signData.data);
2677
+ await this.api.uploadXml(data);
2678
+ await this.getSignedDocList(this.formStore.applicationData.processInstanceId);
2679
+ this.showToaster('success', this.t('pension.consentGiven'), 3000);
2680
+ }
2681
+ }
2682
+ } catch (error) {
2683
+ this.showToaster('error', String(error));
2684
+ return;
2685
+ }
2686
+ } else {
2687
+ if (this.processCode === 19 || this.processCode === 2 || this.processCode === 4) {
2688
+ const result = await this.api.signBts(data);
2689
+ if (result.code === 0) this.formStore.signUrls = result.data;
2690
+ } else {
2691
+ const result = await this.api.signDocument(data);
2692
+ this.formStore.signUrls = result;
2693
+ }
2694
+ return this.formStore.signUrls;
2695
+ }
2696
+ } catch (err) {
2697
+ ErrorHandler(err);
2698
+ }
2699
+ },
2700
+ async downloadTemplate(documentType: number, fileType: string = 'pdf', processInstanceId?: string | number) {
2701
+ try {
2702
+ this.isButtonsLoading = true;
2703
+ const response: any = await this.api.downloadTemplate(documentType, processInstanceId);
2704
+ const blob = new Blob([response], {
2705
+ type: `application/${fileType}`,
2706
+ });
2707
+ const url = window.URL.createObjectURL(blob);
2708
+ const link = document.createElement('a');
2709
+ link.href = url;
2710
+ switch (documentType) {
2711
+ case constants.documentTypes.insuredsList:
2712
+ link.setAttribute('download', 'РФ-ДС-028 Список застрахованных ГССЖ_ГНС, изд.1.xls');
2713
+ break;
2714
+ case constants.documentTypes.statement:
2715
+ link.setAttribute('download', 'Заявление.pdf');
2716
+ break;
2717
+ case constants.documentTypes.contract:
2718
+ link.setAttribute('download', 'Договор страхования.pdf');
2719
+ break;
2720
+ case constants.documentTypes.application1:
2721
+ link.setAttribute('download', 'Приложение №1.pdf');
2722
+ break;
2723
+ case constants.documentTypes.questionnaireInsured:
2724
+ link.setAttribute('download', 'Анкета Застрахованного.docx');
2725
+ break;
2726
+ case constants.documentTypes.invoicePayment:
2727
+ link.setAttribute('download', 'Счет на оплату');
2728
+ break;
2729
+ }
2730
+ document.body.appendChild(link);
2731
+ link.click();
2732
+ } catch (err) {
2733
+ ErrorHandler(err);
2734
+ }
2735
+ this.isButtonsLoading = false;
2736
+ },
2737
+ async sendTemplateToEmail(email: string) {
2738
+ try {
2739
+ this.isButtonsLoading = true;
2740
+ await this.api.sendTemplateToEmail(email);
2741
+ this.showToaster('info', this.t('toaster.successfullyDocSent'), 5000);
2016
2742
  } catch (err) {
2017
2743
  ErrorHandler(err);
2018
2744
  }
2745
+ this.isButtonsLoading = false;
2746
+ },
2747
+ async sendInvoiceToEmail(processInstanceId: string | number, email: string) {
2748
+ try {
2749
+ this.isButtonsLoading = true;
2750
+ await this.api.sendInvoiceToEmail(processInstanceId, email);
2751
+ this.showToaster('info', this.t('toaster.successfullyDocSent'), 5000);
2752
+ } catch (err) {
2753
+ ErrorHandler(err);
2754
+ }
2755
+ this.isButtonsLoading = false;
2756
+ },
2757
+ async generateDocument() {
2758
+ try {
2759
+ this.isButtonsLoading = true;
2760
+ this.formStore.needToScanSignedContract = true;
2761
+ const data: SignDataType = {
2762
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2763
+ name: 'Contract',
2764
+ format: 'pdf',
2765
+ };
2766
+ const response: any = await this.api.generateDocument(data);
2767
+ const blob = new Blob([response], {
2768
+ type: `application/pdf`,
2769
+ });
2770
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2771
+ const url = window.URL.createObjectURL(blob);
2772
+ const link = document.createElement('a');
2773
+ link.href = url;
2774
+ link.setAttribute('download', this.formStore.regNumber + ' Договор страхования');
2775
+ document.body.appendChild(link);
2776
+ link.click();
2777
+ } catch (err) {
2778
+ ErrorHandler(err);
2779
+ }
2780
+ this.isButtonsLoading = false;
2781
+ },
2782
+ async generatePDFDocument(name: string, code: string, format: 'pdf' | 'doc' = 'pdf', open: boolean = false) {
2783
+ try {
2784
+ this.isButtonsLoading = true;
2785
+ this.formStore.needToScanSignedContract = true;
2786
+ const data: any = {
2787
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2788
+ name: name,
2789
+ format: format,
2790
+ };
2791
+ const response: any = await this.api.generatePdfDocument(data);
2792
+ const blob = new Blob([response], {
2793
+ type: format === 'pdf' ? `application/pdf` : `application/vnd.openxmlformats-officedocument.wordprocessingml.document`,
2794
+ });
2795
+ const url = window.URL.createObjectURL(blob);
2796
+ const link = document.createElement('a');
2797
+ link.href = url;
2798
+ link.setAttribute('download', this.formStore.regNumber + ` ${this.dicFileTypeList.find((i: Value) => i.code == code)?.nameRu}`);
2799
+ document.body.appendChild(link);
2800
+ link.click();
2801
+ if (open) {
2802
+ window.open(url, '_blank', `right=100`);
2803
+ }
2804
+ return response;
2805
+ } catch (err) {
2806
+ ErrorHandler(err);
2807
+ } finally {
2808
+ this.isButtonsLoading = false;
2809
+ }
2019
2810
  },
2020
2811
  async registerNumber() {
2021
2812
  try {
@@ -2076,6 +2867,7 @@ export const useDataStore = defineStore('data', {
2076
2867
  Object.keys(this.formStore.isDisabled).forEach(key => {
2077
2868
  this.formStore.isDisabled[key as keyof typeof this.formStore.isDisabled] = !!isDisabled;
2078
2869
  });
2870
+ this.showDisabledMessage = !!isDisabled;
2079
2871
  },
2080
2872
  async reCalculate(processInstanceId: string | number, recalculationData: any, taskId: string, whichSum: string) {
2081
2873
  this.isLoading = true;
@@ -2087,6 +2879,9 @@ export const useDataStore = defineStore('data', {
2087
2879
  const recalculatedValue = await this.api.reCalculate(data);
2088
2880
  if (!!recalculatedValue) {
2089
2881
  await this.getApplicationData(taskId, false, false, false, true);
2882
+ if (this.isGons) {
2883
+ this.formStore.productConditionsForm.isRecalculated = true;
2884
+ }
2090
2885
  this.showToaster(
2091
2886
  'success',
2092
2887
  `${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
@@ -2128,7 +2923,7 @@ export const useDataStore = defineStore('data', {
2128
2923
  }
2129
2924
  }
2130
2925
  } else {
2131
- if (this.formStore[localKey].some((i: any) => i.iin !== null)) {
2926
+ if (this.formStore[localKey].some(i => i.iin !== null)) {
2132
2927
  this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
2133
2928
  return false;
2134
2929
  }
@@ -2215,6 +3010,11 @@ export const useDataStore = defineStore('data', {
2215
3010
  if (this.controls.hasAttachment) {
2216
3011
  const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
2217
3012
  if (areValid) {
3013
+ if (this.isLifetrip && this.formStore.AgentData.fullName === 'Без агента') {
3014
+ this.isLoading = false;
3015
+ this.showToaster('error', this.t('toaster.attachAgentError'), 3000);
3016
+ return false;
3017
+ }
2218
3018
  if (this.isInitiator()) {
2219
3019
  await this.setINSISWorkData();
2220
3020
  }
@@ -2226,8 +3026,8 @@ export const useDataStore = defineStore('data', {
2226
3026
  }
2227
3027
  if (localCheck === false) {
2228
3028
  try {
2229
- if (this.isInitiator() && !this.isGons) {
2230
- if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
3029
+ if (this.isInitiator() && this.members.beneficialOwnerApp.has) {
3030
+ if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
2231
3031
  await Promise.allSettled(
2232
3032
  this.formStore.applicationData.beneficialOwnerApp.map(async (member: any) => {
2233
3033
  await this.api.deleteMember('BeneficialOwner', member.id);
@@ -2247,124 +3047,127 @@ export const useDataStore = defineStore('data', {
2247
3047
  if (!anketa) return false;
2248
3048
  const list = anketa.body;
2249
3049
  if (!list || (list && list.length === 0)) return false;
2250
- let notAnswered = 0;
2251
- for (let x = 0; x < list.length; x++) {
2252
- if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
2253
- notAnswered = notAnswered + 1;
3050
+ const isAnketaValid = ref<boolean>(true);
3051
+ list.forEach(i => {
3052
+ if (
3053
+ (i.first.definedAnswers === 'N' && !i.first.answerText) ||
3054
+ (i.first.definedAnswers === 'Y' && !i.first.answerName) ||
3055
+ (i.first.definedAnswers === 'D' && !i.first.answerName?.match(new RegExp('Нет', 'i')) && !i.first.answerText)
3056
+ ) {
3057
+ isAnketaValid.value = false;
3058
+ return false;
2254
3059
  }
2255
- }
2256
- return notAnswered === 0;
3060
+ if (this.controls.isSecondAnketaRequired && i.first.definedAnswers === 'Y' && i.first.answerName?.match(new RegExp('Да', 'i'))) {
3061
+ if (i.second && i.second.length) {
3062
+ const isValid = i.second.every(second => (second.definedAnswers === 'N' ? !!second.answerText : !!second.answerName));
3063
+ if (!isValid) {
3064
+ isAnketaValid.value = false;
3065
+ this.showToaster('info', this.t('toaster.emptySecondAnketa', { text: i.first.name }), 5000);
3066
+ return false;
3067
+ }
3068
+ } else {
3069
+ // TODO уточнить
3070
+ }
3071
+ }
3072
+ });
3073
+ return isAnketaValid.value;
2257
3074
  },
2258
3075
  async validateAllForms(taskId: string) {
2259
3076
  this.isLoading = true;
2260
3077
  const areMembersValid = await this.validateAllMembers(taskId);
2261
3078
  if (areMembersValid) {
2262
- if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
2263
- const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
2264
- if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i'))) {
2265
- await Promise.allSettled([
2266
- this.getQuestionList(
2267
- 'health',
2268
- this.formStore.applicationData.processInstanceId,
2269
- this.formStore.applicationData.insuredApp[0].id,
2270
- 'surveyByHealthBase',
2271
- 'surveyByHealthSecond',
2272
- ),
2273
- this.getQuestionList(
2274
- 'critical',
2275
- this.formStore.applicationData.processInstanceId,
2276
- this.formStore.applicationData.insuredApp[0].id,
2277
- 'surveyByCriticalBase',
2278
- 'surveyByCriticalSecond',
2279
- ),
2280
- this.isClientAnketaCondition &&
2281
- this.getQuestionList(
2282
- 'health',
2283
- this.formStore.applicationData.processInstanceId,
2284
- this.formStore.applicationData.clientApp.id,
2285
- 'surveyByHealthBasePolicyholder',
2286
- 'surveyByHealthSecond',
2287
- 'policyholder',
2288
- ),
2289
- ]);
2290
- this.isClientAnketaCondition
2291
- ? await Promise.allSettled([
2292
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2293
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2294
- }),
2295
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2296
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2297
- }),
2298
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2299
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2300
- }),
2301
- ])
2302
- : await Promise.allSettled([
2303
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2304
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2305
- }),
2306
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2307
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2308
- }),
2309
- ]);
2310
- } else {
2311
- await Promise.allSettled([
2312
- this.getQuestionList(
2313
- 'health',
2314
- this.formStore.applicationData.processInstanceId,
2315
- this.formStore.applicationData.insuredApp[0].id,
2316
- 'surveyByHealthBase',
2317
- 'surveyByHealthSecond',
2318
- ),
2319
- this.isClientAnketaCondition &&
2320
- this.getQuestionList(
2321
- 'health',
2322
- this.formStore.applicationData.processInstanceId,
2323
- this.formStore.applicationData.clientApp.id,
2324
- 'surveyByHealthBasePolicyholder',
2325
- 'surveyByHealthSecond',
2326
- 'policyholder',
2327
- ),
2328
- ,
2329
- ]);
2330
- this.isClientAnketaCondition
2331
- ? await Promise.allSettled([
2332
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2333
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2334
- }),
2335
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2336
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2337
- }),
2338
- ])
2339
- : await Promise.allSettled(
2340
- this.formStore.surveyByHealthBase!.body.map(async question => {
2341
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2342
- }),
2343
- );
2344
- }
2345
- if (this.validateAnketa('surveyByHealthBase')) {
2346
- let hasCriticalAndItsValid = null;
2347
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2348
- if (this.validateAnketa('surveyByCriticalBase')) {
2349
- hasCriticalAndItsValid = true;
2350
- } else {
2351
- hasCriticalAndItsValid = false;
2352
- this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2353
- }
3079
+ if ((!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) || this.isPension) {
3080
+ if (this.controls.hasAnketa) {
3081
+ const hasCritical =
3082
+ this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName.match(new RegExp('Критическое заболевание Застрахованного', 'i'))) ?? null;
3083
+ if (hasCritical === null || (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')))) {
3084
+ await Promise.allSettled([
3085
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
3086
+ this.isClientAnketaCondition &&
3087
+ this.getQuestionList(
3088
+ 'health',
3089
+ this.formStore.applicationData.processInstanceId,
3090
+ this.formStore.applicationData.clientApp.id,
3091
+ 'surveyByHealthBasePolicyholder',
3092
+ 'policyholder',
3093
+ ),
3094
+ ,
3095
+ ]);
3096
+ this.isClientAnketaCondition
3097
+ ? await Promise.allSettled([
3098
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3099
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3100
+ }),
3101
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3102
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3103
+ }),
3104
+ ])
3105
+ : await Promise.allSettled(
3106
+ this.formStore.surveyByHealthBase!.body.map(async question => {
3107
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3108
+ }),
3109
+ );
2354
3110
  } else {
2355
- hasCriticalAndItsValid = null;
3111
+ await Promise.allSettled([
3112
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
3113
+ this.getQuestionList('critical', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByCriticalBase'),
3114
+ this.isClientAnketaCondition &&
3115
+ this.getQuestionList(
3116
+ 'health',
3117
+ this.formStore.applicationData.processInstanceId,
3118
+ this.formStore.applicationData.clientApp.id,
3119
+ 'surveyByHealthBasePolicyholder',
3120
+ 'policyholder',
3121
+ ),
3122
+ ]);
3123
+ this.isClientAnketaCondition
3124
+ ? await Promise.allSettled([
3125
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3126
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3127
+ }),
3128
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3129
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3130
+ }),
3131
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3132
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3133
+ }),
3134
+ ])
3135
+ : await Promise.allSettled([
3136
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3137
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3138
+ }),
3139
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3140
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3141
+ }),
3142
+ ]);
2356
3143
  }
2357
- if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2358
- if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
2359
- this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
3144
+ if (this.validateAnketa('surveyByHealthBase')) {
3145
+ let hasCriticalAndItsValid = null;
3146
+ if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')) === null) {
3147
+ if (this.validateAnketa('surveyByCriticalBase')) {
3148
+ hasCriticalAndItsValid = true;
3149
+ } else {
3150
+ hasCriticalAndItsValid = false;
3151
+ this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
3152
+ }
3153
+ } else {
3154
+ hasCriticalAndItsValid = null;
3155
+ }
3156
+ if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
3157
+ if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
3158
+ this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
3159
+ this.isLoading = false;
3160
+ return false;
3161
+ }
2360
3162
  this.isLoading = false;
2361
- return false;
3163
+ return true;
2362
3164
  }
2363
- this.isLoading = false;
2364
- return true;
3165
+ } else {
3166
+ this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2365
3167
  }
2366
3168
  } else {
2367
- this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
3169
+ this.isLoading = false;
3170
+ return true;
2368
3171
  }
2369
3172
  } else {
2370
3173
  this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
@@ -2377,7 +3180,10 @@ export const useDataStore = defineStore('data', {
2377
3180
  async getFamilyInfo(iin: string, phoneNumber: string) {
2378
3181
  this.isLoading = true;
2379
3182
  try {
2380
- const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
3183
+ const familyResponse = await this.api.getFamilyInfo({
3184
+ iin: iin.replace(/-/g, ''),
3185
+ phoneNumber: formatPhone(phoneNumber),
3186
+ });
2381
3187
  if (familyResponse.status === 'soap:Server') {
2382
3188
  this.showToaster('error', `${familyResponse.statusName}. Отправьте запрос через некоторое время`, 5000);
2383
3189
  this.isLoading = false;
@@ -2422,6 +3228,32 @@ export const useDataStore = defineStore('data', {
2422
3228
  this.isLoading = false;
2423
3229
  }
2424
3230
  },
3231
+ async getKgd(iin: string) {
3232
+ try {
3233
+ const data = {
3234
+ iinBin: iin.replace(/-/g, ''),
3235
+ };
3236
+ const kgdResponse = await this.api.getKgd(data);
3237
+ return kgdResponse;
3238
+ } catch (err) {
3239
+ return ErrorHandler(err);
3240
+ }
3241
+ },
3242
+ async getGbdUl(bin: string) {
3243
+ if (!this.accessToken) return null;
3244
+ try {
3245
+ const decoded = jwtDecode(this.accessToken);
3246
+ const data = {
3247
+ userName: decoded.code,
3248
+ branchName: decoded.branchCode,
3249
+ bin: bin.replace(/-/g, ''),
3250
+ };
3251
+ const gbdulResponse = await this.api.getGbdUl(data);
3252
+ return gbdulResponse;
3253
+ } catch (err) {
3254
+ return ErrorHandler(err);
3255
+ }
3256
+ },
2425
3257
  async getContragentFromGBDFL(member: Member) {
2426
3258
  // null - ожидание
2427
3259
  // false - ошибка или неправильно
@@ -2453,13 +3285,27 @@ export const useDataStore = defineStore('data', {
2453
3285
  this.isLoading = false;
2454
3286
  return false;
2455
3287
  }
2456
- const { person } = parseXML(gbdResponse.content, true, 'person');
3288
+ if (!gbdResponse.content) {
3289
+ let errMsg: string = '';
3290
+ if (gbdResponse.status) {
3291
+ errMsg += gbdResponse.status;
3292
+ }
3293
+ if (gbdResponse.statusName) {
3294
+ errMsg += gbdResponse.statusName;
3295
+ }
3296
+ if (!!errMsg) {
3297
+ this.showToaster('error', errMsg, 5000);
3298
+ }
3299
+ this.isLoading = false;
3300
+ return false;
3301
+ }
3302
+ const { person } = parseXML(gbdResponse.content, true, 'person') as { person: Api.GBD.Person };
2457
3303
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2458
3304
  if (member.gosPersonData !== null && member.gosPersonData.iin !== member.iin!.replace(/-/g, '')) {
2459
3305
  member.resetMember(false);
2460
3306
  }
2461
3307
  member.gosPersonData = person;
2462
- await this.getContragent(member, false);
3308
+ await this.getContragent(member, false, false);
2463
3309
  member.verifyDate = responseInfo.responseDate;
2464
3310
  member.verifyType = 'GBDFL';
2465
3311
  await this.saveInStoreUserGBDFL(person, member);
@@ -2470,15 +3316,19 @@ export const useDataStore = defineStore('data', {
2470
3316
  this.isLoading = false;
2471
3317
  }
2472
3318
  },
2473
- async saveInStoreUserGBDFL(person: any, member: Member) {
3319
+ async saveInStoreUserGBDFL(person: Api.GBD.Person, member: Member) {
2474
3320
  member.firstName = person.name;
2475
3321
  member.lastName = person.surname;
2476
3322
  member.middleName = person.patronymic ? person.patronymic : '';
3323
+ if (this.isLifetrip) {
3324
+ member.firstNameLat = person.engFirstName ? person.engFirstName : '';
3325
+ member.lastNameLat = person.engSurname ? person.engSurname : '';
3326
+ }
2477
3327
  member.longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2478
3328
  member.birthDate = reformatDate(person.birthDate);
2479
3329
  member.genderName = person.gender.nameRu;
2480
3330
 
2481
- const gender = this.gender.find(i => i.id == person.gender.code);
3331
+ const gender = this.gender.find((i: Value) => i.id == person.gender.code);
2482
3332
  if (gender) member.gender = gender;
2483
3333
 
2484
3334
  const birthPlace = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.birthPlace.country.nameRu, 'i')));
@@ -2557,45 +3407,422 @@ export const useDataStore = defineStore('data', {
2557
3407
  if (person.regAddress.building) member.registrationNumberHouse = person.regAddress.building;
2558
3408
  if (person.regAddress.flat) member.registrationNumberApartment = person.regAddress.flat;
2559
3409
 
2560
- // TODO Доработать логику и для остальных
2561
- if ('length' in person.documents.document) {
2562
- const validDocument = person.documents.document.find((i: any) => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
3410
+ if (Array.isArray(person.documents.document)) {
3411
+ const validDocument = person.documents.document.find(
3412
+ i =>
3413
+ new Date(i.endDate) > new Date(Date.now()) &&
3414
+ i.status.code === '00' &&
3415
+ (i.type.code === Enums.GBD.DocTypes['1UDL'] || i.type.code === Enums.GBD.DocTypes.VNZ || i.type.code === Enums.GBD.DocTypes.PS),
3416
+ );
2563
3417
  if (validDocument) {
2564
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
3418
+ const documentType = this.documentTypes.find((i: Value) => i.ids === Object.keys(Enums.GBD.DocTypes)[Object.values(Enums.GBD.DocTypes).indexOf(validDocument.type.code)]);
2565
3419
  if (documentType) member.documentType = documentType;
2566
-
2567
- member.documentNumber = validDocument.number;
2568
- member.documentExpire = reformatDate(validDocument.endDate);
2569
- member.documentDate = reformatDate(validDocument.beginDate);
2570
- member.documentNumber = validDocument.number;
2571
-
3420
+ if (validDocument.number) member.documentNumber = validDocument.number;
3421
+ if (validDocument.beginDate) member.documentDate = reformatDate(validDocument.beginDate);
3422
+ if (validDocument.endDate) member.documentExpire = reformatDate(validDocument.endDate);
3423
+ const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
3424
+ if (documentIssuer) member.documentIssuers = documentIssuer;
3425
+ }
3426
+ } else {
3427
+ const personDoc = person.documents.document;
3428
+ if (
3429
+ personDoc.status.code === '00' &&
3430
+ new Date(personDoc.endDate) > new Date(Date.now()) &&
3431
+ (personDoc.type.code === Enums.GBD.DocTypes['1UDL'] || personDoc.type.code === Enums.GBD.DocTypes.VNZ || personDoc.type.code === Enums.GBD.DocTypes.PS)
3432
+ ) {
3433
+ const documentType = this.documentTypes.find((i: Value) => i.ids === Object.keys(Enums.GBD.DocTypes)[Object.values(Enums.GBD.DocTypes).indexOf(personDoc.type.code)]);
3434
+ if (documentType) member.documentType = documentType;
3435
+ const documentNumber = personDoc.number;
3436
+ if (documentNumber) member.documentNumber = documentNumber;
3437
+ const documentDate = personDoc.beginDate;
3438
+ if (documentDate) member.documentDate = reformatDate(documentDate);
3439
+ const documentExpire = personDoc.endDate;
3440
+ if (documentExpire) member.documentExpire = reformatDate(documentExpire);
2572
3441
  const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
2573
3442
  if (documentIssuer) member.documentIssuers = documentIssuer;
2574
3443
  }
3444
+ }
3445
+ const economySectorCode = this.economySectorCode.find((i: Value) => i.ids === '500003.9');
3446
+ if (economySectorCode) member.economySectorCode = economySectorCode;
3447
+ },
3448
+ preparePersonData(data: any) {
3449
+ if (data) {
3450
+ Object.keys(data).forEach(key => {
3451
+ if (data[key] === Object(data[key]) && !!data[key]) {
3452
+ this.preparePersonData(data[key]);
3453
+ } else {
3454
+ if (data[key] !== null) {
3455
+ if (key === 'iin' || key === 'bin') data[key] = data[key].replace(/-/g, '');
3456
+ if (key === 'phoneNumber') data[key] = formatPhone(data[key]);
3457
+ if (key === 'issuedOn' || key === 'validUntil' || key === 'birthDate' || key === 'date') data[key] = formatDate(data[key])?.toISOString() ?? '';
3458
+ if (key === 'nameRu' && data['ids']) data['id'] = data['ids'];
3459
+ if (key === 'positionRu') data['positionKz'] = data['positionRu'];
3460
+ }
3461
+ }
3462
+ });
3463
+ }
3464
+ },
3465
+ async startApplicationV2(data: PolicyholderClass) {
3466
+ const policyholder = JSON.parse(JSON.stringify(data)) as any;
3467
+ this.preparePersonData(policyholder);
3468
+ keyDeleter(policyholder as PolicyholderClass, [
3469
+ 'clientData.beneficalOwnerQuest',
3470
+ 'clientData.identityDocument',
3471
+ 'clientData.activityTypes',
3472
+ 'clientData.citizenship',
3473
+ 'clientData.addTaxResidency',
3474
+ 'clientData.gender',
3475
+ 'clientData.placeOfBirth',
3476
+ 'clientData.authoritedPerson.actualAddress',
3477
+ 'clientData.authoritedPerson.bankInfo',
3478
+ 'clientData.authoritedPerson.economySectorCode',
3479
+ 'clientData.authoritedPerson.legalAddress',
3480
+ 'clientData.authoritedPerson.placeOfBirth',
3481
+ 'clientData.authoritedPerson.resident',
3482
+ 'clientData.authoritedPerson.taxResidentCountry',
3483
+ 'clientData.authoritedPerson.addTaxResidency',
3484
+ ]);
3485
+ policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3486
+ try {
3487
+ const response = await this.api.startApplication(policyholder);
3488
+ this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
3489
+ return response.processInstanceId;
3490
+ } catch (err) {
3491
+ return ErrorHandler(err);
3492
+ }
3493
+ },
3494
+ async saveClient(data: PolicyholderClass) {
3495
+ const policyholder = JSON.parse(JSON.stringify(data)) as any;
3496
+ policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3497
+ this.preparePersonData(policyholder);
3498
+ try {
3499
+ await this.api.saveClient(this.formStore.applicationData.processInstanceId, this.formStore.lfb.clientId, policyholder);
3500
+ } catch (err) {
3501
+ return ErrorHandler(err);
3502
+ }
3503
+ },
3504
+ async getApplicationDataV2(taskId: string) {
3505
+ this.isLoading = true;
3506
+ try {
3507
+ const applicationData = await this.api.getApplicationData(taskId);
3508
+ if (this.processCode !== applicationData.processCode) {
3509
+ this.isLoading = false;
3510
+ this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
3511
+ return;
3512
+ }
3513
+
3514
+ this.formStore.applicationData = applicationData;
3515
+ this.formStore.regNumber = applicationData.regNumber;
3516
+ this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
3517
+
3518
+ this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
3519
+ this.formStore.applicationTaskId = taskId;
3520
+ this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
3521
+ this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
3522
+ this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
3523
+ this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
3524
+ this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
3525
+ this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
3526
+
3527
+ this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
3528
+ this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
3529
+
3530
+ const { clientData } = applicationData.clientApp;
3531
+ const beneficialOwnerApp = applicationData.beneficialOwnerApp;
3532
+ const insuredApp = applicationData.insuredApp;
3533
+ const accidentIncidents = applicationData.accidentIncidentDtos;
3534
+ const clientId = applicationData.clientApp.id;
3535
+
3536
+ this.formStore.applicationData.processInstanceId = applicationData.processInstanceId;
3537
+ this.formStore.lfb.policyholder.isIpdl = applicationData.clientApp.isIpdl;
3538
+ this.formStore.lfb.policyholder.clientData = clientData;
3539
+ this.formStore.lfb.policyholder.clientData.authoritedPerson = clientData.authoritedPerson;
3540
+ this.formStore.lfb.policyholder.clientData.iin = reformatIin(clientData.iin);
3541
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.iin = reformatIin(clientData.authoritedPerson.iin);
3542
+ this.formStore.lfb.clientId = clientId;
3543
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.authorityDetails.date = reformatDate(clientData.authoritedPerson.authorityDetails.date);
3544
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.birthDate = reformatDate(clientData.authoritedPerson.birthDate) ?? '';
3545
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.issuedOn = reformatDate(clientData.authoritedPerson.identityDocument.issuedOn) ?? '';
3546
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.validUntil = reformatDate(clientData.authoritedPerson.identityDocument.validUntil) ?? '';
3547
+ const gender = this.gender.find((i: Value) => i.id === clientData.authoritedPerson.gender);
3548
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.gender = gender ? gender : new Value();
3549
+
3550
+ if (clientData && clientData.activityTypes !== null) {
3551
+ this.formStore.lfb.policyholderActivities = clientData.activityTypes;
3552
+ }
3553
+
3554
+ if (beneficialOwnerApp && beneficialOwnerApp.length) {
3555
+ this.formStore.lfb.beneficialOwners = beneficialOwnerApp;
3556
+ this.formStore.lfb.isPolicyholderBeneficialOwner = clientData.authoritedPerson.iin.replace(/-/g, '') === beneficialOwnerApp[0].beneficialOwnerData.iin ? true : false;
3557
+ this.formStore.lfb.beneficialOwners.forEach(beneficial => {
3558
+ beneficial.beneficialOwnerData.birthDate = reformatDate(beneficial.beneficialOwnerData.birthDate as string) ?? '';
3559
+ beneficial.beneficialOwnerData.identityDocument.validUntil = reformatDate(beneficial.beneficialOwnerData.identityDocument.validUntil as string) ?? '';
3560
+ beneficial.beneficialOwnerData.iin = reformatIin(beneficial.beneficialOwnerData.iin as string);
3561
+ beneficial.beneficialOwnerData.identityDocument.issuedOn = reformatDate(beneficial.beneficialOwnerData.identityDocument.issuedOn as string) ?? '';
3562
+ //@ts-ignore
3563
+ const gender = this.gender.find((i: Value) => i.id === beneficial.beneficialOwnerData.gender);
3564
+ beneficial.beneficialOwnerData.gender = gender ? gender : new Value();
3565
+ });
3566
+ }
3567
+
3568
+ if (insuredApp && insuredApp.length) {
3569
+ const res = await this.newInsuredList(insuredApp);
3570
+ this.formStore.lfb.clients = res;
3571
+ }
3572
+
3573
+ if (accidentIncidents && accidentIncidents.length) {
3574
+ this.formStore.lfb.accidentIncidents = accidentIncidents;
3575
+ this.formStore.lfb.accidentIncidents.forEach(incident => {
3576
+ incident.amount = incident.amount === 0 ? '' : incident.amount;
3577
+ incident.count = incident.count === 0 ? '' : incident.count;
3578
+ });
3579
+ }
3580
+
3581
+ this.formStore.productConditionsForm.calcDate = reformatDate(applicationData.policyAppDto.calcDate);
3582
+ this.formStore.productConditionsForm.contractEndDate = reformatDate(applicationData.policyAppDto.contractEndDate);
3583
+ this.formStore.productConditionsForm.agentCommission = applicationData.policyAppDto.agentCommission === 0 ? null : applicationData.policyAppDto.agentCommission;
3584
+ this.formStore.productConditionsForm.fixInsSum = this.getNumberWithSpaces(applicationData.policyAppDto.fixInsSum === 0 ? null : applicationData.policyAppDto.fixInsSum);
3585
+ this.formStore.productConditionsForm.coverPeriod = 12;
3586
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(applicationData.policyAppDto.amount === 0 ? null : applicationData.policyAppDto.amount);
3587
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
3588
+ applicationData.policyAppDto.mainPremiumWithCommission === 0 ? null : applicationData.policyAppDto.mainPremiumWithCommission,
3589
+ );
3590
+ const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
3591
+ this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
3592
+ const processGfot = this.processGfot.find(item => item.id == applicationData.policyAppDto.processDefinitionFgotId);
3593
+ this.formStore.productConditionsForm.processGfot = processGfot ? processGfot : new Value();
3594
+ } catch (err) {
3595
+ ErrorHandler(err);
3596
+ if (err instanceof AxiosError) {
3597
+ this.sendToParent(constants.postActions.toHomePage, err.response?.data);
3598
+ this.isLoading = false;
3599
+ return false;
3600
+ }
3601
+ }
3602
+ this.isLoading = false;
3603
+ },
3604
+ async saveAccidentIncidents(data: AccidentIncidents[]) {
3605
+ try {
3606
+ const dataCopy = JSON.parse(JSON.stringify(data));
3607
+ for (const incident of dataCopy) {
3608
+ incident.count = !!incident.count ? incident.count : 0;
3609
+ incident.amount = incident.amount ? incident.amount : 0;
3610
+ }
3611
+ const response = await this.api.saveAccidentIncidents(this.formStore.applicationData.processInstanceId, dataCopy);
3612
+ return response;
3613
+ } catch (err) {
3614
+ return ErrorHandler(err);
3615
+ }
3616
+ },
3617
+ async saveClientActivityTypes(data: PolicyholderActivity[]) {
3618
+ try {
3619
+ const response = await this.api.saveClientActivityTypes(this.formStore.applicationData.clientApp.id, data);
3620
+ return response;
3621
+ } catch (err) {
3622
+ return ErrorHandler(err);
3623
+ }
3624
+ },
3625
+ async saveBeneficialOwnerList(data: BeneficialOwner[]) {
3626
+ const beneficialOwnerList = JSON.parse(JSON.stringify(data)) as any;
3627
+ for (const item of beneficialOwnerList) {
3628
+ keyDeleter(item as BeneficialOwner, [
3629
+ 'beneficialOwnerData.activityTypes',
3630
+ 'beneficialOwnerData.actualAddress',
3631
+ 'beneficialOwnerData.addTaxResidency',
3632
+ 'beneficialOwnerData.authoritedPerson',
3633
+ 'beneficialOwnerData.authorityDetails',
3634
+ 'beneficialOwnerData.bankInfo',
3635
+ 'beneficialOwnerData.legalAddress',
3636
+ 'beneficialOwnerData.placeOfBirth',
3637
+ 'beneficialOwnerData.typeOfEconomicActivity',
3638
+ ]);
3639
+ item.processInstanceId = this.formStore.applicationData.processInstanceId;
3640
+ item.beneficialOwnerData.gender = item.beneficialOwnerData.gender.nameRu === 'Мужской' ? 1 : 2;
3641
+ this.preparePersonData(item.beneficialOwnerData);
3642
+ }
3643
+ try {
3644
+ const response = await this.api.saveBeneficialOwnerList(this.formStore.applicationData.processInstanceId, beneficialOwnerList);
3645
+ return response;
3646
+ } catch (err) {
3647
+ return ErrorHandler(err);
3648
+ }
3649
+ },
3650
+ async saveBeneficialOwner(data: BeneficialOwner) {
3651
+ const beneficialOwner = JSON.parse(JSON.stringify(data)) as any;
3652
+ keyDeleter(beneficialOwner as BeneficialOwner, [
3653
+ 'beneficialOwnerData.activityTypes',
3654
+ 'beneficialOwnerData.actualAddress',
3655
+ 'beneficialOwnerData.addTaxResidency',
3656
+ 'beneficialOwnerData.authoritedPerson',
3657
+ 'beneficialOwnerData.authorityDetails',
3658
+ 'beneficialOwnerData.bankInfo',
3659
+ 'beneficialOwnerData.legalAddress',
3660
+ 'beneficialOwnerData.placeOfBirth',
3661
+ 'beneficialOwnerData.typeOfEconomicActivity',
3662
+ ]);
3663
+ beneficialOwner.beneficialOwnerData.gender = beneficialOwner.beneficialOwnerData.gender.nameRu === 'Мужской' ? 1 : 2;
3664
+ this.preparePersonData(beneficialOwner.beneficialOwnerData);
3665
+ try {
3666
+ const response = await this.api.saveBeneficialOwner(this.formStore.applicationData.processInstanceId, String(beneficialOwner.id), beneficialOwner);
3667
+ return response;
3668
+ } catch (err) {
3669
+ return ErrorHandler(err);
3670
+ }
3671
+ },
3672
+ async saveInsuredList(insuredList: any) {
3673
+ try {
3674
+ await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, insuredList);
3675
+ return true;
3676
+ } catch (err) {
3677
+ return ErrorHandler(err);
3678
+ }
3679
+ },
3680
+ async saveInsured(insured: any) {
3681
+ try {
3682
+ const response = await this.api.saveInsured(this.formStore.applicationData.processInstanceId, insured.id, insured);
3683
+ return response;
3684
+ } catch (err) {
3685
+ return ErrorHandler(err);
3686
+ }
3687
+ },
3688
+ newInsuredList(list: any) {
3689
+ const clients = list.map((item: any, index: number) => {
3690
+ const client = item.insuredData;
3691
+ return {
3692
+ id: index,
3693
+ fullName: client.longName,
3694
+ gender: client.gender,
3695
+ position: client.workDetails.positionRu,
3696
+ birthDate: client.birthDate,
3697
+ iin: reformatIin(client.iin),
3698
+ insSum: client.insuredPolicyData.insSum,
3699
+ premium: client.insuredPolicyData.premium,
3700
+ premiumWithLoad: client.insuredPolicyData.premiumWithLoad,
3701
+ hasAttachedFile: client.hasAttachedFile,
3702
+ };
3703
+ });
3704
+ return clients;
3705
+ },
3706
+ validateMultipleMembersV2(localKey: string, applicationKey: keyof typeof this.formStore.applicationData, text: string) {
3707
+ // @ts-ignore
3708
+ if (this.formStore.lfb[localKey].length === this.formStore.applicationData[applicationKey].length) {
3709
+ // @ts-ignore
3710
+ if (this.formStore.lfb[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
3711
+ // @ts-ignore
3712
+ const localMembers = [...this.formStore.lfb[localKey]].sort((a, b) => Number(a.id) - Number(b.id));
3713
+ const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.id - b.id);
3714
+ if (localMembers.every((each, index) => applicationMembers[index].iin === each.iin?.replace(/-/g, '')) === false) {
3715
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3716
+ return false;
3717
+ }
3718
+ }
2575
3719
  } else {
2576
- const documentType =
2577
- person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2578
- ? this.documentTypes.find(i => i.ids === '1UDL')
2579
- : this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2580
- ? this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2581
- : new Value();
2582
- if (documentType) member.documentType = documentType;
3720
+ // @ts-ignore
3721
+ if (this.formStore.lfb[localKey].some(i => i.iin !== null)) {
3722
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3723
+ return false;
3724
+ }
3725
+ if (this.formStore.applicationData[applicationKey].length !== 0) {
3726
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3727
+ return false;
3728
+ } else {
3729
+ // @ts-ignore
3730
+ if (this.formStore.lfb[localKey][0].iin !== null) {
3731
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3732
+ return false;
3733
+ }
3734
+ }
3735
+ }
3736
+ return true;
3737
+ },
3738
+ async validateAllFormsV2(taskId: string) {
3739
+ this.isLoading = true;
3740
+ if (taskId === '0') {
3741
+ this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
3742
+ return false;
3743
+ }
3744
+
3745
+ if (this.formStore.applicationData.clientApp.iin !== this.formStore.applicationData.clientApp.iin) {
3746
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
3747
+ return false;
3748
+ }
3749
+
3750
+ if (this.formStore.lfb.beneficialOwners) {
3751
+ if (this.validateMultipleMembersV2('beneficialOwners', 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
3752
+ return false;
3753
+ }
3754
+ const inStatement = this.formStore.lfb.beneficialOwners.every(i => i.beneficialOwnerData.id !== null);
3755
+ if (inStatement === false) {
3756
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficialOwner') }));
3757
+ return false;
3758
+ }
3759
+ }
3760
+
3761
+ if (this.formStore.applicationData.clientApp.clientData.activityTypes === null) {
3762
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'деятельности Страхователя' }), 3000);
3763
+ return false;
3764
+ }
2583
3765
 
2584
- const documentNumber = person.documents.document.number;
2585
- if (documentNumber) member.documentNumber = documentNumber;
3766
+ if (this.formStore.lfb.clients) {
3767
+ if (this.validateMultipleMembersV2('clients', 'insuredApp', 'застрахованных') === false) {
3768
+ return false;
3769
+ }
3770
+ const inStatement = this.formStore.lfb.clients.every(i => i.id !== null);
3771
+ if (inStatement === false) {
3772
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.insured') }));
3773
+ return false;
3774
+ }
3775
+ }
2586
3776
 
2587
- const documentDate = person.documents.document.beginDate;
2588
- if (documentDate) member.documentDate = reformatDate(documentDate);
3777
+ if (this.formStore.lfb.clients && this.formStore.lfb.clients.length <= 10) {
3778
+ for (const client of this.formStore.lfb.clients) {
3779
+ if (client.hasAttachedFile === false) {
3780
+ this.showToaster('error', this.t('toaster.needAttachQuestionnaire'), 3000);
3781
+ return false;
3782
+ }
3783
+ }
3784
+ }
2589
3785
 
2590
- const documentExpire = person.documents.document.endDate;
2591
- if (documentExpire) member.documentExpire = reformatDate(documentExpire);
3786
+ if (this.formStore.productConditionsForm.insurancePremiumPerMonth === null) {
3787
+ this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
3788
+ return false;
3789
+ }
2592
3790
 
2593
- // TODO уточнить
2594
- const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
2595
- if (documentIssuer) member.documentIssuers = documentIssuer;
3791
+ if (this.formStore.productConditionsForm.insurancePremiumPerMonth === '0') {
3792
+ this.showToaster('error', this.t('toaster.notZeroPremium'), 3000);
3793
+ return false;
3794
+ }
3795
+
3796
+ return true;
3797
+ },
3798
+ async getVariableData(processCode: number) {
3799
+ try {
3800
+ const response = await this.api.getVariableData(0, processCode);
3801
+ if (response) {
3802
+ return response.data.slice(0, 10);
3803
+ }
3804
+ return null;
3805
+ } catch (err) {
3806
+ ErrorHandler(err);
3807
+ return null;
3808
+ }
3809
+ },
3810
+ async checkIIN(iin: string) {
3811
+ try {
3812
+ const response = await this.api.checkIIN(iin);
3813
+ return response;
3814
+ } catch (err) {
3815
+ ErrorHandler(err);
3816
+ return null;
3817
+ }
3818
+ },
3819
+ async checkAccountNumber(iik: string) {
3820
+ try {
3821
+ const checked = await this.api.checkAccountNumber(iik);
3822
+ return checked;
3823
+ } catch (err) {
3824
+ return ErrorHandler(err);
2596
3825
  }
2597
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
2598
- if (economySectorCode) member.economySectorCode = economySectorCode;
2599
3826
  },
2600
3827
  async isCourseChanged(processInstanceId: string) {
2601
3828
  try {
@@ -2605,7 +3832,20 @@ export const useDataStore = defineStore('data', {
2605
3832
  return ErrorHandler(err);
2606
3833
  }
2607
3834
  },
3835
+ async generateShortLink(url: string, template?: Api.GenerateShortLink.Templates) {
3836
+ try {
3837
+ const response = await this.api.generateShortLink({
3838
+ link: url,
3839
+ priority: 'low',
3840
+ template: template,
3841
+ });
3842
+ return response.link;
3843
+ } catch (err) {
3844
+ return ErrorHandler(err);
3845
+ }
3846
+ },
2608
3847
  hasJobSection(whichForm: keyof typeof StoreMembers) {
3848
+ if (this.isLifetrip || this.isPension) return false;
2609
3849
  switch (whichForm) {
2610
3850
  case this.formStore.beneficiaryFormKey:
2611
3851
  case this.formStore.beneficialOwnerFormKey:
@@ -2616,7 +3856,7 @@ export const useDataStore = defineStore('data', {
2616
3856
  }
2617
3857
  },
2618
3858
  hasBirthSection(whichForm: keyof typeof StoreMembers) {
2619
- if (this.isGons) return false;
3859
+ if (this.isGons || this.isPension) return false;
2620
3860
  switch (whichForm) {
2621
3861
  case this.formStore.beneficiaryFormKey:
2622
3862
  return false;
@@ -2637,30 +3877,79 @@ export const useDataStore = defineStore('data', {
2637
3877
  }
2638
3878
  },
2639
3879
  hasContactSection(whichForm: keyof typeof StoreMembers) {
2640
- if (this.isGons) return false;
3880
+ if (this.isGons || this.isPension) return false;
2641
3881
  switch (whichForm) {
2642
3882
  default:
2643
3883
  return true;
2644
3884
  }
2645
3885
  },
3886
+ hasBankSection(whichForm: keyof typeof StoreMembers) {
3887
+ if (!this.isPension) return false;
3888
+ switch (whichForm) {
3889
+ case 'beneficiaryForm':
3890
+ return false;
3891
+ default:
3892
+ return true;
3893
+ }
3894
+ },
3895
+ hasAdditionalDocumentsSection(whichForm: keyof typeof StoreMembers) {
3896
+ if (!this.isPension) return false;
3897
+ switch (whichForm) {
3898
+ case 'beneficiaryForm':
3899
+ return false;
3900
+ default:
3901
+ return true;
3902
+ }
3903
+ },
3904
+ hasFamilyTiesSection(whichForm: keyof typeof StoreMembers) {
3905
+ if (!this.isPension) return false;
3906
+ switch (whichForm) {
3907
+ case 'policyholderForm':
3908
+ return false;
3909
+ case 'beneficiaryForm':
3910
+ return true;
3911
+ default:
3912
+ return false;
3913
+ }
3914
+ },
2646
3915
  hasPercentageOfPayoutAmount() {
2647
3916
  return true;
2648
3917
  },
2649
- canViewInvoiceInfo() {
2650
- return this.isAdmin();
3918
+ hasAccess() {
3919
+ const baseAccessRoles = this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn();
3920
+ return {
3921
+ invoiceInfo: this.isAdmin(),
3922
+ toLKA: this.isAgent() || baseAccessRoles,
3923
+ toAML: this.isCompliance() || baseAccessRoles,
3924
+ toAULETTI: this.isAgentAuletti() || baseAccessRoles,
3925
+ toLKA_A: this.isAgentAuletti() || baseAccessRoles,
3926
+ toEFO:
3927
+ this.isManager() ||
3928
+ this.isAgent() ||
3929
+ this.isAgentMycar() ||
3930
+ this.isManagerHalykBank() ||
3931
+ this.isHeadManager() ||
3932
+ this.isServiceManager() ||
3933
+ this.isUnderwriter() ||
3934
+ this.isActuary() ||
3935
+ this.isAdmin() ||
3936
+ this.isCompliance() ||
3937
+ this.isAnalyst() ||
3938
+ this.isUpk() ||
3939
+ this.isFinCenter() ||
3940
+ this.isSupervisor() ||
3941
+ this.isSupport() ||
3942
+ this.isDrn() ||
3943
+ this.isUrp() ||
3944
+ this.isUsns() ||
3945
+ this.isAccountant() ||
3946
+ this.isBranchDirector() ||
3947
+ this.isUSNSACCINS() ||
3948
+ this.isDsuio() ||
3949
+ this.isAdjuster() ||
3950
+ this.isDsoDirector() ||
3951
+ this.isAccountantDirector(),
3952
+ };
2651
3953
  },
2652
3954
  },
2653
3955
  });
2654
-
2655
- // Для карты клиента
2656
- // export const useContragentStore = defineStore('contragent', {
2657
- // state: () => ({
2658
- // ...new Contragent(),
2659
- // formatDate: new Contragent().formatDate,
2660
- // getDateByKey: new Contragent().getDateByKey,
2661
- // getBirthDate: new Contragent().getBirthDate,
2662
- // getDocumentExpireDate: new Contragent().getDocumentExpireDate,
2663
- // getDocumentDate: new Contragent().getDocumentDate,
2664
- // getAgeByBirthDate: new Contragent().getAgeByBirthDate,
2665
- // }),
2666
- // });