hl-core 0.0.9-beta.3 → 0.0.9-beta.31

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 +862 -0
  2. package/api/index.ts +2 -620
  3. package/api/interceptors.ts +58 -14
  4. package/components/Button/Btn.vue +3 -3
  5. package/components/Complex/ContentBlock.vue +1 -1
  6. package/components/Complex/MessageBlock.vue +2 -2
  7. package/components/Complex/Page.vue +8 -2
  8. package/components/Complex/WhiteBlock.vue +7 -0
  9. package/components/Dialog/Dialog.vue +60 -15
  10. package/components/Dialog/FamilyDialog.vue +5 -5
  11. package/components/Form/DynamicForm.vue +99 -0
  12. package/components/Form/FormBlock.vue +36 -29
  13. package/components/Form/FormData.vue +48 -0
  14. package/components/Form/FormSection.vue +2 -2
  15. package/components/Form/FormTextSection.vue +3 -3
  16. package/components/Form/FormToggle.vue +3 -3
  17. package/components/Form/ManagerAttachment.vue +104 -52
  18. package/components/Form/ProductConditionsBlock.vue +73 -20
  19. package/components/Input/DynamicInput.vue +23 -0
  20. package/components/Input/EmptyFormField.vue +1 -1
  21. package/components/Input/FileInput.vue +15 -4
  22. package/components/Input/Monthpicker.vue +33 -0
  23. package/components/Input/PanelInput.vue +5 -1
  24. package/components/Input/RoundedEmptyField.vue +5 -0
  25. package/components/Input/RoundedSelect.vue +13 -0
  26. package/components/Input/SwitchInput.vue +64 -0
  27. package/components/Input/TextInput.vue +161 -0
  28. package/components/Layout/Drawer.vue +17 -4
  29. package/components/Layout/Header.vue +2 -2
  30. package/components/Layout/SettingsPanel.vue +10 -15
  31. package/components/List/ListEmpty.vue +1 -1
  32. package/components/Menu/MenuHover.vue +1 -1
  33. package/components/Menu/MenuNav.vue +3 -3
  34. package/components/Menu/MenuNavItem.vue +4 -4
  35. package/components/Pages/Anketa.vue +144 -65
  36. package/components/Pages/Auth.vue +21 -10
  37. package/components/Pages/ContragentForm.vue +505 -0
  38. package/components/Pages/Documents.vue +57 -11
  39. package/components/Pages/InvoiceInfo.vue +2 -2
  40. package/components/Pages/MemberForm.vue +253 -89
  41. package/components/Pages/ProductAgreement.vue +2 -11
  42. package/components/Pages/ProductConditions.vue +777 -164
  43. package/components/Panel/PanelHandler.vue +297 -54
  44. package/components/Panel/PanelSelectItem.vue +18 -3
  45. package/components/Panel/RightPanelCloser.vue +7 -0
  46. package/components/Utilities/IconBorder.vue +17 -0
  47. package/composables/axios.ts +1 -1
  48. package/composables/classes.ts +405 -9
  49. package/composables/constants.ts +40 -0
  50. package/composables/fields.ts +203 -0
  51. package/composables/index.ts +48 -0
  52. package/composables/styles.ts +22 -10
  53. package/configs/i18n.ts +0 -2
  54. package/layouts/default.vue +46 -4
  55. package/layouts/full.vue +1 -1
  56. package/locales/ru.json +428 -11
  57. package/nuxt.config.ts +1 -1
  58. package/package.json +30 -39
  59. package/pages/500.vue +2 -2
  60. package/pages/Token.vue +1 -0
  61. package/plugins/helperFunctionsPlugins.ts +6 -7
  62. package/plugins/vuetifyPlugin.ts +2 -0
  63. package/store/data.store.ts +936 -217
  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 +38 -2
  68. package/types/enum.ts +8 -0
  69. package/types/form.ts +94 -0
  70. package/types/index.ts +162 -10
  71. package/components/Button/BtnIcon.vue +0 -47
  72. package/locales/kz.json +0 -590
@@ -3,7 +3,7 @@ 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, Contragent, DocumentItem, Member, Value, CountryValue, MemberV2, PolicyholderActivity, BeneficialOwner } from '../composables/classes';
7
7
  import { ApiClass } from '../api';
8
8
  import { useFormStore } from './form.store';
9
9
  import { AxiosError } from 'axios';
@@ -39,13 +39,17 @@ export const useDataStore = defineStore('data', {
39
39
  isBaiterek: state => state.product === 'baiterek',
40
40
  isBolashak: state => state.product === 'bolashak',
41
41
  isMycar: state => state.product === 'mycar',
42
+ isLifeBusiness: state => state.product === 'lifebusiness',
42
43
  isLifetrip: state => state.product === 'lifetrip',
43
44
  isLiferenta: state => state.product === 'liferenta',
44
45
  isGons: state => state.product === 'gons',
45
46
  isKazyna: state => state.product === 'halykkazyna',
47
+ isDas: state => state.product === 'daskamkorlyk',
46
48
  isCalculator: state => state.product === 'calculator',
47
49
  isCheckContract: state => state.product === 'checkcontract',
48
50
  isCheckContragent: state => state.product === 'checkcontragent',
51
+ isDSO: state => state.product === 'dso',
52
+ isUU: state => state.product === 'uu',
49
53
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
50
54
  hasClientAnketa: state => state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10),
51
55
  isClientAnketaCondition: state =>
@@ -72,14 +76,31 @@ export const useDataStore = defineStore('data', {
72
76
  childFrame.contentWindow.postMessage({ action: action, value: value }, '*');
73
77
  }
74
78
  },
75
- copyToClipboard(text: any) {
79
+ async copyToClipboard(text: unknown) {
76
80
  if (typeof text === 'string' || typeof text === 'number') {
77
- if (this.isBridge) {
78
- navigator.clipboard.writeText(String(text));
81
+ if (navigator.clipboard && window.isSecureContext) {
82
+ if (this.isBridge) {
83
+ await navigator.clipboard.writeText(String(text));
84
+ this.showToaster('success', this.t('toaster.copied'));
85
+ } else {
86
+ this.sendToParent(constants.postActions.clipboard, String(text));
87
+ }
79
88
  } else {
80
- this.sendToParent(constants.postActions.clipboard, String(text));
89
+ const textarea = document.createElement('textarea');
90
+ textarea.value = String(text);
91
+ textarea.style.position = 'absolute';
92
+ textarea.style.left = '-99999999px';
93
+ document.body.prepend(textarea);
94
+ textarea.select();
95
+ try {
96
+ document.execCommand('copy');
97
+ this.showToaster('success', this.t('toaster.copied'));
98
+ } catch (err) {
99
+ console.log(err);
100
+ } finally {
101
+ textarea.remove();
102
+ }
81
103
  }
82
- this.showToaster('success', this.t('toaster.copied'));
83
104
  } else {
84
105
  this.showToaster('error', this.t('toaster.noUrl'));
85
106
  }
@@ -226,24 +247,15 @@ export const useDataStore = defineStore('data', {
226
247
  this.getUserRoles();
227
248
  }
228
249
  const checkPermission = () => {
250
+ const hasAccess = this.hasAccess();
229
251
  if (this.isAML) {
230
- return this.isCompliance() || this.isAdmin() || this.isSupport() || this.isAnalyst();
252
+ return hasAccess.toAML;
231
253
  }
232
254
  if (this.isLKA) {
233
- return this.isAgent() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn();
255
+ return hasAccess.toLKA;
234
256
  }
235
257
  if (this.isEFO) {
236
- return (
237
- this.isInitiator() ||
238
- this.isUnderwriter() ||
239
- this.isAdmin() ||
240
- this.isCompliance() ||
241
- this.isAnalyst() ||
242
- this.isUpk() ||
243
- this.isFinCenter() ||
244
- this.isSupervisor() ||
245
- this.isSupport()
246
- );
258
+ return hasAccess.toEFO;
247
259
  }
248
260
  return false;
249
261
  };
@@ -287,6 +299,7 @@ export const useDataStore = defineStore('data', {
287
299
  },
288
300
  async resetSelected(route: RouteType) {
289
301
  this.settings.open = false;
302
+ this.rightPanel.open = false;
290
303
  this.panel.open = false;
291
304
  this.panelAction = null;
292
305
  this.menu.selectedItem = new MenuItem();
@@ -439,9 +452,9 @@ export const useDataStore = defineStore('data', {
439
452
  member.verifyDate = user.personalData.verifyDate;
440
453
  member.iin = reformatIin(user.personalData.iin);
441
454
  member.age = String(user.personalData.age);
442
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
455
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
443
456
  member.birthPlace = country && Object.keys(country).length ? country : new Value();
444
- const gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
457
+ const gender = this.gender.find((i: Value) => i.nameRu === user.personalData.genderName);
445
458
  member.gender = gender ? gender : new Value();
446
459
  member.gender.id = user.personalData.gender;
447
460
  member.birthDate = reformatDate(user.personalData.birthDate);
@@ -463,8 +476,8 @@ export const useDataStore = defineStore('data', {
463
476
  return user.documents.find(i => i.type === '1UDL');
464
477
  })();
465
478
  const userDocument = documentByPriority ? documentByPriority : user.documents[0];
466
- const documentType = this.documentTypes.find(i => i.ids === userDocument.type);
467
- const documentIssuer = this.documentIssuers.find(i => i.nameRu === userDocument.issuerNameRu);
479
+ const documentType = this.documentTypes.find((i: Value) => i.ids === userDocument.type);
480
+ const documentIssuer = this.documentIssuers.find((i: Value) => i.nameRu === userDocument.issuerNameRu);
468
481
  member.documentType = documentType ? documentType : new Value();
469
482
  member.documentNumber = userDocument.number;
470
483
  member.documentIssuers = documentIssuer ? documentIssuer : new Value();
@@ -476,16 +489,22 @@ export const useDataStore = defineStore('data', {
476
489
  user.data.forEach(questData => {
477
490
  this.searchFromList(member, questData);
478
491
  });
492
+ if (this.isLifetrip) {
493
+ const lastNameLat = user.data.find(obj => obj.questId === '500147');
494
+ const firstNameLat = user.data.find(obj => obj.questId === '500148');
495
+ member.lastNameLat = lastNameLat ? (lastNameLat.questAnswer as string) : null;
496
+ member.firstNameLat = firstNameLat ? (firstNameLat.questAnswer as string) : null;
497
+ }
479
498
  }
480
499
  if ('address' in user && user.address && user.address.length) {
481
500
  const userAddress = user.address[0];
482
501
  const countryName = userAddress.countryName;
483
502
  if (countryName) {
484
- const country = this.countries.find(i => i.nameRu?.match(new RegExp(countryName, 'i')));
503
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(countryName, 'i')));
485
504
  member.registrationCountry = country ? country : new Value();
486
505
  }
487
- const province = this.states.find(i => i.ids === userAddress.stateCode);
488
- const localityType = this.localityTypes.find(i => i.nameRu === userAddress.cityTypeName);
506
+ const province = this.states.find((i: Value) => i.ids === userAddress.stateCode);
507
+ const localityType = this.localityTypes.find((i: Value) => i.nameRu === userAddress.cityTypeName);
489
508
  const city = this.cities.find(i => !!userAddress.cityName && i.nameRu === userAddress.cityName.replace('г.', ''));
490
509
  const region = this.regions.find(i => !!userAddress.regionCode && i.ids == userAddress.regionCode);
491
510
  member.registrationStreet = userAddress.streetName;
@@ -535,7 +554,7 @@ export const useDataStore = defineStore('data', {
535
554
  };
536
555
  const qData = getQuestionariesData();
537
556
  if (qData && qData.from && qData.from.length && qData.field) {
538
- const qResult = qData.from.find(i => i.ids === searchIt.questAnswer);
557
+ const qResult = qData.from.find((i: Value) => i.ids === searchIt.questAnswer);
539
558
  //@ts-ignore
540
559
  member[qData.field] = qResult ? qResult : new Value();
541
560
  }
@@ -586,7 +605,14 @@ export const useDataStore = defineStore('data', {
586
605
  this.contragentList = [];
587
606
  }
588
607
  },
589
- async saveContragent(user: Member, whichForm: keyof typeof StoreMembers, whichIndex: number | null, onlySaveAction: boolean = true) {
608
+ async saveContragent(user: Member, whichForm: keyof typeof StoreMembers | 'contragent', whichIndex: number | null, onlySaveAction: boolean = true) {
609
+ if (this.isGons && user.iin && whichForm === 'beneficiaryForm' && useEnv().isProduction) {
610
+ const doesHaveActiveContract = await this.api.checkBeneficiariesInActualPolicy(user.iin.replace(/-/g, ''));
611
+ if (doesHaveActiveContract) {
612
+ this.showToaster('error', this.t('toaster.doesHaveActiveContract'), 6000);
613
+ return false;
614
+ }
615
+ }
590
616
  this.isLoading = !onlySaveAction;
591
617
  const hasInsisId = await this.alreadyInInsis(user);
592
618
  if (typeof hasInsisId === 'number') {
@@ -684,6 +710,26 @@ export const useDataStore = defineStore('data', {
684
710
  });
685
711
  }
686
712
  }
713
+ if (this.isLifetrip) {
714
+ const lastNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500147') : undefined;
715
+ const firstNameLat = userResponseQuestionnaires !== null ? userResponseQuestionnaires.find(i => i.questId === '500148') : undefined;
716
+ questionariesData.push({
717
+ id: lastNameLat ? lastNameLat.id : 0,
718
+ contragentId: Number(user.id),
719
+ questAnswer: user.lastNameLat ?? '',
720
+ questAnswerName: null,
721
+ questName: 'Фамилия на латинице',
722
+ questId: '500147',
723
+ });
724
+ questionariesData.push({
725
+ id: firstNameLat ? firstNameLat.id : 0,
726
+ contragentId: Number(user.id),
727
+ questAnswer: user.firstNameLat ?? '',
728
+ questAnswerName: null,
729
+ questName: 'Имя на латинице',
730
+ questId: '500148',
731
+ });
732
+ }
687
733
 
688
734
  const userResponseContacts = 'response' in user && user.response && 'contacts' in user.response && user.response.contacts ? user.response.contacts : null;
689
735
  const contactsData: ContragentContacts[] = [];
@@ -788,8 +834,12 @@ export const useDataStore = defineStore('data', {
788
834
 
789
835
  const personId = await this.api.saveContragent(data);
790
836
  if (personId > 0) {
791
- await this.getContragentById(personId, whichForm, false, whichIndex);
792
- user.otpTokenId = null;
837
+ if (this.isLKA || whichForm === 'contragent') {
838
+ return personId;
839
+ } else {
840
+ await this.getContragentById(personId, whichForm, false, whichIndex);
841
+ user.otpTokenId = null;
842
+ }
793
843
  } else {
794
844
  return false;
795
845
  }
@@ -947,7 +997,7 @@ export const useDataStore = defineStore('data', {
947
997
  annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
948
998
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
949
999
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
950
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1000
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
951
1001
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id ?? undefined,
952
1002
  lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply ?? ''),
953
1003
  lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive ?? ''),
@@ -970,6 +1020,12 @@ export const useDataStore = defineStore('data', {
970
1020
  conditionsData.policyAppDto.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
971
1021
  conditionsData.policyAppDto.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
972
1022
  }
1023
+ if (this.isLifeBusiness) {
1024
+ conditionsData.policyAppDto.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1025
+ conditionsData.policyAppDto.fixInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1026
+ conditionsData.policyAppDto.tariffId = String(this.formStore.productConditionsForm.processTariff.id);
1027
+ conditionsData.policyAppDto.processDefinitionFgotId = (this.formStore.productConditionsForm.processGfot.id as string) ?? undefined;
1028
+ }
973
1029
  return conditionsData;
974
1030
  },
975
1031
  async clearAddCovers(coverCode: number, coverValue: string) {
@@ -988,6 +1044,8 @@ export const useDataStore = defineStore('data', {
988
1044
  }
989
1045
  },
990
1046
  async deleteInsuredLogic() {
1047
+ // TODO Просмотреть
1048
+ if (this.isLifetrip) return;
991
1049
  const applicationData = this.getConditionsData();
992
1050
  const clearCovers = [{ code: 10, value: 'excluded' }];
993
1051
  await Promise.allSettled(
@@ -1046,7 +1104,7 @@ export const useDataStore = defineStore('data', {
1046
1104
  this.isLoading = false;
1047
1105
  }
1048
1106
  },
1049
- async setINSISWorkData() {
1107
+ async setINSISWorkData(loading: boolean = true) {
1050
1108
  if (!this.formStore.applicationData.insisWorkDataApp) return;
1051
1109
  const data: InsisWorkDataApp = {
1052
1110
  id: this.formStore.applicationData.insisWorkDataApp.id,
@@ -1065,7 +1123,7 @@ export const useDataStore = defineStore('data', {
1065
1123
  insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
1066
1124
  };
1067
1125
  try {
1068
- this.isLoading = true;
1126
+ this.isLoading = loading;
1069
1127
  await this.api.setINSISWorkData(data);
1070
1128
  } catch (err) {
1071
1129
  ErrorHandler(err);
@@ -1094,7 +1152,7 @@ export const useDataStore = defineStore('data', {
1094
1152
  async getFromApi(whichField: string, whichRequest: string, parameter?: any, reset: boolean = false): Promise<Value[]> {
1095
1153
  const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
1096
1154
  const currentHour = new Date().getHours();
1097
- const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / 15);
1155
+ const currentMinutePart = Math.ceil((new Date().getMinutes() + 1) / (this.isLKA ? 60 : 15));
1098
1156
 
1099
1157
  const getDataCondition = () => {
1100
1158
  if (!storageValue) return true;
@@ -1140,7 +1198,28 @@ export const useDataStore = defineStore('data', {
1140
1198
  return this[whichField];
1141
1199
  },
1142
1200
  async getCountries() {
1143
- return await this.getFromApi('countries', 'getCountries');
1201
+ const response = await this.getFromApi('countries', 'getCountries');
1202
+ const kzIndex = response.findIndex(country => country.ids === 'KZ');
1203
+ if (kzIndex !== -1) {
1204
+ const element = response.splice(kzIndex, 1)[0];
1205
+ response.splice(0, 0, element);
1206
+ }
1207
+ return response;
1208
+ },
1209
+ async getDicCountries() {
1210
+ if (this.isLifetrip) return await this.getFromApi('dicAllCountries', 'getArmDicts', 'DicCountry');
1211
+ },
1212
+ async getDicTripType() {
1213
+ if (this.isLifetrip) return await this.getFromApi('types', 'getArmDicts', 'DicTripType');
1214
+ },
1215
+ async getDicTripPurpose() {
1216
+ if (this.isLifetrip) return await this.getFromApi('purposes', 'getArmDicts', 'DicTripPurpose');
1217
+ },
1218
+ async getDicTripWorkType() {
1219
+ if (this.isLifetrip) return await this.getFromApi('workTypes', 'getArmDicts', 'DicTripWorkType');
1220
+ },
1221
+ async getDicSportsType() {
1222
+ if (this.isLifetrip) return await this.getFromApi('sportsTypes', 'getArmDicts', 'DicSportsType');
1144
1223
  },
1145
1224
  async getCitizenshipCountries() {
1146
1225
  return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
@@ -1154,15 +1233,15 @@ export const useDataStore = defineStore('data', {
1154
1233
  async getStates(key?: string, member?: Member) {
1155
1234
  await this.getFromApi('states', 'getStates');
1156
1235
  //@ts-ignore
1157
- if (key && member[key] && member[key].ids !== null) return this.states.filter(i => i.code === member[key].ids);
1236
+ if (key && member[key] && member[key].ids !== null) return this.states.filter((i: Value) => i.code === member[key].ids);
1158
1237
  return this.states;
1159
1238
  },
1160
1239
  async getRegions(key?: string, member?: Member) {
1161
1240
  await this.getFromApi('regions', 'getRegions');
1162
1241
  //@ts-ignore
1163
- if (key && member[key] && member[key].ids !== null) return this.regions.filter(i => i.code === member[key].ids);
1242
+ if (key && member[key] && member[key].ids !== null) return this.regions.filter((i: Value) => i.code === member[key].ids);
1164
1243
  if (member && member.registrationProvince.ids !== null) {
1165
- return this.regions.filter(i => i.code === member.registrationProvince.ids);
1244
+ return this.regions.filter((i: Value) => i.code === member.registrationProvince.ids);
1166
1245
  } else {
1167
1246
  return this.regions;
1168
1247
  }
@@ -1170,13 +1249,27 @@ export const useDataStore = defineStore('data', {
1170
1249
  async getCities(key?: string, member?: Member) {
1171
1250
  await this.getFromApi('cities', 'getCities');
1172
1251
  //@ts-ignore
1173
- if (key && member[key] && member[key].ids !== null) return this.cities.filter(i => i.code === member[key].ids);
1252
+ if (key && member[key] && member[key].ids !== null) return this.cities.filter((i: Value) => i.code === member[key].ids);
1174
1253
  if (member && member.registrationProvince.ids !== null) {
1175
- return this.cities.filter(i => i.code === member.registrationProvince.ids);
1254
+ return this.cities.filter((i: Value) => i.code === member.registrationProvince.ids);
1176
1255
  } else {
1177
1256
  return this.cities;
1178
1257
  }
1179
1258
  },
1259
+ async getCitiesEfo(key?: string, member?: MemberV2, parentKey?: string) {
1260
+ if (this.isLifeBusiness) {
1261
+ await this.getFromApi('cities', 'getCities');
1262
+ //@ts-ignore
1263
+ if (key && member[parentKey][key] && member[parentKey][key].ids !== null) return this.cities.filter(i => i.code === member[parentKey][key].ids);
1264
+ //@ts-ignore
1265
+ if (member && member[parentKey].registrationProvince.ids !== null) {
1266
+ //@ts-ignore
1267
+ return this.cities.filter(i => i.code === member[parentKey].registrationProvince.ids);
1268
+ } else {
1269
+ return this.cities;
1270
+ }
1271
+ }
1272
+ },
1180
1273
  async getLocalityTypes() {
1181
1274
  return await this.getFromApi('localityTypes', 'getLocalityTypes');
1182
1275
  },
@@ -1203,36 +1296,50 @@ export const useDataStore = defineStore('data', {
1203
1296
  async getSectorCodeList() {
1204
1297
  return await this.getFromApi('economySectorCode', 'getSectorCode');
1205
1298
  },
1299
+ async getEconomicActivityType() {
1300
+ if (this.isDas) return await this.getFromApi('economicActivityType', 'getEconomicActivityType');
1301
+ },
1206
1302
  async getFamilyStatuses() {
1207
1303
  return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
1208
1304
  },
1209
1305
  async getRelationTypes() {
1210
1306
  return await this.getFromApi('relations', 'getRelationTypes');
1211
1307
  },
1212
- async getProcessIndexRate() {
1213
- return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
1308
+ async getBanks() {
1309
+ if (this.isLifeBusiness || this.isDas) return await this.getFromApi('banks', 'getBanks');
1214
1310
  },
1215
- async getProcessCoverTypeSum(type?: any) {
1216
- return await this.getFromApi('processCoverTypeSum', 'getProcessCoverTypeSum', type);
1311
+ async getProcessIndexRate() {
1312
+ if (this.processCode) {
1313
+ return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
1314
+ }
1217
1315
  },
1218
1316
  async getProcessPaymentPeriod() {
1219
- return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
1317
+ if (this.processCode) {
1318
+ return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
1319
+ }
1220
1320
  },
1221
1321
  async getQuestionRefs(id?: string) {
1222
1322
  return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
1223
1323
  },
1224
1324
  async getProcessTariff() {
1225
- return await this.getFromApi('processTariff', 'getProcessTariff');
1325
+ if (this.processCode) return await this.getFromApi('processTariff', 'getProcessTariff', this.processCode);
1226
1326
  },
1227
1327
  async getDicAnnuityTypeList() {
1228
1328
  return await this.getFromApi('dicAnnuityTypeList', 'getDicAnnuityTypeList');
1229
1329
  },
1230
1330
  async getProcessAnnuityPaymentPeriod() {
1231
- return await this.getFromApi('processAnnuityPaymentPeriod', 'getProcessAnnuityPaymentPeriod', this.processCode);
1331
+ if (this.processCode) {
1332
+ return await this.getFromApi('processAnnuityPaymentPeriod', 'getProcessAnnuityPaymentPeriod', this.processCode);
1333
+ }
1232
1334
  },
1233
1335
  async getInsurancePay() {
1234
1336
  return await this.getFromApi('insurancePay', 'getInsurancePay');
1235
1337
  },
1338
+ async getProcessGfot() {
1339
+ if (this.processCode) {
1340
+ return await this.getFromApi('processGfot', 'getProcessGfot', this.processCode);
1341
+ }
1342
+ },
1236
1343
  async getCurrencies() {
1237
1344
  try {
1238
1345
  const currencies = await this.api.getCurrencies();
@@ -1246,6 +1353,9 @@ export const useDataStore = defineStore('data', {
1246
1353
  async getDictionaryItems(dictName: string) {
1247
1354
  return await this.getFromApi(dictName, 'getDictionaryItems', dictName);
1248
1355
  },
1356
+ getGenderList() {
1357
+ return this.gender;
1358
+ },
1249
1359
  async getAllFormsData() {
1250
1360
  await Promise.allSettled([
1251
1361
  this.getCountries(),
@@ -1255,6 +1365,7 @@ export const useDataStore = defineStore('data', {
1255
1365
  this.getStates(),
1256
1366
  this.getRegions(),
1257
1367
  this.getCities(),
1368
+ this.getCitiesEfo(),
1258
1369
  this.getLocalityTypes(),
1259
1370
  this.getDocumentTypes(),
1260
1371
  this.getDocumentIssuers(),
@@ -1271,59 +1382,67 @@ export const useDataStore = defineStore('data', {
1271
1382
  this.getInsurancePay(),
1272
1383
  this.getDictionaryItems('RegionPolicy'),
1273
1384
  this.getDictionaryItems('SaleChanellPolicy'),
1385
+ this.getDicTripType(),
1386
+ this.getDicCountries(),
1387
+ this.getDicTripWorkType(),
1388
+ this.getDicSportsType(),
1389
+ this.getDicTripPurpose(),
1390
+ this.getCurrencies(),
1391
+ this.getProcessGfot(),
1392
+ this.getBanks(),
1393
+ this.getEconomicActivityType(),
1274
1394
  ]);
1275
1395
  },
1276
1396
  async getQuestionList(
1277
1397
  surveyType: 'health' | 'critical',
1278
1398
  processInstanceId: string | number,
1279
1399
  insuredId: any,
1280
- baseField: string,
1281
- secondaryField: string,
1400
+ baseField: 'surveyByHealthBase' | 'surveyByCriticalBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBasePolicyholder',
1282
1401
  whichMember: 'insured' | 'policyholder' = 'insured',
1283
1402
  ) {
1284
- //@ts-ignore
1285
- if (!this.formStore[baseField] || (this.formStore[baseField] && !this.formStore[baseField].length)) {
1286
- try {
1287
- if (whichMember === 'insured') {
1288
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1289
- this.api.getQuestionList(surveyType, processInstanceId, insuredId),
1290
- this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1291
- ]);
1292
- if (baseQuestions.status === 'fulfilled') {
1293
- //@ts-ignore
1294
- this.formStore[baseField] = baseQuestions.value;
1295
- }
1296
- if (secondaryQuestions.status === 'fulfilled') {
1297
- //@ts-ignore
1298
- this.formStore[secondaryField] = secondaryQuestions;
1299
- }
1300
- }
1301
- if (whichMember === 'policyholder') {
1302
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1303
- this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1304
- this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1305
- ]);
1306
- if (baseQuestions.status === 'fulfilled') {
1307
- //@ts-ignore
1308
- this.formStore[baseField] = baseQuestions.value;
1309
- }
1310
- if (secondaryQuestions.status === 'fulfilled') {
1311
- //@ts-ignore
1312
- this.formStore[secondaryField] = secondaryQuestions;
1313
- }
1403
+ try {
1404
+ const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1405
+ whichMember === 'insured' ? this.api.getQuestionList(surveyType, processInstanceId, insuredId) : this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1406
+ whichMember === 'insured'
1407
+ ? this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId)
1408
+ : this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1409
+ ,
1410
+ ]);
1411
+ if (baseQuestions.status === 'fulfilled') {
1412
+ this.formStore[baseField] = baseQuestions.value;
1413
+ }
1414
+ if (secondaryQuestions.status === 'fulfilled') {
1415
+ const baseAnketa = this.formStore[baseField];
1416
+ if (baseAnketa && baseAnketa.body && baseAnketa.body.length) {
1417
+ baseAnketa.body.forEach(i => {
1418
+ if (i.first.definedAnswers === 'Y' && i.second === null && secondaryQuestions.value) {
1419
+ i.second = structuredClone(secondaryQuestions.value);
1420
+ }
1421
+ });
1314
1422
  }
1315
- } catch (err) {
1316
- console.log(err);
1317
1423
  }
1424
+ } catch (err) {
1425
+ ErrorHandler(err);
1318
1426
  }
1319
- //@ts-ignore
1320
1427
  return this.formStore[baseField];
1321
1428
  },
1322
1429
  getNumberWithSpaces(n: any) {
1323
1430
  return n === null ? null : Number((typeof n === 'string' ? n : n.toFixed().toString()).replace(/[^0-9]+/g, '')).toLocaleString('ru');
1324
1431
  },
1432
+ getNumberWithSpacesAfterComma(n: number) {
1433
+ let parts = n.toFixed(2).split('.');
1434
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
1435
+ return parts.join(',');
1436
+ },
1325
1437
  getNumberWithDot(n: any) {
1326
- return n === null ? null : n.toLocaleString('ru', { maximumFractionDigits: 2, minimumFractionDigits: 2 }).replace(/,/g, '.');
1438
+ return n === null
1439
+ ? null
1440
+ : n
1441
+ .toLocaleString('ru', {
1442
+ maximumFractionDigits: 2,
1443
+ minimumFractionDigits: 2,
1444
+ })
1445
+ .replace(/,/g, '.');
1327
1446
  },
1328
1447
  async getTaskList(
1329
1448
  search: string = '',
@@ -1363,7 +1482,14 @@ export const useDataStore = defineStore('data', {
1363
1482
  delete query.processCodes;
1364
1483
  query.processCode = byOneProcess;
1365
1484
  }
1366
- const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
1485
+ const taskList = await this.api.getTaskList(
1486
+ processInstanceId === null
1487
+ ? query
1488
+ : {
1489
+ ...query,
1490
+ processInstanceId: processInstanceId,
1491
+ },
1492
+ );
1367
1493
  if (needToReturn) {
1368
1494
  this.isLoading = false;
1369
1495
  return taskList.items;
@@ -1449,7 +1575,7 @@ export const useDataStore = defineStore('data', {
1449
1575
  },
1450
1576
  findObject(from: string, key: string, searchKey: any): any {
1451
1577
  // @ts-ignore
1452
- const found = this[from].find(i => i[key] == searchKey);
1578
+ const found = this[from].find((i: Value) => i[key] == searchKey);
1453
1579
  return found || new Value();
1454
1580
  },
1455
1581
  async searchAgentByName(name: string) {
@@ -1500,18 +1626,69 @@ export const useDataStore = defineStore('data', {
1500
1626
  this.isLoading = false;
1501
1627
  }
1502
1628
  },
1629
+ async getTripInsuredAmount(show: boolean = true) {
1630
+ this.isLoading = true;
1631
+ try {
1632
+ const countryID: string[] = [];
1633
+ for (let country = 0; country < this.formStore.productConditionsForm.calculatorForm.countries!.length; country++) {
1634
+ countryID.push(this.formStore.productConditionsForm.calculatorForm.countries![country].id as string);
1635
+ }
1636
+
1637
+ const form = {
1638
+ tripTypeID: this.formStore.productConditionsForm.calculatorForm.type.id,
1639
+ countryID,
1640
+ };
1641
+
1642
+ const result = await this.api.getTripInsuredAmount(form);
1643
+ const amounts: Value[] = [];
1644
+ result.amounts.forEach(amount => {
1645
+ amounts.push(new Value(amount['id'], amount['nameRu']));
1646
+ });
1647
+
1648
+ this.amountArray = amounts;
1649
+ this.formStore.productConditionsForm.calculatorForm.amount = new Value();
1650
+ this.currency = result.currency;
1651
+
1652
+ if (show) {
1653
+ this.showToaster('success', this.t('toaster.tripInsuredAmountCalculated'), 1000);
1654
+ }
1655
+ } catch (err) {
1656
+ ErrorHandler(err);
1657
+ }
1658
+ this.isLoading = false;
1659
+ },
1660
+ async getPeriod() {
1661
+ if (this.periodArray.length === 0) {
1662
+ try {
1663
+ const response = await this.api.getTripInsuranceDaysOptions();
1664
+ if (response) {
1665
+ const new3 = response.period;
1666
+ const newPeriod: Value[] = [];
1667
+ const newMaxDays: Value[] = [];
1668
+ Object.keys(new3).forEach(key => {
1669
+ newPeriod.push(new Value(key, key, key, key));
1670
+ new3[key as keyof typeof new3].forEach(item => {
1671
+ newMaxDays.push(new Value(item, item, item, key));
1672
+ });
1673
+ });
1674
+ this.periodArray = newPeriod;
1675
+ this.maxDaysAllArray = newMaxDays;
1676
+ }
1677
+ } catch (err) {
1678
+ ErrorHandler(err);
1679
+ }
1680
+ }
1681
+ },
1503
1682
  async calculateWithoutApplication(showLoader: boolean = false, product: string | null = null) {
1504
1683
  this.isLoading = showLoader;
1505
1684
  try {
1506
- if (!this.formStore.productConditionsForm.signDate || !this.formStore.productConditionsForm.birthDate) {
1685
+ if (!this.formStore.productConditionsForm.signDate) {
1507
1686
  return;
1508
1687
  }
1509
1688
  const signDate = formatDate(this.formStore.productConditionsForm.signDate);
1510
- const birthDate = formatDate(this.formStore.productConditionsForm.birthDate);
1511
- if (!signDate || !birthDate) return;
1512
1689
  const calculationData: RecalculationDataType & PolicyAppDto = {
1513
- signDate: signDate.toISOString(),
1514
- birthDate: birthDate.toISOString(),
1690
+ signDate: signDate ? signDate.toISOString() : undefined,
1691
+ birthDate: this.formStore.productConditionsForm.birthDate ? formatDate(this.formStore.productConditionsForm.birthDate)!.toISOString() : undefined,
1515
1692
  gender: Number(this.formStore.productConditionsForm.gender.id),
1516
1693
  amount: getNumber(String(this.formStore.productConditionsForm.requestedSumInsured)),
1517
1694
  premium: getNumber(String(this.formStore.productConditionsForm.insurancePremiumPerMonth)),
@@ -1519,7 +1696,7 @@ export const useDataStore = defineStore('data', {
1519
1696
  payPeriod: Number(this.formStore.productConditionsForm.coverPeriod),
1520
1697
  indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1521
1698
  ? this.formStore.productConditionsForm.processIndexRate.id ?? undefined
1522
- : this.processIndexRate.find(i => i.code === '0')?.id ?? undefined,
1699
+ : this.processIndexRate.find((i: Value) => i.code === '0')?.id ?? undefined,
1523
1700
  paymentPeriodId: (this.formStore.productConditionsForm.paymentPeriod.id as string) ?? undefined,
1524
1701
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1525
1702
  };
@@ -1528,15 +1705,23 @@ export const useDataStore = defineStore('data', {
1528
1705
  calculationData.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1529
1706
  calculationData.currencyExchangeRate = this.currencies.usd;
1530
1707
  }
1531
- if (this.isLiferenta) {
1708
+ if (this.isLiferenta || product === 'liferenta') {
1532
1709
  calculationData.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1533
1710
  calculationData.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
1534
1711
  calculationData.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
1535
1712
  calculationData.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
1536
1713
  }
1714
+ if (this.isLifeBusiness || product === 'lifebusiness') {
1715
+ calculationData.clients = this.formStore.lfb.clients;
1716
+ calculationData.insrCount = this.formStore.lfb.clients.length;
1717
+ calculationData.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1718
+ calculationData.fixInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1719
+ calculationData.agentCommission = this.formStore.productConditionsForm.processTariff.id;
1720
+ calculationData.processDefinitionFgotId = this.formStore.productConditionsForm.processGfot.id;
1721
+ }
1537
1722
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1538
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1539
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1723
+ if (calculationResponse.amount) this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1724
+ if (calculationResponse.premium) this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1540
1725
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1541
1726
  if (this.isKazyna || product === 'halykkazyna') {
1542
1727
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
@@ -1545,9 +1730,25 @@ export const useDataStore = defineStore('data', {
1545
1730
  this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1546
1731
  }
1547
1732
  }
1548
- if (this.isLiferenta) {
1733
+ if (this.isLiferenta || product === 'liferenta') {
1549
1734
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(calculationResponse.annuityMonthPay);
1550
1735
  }
1736
+ if (this.isGons || product === 'gons') {
1737
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(calculationResponse.totalAmount5);
1738
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(calculationResponse.totalAmount7);
1739
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(calculationResponse.statePremium5);
1740
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(calculationResponse.statePremium7);
1741
+ }
1742
+ if (this.isLifeBusiness || product === 'lifebusiness') {
1743
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.mainPremium);
1744
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.fixInsSum === 0 ? null : calculationResponse.fixInsSum);
1745
+ this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1746
+ if (calculationResponse.clients) {
1747
+ this.formStore.lfb.clients = calculationResponse.clients;
1748
+ }
1749
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1750
+ return calculationResponse;
1751
+ }
1551
1752
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1552
1753
  } catch (err) {
1553
1754
  ErrorHandler(err);
@@ -1583,6 +1784,82 @@ export const useDataStore = defineStore('data', {
1583
1784
  if (this.isLiferenta) {
1584
1785
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(applicationData.policyAppDto.annuityMonthPay);
1585
1786
  }
1787
+ if (this.isGons) {
1788
+ const govPremiums = await this.api.getGovernmentPremiums(String(id));
1789
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(govPremiums.totalAmount5 === null ? null : govPremiums.totalAmount5);
1790
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(govPremiums.totalAmount7 === null ? null : govPremiums.totalAmount7);
1791
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(govPremiums.statePremium5 === null ? null : govPremiums.statePremium5);
1792
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
1793
+ }
1794
+ if (this.isLifeBusiness) {
1795
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
1796
+ if (applicationData.insuredApp && applicationData.insuredApp.length) {
1797
+ const res = await this.newInsuredList(applicationData.insuredApp);
1798
+ this.formStore.lfb.clients = res;
1799
+ }
1800
+ }
1801
+
1802
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1803
+ } catch (err) {
1804
+ ErrorHandler(err);
1805
+ }
1806
+ this.isLoading = false;
1807
+ },
1808
+ async calculatePrice(taskId?: string) {
1809
+ this.isLoading = true;
1810
+ try {
1811
+ const priceForm: {
1812
+ processInstanceId?: string | number | null;
1813
+ id?: string | null;
1814
+ addCoversDto?: AddCover[];
1815
+ insuredAmountId?: string | number | null;
1816
+ age?: string | number | null;
1817
+ lifeTripCountries?: string[] | null;
1818
+ tripPurposeId?: string | number | null;
1819
+ workTypeId?: string | number | null;
1820
+ sportsTypeId?: string | number | null;
1821
+ singleTripDays?: number;
1822
+ multipleTripMaxDays?: number;
1823
+ tripInsurancePeriod?: number;
1824
+ startDate?: string | null;
1825
+ endDate?: string | null;
1826
+ } = {};
1827
+ priceForm.insuredAmountId = this.formStore.productConditionsForm.calculatorForm.amount.id;
1828
+ priceForm.age = this.formStore.productConditionsForm.calculatorForm.age;
1829
+ priceForm.lifeTripCountries = this.formStore.productConditionsForm.calculatorForm.countries!.map(item => item.id as string);
1830
+ priceForm.tripPurposeId = this.formStore.productConditionsForm.calculatorForm.purpose.id;
1831
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'WorkStudy') {
1832
+ priceForm.workTypeId = this.formStore.productConditionsForm.calculatorForm.workType.id;
1833
+ }
1834
+ if (this.formStore.productConditionsForm.calculatorForm.purpose.code === 'Sport') {
1835
+ priceForm.sportsTypeId = this.formStore.productConditionsForm.calculatorForm.sportsType!.id;
1836
+ }
1837
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
1838
+ priceForm.singleTripDays = Number(this.formStore.productConditionsForm.calculatorForm.days);
1839
+ } else {
1840
+ priceForm.multipleTripMaxDays = Number(this.formStore.productConditionsForm.calculatorForm.maxDays.nameRu);
1841
+ priceForm.tripInsurancePeriod = Number(this.formStore.productConditionsForm.calculatorForm.period.nameRu);
1842
+ }
1843
+ if (this.isTask()) {
1844
+ priceForm.processInstanceId = this.formStore.applicationData.processInstanceId!;
1845
+ priceForm.id = taskId!;
1846
+ priceForm.age = Number(this.formStore.policyholderForm.age);
1847
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Multiple') {
1848
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
1849
+ } else {
1850
+ priceForm.startDate = formatDate(this.formStore.productConditionsForm.calculatorForm.startDate!)!.toISOString();
1851
+ priceForm.endDate = formatDate(this.formStore.productConditionsForm.calculatorForm.endDate!)!.toISOString();
1852
+ }
1853
+ }
1854
+ const result = await this.api.getCalculator(priceForm);
1855
+ if (this.isTask() && taskId) {
1856
+ await this.api.setApplication(priceForm);
1857
+ const applicationData = await this.api.getApplicationData(taskId);
1858
+ this.formStore.applicationData = applicationData;
1859
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
1860
+ } else {
1861
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(result)} тг`;
1862
+ }
1586
1863
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1587
1864
  } catch (err) {
1588
1865
  ErrorHandler(err);
@@ -1615,6 +1892,7 @@ export const useDataStore = defineStore('data', {
1615
1892
  this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
1616
1893
  return;
1617
1894
  }
1895
+ this.formStore.regNumber = applicationData.regNumber;
1618
1896
  this.formStore.applicationData = applicationData;
1619
1897
  this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
1620
1898
 
@@ -1648,7 +1926,49 @@ export const useDataStore = defineStore('data', {
1648
1926
  this.formStore.finCenterData.regNumber = applicationData.finCenterData.regNumber;
1649
1927
  this.formStore.finCenterData.date = reformatDate(applicationData.finCenterData.date);
1650
1928
  }
1929
+ if ('lifeTripApp' in applicationData && setProductConditions) {
1930
+ const tripType = this.types.find((i: Value) => i.id === applicationData.lifeTripApp.tripTypeId);
1931
+ this.formStore.productConditionsForm.calculatorForm.type = tripType ? tripType : new Value();
1932
+
1933
+ const countries: CountryValue[] = [];
1934
+ for (let i in applicationData.lifeTripApp.lifeTripCountries) {
1935
+ const tripCountry = this.dicAllCountries.find(country => country.id === applicationData.lifeTripApp.lifeTripCountries[i]);
1936
+ if (tripCountry) {
1937
+ countries.push(tripCountry);
1938
+ }
1939
+ }
1940
+ this.formStore.productConditionsForm.calculatorForm.countries = countries ? countries : [];
1941
+
1942
+ if (this.formStore.productConditionsForm.calculatorForm.countries.length && this.formStore.productConditionsForm.calculatorForm.type.nameRu != null) {
1943
+ await this.getTripInsuredAmount(false);
1944
+ }
1945
+
1946
+ const amount = this.amountArray.find((i: Value) => i.id === applicationData.lifeTripApp.insuredAmountId);
1947
+ this.formStore.productConditionsForm.calculatorForm.amount = amount ? amount : new Value();
1948
+
1949
+ const purpose = this.purposes.find((i: Value) => i.id === applicationData.lifeTripApp.tripPurposeId);
1950
+ this.formStore.productConditionsForm.calculatorForm.purpose = purpose ? purpose : new Value();
1951
+
1952
+ if (applicationData.lifeTripApp.workTypeId != null) {
1953
+ const work = this.workTypes.find((i: Value) => i.id === applicationData.lifeTripApp.workTypeId);
1954
+ this.formStore.productConditionsForm.calculatorForm.workType = work ? work : new Value();
1955
+ }
1956
+ if (applicationData.lifeTripApp.sportsTypeId != null) {
1957
+ const sport = this.sportsTypes.find((i: Value) => i.id === applicationData.lifeTripApp.sportsTypeId);
1958
+ this.formStore.productConditionsForm.calculatorForm.sportsType = sport ? sport : new Value();
1959
+ }
1960
+ if (this.formStore.productConditionsForm.calculatorForm.type.code === 'Single') {
1961
+ this.formStore.productConditionsForm.calculatorForm.days = Number(applicationData.lifeTripApp.singleTripDays);
1962
+ } else {
1963
+ await this.getPeriod();
1964
+ this.formStore.productConditionsForm.calculatorForm.maxDays = this.maxDaysAllArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.multipleTripMaxDays)!;
1965
+ this.formStore.productConditionsForm.calculatorForm.period = this.periodArray.find((i: Value) => i.nameRu == applicationData.lifeTripApp.tripInsurancePeriod)!;
1966
+ }
1967
+ this.formStore.productConditionsForm.calculatorForm.startDate = reformatDate(applicationData.lifeTripApp.startDate);
1968
+ this.formStore.productConditionsForm.calculatorForm.endDate = reformatDate(applicationData.lifeTripApp.endDate);
1651
1969
 
1970
+ this.formStore.productConditionsForm.calculatorForm.price = `${Math.ceil(applicationData.lifeTripApp.totalPremiumKZT)} тг`;
1971
+ }
1652
1972
  if (fetchMembers) {
1653
1973
  let allMembers = [
1654
1974
  {
@@ -1718,7 +2038,7 @@ export const useDataStore = defineStore('data', {
1718
2038
  if (insuredData && insuredData.length) {
1719
2039
  insuredData.forEach((each, index) => {
1720
2040
  this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
1721
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2041
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1722
2042
  this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1723
2043
  });
1724
2044
  }
@@ -1726,11 +2046,11 @@ export const useDataStore = defineStore('data', {
1726
2046
  if (beneficiaryData && beneficiaryData.length) {
1727
2047
  beneficiaryData.forEach((each, index) => {
1728
2048
  this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
1729
- const relationDegree = this.relations.find(i => i.ids == each.relationId);
2049
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
1730
2050
  this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
1731
2051
  this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
1732
2052
  if (this.isLiferenta || this.isBolashak) {
1733
- const insurancePay = this.insurancePay.find(i => i.id == each.beneficiaryInsurancePayId);
2053
+ const insurancePay = this.insurancePay.find((i: Value) => i.id == each.beneficiaryInsurancePayId);
1734
2054
  this.formStore.beneficiaryForm[index].insurancePay = insurancePay ? insurancePay : new Value();
1735
2055
  }
1736
2056
  });
@@ -1763,6 +2083,8 @@ export const useDataStore = defineStore('data', {
1763
2083
  }
1764
2084
  }
1765
2085
  if (setProductConditions) {
2086
+ this.formStore.policyNumber = applicationData.policyAppDto.policyNumber;
2087
+ this.formStore.contractDate = reformatDate(applicationData.policyAppDto.contractDate);
1766
2088
  this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
1767
2089
  this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
1768
2090
  // this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
@@ -1858,6 +2180,7 @@ export const useDataStore = defineStore('data', {
1858
2180
  return true;
1859
2181
  } catch (err) {
1860
2182
  this.isLoading = false;
2183
+ this.isButtonsLoading = false;
1861
2184
  return ErrorHandler(err);
1862
2185
  }
1863
2186
  },
@@ -1879,6 +2202,7 @@ export const useDataStore = defineStore('data', {
1879
2202
  }
1880
2203
  case constants.actions.reject:
1881
2204
  case constants.actions.return:
2205
+ case constants.actions.signed:
1882
2206
  case constants.actions.rejectclient:
1883
2207
  case constants.actions.accept: {
1884
2208
  try {
@@ -1897,7 +2221,10 @@ export const useDataStore = defineStore('data', {
1897
2221
  }
1898
2222
  case constants.actions.affiliate: {
1899
2223
  try {
1900
- const sended = await this.sendUnderwritingCouncilTask({ taskId: taskId, decision: constants.actions.accept });
2224
+ const sended = await this.sendUnderwritingCouncilTask({
2225
+ taskId: taskId,
2226
+ decision: constants.actions.accept,
2227
+ });
1901
2228
  if (!sended) return;
1902
2229
  this.formStore.$reset();
1903
2230
  if (this.isEFO || this.isAML) {
@@ -1988,11 +2315,25 @@ export const useDataStore = defineStore('data', {
1988
2315
  const prepareSignDocuments = (): SignDataType[] => {
1989
2316
  switch (this.formStore.applicationData.statusCode) {
1990
2317
  case 'ContractSignedFrom':
1991
- return [{ processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Contract', format: 'pdf' }];
2318
+ return [
2319
+ {
2320
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2321
+ name: 'Contract',
2322
+ format: 'pdf',
2323
+ },
2324
+ ];
1992
2325
  default:
1993
2326
  return [
1994
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Agreement', format: 'pdf' },
1995
- { processInstanceId: String(this.formStore.applicationData.processInstanceId), name: 'Statement', format: 'pdf' },
2327
+ {
2328
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2329
+ name: 'Agreement',
2330
+ format: 'pdf',
2331
+ },
2332
+ {
2333
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2334
+ name: 'Statement',
2335
+ format: 'pdf',
2336
+ },
1996
2337
  ];
1997
2338
  }
1998
2339
  };
@@ -2004,6 +2345,60 @@ export const useDataStore = defineStore('data', {
2004
2345
  ErrorHandler(err);
2005
2346
  }
2006
2347
  },
2348
+ async downloadTemplate() {
2349
+ try {
2350
+ this.isButtonsLoading = true;
2351
+ const response: any = await this.api.downloadTemplate();
2352
+ const blob = new Blob([response], {
2353
+ type: `application/pdf`,
2354
+ });
2355
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2356
+ const url = window.URL.createObjectURL(blob);
2357
+ const link = document.createElement('a');
2358
+ link.href = url;
2359
+ link.setAttribute('download', this.formStore.regNumber + ' Договор страхования');
2360
+ document.body.appendChild(link);
2361
+ link.click();
2362
+ } catch (err) {
2363
+ ErrorHandler(err);
2364
+ }
2365
+ this.isButtonsLoading = false;
2366
+ },
2367
+ async sendTemplateToEmail(email: string) {
2368
+ try {
2369
+ this.isButtonsLoading = true;
2370
+ await this.api.sendTemplateToEmail(email);
2371
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2372
+ } catch (err) {
2373
+ ErrorHandler(err);
2374
+ }
2375
+ this.isButtonsLoading = false;
2376
+ },
2377
+ async generateDocument() {
2378
+ try {
2379
+ this.isButtonsLoading = true;
2380
+ this.formStore.needToScanSignedContract = true;
2381
+ const data: SignDataType = {
2382
+ processInstanceId: String(this.formStore.applicationData.processInstanceId),
2383
+ name: 'Contract',
2384
+ format: 'pdf',
2385
+ };
2386
+ const response: any = await this.api.generateDocument(data);
2387
+ const blob = new Blob([response], {
2388
+ type: `application/pdf`,
2389
+ });
2390
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2391
+ const url = window.URL.createObjectURL(blob);
2392
+ const link = document.createElement('a');
2393
+ link.href = url;
2394
+ link.setAttribute('download', this.formStore.regNumber + ' Договор страхования');
2395
+ document.body.appendChild(link);
2396
+ link.click();
2397
+ } catch (err) {
2398
+ ErrorHandler(err);
2399
+ }
2400
+ this.isButtonsLoading = false;
2401
+ },
2007
2402
  async registerNumber() {
2008
2403
  try {
2009
2404
  if (!this.formStore.finCenterData.date) return;
@@ -2074,6 +2469,9 @@ export const useDataStore = defineStore('data', {
2074
2469
  const recalculatedValue = await this.api.reCalculate(data);
2075
2470
  if (!!recalculatedValue) {
2076
2471
  await this.getApplicationData(taskId, false, false, false, true);
2472
+ if (this.isGons) {
2473
+ this.formStore.productConditionsForm.isRecalculated = true;
2474
+ }
2077
2475
  this.showToaster(
2078
2476
  'success',
2079
2477
  `${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
@@ -2115,7 +2513,7 @@ export const useDataStore = defineStore('data', {
2115
2513
  }
2116
2514
  }
2117
2515
  } else {
2118
- if (this.formStore[localKey].some((i: any) => i.iin !== null)) {
2516
+ if (this.formStore[localKey].some(i => i.iin !== null)) {
2119
2517
  this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
2120
2518
  return false;
2121
2519
  }
@@ -2213,8 +2611,8 @@ export const useDataStore = defineStore('data', {
2213
2611
  }
2214
2612
  if (localCheck === false) {
2215
2613
  try {
2216
- if (this.isInitiator() && !this.isGons) {
2217
- if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
2614
+ if (this.isInitiator() && this.members.beneficialOwnerApp.has) {
2615
+ if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
2218
2616
  await Promise.allSettled(
2219
2617
  this.formStore.applicationData.beneficialOwnerApp.map(async (member: any) => {
2220
2618
  await this.api.deleteMember('BeneficialOwner', member.id);
@@ -2234,124 +2632,127 @@ export const useDataStore = defineStore('data', {
2234
2632
  if (!anketa) return false;
2235
2633
  const list = anketa.body;
2236
2634
  if (!list || (list && list.length === 0)) return false;
2237
- let notAnswered = 0;
2238
- for (let x = 0; x < list.length; x++) {
2239
- if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
2240
- notAnswered = notAnswered + 1;
2635
+ const isAnketaValid = ref<boolean>(true);
2636
+ list.forEach(i => {
2637
+ if (
2638
+ (i.first.definedAnswers === 'N' && !i.first.answerText) ||
2639
+ (i.first.definedAnswers === 'Y' && !i.first.answerName) ||
2640
+ (i.first.definedAnswers === 'D' && !i.first.answerName?.match(new RegExp('Нет', 'i')) && !i.first.answerText)
2641
+ ) {
2642
+ isAnketaValid.value = false;
2643
+ return false;
2241
2644
  }
2242
- }
2243
- return notAnswered === 0;
2645
+ if (this.controls.isSecondAnketaRequired && i.first.definedAnswers === 'Y' && i.first.answerName?.match(new RegExp('Да', 'i'))) {
2646
+ if (i.second && i.second.length) {
2647
+ const isValid = i.second.every(second => (second.definedAnswers === 'N' ? !!second.answerText : !!second.answerName));
2648
+ if (!isValid) {
2649
+ isAnketaValid.value = false;
2650
+ this.showToaster('info', this.t('toaster.emptySecondAnketa', { text: i.first.name }), 5000);
2651
+ return false;
2652
+ }
2653
+ } else {
2654
+ // TODO уточнить
2655
+ }
2656
+ }
2657
+ });
2658
+ return isAnketaValid.value;
2244
2659
  },
2245
2660
  async validateAllForms(taskId: string) {
2246
2661
  this.isLoading = true;
2247
2662
  const areMembersValid = await this.validateAllMembers(taskId);
2248
2663
  if (areMembersValid) {
2249
2664
  if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
2250
- const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
2251
- if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i'))) {
2252
- await Promise.allSettled([
2253
- this.getQuestionList(
2254
- 'health',
2255
- this.formStore.applicationData.processInstanceId,
2256
- this.formStore.applicationData.insuredApp[0].id,
2257
- 'surveyByHealthBase',
2258
- 'surveyByHealthSecond',
2259
- ),
2260
- this.getQuestionList(
2261
- 'critical',
2262
- this.formStore.applicationData.processInstanceId,
2263
- this.formStore.applicationData.insuredApp[0].id,
2264
- 'surveyByCriticalBase',
2265
- 'surveyByCriticalSecond',
2266
- ),
2267
- this.isClientAnketaCondition &&
2268
- this.getQuestionList(
2269
- 'health',
2270
- this.formStore.applicationData.processInstanceId,
2271
- this.formStore.applicationData.clientApp.id,
2272
- 'surveyByHealthBasePolicyholder',
2273
- 'surveyByHealthSecond',
2274
- 'policyholder',
2275
- ),
2276
- ]);
2277
- this.isClientAnketaCondition
2278
- ? await Promise.allSettled([
2279
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2280
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2281
- }),
2282
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2283
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2284
- }),
2285
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2286
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2287
- }),
2288
- ])
2289
- : await Promise.allSettled([
2290
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2291
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2292
- }),
2293
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2294
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2295
- }),
2296
- ]);
2297
- } else {
2298
- await Promise.allSettled([
2299
- this.getQuestionList(
2300
- 'health',
2301
- this.formStore.applicationData.processInstanceId,
2302
- this.formStore.applicationData.insuredApp[0].id,
2303
- 'surveyByHealthBase',
2304
- 'surveyByHealthSecond',
2305
- ),
2306
- this.isClientAnketaCondition &&
2307
- this.getQuestionList(
2308
- 'health',
2309
- this.formStore.applicationData.processInstanceId,
2310
- this.formStore.applicationData.clientApp.id,
2311
- 'surveyByHealthBasePolicyholder',
2312
- 'surveyByHealthSecond',
2313
- 'policyholder',
2314
- ),
2315
- ,
2316
- ]);
2317
- this.isClientAnketaCondition
2318
- ? await Promise.allSettled([
2319
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2320
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2321
- }),
2322
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2323
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2324
- }),
2325
- ])
2326
- : await Promise.allSettled(
2327
- this.formStore.surveyByHealthBase!.body.map(async question => {
2328
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2329
- }),
2330
- );
2331
- }
2332
- if (this.validateAnketa('surveyByHealthBase')) {
2333
- let hasCriticalAndItsValid = null;
2334
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2335
- if (this.validateAnketa('surveyByCriticalBase')) {
2336
- hasCriticalAndItsValid = true;
2337
- } else {
2338
- hasCriticalAndItsValid = false;
2339
- this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2340
- }
2665
+ if (this.controls.hasAnketa) {
2666
+ const hasCritical =
2667
+ this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName.match(new RegExp('Критическое заболевание Застрахованного', 'i'))) ?? null;
2668
+ if (hasCritical === null || (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')))) {
2669
+ await Promise.allSettled([
2670
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2671
+ this.isClientAnketaCondition &&
2672
+ this.getQuestionList(
2673
+ 'health',
2674
+ this.formStore.applicationData.processInstanceId,
2675
+ this.formStore.applicationData.clientApp.id,
2676
+ 'surveyByHealthBasePolicyholder',
2677
+ 'policyholder',
2678
+ ),
2679
+ ,
2680
+ ]);
2681
+ this.isClientAnketaCondition
2682
+ ? await Promise.allSettled([
2683
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2684
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2685
+ }),
2686
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2687
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2688
+ }),
2689
+ ])
2690
+ : await Promise.allSettled(
2691
+ this.formStore.surveyByHealthBase!.body.map(async question => {
2692
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2693
+ }),
2694
+ );
2341
2695
  } else {
2342
- hasCriticalAndItsValid = null;
2696
+ await Promise.allSettled([
2697
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2698
+ this.getQuestionList('critical', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByCriticalBase'),
2699
+ this.isClientAnketaCondition &&
2700
+ this.getQuestionList(
2701
+ 'health',
2702
+ this.formStore.applicationData.processInstanceId,
2703
+ this.formStore.applicationData.clientApp.id,
2704
+ 'surveyByHealthBasePolicyholder',
2705
+ 'policyholder',
2706
+ ),
2707
+ ]);
2708
+ this.isClientAnketaCondition
2709
+ ? await Promise.allSettled([
2710
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2711
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2712
+ }),
2713
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2714
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2715
+ }),
2716
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2717
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2718
+ }),
2719
+ ])
2720
+ : await Promise.allSettled([
2721
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2722
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2723
+ }),
2724
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2725
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2726
+ }),
2727
+ ]);
2343
2728
  }
2344
- if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2345
- if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
2346
- this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
2729
+ if (this.validateAnketa('surveyByHealthBase')) {
2730
+ let hasCriticalAndItsValid = null;
2731
+ if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')) === null) {
2732
+ if (this.validateAnketa('surveyByCriticalBase')) {
2733
+ hasCriticalAndItsValid = true;
2734
+ } else {
2735
+ hasCriticalAndItsValid = false;
2736
+ this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
2737
+ }
2738
+ } else {
2739
+ hasCriticalAndItsValid = null;
2740
+ }
2741
+ if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
2742
+ if (this.isClientAnketaCondition && this.validateAnketa('surveyByHealthBasePolicyholder') === false) {
2743
+ this.showToaster('error', this.t('toaster.emptyHealthAnketaPolicyholder'), 3000);
2744
+ this.isLoading = false;
2745
+ return false;
2746
+ }
2347
2747
  this.isLoading = false;
2348
- return false;
2748
+ return true;
2349
2749
  }
2350
- this.isLoading = false;
2351
- return true;
2750
+ } else {
2751
+ this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2352
2752
  }
2353
2753
  } else {
2354
- this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
2754
+ this.isLoading = false;
2755
+ return true;
2355
2756
  }
2356
2757
  } else {
2357
2758
  this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
@@ -2364,7 +2765,10 @@ export const useDataStore = defineStore('data', {
2364
2765
  async getFamilyInfo(iin: string, phoneNumber: string) {
2365
2766
  this.isLoading = true;
2366
2767
  try {
2367
- const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
2768
+ const familyResponse = await this.api.getFamilyInfo({
2769
+ iin: iin.replace(/-/g, ''),
2770
+ phoneNumber: formatPhone(phoneNumber),
2771
+ });
2368
2772
  if (familyResponse.status === 'soap:Server') {
2369
2773
  this.showToaster('error', `${familyResponse.statusName}. Отправьте запрос через некоторое время`, 5000);
2370
2774
  this.isLoading = false;
@@ -2409,6 +2813,32 @@ export const useDataStore = defineStore('data', {
2409
2813
  this.isLoading = false;
2410
2814
  }
2411
2815
  },
2816
+ async getKgd(iin: string) {
2817
+ try {
2818
+ const data = {
2819
+ iinBin: iin.replace(/-/g, ''),
2820
+ };
2821
+ const kgdResponse = await this.api.getKgd(data);
2822
+ return kgdResponse;
2823
+ } catch (err) {
2824
+ return ErrorHandler(err);
2825
+ }
2826
+ },
2827
+ async getGbdUl(bin: string) {
2828
+ if (!this.accessToken) return null;
2829
+ try {
2830
+ const decoded = jwtDecode(this.accessToken);
2831
+ const data = {
2832
+ userName: decoded.code,
2833
+ branchName: decoded.branchCode,
2834
+ bin: bin.replace(/-/g, ''),
2835
+ };
2836
+ const gbdulResponse = await this.api.getGbdUl(data);
2837
+ return gbdulResponse;
2838
+ } catch (err) {
2839
+ return ErrorHandler(err);
2840
+ }
2841
+ },
2412
2842
  async getContragentFromGBDFL(member: Member) {
2413
2843
  // null - ожидание
2414
2844
  // false - ошибка или неправильно
@@ -2440,6 +2870,20 @@ export const useDataStore = defineStore('data', {
2440
2870
  this.isLoading = false;
2441
2871
  return false;
2442
2872
  }
2873
+ if (!gbdResponse.content) {
2874
+ let errMsg: string = '';
2875
+ if (gbdResponse.status) {
2876
+ errMsg += gbdResponse.status;
2877
+ }
2878
+ if (gbdResponse.statusName) {
2879
+ errMsg += gbdResponse.statusName;
2880
+ }
2881
+ if (!!errMsg) {
2882
+ this.showToaster('error', errMsg, 5000);
2883
+ }
2884
+ this.isLoading = false;
2885
+ return false;
2886
+ }
2443
2887
  const { person } = parseXML(gbdResponse.content, true, 'person');
2444
2888
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2445
2889
  if (member.gosPersonData !== null && member.gosPersonData.iin !== member.iin!.replace(/-/g, '')) {
@@ -2461,11 +2905,15 @@ export const useDataStore = defineStore('data', {
2461
2905
  member.firstName = person.name;
2462
2906
  member.lastName = person.surname;
2463
2907
  member.middleName = person.patronymic ? person.patronymic : '';
2908
+ if (this.isLifetrip) {
2909
+ member.firstNameLat = person.engFirstName ? person.engFirstName : '';
2910
+ member.lastNameLat = person.engSurname ? person.engSurname : '';
2911
+ }
2464
2912
  member.longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
2465
2913
  member.birthDate = reformatDate(person.birthDate);
2466
2914
  member.genderName = person.gender.nameRu;
2467
2915
 
2468
- const gender = this.gender.find(i => i.id == person.gender.code);
2916
+ const gender = this.gender.find((i: Value) => i.id == person.gender.code);
2469
2917
  if (gender) member.gender = gender;
2470
2918
 
2471
2919
  const birthPlace = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.birthPlace.country.nameRu, 'i')));
@@ -2548,7 +2996,7 @@ export const useDataStore = defineStore('data', {
2548
2996
  if ('length' in person.documents.document) {
2549
2997
  const validDocument = person.documents.document.find((i: any) => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
2550
2998
  if (validDocument) {
2551
- const documentType = this.documentTypes.find(i => i.ids === '1UDL');
2999
+ const documentType = this.documentTypes.find((i: Value) => i.ids === '1UDL');
2552
3000
  if (documentType) member.documentType = documentType;
2553
3001
 
2554
3002
  member.documentNumber = validDocument.number;
@@ -2562,7 +3010,7 @@ export const useDataStore = defineStore('data', {
2562
3010
  } else {
2563
3011
  const documentType =
2564
3012
  person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
2565
- ? this.documentTypes.find(i => i.ids === '1UDL')
3013
+ ? this.documentTypes.find((i: Value) => i.ids === '1UDL')
2566
3014
  : this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2567
3015
  ? this.documentTypes.find(i => (i.nameRu as string).match(new RegExp(person.documents.document.type.nameRu, 'i')))
2568
3016
  : new Value();
@@ -2581,9 +3029,265 @@ export const useDataStore = defineStore('data', {
2581
3029
  const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
2582
3030
  if (documentIssuer) member.documentIssuers = documentIssuer;
2583
3031
  }
2584
- const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
3032
+ const economySectorCode = this.economySectorCode.find((i: Value) => i.ids === '500003.9');
2585
3033
  if (economySectorCode) member.economySectorCode = economySectorCode;
2586
3034
  },
3035
+ async startApplicationV2(policyholder: MemberV2) {
3036
+ if (!policyholder.iin) return false;
3037
+ try {
3038
+ const response = await this.api.startApplication(policyholder);
3039
+ this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
3040
+ return response.processInstanceId;
3041
+ } catch (err) {
3042
+ return ErrorHandler(err);
3043
+ }
3044
+ },
3045
+ async saveClient(policyholder: MemberV2) {
3046
+ try {
3047
+ this.formStore.applicationData.clientApp.clientData = policyholder;
3048
+ const response = await this.api.saveClient(this.formStore.applicationData.processInstanceId, this.formStore.lfb.clientId, this.formStore.applicationData.clientApp);
3049
+ return response;
3050
+ } catch (err) {
3051
+ return ErrorHandler(err);
3052
+ }
3053
+ },
3054
+ async getApplicationDataV2(taskId: string) {
3055
+ this.isLoading = true;
3056
+ try {
3057
+ const applicationData = await this.api.getApplicationData(taskId);
3058
+ if (this.processCode !== applicationData.processCode) {
3059
+ this.isLoading = false;
3060
+ this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
3061
+ return;
3062
+ }
3063
+
3064
+ this.formStore.applicationData = applicationData;
3065
+ this.formStore.regNumber = applicationData.regNumber;
3066
+ this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
3067
+
3068
+ this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
3069
+ this.formStore.applicationTaskId = taskId;
3070
+ this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
3071
+ this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
3072
+ this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
3073
+ this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
3074
+ this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
3075
+ this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
3076
+
3077
+ this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
3078
+ this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
3079
+
3080
+ const { clientData } = applicationData.clientApp;
3081
+ const beneficialOwnerApp = applicationData.beneficialOwnerApp;
3082
+ const insuredApp = applicationData.insuredApp;
3083
+ const accidentIncidents = applicationData.accidentIncidentDtos;
3084
+ const clientId = applicationData.clientApp.id;
3085
+
3086
+ this.formStore.applicationData.processInstanceId = applicationData.processInstanceId;
3087
+ this.formStore.lfb.policyholder = clientData;
3088
+ this.formStore.lfb.policyholder.iin = reformatIin(clientData.iin);
3089
+ this.formStore.lfb.clientId = clientId;
3090
+ this.formStore.lfb.policyholder.authorityDetails.date = reformatDate(clientData.authorityDetails.date);
3091
+
3092
+ if (clientData && clientData.organizationInfo.activityTypes !== null) {
3093
+ this.formStore.lfb.policyholderActivities = clientData.organizationInfo.activityTypes;
3094
+ }
3095
+
3096
+ if (beneficialOwnerApp && beneficialOwnerApp.length) {
3097
+ this.formStore.lfb.beneficialOwners = beneficialOwnerApp;
3098
+ this.formStore.lfb.isPolicyholderBeneficialOwner = clientData.iin.replace(/-/g, '') === beneficialOwnerApp[0].beneficialOwnerData.iin ? true : false;
3099
+ this.formStore.lfb.beneficialOwners.forEach(beneficial => {
3100
+ beneficial.beneficialOwnerData.identityDocument!.validUntil = reformatDate(beneficial.beneficialOwnerData.identityDocument!.validUntil as string);
3101
+ });
3102
+ }
3103
+
3104
+ if (insuredApp && insuredApp.length) {
3105
+ const res = await this.newInsuredList(insuredApp);
3106
+ this.formStore.lfb.clients = res;
3107
+ }
3108
+
3109
+ if (accidentIncidents && accidentIncidents.length) {
3110
+ this.formStore.lfb.accidentIncidents = accidentIncidents;
3111
+ this.formStore.lfb.accidentIncidents.forEach(incident => {
3112
+ incident.amount = incident.amount === 0 ? null : incident.amount;
3113
+ incident.count = incident.count === 0 ? null : incident.count;
3114
+ });
3115
+ }
3116
+
3117
+ this.formStore.productConditionsForm.coverPeriod = 12;
3118
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(applicationData.policyAppDto.amount === 0 ? null : applicationData.policyAppDto.amount);
3119
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
3120
+ applicationData.policyAppDto.mainPremium === 0 ? null : applicationData.policyAppDto.mainPremium,
3121
+ );
3122
+ const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
3123
+ this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
3124
+ const processTariff = this.processTariff.find(item => item.id == applicationData.policyAppDto.tariffId);
3125
+ this.formStore.productConditionsForm.processTariff = processTariff ? processTariff : new Value();
3126
+ const processGfot = this.processGfot.find(item => item.id == applicationData.policyAppDto.processDefinitionFgotId);
3127
+ this.formStore.productConditionsForm.processGfot = processGfot ? processGfot : new Value();
3128
+ } catch (err) {
3129
+ ErrorHandler(err);
3130
+ if (err instanceof AxiosError) {
3131
+ this.sendToParent(constants.postActions.toHomePage, err.response?.data);
3132
+ this.isLoading = false;
3133
+ return false;
3134
+ }
3135
+ }
3136
+ this.isLoading = false;
3137
+ },
3138
+ async saveAccidentIncidents(data: AccidentIncidents[]) {
3139
+ try {
3140
+ const response = await this.api.saveAccidentIncidents(this.formStore.applicationData.processInstanceId, data);
3141
+ return response;
3142
+ } catch (err) {
3143
+ return ErrorHandler(err);
3144
+ }
3145
+ },
3146
+ async saveClientAcivityTypes(data: PolicyholderActivity[]) {
3147
+ try {
3148
+ const response = await this.api.saveClientAcivityTypes(this.formStore.applicationData.clientApp.id, data);
3149
+ return response;
3150
+ } catch (err) {
3151
+ return ErrorHandler(err);
3152
+ }
3153
+ },
3154
+ async saveBeneficialOwnerList(beneficialOwnerList: BeneficialOwner[]) {
3155
+ try {
3156
+ const response = await this.api.saveBeneficialOwnerList(this.formStore.applicationData.processInstanceId, beneficialOwnerList);
3157
+ return response;
3158
+ } catch (err) {
3159
+ return ErrorHandler(err);
3160
+ }
3161
+ },
3162
+ async saveBeneficialOwner(beneficialOwner: BeneficialOwner) {
3163
+ try {
3164
+ const response = await this.api.saveBeneficialOwner(this.formStore.applicationData.processInstanceId, beneficialOwner.id, beneficialOwner);
3165
+ return response;
3166
+ } catch (err) {
3167
+ return ErrorHandler(err);
3168
+ }
3169
+ },
3170
+ async saveInsuredList(insuredList: any) {
3171
+ try {
3172
+ const response = await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, insuredList);
3173
+ return response;
3174
+ } catch (err) {
3175
+ return ErrorHandler(err);
3176
+ }
3177
+ },
3178
+ async saveInsured(insured: any) {
3179
+ try {
3180
+ const response = await this.api.saveInsured(this.formStore.applicationData.processInstanceId, insured.id, insured);
3181
+ return response;
3182
+ } catch (err) {
3183
+ return ErrorHandler(err);
3184
+ }
3185
+ },
3186
+ newInsuredList(list: any) {
3187
+ const clients = list.map((item: any, index: number) => {
3188
+ const client = item.insuredData;
3189
+ return {
3190
+ id: index,
3191
+ fullName: client.longName,
3192
+ gender: client.gender,
3193
+ position: item.workDetails?.position,
3194
+ birthDate: client.birthDate,
3195
+ iin: client.iin,
3196
+ insSum: client.insuredPolicyData.insSum,
3197
+ premium: client.insuredPolicyData.premium,
3198
+ };
3199
+ });
3200
+ return clients;
3201
+ },
3202
+ validateMultipleMembersV2(localKey: string, applicationKey: keyof typeof this.formStore.applicationData, text: string) {
3203
+ // @ts-ignore
3204
+ if (this.formStore.lfb[localKey].length === this.formStore.applicationData[applicationKey].length) {
3205
+ // @ts-ignore
3206
+ if (this.formStore.lfb[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
3207
+ // @ts-ignore
3208
+ const localMembers = [...this.formStore.lfb[localKey]].sort((a, b) => Number(a.id) - Number(b.id));
3209
+ const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.id - b.id);
3210
+ if (localMembers.every((each, index) => applicationMembers[index].iin === each.iin?.replace(/-/g, '')) === false) {
3211
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3212
+ return false;
3213
+ }
3214
+ }
3215
+ } else {
3216
+ // @ts-ignore
3217
+ if (this.formStore.lfb[localKey].some(i => i.iin !== null)) {
3218
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3219
+ return false;
3220
+ }
3221
+ if (this.formStore.applicationData[applicationKey].length !== 0) {
3222
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3223
+ return false;
3224
+ } else {
3225
+ // @ts-ignore
3226
+ if (this.formStore.lfb[localKey][0].iin !== null) {
3227
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3228
+ return false;
3229
+ }
3230
+ }
3231
+ }
3232
+ return true;
3233
+ },
3234
+ async validateAllFormsV2(taskId: string) {
3235
+ this.isLoading = true;
3236
+ if (taskId === '0') {
3237
+ this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
3238
+ return false;
3239
+ }
3240
+
3241
+ if (this.formStore.applicationData.clientApp.iin !== this.formStore.applicationData.clientApp.iin) {
3242
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
3243
+ return false;
3244
+ }
3245
+
3246
+ if (this.formStore.lfb.beneficialOwners) {
3247
+ if (this.validateMultipleMembersV2('beneficialOwners', 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
3248
+ return false;
3249
+ }
3250
+ const inStatement = this.formStore.lfb.beneficialOwners.every(i => i.id !== null);
3251
+ if (inStatement === false) {
3252
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficialOwner') }));
3253
+ return false;
3254
+ }
3255
+ }
3256
+
3257
+ if (this.formStore.lfb.policyholderActivities) {
3258
+ if (this.formStore.lfb.policyholderActivities.length !== this.formStore.applicationData.clientApp.clientData.organizationInfo.activityTypes.length) {
3259
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'деятельности Страхователя' }), 3000);
3260
+ return false;
3261
+ }
3262
+ }
3263
+
3264
+ if (this.formStore.lfb.clients) {
3265
+ if (this.validateMultipleMembersV2('clients', 'insuredApp', 'застрахованных') === false) {
3266
+ return false;
3267
+ }
3268
+ const inStatement = this.formStore.lfb.clients.every(i => i.id !== null);
3269
+ if (inStatement === false) {
3270
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.insured') }));
3271
+ return false;
3272
+ }
3273
+ }
3274
+
3275
+ if (this.formStore.productConditionsForm.insurancePremiumPerMonth === null) {
3276
+ this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
3277
+ return false;
3278
+ }
3279
+
3280
+ return true;
3281
+ },
3282
+ async checkIIN(iin: number) {
3283
+ try {
3284
+ const response = await this.api.checkIIN(iin);
3285
+ return response;
3286
+ } catch (err) {
3287
+ ErrorHandler(err);
3288
+ return null;
3289
+ }
3290
+ },
2587
3291
  async isCourseChanged(processInstanceId: string) {
2588
3292
  try {
2589
3293
  const response = await this.api.isCourseChanged(processInstanceId);
@@ -2593,6 +3297,7 @@ export const useDataStore = defineStore('data', {
2593
3297
  }
2594
3298
  },
2595
3299
  hasJobSection(whichForm: keyof typeof StoreMembers) {
3300
+ if (this.isLifetrip) return false;
2596
3301
  switch (whichForm) {
2597
3302
  case this.formStore.beneficiaryFormKey:
2598
3303
  case this.formStore.beneficialOwnerFormKey:
@@ -2633,8 +3338,22 @@ export const useDataStore = defineStore('data', {
2633
3338
  hasPercentageOfPayoutAmount() {
2634
3339
  return true;
2635
3340
  },
2636
- canViewInvoiceInfo() {
2637
- return this.isAdmin();
3341
+ hasAccess() {
3342
+ return {
3343
+ invoiceInfo: this.isAdmin(),
3344
+ toLKA: this.isAgent() || this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn(),
3345
+ toAML: this.isCompliance() || this.isAdmin() || this.isSupport() || this.isAnalyst(),
3346
+ toEFO:
3347
+ this.isInitiator() ||
3348
+ this.isUnderwriter() ||
3349
+ this.isAdmin() ||
3350
+ this.isCompliance() ||
3351
+ this.isAnalyst() ||
3352
+ this.isUpk() ||
3353
+ this.isFinCenter() ||
3354
+ this.isSupervisor() ||
3355
+ this.isSupport(),
3356
+ };
2638
3357
  },
2639
3358
  },
2640
3359
  });