hl-core 0.0.10-beta.5 → 0.0.10-beta.51

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 (42) hide show
  1. package/README.md +0 -2
  2. package/api/base.api.ts +345 -137
  3. package/api/interceptors.ts +3 -5
  4. package/components/Dialog/Dialog.vue +5 -1
  5. package/components/Dialog/FamilyDialog.vue +15 -4
  6. package/components/Form/DigitalDocument.vue +52 -0
  7. package/components/Form/FormSource.vue +30 -0
  8. package/components/Form/ManagerAttachment.vue +60 -11
  9. package/components/Form/ProductConditionsBlock.vue +12 -6
  10. package/components/Input/Datepicker.vue +5 -0
  11. package/components/Input/FileInput.vue +1 -1
  12. package/components/Input/FormInput.vue +5 -0
  13. package/components/Input/OtpInput.vue +25 -0
  14. package/components/Input/RoundedInput.vue +2 -0
  15. package/components/Input/RoundedSelect.vue +2 -0
  16. package/components/Input/TextAreaField.vue +71 -0
  17. package/components/Menu/MenuNav.vue +1 -1
  18. package/components/Pages/Anketa.vue +207 -176
  19. package/components/Pages/ContragentForm.vue +1 -1
  20. package/components/Pages/Documents.vue +452 -64
  21. package/components/Pages/MemberForm.vue +416 -180
  22. package/components/Pages/ProductConditions.vue +1021 -243
  23. package/components/Panel/PanelHandler.vue +297 -124
  24. package/components/Utilities/Chip.vue +1 -1
  25. package/components/Utilities/JsonViewer.vue +1 -2
  26. package/composables/classes.ts +124 -20
  27. package/composables/constants.ts +46 -1
  28. package/composables/index.ts +336 -8
  29. package/composables/styles.ts +8 -24
  30. package/configs/pwa.ts +1 -7
  31. package/layouts/clear.vue +1 -1
  32. package/layouts/default.vue +1 -1
  33. package/layouts/full.vue +1 -1
  34. package/locales/ru.json +90 -19
  35. package/nuxt.config.ts +10 -12
  36. package/package.json +12 -12
  37. package/plugins/head.ts +7 -1
  38. package/store/data.store.ts +966 -575
  39. package/store/member.store.ts +17 -6
  40. package/store/rules.ts +23 -3
  41. package/types/enum.ts +42 -2
  42. package/types/index.ts +111 -56
@@ -2,12 +2,12 @@ import { defineStore } from 'pinia';
2
2
  import { rules } from './rules';
3
3
  import { i18n } from '../configs/i18n';
4
4
  import { Toast, Types as ToastTypes, Positions, ToastOptions } from './toast';
5
- import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate } from '../composables';
6
- import { DataStoreClass, DocumentItem, Member, Value, CountryValue, PolicyholderActivity, BeneficialOwner, PolicyholderClass } from '../composables/classes';
5
+ import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate, RoleController, ProcessController, sanitize } from '../composables';
6
+ import { DataStoreClass, DocumentItem, Member, Value, CountryValue, PolicyholderActivity, BeneficialOwner, PolicyholderClass, GroupMember } 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, Enums } from '../types/enum';
10
+ import { PostActions, StoreMembers, MemberCodes, MemberAppCodes, CoreEnums } from '../types/enum';
11
11
  import type * as Types from '../types';
12
12
  //@ts-ignore
13
13
  import { NCALayerClient } from 'ncalayer-js-client';
@@ -15,11 +15,14 @@ import { NCALayerClient } from 'ncalayer-js-client';
15
15
  export const useDataStore = defineStore('data', {
16
16
  state: () => ({
17
17
  ...new DataStoreClass(),
18
+ ...new RoleController(),
19
+ ...new ProcessController(),
18
20
  t: i18n.t,
19
21
  rules: rules,
20
22
  toast: Toast,
21
23
  toastTypes: ToastTypes,
22
24
  toastPositions: Positions,
25
+ sanitize: sanitize,
23
26
  isValidGUID: isValidGUID,
24
27
  router: useRouter(),
25
28
  formStore: useFormStore(),
@@ -60,10 +63,14 @@ export const useDataStore = defineStore('data', {
60
63
  isCheckContract: state => state.product === 'checkcontract',
61
64
  isCheckContragent: state => state.product === 'checkcontragent',
62
65
  isPrePension: state => state.product === 'prepensionannuity',
66
+ isCritical: state => state.product === 'criticalillness',
67
+ isBalam: state => state.product === 'balam',
68
+ isTumar: state => state.product === 'tumar',
63
69
  isDSO: state => state.product === 'dso',
64
70
  isUU: state => state.product === 'uu',
65
- hasClientAnketa: state => state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10),
71
+ hasClientAnketa: state => Array.isArray(state.formStore.additionalInsuranceTerms) && state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10),
66
72
  isClientAnketaCondition: state =>
73
+ Array.isArray(state.formStore.additionalInsuranceTerms) &&
67
74
  !state.formStore.insuredForm.find(member => member.iin === state.formStore.policyholderForm.iin) &&
68
75
  !!state.formStore.additionalInsuranceTerms.find(i => i.coverTypeCode === 10 && i.coverSumCode === 'included'),
69
76
  },
@@ -138,7 +145,7 @@ export const useDataStore = defineStore('data', {
138
145
  if (showError) this.showToaster('error', this.t('toaster.noUrl'));
139
146
  }
140
147
  },
141
- getFilesByIIN(iin: string) {
148
+ getDocsByIIN(iin: string) {
142
149
  return iin ? this.formStore.signedDocumentList.filter(file => file.iin === iin && file.fileTypeName === 'Удостоверение личности') : null;
143
150
  },
144
151
  async getNewAccessToken() {
@@ -160,22 +167,23 @@ export const useDataStore = defineStore('data', {
160
167
  getUserRoles() {
161
168
  if (this.accessToken && this.user.roles.length === 0) {
162
169
  const decoded = jwtDecode(this.accessToken);
163
- this.user.id = decoded.sub;
164
- this.user.fullName = `${decoded.lastName} ${decoded.firstName} ${decoded.middleName ? decoded.middleName : ''}`;
165
- const key = getKeyWithPattern(decoded, 'role');
166
- if (key) {
167
- const roles = decoded[key];
168
- if (typeof roles === 'string') {
169
- this.user.roles.push(roles);
170
- } else if (typeof roles === 'object') {
171
- this.user.roles = roles;
170
+ if (decoded) {
171
+ this.user.id = String(decoded.sub);
172
+ this.user.fullName = `${decoded.lastName} ${decoded.firstName} ${decoded.middleName ?? ''}`;
173
+ this.user.code = decoded.code;
174
+ this.user.branchCode = decoded.branchCode;
175
+ const key = getKeyWithPattern(decoded, 'role');
176
+ if (key) {
177
+ const roles = decoded[key as keyof Types.Utils.JwtToken];
178
+ if (typeof roles === 'string') {
179
+ this.user.roles.push(roles);
180
+ } else if (typeof roles === 'object') {
181
+ this.user.roles = roles;
182
+ }
172
183
  }
173
184
  }
174
185
  }
175
186
  },
176
- getUserData() {
177
- return this.accessToken ? jwtDecode(this.accessToken) : null;
178
- },
179
187
  async getUserGroups() {
180
188
  try {
181
189
  this.isLoading = true;
@@ -186,140 +194,17 @@ export const useDataStore = defineStore('data', {
186
194
  this.isLoading = false;
187
195
  }
188
196
  },
189
- isRole(whichRole: keyof typeof Roles) {
190
- if (this.user.roles.length === 0) {
191
- this.getUserRoles();
192
- }
193
- const isRole = this.user.roles.find(i => i === whichRole);
194
- return !!isRole;
195
- },
196
- isInitiator() {
197
- return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager() || this.isAgentAuletti();
198
- },
199
- isManager() {
200
- return this.isRole(constants.roles.Manager);
201
- },
202
- isCompliance() {
203
- return this.isRole(constants.roles.Compliance);
204
- },
205
- isAdmin() {
206
- return this.isRole(constants.roles.Admin);
207
- },
208
- isJurist() {
209
- return this.isRole(constants.roles.Jurist);
210
- },
211
- isAgent() {
212
- return this.isRole(constants.roles.Agent);
213
- },
214
- isManagerHalykBank() {
215
- return this.isRole(constants.roles.ManagerHalykBank);
216
- },
217
- isServiceManager() {
218
- return this.isRole(constants.roles.ServiceManager);
219
- },
220
- isUnderwriter() {
221
- return this.isRole(constants.roles.Underwriter);
222
- },
223
- isActuary() {
224
- return this.isRole(constants.roles.Actuary);
225
- },
226
- isAgentMycar() {
227
- return this.isRole(constants.roles.AgentMycar);
228
- },
229
- isAgentAuletti() {
230
- return this.isRole(constants.roles.AgentAuletti);
231
- },
232
- isAnalyst() {
233
- return this.isRole(constants.roles.Analyst);
234
- },
235
- isUpk() {
236
- return this.isRole(constants.roles.UPK);
237
- },
238
- isUrp() {
239
- return this.isRole(constants.roles.URP);
240
- },
241
- isUsns() {
242
- return this.isRole(constants.roles.USNS);
243
- },
244
- isAccountant() {
245
- return this.isRole(constants.roles.Accountant);
246
- },
247
- isDrn() {
248
- return this.isRole(constants.roles.DRNSJ);
249
- },
250
- isSupport() {
251
- return this.isRole(constants.roles.Support);
252
- },
253
- isFinCenter() {
254
- return this.isRole(constants.roles.FinCenter);
255
- },
256
- isSupervisor() {
257
- return this.isRole(constants.roles.Supervisor);
258
- },
259
- isHeadManager() {
260
- return this.isRole(constants.roles.HeadManager);
261
- },
262
- isBranchDirector() {
263
- return this.isRole(constants.roles.BranchDirector);
264
- },
265
- isUSNSACCINS() {
266
- return this.isRole(constants.roles.USNSACCINS);
267
- },
268
- isDsuio() {
269
- return this.isRole(constants.roles.Dsuio);
270
- },
271
- isAdjuster() {
272
- return this.isRole(constants.roles.Adjuster);
273
- },
274
- isDsoDirector() {
275
- return this.isRole(constants.roles.DsoDirector);
276
- },
277
- isAccountantDirector() {
278
- return this.isRole(constants.roles.AccountantDirector);
279
- },
280
- isProcessEditable(statusCode?: keyof typeof Statuses) {
281
- const getEditibleStatuses = () => {
282
- const defaultStatuses = constants.editableStatuses;
283
- return defaultStatuses;
284
- };
285
- return !!getEditibleStatuses().find(status => status === statusCode);
286
- },
287
- isProcessReturnable(statusCode?: keyof typeof Statuses) {
288
- const getReturnableStatuses = () => {
289
- const defaultStatuses = constants.returnStatementStatuses;
290
- return defaultStatuses;
291
- };
292
- return !!getReturnableStatuses().find(status => status === statusCode);
293
- },
294
- isProcessCancel(statusCode?: keyof typeof Statuses) {
295
- const getCanceleStatuses = () => {
296
- const defaultStatuses = constants.cancelApplicationStatuses;
297
- return defaultStatuses;
298
- };
299
- return !!getCanceleStatuses().find(status => status === statusCode);
300
- },
301
- isProcessReject(statusCode?: keyof typeof Statuses) {
302
- const getRejectStatuses = () => {
303
- const defaultStatuses = constants.rejectApplicationStatuses;
304
- return defaultStatuses;
305
- };
306
- return !!getRejectStatuses().find(status => status === statusCode);
307
- },
308
197
  isTask() {
309
198
  return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
310
199
  },
311
200
  validateAccess() {
312
- try {
313
- const hasAccess = this.hasAccess();
314
- if (this.isAML) return hasAccess.toAML;
315
- if (this.isLKA) return hasAccess.toLKA;
316
- if (this.isEFO) return hasAccess.toEFO;
317
- if (this.isAULETTI) return hasAccess.toAULETTI;
318
- if (this.isLKA_A) return hasAccess.toLKA_A;
319
- return false;
320
- } catch (err) {
321
- return ErrorHandler(err);
322
- }
201
+ const hasAccess = this.hasAccess();
202
+ if (this.isAML) return hasAccess.toAML;
203
+ if (this.isLKA) return hasAccess.toLKA;
204
+ if (this.isEFO) return hasAccess.toEFO;
205
+ if (this.isAULETTI) return hasAccess.toAULETTI;
206
+ if (this.isLKA_A) return hasAccess.toLKA_A;
207
+ return false;
323
208
  },
324
209
  async loginUser(login: string, password: string, numAttempt: number) {
325
210
  try {
@@ -394,53 +279,91 @@ export const useDataStore = defineStore('data', {
394
279
  await this.router.replace({ name: route.name });
395
280
  }
396
281
  },
397
- async getFile(file: DocumentItem, mode: string = 'view', fileType: string = 'pdf') {
282
+ async getDoc(file: DocumentItem, mode: string = 'view', fileType: string = 'pdf') {
398
283
  if (!file.id) return;
399
284
  try {
400
285
  this.isLoading = true;
401
- await this.api.getFile(file.id).then((response: any) => {
402
- if (!['pdf', 'docx'].includes(fileType)) {
403
- const blob = new Blob([response], { type: `image/${fileType}` });
404
- const url = window.URL.createObjectURL(blob);
405
- const link = document.createElement('a');
406
- link.href = url;
407
- if (mode === 'view') {
408
- setTimeout(() => {
409
- window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
410
- });
286
+ if (this.isPension) {
287
+ await this.api.file.getDocNew(file.id).then((response: any) => {
288
+ if (!['pdf', 'docx'].includes(fileType)) {
289
+ const blob = new Blob([response], { type: `image/${fileType}` });
290
+ const url = window.URL.createObjectURL(blob);
291
+ const link = document.createElement('a');
292
+ link.href = url;
293
+ if (mode === 'view') {
294
+ setTimeout(() => {
295
+ window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
296
+ });
297
+ } else {
298
+ link.setAttribute('download', file.fileName!);
299
+ document.body.appendChild(link);
300
+ link.click();
301
+ }
411
302
  } else {
412
- link.setAttribute('download', file.fileName!);
413
- document.body.appendChild(link);
414
- link.click();
415
- }
416
- } else {
417
- const blob = new Blob([response], {
418
- type: `application/${fileType}`,
419
- });
420
- const url = window.URL.createObjectURL(blob);
421
- const link = document.createElement('a');
422
- link.href = url;
423
- if (mode === 'view') {
424
- setTimeout(() => {
425
- window.open(url, '_blank', `right=100`);
303
+ const blob = new Blob([response], {
304
+ type: `application/${fileType}`,
426
305
  });
306
+ const url = window.URL.createObjectURL(blob);
307
+ const link = document.createElement('a');
308
+ link.href = url;
309
+ if (mode === 'view') {
310
+ setTimeout(() => {
311
+ window.open(url, '_blank', `right=100`);
312
+ });
313
+ } else {
314
+ link.setAttribute('download', file.fileName!);
315
+ document.body.appendChild(link);
316
+ link.click();
317
+ }
318
+ }
319
+ });
320
+ } else {
321
+ await this.api.file.getDoc(file.id).then((response: any) => {
322
+ if (!['pdf', 'docx'].includes(fileType)) {
323
+ const blob = new Blob([response], { type: `image/${fileType}` });
324
+ const url = window.URL.createObjectURL(blob);
325
+ const link = document.createElement('a');
326
+ link.href = url;
327
+ if (mode === 'view') {
328
+ setTimeout(() => {
329
+ window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
330
+ });
331
+ } else {
332
+ link.setAttribute('download', file.fileName!);
333
+ document.body.appendChild(link);
334
+ link.click();
335
+ }
427
336
  } else {
428
- link.setAttribute('download', file.fileName!);
429
- document.body.appendChild(link);
430
- link.click();
337
+ const blob = new Blob([response], {
338
+ type: `application/${fileType}`,
339
+ });
340
+ const url = window.URL.createObjectURL(blob);
341
+ const link = document.createElement('a');
342
+ link.href = url;
343
+ if (mode === 'view') {
344
+ setTimeout(() => {
345
+ window.open(url, '_blank', `right=100`);
346
+ });
347
+ } else {
348
+ link.setAttribute('download', file.fileName!);
349
+ document.body.appendChild(link);
350
+ link.click();
351
+ }
431
352
  }
432
- }
433
- });
353
+ });
354
+ }
434
355
  } catch (err) {
435
356
  ErrorHandler(err);
436
357
  } finally {
437
358
  this.isLoading = false;
438
359
  }
439
360
  },
440
- async deleteFile(data: DocumentItem) {
361
+ async deleteFile(data: DocumentItem, showToaster: boolean = true) {
441
362
  try {
442
- await this.api.deleteFile(data);
443
- this.showToaster('success', this.t('toaster.fileWasDeleted'), 3000);
363
+ await this.api.file.deleteFile(data);
364
+ if (showToaster) {
365
+ this.showToaster('success', this.t('toaster.fileWasDeleted'), 3000);
366
+ }
444
367
  } catch (err) {
445
368
  ErrorHandler(err);
446
369
  }
@@ -448,7 +371,7 @@ export const useDataStore = defineStore('data', {
448
371
  async uploadFiles(data: FormData, load: boolean = false) {
449
372
  this.isLoading = load;
450
373
  try {
451
- await this.api.uploadFiles(data);
374
+ await this.api.file.uploadFiles(data);
452
375
  return true;
453
376
  } catch (err) {
454
377
  return ErrorHandler(err);
@@ -458,14 +381,28 @@ export const useDataStore = defineStore('data', {
458
381
  },
459
382
  async getContragent(member: Member, load: boolean = true, showToaster: boolean = true) {
460
383
  this.isLoading = load;
461
- if (!member.iin) return;
384
+ const isNonResident = this.isPension && member.signOfResidency.ids === '500011.2';
385
+ if (isNonResident) {
386
+ if (!member.firstName || !member.lastName) return;
387
+ } else {
388
+ if (!member.iin) return;
389
+ }
462
390
  try {
463
- const queryData = {
464
- firstName: '',
465
- lastName: '',
466
- middleName: '',
467
- iin: member.iin.replace(/-/g, ''),
468
- };
391
+ const queryData = isNonResident
392
+ ? {
393
+ firstName: member.firstName ?? '',
394
+ lastName: member.lastName ?? '',
395
+ middleName: member.middleName ?? '',
396
+ iin: '',
397
+ birthDate: member.birthDate ? formatDate(member.birthDate)?.toISOString() ?? '' : '',
398
+ }
399
+ : {
400
+ firstName: '',
401
+ lastName: '',
402
+ middleName: '',
403
+ iin: member.iin ? member.iin.replace(/-/g, '') : '',
404
+ birthDate: '',
405
+ };
469
406
  const contragentResponse = await this.api.getContragent(queryData);
470
407
  if (contragentResponse.totalItems > 0) {
471
408
  if (contragentResponse.items.length === 1) {
@@ -474,25 +411,32 @@ export const useDataStore = defineStore('data', {
474
411
  const sortedByRegistrationDate = contragentResponse.items.sort(
475
412
  (left, right) => new Date(right.registrationDate).getMilliseconds() - new Date(left.registrationDate).getMilliseconds(),
476
413
  );
477
- await this.serializeContragentData(member, sortedByRegistrationDate[0]);
414
+ if (!isNonResident) await this.serializeContragentData(member, sortedByRegistrationDate[0]);
478
415
  }
479
416
  member.gotFromInsis = true;
480
417
  } else {
481
418
  if (showToaster) this.showToaster('error', this.t('toaster.notFoundUser'));
482
419
  }
420
+ if (isNonResident) return contragentResponse;
483
421
  } catch (err) {
484
422
  ErrorHandler(err);
485
423
  }
486
424
  this.isLoading = false;
487
425
  },
488
- async getContragentById(id: number, whichForm: keyof typeof StoreMembers, load: boolean = true, whichIndex: number | null = null) {
426
+ async getContragentById(id: number, whichForm: keyof typeof StoreMembers | 'slaveInsuredForm', load: boolean = true, whichIndex: number | null = null) {
489
427
  if (Number(id) === 0) return;
490
428
  this.isLoading = load;
491
429
  try {
492
- const member = whichIndex === null ? this.formStore[whichForm as Types.SingleMember] : this.formStore[whichForm as Types.MultipleMember][whichIndex];
430
+ const member =
431
+ this.isPension && whichForm === 'slaveInsuredForm'
432
+ ? this.formStore.slaveInsuredForm
433
+ : whichIndex === null
434
+ ? this.formStore[whichForm as Types.SingleMember]
435
+ : this.formStore[whichForm as Types.MultipleMember][whichIndex];
436
+
493
437
  const contragentResponse = await this.api.getContragentById(id);
494
438
  if (contragentResponse.totalItems > 0) {
495
- await this.serializeContragentData(member, contragentResponse.items[0]);
439
+ await this.serializeContragentData(member, contragentResponse.items[0], whichForm);
496
440
  } else {
497
441
  this.showToaster('error', this.t('toaster.notFoundUser'));
498
442
  }
@@ -502,7 +446,7 @@ export const useDataStore = defineStore('data', {
502
446
  this.isLoading = false;
503
447
  }
504
448
  },
505
- async serializeContragentData(member: Member, contragent: Types.ContragentType) {
449
+ async serializeContragentData(member: Member, contragent: Types.ContragentType, whichForm?: keyof typeof StoreMembers | 'slaveInsuredForm') {
506
450
  const [questionairesResponse, contactsResponse, documentsResponse, addressResponse] = await Promise.allSettled([
507
451
  this.api.getContrAgentData(contragent.id),
508
452
  this.api.getContrAgentContacts(contragent.id),
@@ -524,23 +468,34 @@ export const useDataStore = defineStore('data', {
524
468
  if (addressResponse.status === 'fulfilled' && addressResponse.value && addressResponse.value.length) {
525
469
  member.response.addresses = addressResponse.value;
526
470
  }
527
- this.parseContragent(member, {
528
- personalData: contragent,
529
- data: questionairesResponse.status === 'fulfilled' ? questionairesResponse.value : undefined,
530
- contacts: contactsResponse.status === 'fulfilled' ? contactsResponse.value : undefined,
531
- documents: documentsResponse.status === 'fulfilled' ? documentsResponse.value : undefined,
532
- address: addressResponse.status === 'fulfilled' ? addressResponse.value : undefined,
533
- });
471
+ this.parseContragent(
472
+ member,
473
+ {
474
+ personalData: contragent,
475
+ data: questionairesResponse.status === 'fulfilled' ? questionairesResponse.value : undefined,
476
+ contacts: contactsResponse.status === 'fulfilled' ? contactsResponse.value : undefined,
477
+ documents: documentsResponse.status === 'fulfilled' ? documentsResponse.value : undefined,
478
+ address: addressResponse.status === 'fulfilled' ? addressResponse.value : undefined,
479
+ },
480
+ whichForm,
481
+ );
534
482
  },
535
483
  parseContragent(
536
484
  member: Member,
537
- user: { personalData: Types.ContragentType; data?: Types.ContragentQuestionaries[]; contacts?: Types.ContragentContacts[]; documents?: Types.ContragentDocuments[]; address?: Types.ContragentAddress[] },
485
+ user: {
486
+ personalData: Types.ContragentType;
487
+ data?: Types.ContragentQuestionaries[];
488
+ contacts?: Types.ContragentContacts[];
489
+ documents?: Types.ContragentDocuments[];
490
+ address?: Types.ContragentAddress[];
491
+ },
492
+ whichForm?: keyof typeof StoreMembers | 'slaveInsuredForm',
538
493
  ) {
539
494
  member.verifyType = user.personalData.verifyType;
540
495
  member.verifyDate = user.personalData.verifyDate;
541
496
  member.iin = reformatIin(user.personalData.iin);
542
497
  member.age = String(user.personalData.age);
543
- const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
498
+ const country = this.countries.find((i: Value) => i.nameRu?.match(new RegExp(user.personalData.birthPlace ?? 'undefined', 'i')));
544
499
  member.birthPlace = country && Object.keys(country).length ? country : new Value();
545
500
  const gender = this.gender.find((i: Value) => i.nameRu === user.personalData.genderName);
546
501
  member.gender = gender ? gender : new Value();
@@ -557,13 +512,23 @@ export const useDataStore = defineStore('data', {
557
512
 
558
513
  if ('documents' in user && user.documents && user.documents.length) {
559
514
  member.documentsList = user.documents;
560
- const documentByPriority = user.documents.find(i => i.type === Enums.Insis.DocTypes['1UDL']);
515
+ const documentByPriority = user.documents.find(i => {
516
+ if (this.isLifetrip && (whichForm !== this.formStore.policyholderFormKey || this.formStore.isPolicyholderInsured === true)) {
517
+ return i.type === CoreEnums.Insis.DocTypes['PS'];
518
+ }
519
+ return i.type === CoreEnums.Insis.DocTypes['1UDL'];
520
+ });
561
521
  const userDocument = documentByPriority ? documentByPriority : user.documents[0];
562
522
  const documentType = this.documentTypes.find((i: Value) => i.ids === userDocument.type);
563
523
  const documentIssuer = this.documentIssuers.find((i: Value) => i.nameRu === userDocument.issuerNameRu);
564
524
  member.documentType = documentType ? documentType : new Value();
565
525
  member.documentNumber = userDocument.number;
566
526
  member.documentIssuers = documentIssuer ? documentIssuer : new Value();
527
+ if (userDocument.issuerNameRu === 'Другое') {
528
+ member.documentIssuers.issuerOtherNameRu = userDocument.issuerOtherNameRu;
529
+ member.documentIssuers.issuerOtherNameOrig = userDocument.issuerOtherNameOrig;
530
+ member.documentIssuers.issuerOtherName = userDocument.issuerOtherName;
531
+ }
567
532
  member.documentDate = reformatDate(userDocument.issueDate);
568
533
  member.documentExpire = reformatDate(userDocument.expireDate);
569
534
  }
@@ -639,23 +604,30 @@ export const useDataStore = defineStore('data', {
639
604
  if (qData && qData.from && qData.from.length && qData.field) {
640
605
  const qResult = qData.from.find((i: Value) => i.ids === searchIt.questAnswer);
641
606
  //@ts-ignore
642
- member[qData.field] = qResult ? qResult : new Value();
607
+ member[qData.field] = qResult ?? new Value();
643
608
  }
644
609
  },
645
610
  async alreadyInInsis(member: Member) {
646
- if (!member.iin) return null;
611
+ const isNonResident = this.isPension && member.signOfResidency.ids === '500011.2';
612
+ if (isNonResident) {
613
+ if (!member.firstName || !member.lastName) return;
614
+ } else {
615
+ if (!member.iin) return;
616
+ }
647
617
  try {
648
618
  const queryData = {
649
- iin: member.iin.replaceAll('-', ''),
619
+ iin: !!member.iin && !isNonResident ? member.iin.replaceAll('-', '') : '',
650
620
  firstName: !!member.firstName ? member.firstName : '',
651
621
  lastName: !!member.lastName ? member.lastName : '',
652
622
  middleName: !!member.middleName ? member.middleName : '',
623
+ birthDate: !!member.birthDate ? formatDate(member.birthDate)?.toISOString() ?? '' : '',
653
624
  };
654
625
  const contragent = await this.api.getContragent(queryData);
655
626
  if (contragent.totalItems > 0) {
656
627
  if (contragent.items.length === 1) {
657
628
  return contragent.items[0];
658
629
  } else {
630
+ if (this.isPension && queryData.iin === '') return contragent.items.find(i => i.id === member.id);
659
631
  const sortedByRegistrationDate = contragent.items.sort(
660
632
  (left, right) => new Date(right.registrationDate).getMilliseconds() - new Date(left.registrationDate).getMilliseconds(),
661
633
  );
@@ -689,8 +661,8 @@ export const useDataStore = defineStore('data', {
689
661
  }
690
662
  },
691
663
  async saveContragent(user: Member, whichForm: keyof typeof StoreMembers | 'contragent', whichIndex: number | null, onlySaveAction: boolean = true) {
692
- if (this.isGons && user.iin && whichForm === 'beneficiaryForm' && useEnv().isProduction) {
693
- const doesHaveActiveContract = await this.api.checkBeneficiariesInActualPolicy(user.iin.replace(/-/g, ''));
664
+ if (this.isGons && user.iin && whichForm === 'beneficiaryForm') {
665
+ const doesHaveActiveContract = await this.api.checkBeneficiariesActualPolicy(String(this.formStore.applicationData.processInstanceId));
694
666
  if (doesHaveActiveContract) {
695
667
  this.showToaster('error', this.t('toaster.doesHaveActiveContract'), 6000);
696
668
  return false;
@@ -727,7 +699,7 @@ export const useDataStore = defineStore('data', {
727
699
  const contragentData: Types.ContragentType = {
728
700
  id: Number(user.id),
729
701
  type: Number(user.type),
730
- iin: user.iin!.replace(/-/g, ''),
702
+ iin: user.iin ? user.iin.replace(/-/g, '') : '',
731
703
  longName: user.longName !== null ? user.longName : (user.lastName ?? '') + (user.firstName ?? '') + (user.middleName ?? ''),
732
704
  lastName: user.lastName ?? '',
733
705
  firstName: user.firstName ?? '',
@@ -881,6 +853,11 @@ export const useDataStore = defineStore('data', {
881
853
  verifyType: user.verifyType,
882
854
  verifyDate: user.verifyDate,
883
855
  };
856
+ if (user.documentIssuers.ids === '1') {
857
+ userDocument.issuerOtherName = user.documentIssuers.issuerOtherName;
858
+ userDocument.issuerOtherNameOrig = user.documentIssuers.issuerOtherNameOrig;
859
+ userDocument.issuerOtherNameRu = user.documentIssuers.issuerOtherNameRu;
860
+ }
884
861
  if (hasAlreadyDocument !== -1) {
885
862
  documentsData[hasAlreadyDocument] = userDocument;
886
863
  } else {
@@ -954,7 +931,12 @@ export const useDataStore = defineStore('data', {
954
931
  isTerror: member.isTerror,
955
932
  isIpdlCompliance: null,
956
933
  isTerrorCompliance: null,
934
+ fromService: this.isGons && whichMember === 'Beneficiary' ? (member.chooseChild === 'Добавить выгодоприобретателя' ? false : true) : true,
957
935
  };
936
+
937
+ if (this.isPension && memberFromApplicaiton && memberFromApplicaiton.processInstanceId === this.formStore.applicationData.slave?.processInstanceId) {
938
+ data.processInstanceId = this.formStore.applicationData.slave.processInstanceId;
939
+ }
958
940
  data.id = memberFromApplicaiton && memberFromApplicaiton.id ? memberFromApplicaiton.id : null;
959
941
  if (whichMember === 'Client') {
960
942
  data.isInsured = this.formStore.isPolicyholderInsured;
@@ -964,6 +946,12 @@ export const useDataStore = defineStore('data', {
964
946
  data.jobName = member.jobPlace;
965
947
  data.positionCode = member.positionCode;
966
948
  data.familyStatusId = member.familyStatus.id;
949
+ if (this.isPension) {
950
+ data.id =
951
+ memberFromApplicaiton.processInstanceId === this.formStore.applicationData.processInstanceId
952
+ ? this.formStore.applicationData.clientApp.id
953
+ : this.formStore.applicationData.slave.clientApp.id;
954
+ }
967
955
  }
968
956
  if (whichMember === 'Spokesman') {
969
957
  if (!!memberFromApplicaiton && memberFromApplicaiton.iin !== data.iin) {
@@ -1022,6 +1010,12 @@ export const useDataStore = defineStore('data', {
1022
1010
  data.familyStatusId = member.familyStatus.id;
1023
1011
  data.relationId = member.relationDegree.ids;
1024
1012
  data.relationName = member.relationDegree.nameRu;
1013
+ if (this.isPension) {
1014
+ data.id =
1015
+ memberFromApplicaiton.processInstanceId === this.formStore.applicationData.processInstanceId
1016
+ ? this.formStore.applicationData.insuredApp[0].id
1017
+ : this.formStore.applicationData.slave.insuredApp[0].id;
1018
+ }
1025
1019
  }
1026
1020
  if (whichMember === 'Beneficiary') {
1027
1021
  if (
@@ -1066,10 +1060,20 @@ export const useDataStore = defineStore('data', {
1066
1060
  }
1067
1061
  }
1068
1062
  },
1069
- async setApplication(applicationData: object, calculate: boolean = false) {
1063
+ async setApplication(applicationData: any, calculate: boolean = false) {
1070
1064
  try {
1071
1065
  this.isLoading = true;
1072
1066
  this.isButtonsLoading = true;
1067
+ if (this.isPension) {
1068
+ applicationData.transferContractCompany = '';
1069
+ if (applicationData.slave) {
1070
+ applicationData.slave.guaranteedPeriod = applicationData.slave.guaranteedPeriod ?? 0;
1071
+ applicationData.slave.transferContractCompany = '';
1072
+ }
1073
+ if (Number(this.formStore.applicationData.processCode) === 24) {
1074
+ applicationData.transferContractAmount = applicationData.parentContractAmount - applicationData.refundAmount;
1075
+ }
1076
+ }
1073
1077
  await this.api.setApplication(applicationData);
1074
1078
  if (calculate) {
1075
1079
  await this.api.calculatePension(String(this.formStore.applicationData.processInstanceId));
@@ -1124,6 +1128,22 @@ export const useDataStore = defineStore('data', {
1124
1128
  conditionsData.policyAppDto.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1125
1129
  conditionsData.policyAppDto.currencyExchangeRate = this.currencies.usd;
1126
1130
  }
1131
+ if (this.isGons) {
1132
+ conditionsData.policyAppDto.premiumInCurrency =
1133
+ this.formStore.productConditionsForm.currency.code === 'KZT' ? null : getNumber(String(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar));
1134
+ conditionsData.policyAppDto.amountInCurrency =
1135
+ this.formStore.productConditionsForm.currency.code === 'KZT' ? null : getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1136
+ conditionsData.policyAppDto.currencyExchangeRate = this.formStore.productConditionsForm.currency.code === 'KZT' ? null : this.currencies.usd;
1137
+ conditionsData.policyAppDto.currency = this.formStore.productConditionsForm.currency.code as string;
1138
+ //@ts-ignore
1139
+ if (isNaN(String(this.formStore.productConditionsForm.requestedSumInsured).replace(/\s/g, ''))) {
1140
+ conditionsData.policyAppDto.amount = parseFloat(String(this.formStore.productConditionsForm.requestedSumInsured).replace(/\s/g, '').replace(',', '.'));
1141
+ }
1142
+ //@ts-ignore
1143
+ if (isNaN(String(this.formStore.productConditionsForm.insurancePremiumPerMonth).replace(/\s/g, ''))) {
1144
+ conditionsData.policyAppDto.premium = parseFloat(String(this.formStore.productConditionsForm.insurancePremiumPerMonth).replace(/\s/g, '').replace(',', '.'));
1145
+ }
1146
+ }
1127
1147
  if (this.isLiferenta) {
1128
1148
  conditionsData.policyAppDto.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1129
1149
  conditionsData.policyAppDto.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
@@ -1210,8 +1230,10 @@ export const useDataStore = defineStore('data', {
1210
1230
  }
1211
1231
  if (value !== null && this.formStore.definedAnswersId[whichSurvey][filter].length) {
1212
1232
  const answer = this.formStore.definedAnswersId[whichSurvey][filter].find((answer: any) => answer.nameRu.match(new RegExp(value, 'i')));
1213
- //@ts-ignore
1214
- this.formStore[whichSurvey].body[index].first.answerId = answer.ids;
1233
+ if (this.formStore[whichSurvey]) {
1234
+ //@ts-ignore
1235
+ this.formStore[whichSurvey].body[index].first.answerId = answer.ids;
1236
+ }
1215
1237
  }
1216
1238
  return this.formStore.definedAnswersId[whichSurvey];
1217
1239
  },
@@ -1243,6 +1265,8 @@ export const useDataStore = defineStore('data', {
1243
1265
  regionPolicyName: this.formStore.RegionPolicy.nameRu ?? '',
1244
1266
  managerPolicy: this.formStore.ManagerPolicy.ids as string,
1245
1267
  managerPolicyName: this.formStore.ManagerPolicy.nameRu ?? '',
1268
+ executorGPH: (this.formStore.ExecutorGPH.ids as string) ?? undefined,
1269
+ executorGPHName: this.formStore.ExecutorGPH.nameRu ?? undefined,
1246
1270
  insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
1247
1271
  };
1248
1272
  try {
@@ -1455,7 +1479,8 @@ export const useDataStore = defineStore('data', {
1455
1479
  return await this.getFromApi('economySectorCode', 'getSectorCode');
1456
1480
  },
1457
1481
  async getEconomicActivityType() {
1458
- if (this.isLifeBusiness || this.isGns || this.isDas || this.isUU || this.isPrePension) return await this.getFromApi('economicActivityType', 'getEconomicActivityType');
1482
+ const makeCall = this.isLifeBusiness || this.isGns || this.isDas || this.isUU || this.isPrePension || this.isCritical;
1483
+ if (makeCall) return await this.getFromApi('economicActivityType', 'getEconomicActivityType');
1459
1484
  },
1460
1485
  async getFamilyStatuses() {
1461
1486
  return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
@@ -1467,48 +1492,53 @@ export const useDataStore = defineStore('data', {
1467
1492
  return await this.getFromApi('relations', 'getRelationTypes');
1468
1493
  },
1469
1494
  async getBanks() {
1470
- if (this.isLifeBusiness || this.isDas || this.isUU || this.isPension || this.isGns || this.isPrePension || this.isDSO) return await this.getFromApi('banks', 'getBanks');
1495
+ const makeCall = this.isLifeBusiness || this.isDas || this.isUU || this.isPension || this.isGns || this.isPrePension || this.isDSO || this.isCritical;
1496
+ if (makeCall) return await this.getFromApi('banks', 'getBanks');
1471
1497
  },
1472
1498
  async getInsuranceCompanies() {
1473
1499
  if (this.isPension) return await this.getFromApi('transferContractCompanies', 'getInsuranceCompanies');
1474
1500
  },
1475
1501
  async getProcessIndexRate() {
1476
- if (this.processCode) {
1477
- return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
1478
- }
1502
+ const makeCall = (this.isBaiterek || this.isBolashak || this.isGons) && this.processCode;
1503
+ if (makeCall) return await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
1479
1504
  },
1480
1505
  async getProcessPaymentPeriod() {
1481
- if (this.processCode) {
1482
- return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
1483
- }
1506
+ const makeCall = !this.isPension && this.processCode;
1507
+ if (makeCall) return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
1508
+ },
1509
+ async getProgramType() {
1510
+ const makeCall = this.isCritical && this.processCode;
1511
+ if (makeCall) return await this.getFromApi('programType', 'getProgramType', this.processCode);
1484
1512
  },
1485
1513
  async getQuestionRefs(id?: string) {
1486
1514
  return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
1487
1515
  },
1488
- async getProcessTariff() {
1489
- if (this.processCode) return await this.getFromApi('processTariff', 'getProcessTariff', this.processCode);
1490
- },
1491
1516
  async getDicAnnuityTypeList() {
1492
1517
  return await this.getFromApi('dicAnnuityTypeList', 'getDicAnnuityTypeList');
1493
1518
  },
1494
1519
  async getProcessAnnuityPaymentPeriod() {
1495
- if (this.processCode) {
1496
- return await this.getFromApi('processAnnuityPaymentPeriod', 'getProcessAnnuityPaymentPeriod', this.processCode);
1497
- }
1520
+ const makeCall = this.isLiferenta && this.processCode;
1521
+ if (makeCall) return await this.getFromApi('processAnnuityPaymentPeriod', 'getProcessAnnuityPaymentPeriod', this.processCode);
1498
1522
  },
1499
1523
  async getInsurancePay() {
1500
1524
  return await this.getFromApi('insurancePay', 'getInsurancePay');
1501
1525
  },
1502
1526
  async getProcessGfot() {
1503
- if (this.processCode) {
1504
- return await this.getFromApi('processGfot', 'getProcessGfot', this.processCode);
1505
- }
1527
+ const makeCall = (this.isLifeBusiness || this.isGns) && this.processCode;
1528
+ if (makeCall) return await this.getFromApi('processGfot', 'getProcessGfot', this.processCode);
1529
+ },
1530
+ async getSource() {
1531
+ return await this.getFromApi('Source', 'getSource');
1506
1532
  },
1507
1533
  async getCurrencies() {
1508
1534
  try {
1509
- const currencies = await this.api.getCurrencies();
1510
- this.currencies = currencies;
1511
- return currencies;
1535
+ const makeCall = !this.isLKA && !this.isLKA_A;
1536
+ if (makeCall) {
1537
+ const currencies = await this.api.getCurrencies();
1538
+ this.currencies = currencies;
1539
+ return currencies;
1540
+ }
1541
+ return null;
1512
1542
  } catch (err) {
1513
1543
  console.log(err);
1514
1544
  }
@@ -1521,7 +1551,8 @@ export const useDataStore = defineStore('data', {
1521
1551
  return this.gender;
1522
1552
  },
1523
1553
  async getAuthorityBasis() {
1524
- if (this.isDas || this.isLifeBusiness || this.isGns || this.isUU || this.isPrePension) return await this.getFromApi('authorityBasis', 'getArmDicts', 'DicAuthorityBasis');
1554
+ if (this.isDas || this.isLifeBusiness || this.isGns || this.isUU || this.isPrePension || this.isCritical)
1555
+ return await this.getFromApi('authorityBasis', 'getArmDicts', 'DicAuthorityBasis');
1525
1556
  },
1526
1557
  async getWorkPosition(search: string) {
1527
1558
  try {
@@ -1549,8 +1580,8 @@ export const useDataStore = defineStore('data', {
1549
1580
  this.getFamilyStatuses(),
1550
1581
  this.getRelationTypes(),
1551
1582
  this.getProcessIndexRate(),
1552
- this.getProcessTariff(),
1553
1583
  this.getProcessPaymentPeriod(),
1584
+ this.getProgramType(),
1554
1585
  this.getDicFileTypeList(),
1555
1586
  this.getDicAnnuityTypeList(),
1556
1587
  this.getProcessAnnuityPaymentPeriod(),
@@ -1564,6 +1595,7 @@ export const useDataStore = defineStore('data', {
1564
1595
  this.getDicTripPurpose(),
1565
1596
  this.getCurrencies(),
1566
1597
  this.getProcessGfot(),
1598
+ this.getSource(),
1567
1599
  this.getBanks(),
1568
1600
  this.getInsuranceCompanies(),
1569
1601
  this.getEconomicActivityType(),
@@ -1592,16 +1624,19 @@ export const useDataStore = defineStore('data', {
1592
1624
  if (secondaryQuestions.status === 'fulfilled') {
1593
1625
  const baseAnketa = this.formStore[baseField];
1594
1626
  if (baseAnketa && baseAnketa.body && baseAnketa.body.length) {
1595
- baseAnketa.body.forEach(i => {
1596
- if (i.first.definedAnswers === 'Y' && i.second === null && secondaryQuestions.value) {
1597
- i.second = structuredClone(secondaryQuestions.value);
1627
+ const isSpecialSurvey = this.isBaiterek || this.isBolashak || this.isLiferenta;
1628
+ for (const i of baseAnketa.body) {
1629
+ if (i.second === null && secondaryQuestions.value) {
1630
+ i.second = isSpecialSurvey
1631
+ ? await this.api.getQuestionListSecondById(`${surveyType}second`, processInstanceId, insuredId, i.first.id)
1632
+ : structuredClone(secondaryQuestions.value);
1598
1633
  }
1599
1634
  if (i.first.definedAnswers === 'Y' && i.second && i.second.length) {
1600
1635
  i.second.forEach(second => {
1601
1636
  if (second.answerType === 'D') second.answerText = reformatDate(String(second.answerText));
1602
1637
  });
1603
1638
  }
1604
- });
1639
+ }
1605
1640
  }
1606
1641
  }
1607
1642
  } catch (err) {
@@ -1621,11 +1656,11 @@ export const useDataStore = defineStore('data', {
1621
1656
  return n === null
1622
1657
  ? null
1623
1658
  : n
1624
- .toLocaleString('ru', {
1625
- maximumFractionDigits: 2,
1626
- minimumFractionDigits: 2,
1627
- })
1628
- .replace(/,/g, '.');
1659
+ .toLocaleString('ru', {
1660
+ maximumFractionDigits: 2,
1661
+ minimumFractionDigits: 2,
1662
+ })
1663
+ .replace(/,/g, '.');
1629
1664
  },
1630
1665
  async getTaskList(
1631
1666
  search: string = '',
@@ -1659,23 +1694,23 @@ export const useDataStore = defineStore('data', {
1659
1694
  column: column,
1660
1695
  direction: direction,
1661
1696
  groupCode: groupCode,
1662
- processCodes: Object.values(constants.products),
1697
+ processCodes: this.isEFO
1698
+ ? Object.values(constants.products).filter(
1699
+ i => i !== constants.products.pensionannuity && i !== constants.products.pensionannuityrefund && i !== constants.products.pensionannuityjoint,
1700
+ )
1701
+ : [constants.products.baiterek],
1663
1702
  };
1664
1703
  if (byOneProcess !== null) {
1665
1704
  delete query.processCodes;
1666
1705
  query.processCode = byOneProcess;
1667
1706
  }
1668
- if (byOneProcess === 19 && !useEnv().isProduction) {
1669
- query.processCodes = [19, 2];
1670
- delete query.processCode;
1671
- }
1672
1707
  const taskList = await this.api.getTaskList(
1673
1708
  processInstanceId === null
1674
1709
  ? query
1675
1710
  : {
1676
- ...query,
1677
- processInstanceId: processInstanceId,
1678
- },
1711
+ ...query,
1712
+ processInstanceId: processInstanceId,
1713
+ },
1679
1714
  );
1680
1715
  if (needToReturn) {
1681
1716
  this.isLoading = false;
@@ -1782,6 +1817,13 @@ export const useDataStore = defineStore('data', {
1782
1817
  console.log(err);
1783
1818
  }
1784
1819
  },
1820
+ async filterExecutorByRegion(filterName: string) {
1821
+ try {
1822
+ this.ExecutorGPH = await this.api.filterExecutorByRegion('ExecutorGPH', filterName);
1823
+ } catch (err) {
1824
+ console.log(err);
1825
+ }
1826
+ },
1785
1827
  async getUnderwritingCouncilData(id: string | number) {
1786
1828
  try {
1787
1829
  const response: any = await this.api.getUnderwritingCouncilData(id);
@@ -1804,7 +1846,10 @@ export const useDataStore = defineStore('data', {
1804
1846
  async getDefaultCalculationData(showLoader: boolean = false, product: string | null = null) {
1805
1847
  this.isLoading = showLoader;
1806
1848
  try {
1807
- const calculationData = await this.api.getDefaultCalculationData(this.isCalculator ? product : undefined);
1849
+ const calculationData = await this.api.getDefaultCalculationData(
1850
+ this.isCalculator ? product : undefined,
1851
+ this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns' ? Number(this.processCode) : undefined,
1852
+ );
1808
1853
  return calculationData;
1809
1854
  } catch (err) {
1810
1855
  ErrorHandler(err);
@@ -1892,6 +1937,23 @@ export const useDataStore = defineStore('data', {
1892
1937
  calculationData.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1893
1938
  calculationData.currencyExchangeRate = this.currencies.usd;
1894
1939
  }
1940
+ if (this.isGons || product === 'gons') {
1941
+ calculationData.premiumInCurrency =
1942
+ this.formStore.productConditionsForm.currency.code === 'KZT' ? null : getNumber(String(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar));
1943
+ calculationData.amountInCurrency =
1944
+ this.formStore.productConditionsForm.currency.code === 'KZT' ? null : getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1945
+ calculationData.currencyExchangeRate = this.formStore.productConditionsForm.currency.code === 'KZT' ? null : this.currencies.usd;
1946
+
1947
+ calculationData.currency = this.formStore.productConditionsForm.currency.code as string;
1948
+ //@ts-ignore
1949
+ if (isNaN(String(this.formStore.productConditionsForm.requestedSumInsured).replace(/\s/g, ''))) {
1950
+ calculationData.amount = parseFloat(String(this.formStore.productConditionsForm.requestedSumInsured).replace(/\s/g, '').replace(',', '.'));
1951
+ }
1952
+ //@ts-ignore
1953
+ if (isNaN(String(this.formStore.productConditionsForm.insurancePremiumPerMonth).replace(/\s/g, ''))) {
1954
+ calculationData.premium = parseFloat(String(this.formStore.productConditionsForm.insurancePremiumPerMonth).replace(/\s/g, '').replace(',', '.'));
1955
+ }
1956
+ }
1895
1957
  if (this.isLiferenta || product === 'liferenta') {
1896
1958
  calculationData.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1897
1959
  calculationData.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
@@ -1909,11 +1971,20 @@ export const useDataStore = defineStore('data', {
1909
1971
  calculationData.contractEndDate = formatDate(this.formStore.productConditionsForm.contractEndDate as string)!.toISOString();
1910
1972
  calculationData.calcDate = formatDate(this.formStore.productConditionsForm.calcDate as string)!.toISOString();
1911
1973
  }
1912
- const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1913
- if (calculationResponse.amount) this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1914
- if (calculationResponse.premium) this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1974
+ const calculationResponse = await this.api.calculateWithoutApplication(
1975
+ calculationData,
1976
+ this.isCalculator ? product : undefined,
1977
+ this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns' ? Number(this.processCode) : undefined,
1978
+ );
1979
+ if (calculationResponse.amount)
1980
+ this.formStore.productConditionsForm.requestedSumInsured =
1981
+ this.isGons || product === 'gons' ? this.getNumberWithSpacesAfterComma(calculationResponse.amount) : this.getNumberWithSpaces(calculationResponse.amount);
1982
+ if (calculationResponse.premium)
1983
+ this.formStore.productConditionsForm.insurancePremiumPerMonth =
1984
+ this.isGons || product === 'gons' ? this.getNumberWithSpacesAfterComma(calculationResponse.premium) : this.getNumberWithSpaces(calculationResponse.premium);
1985
+
1915
1986
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1916
- if (this.isKazyna || product === 'halykkazyna') {
1987
+ if (this.isKazyna || product === 'halykkazyna' || this.isGons || product === 'gons') {
1917
1988
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
1918
1989
  this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(calculationResponse.amountInCurrency);
1919
1990
  } else {
@@ -1930,7 +2001,7 @@ export const useDataStore = defineStore('data', {
1930
2001
  this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(calculationResponse.statePremium7);
1931
2002
  }
1932
2003
  if (this.isLifeBusiness || product === 'lifebusiness' || this.isGns || product === 'gns') {
1933
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.mainPremiumWithCommission);
2004
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpacesAfterComma(calculationResponse.mainPremiumWithCommission as number);
1934
2005
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.mainInsSum === 0 ? null : calculationResponse.mainInsSum);
1935
2006
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1936
2007
  if (calculationResponse.agentCommission) {
@@ -1950,17 +2021,23 @@ export const useDataStore = defineStore('data', {
1950
2021
  return !!this.formStore.productConditionsForm.requestedSumInsured && !!this.formStore.productConditionsForm.insurancePremiumPerMonth;
1951
2022
  }
1952
2023
  },
1953
- async calculate(taskId: string) {
2024
+ async calculate(taskId: string, isHalykBank: boolean = false) {
1954
2025
  this.isLoading = true;
1955
2026
  try {
1956
2027
  const id = this.formStore.applicationData.processInstanceId;
1957
- if (!this.isPension) await this.api.setApplication(this.getConditionsData());
2028
+ if (!this.isPension && !(this.formStore.lfb.add && (this.isLifeBusiness || this.isGns))) await this.api.setApplication(this.getConditionsData());
1958
2029
  const result = ref();
1959
- result.value = await this.api.getCalculation(String(id));
1960
- const applicationData = await this.api.getApplicationData(taskId);
2030
+ let applicationData = null;
2031
+ if (!isHalykBank) result.value = await this.api.getCalculation(String(id));
2032
+ if (this.isLifeBusiness || this.isGns) {
2033
+ await this.getApplicationDataV2(taskId);
2034
+ return;
2035
+ } else {
2036
+ applicationData = await this.api.getApplicationData(taskId);
2037
+ }
1961
2038
  this.formStore.applicationData = applicationData;
1962
2039
  if (this.formStore.applicationData.addCoverDto) this.formStore.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
1963
- if (this.isKazyna && this.currencies.usd) {
2040
+ if ((this.isKazyna || this.isGons) && this.currencies.usd) {
1964
2041
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
1965
2042
  this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(result.value / this.currencies.usd);
1966
2043
  } else {
@@ -1968,11 +2045,15 @@ export const useDataStore = defineStore('data', {
1968
2045
  }
1969
2046
  }
1970
2047
  if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
1971
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result.value);
1972
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(applicationData.policyAppDto.premium);
2048
+ this.formStore.productConditionsForm.requestedSumInsured = this.isGons ? this.getNumberWithSpacesAfterComma(result.value) : this.getNumberWithSpaces(result.value);
2049
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.isGons
2050
+ ? this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.premium)
2051
+ : this.getNumberWithSpaces(applicationData.policyAppDto.premium);
1973
2052
  } else {
1974
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
1975
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(applicationData.policyAppDto.amount);
2053
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.isGons ? this.getNumberWithSpacesAfterComma(result.value) : this.getNumberWithSpaces(result.value);
2054
+ this.formStore.productConditionsForm.requestedSumInsured = this.isGons
2055
+ ? this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.amount)
2056
+ : this.getNumberWithSpaces(applicationData.policyAppDto.amount);
1976
2057
  }
1977
2058
  if (this.isLiferenta) {
1978
2059
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(applicationData.policyAppDto.annuityMonthPay);
@@ -1985,11 +2066,22 @@ export const useDataStore = defineStore('data', {
1985
2066
  this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
1986
2067
  }
1987
2068
  if (this.isLifeBusiness || this.isGns) {
1988
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
2069
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpacesAfterComma(result.value);
1989
2070
  if (applicationData.insuredApp && applicationData.insuredApp.length) {
1990
2071
  const res = await this.newInsuredList(applicationData.insuredApp);
1991
2072
  this.formStore.lfb.clients = res;
1992
2073
  }
2074
+ if (this.formStore.lfb.add) {
2075
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.premium);
2076
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.amount);
2077
+ if (applicationData.policyAppDto.mainPremiumWithCommission > 0) {
2078
+ this.formStore.productConditionsForm.amountPaid = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.mainPremiumWithCommission);
2079
+ this.formStore.productConditionsForm.amountRefunded = null;
2080
+ } else {
2081
+ this.formStore.productConditionsForm.amountRefunded = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.mainPremiumWithCommission);
2082
+ this.formStore.productConditionsForm.amountPaid = null;
2083
+ }
2084
+ }
1993
2085
  }
1994
2086
 
1995
2087
  this.showToaster('success', this.t('toaster.calculated'), 1000);
@@ -1998,6 +2090,53 @@ export const useDataStore = defineStore('data', {
1998
2090
  }
1999
2091
  this.isLoading = false;
2000
2092
  },
2093
+ async reCalculateRefund(insSum: number, insSumMain: number, guaranteedPeriod: number, isOppv: boolean, transferContractMonthCount: number | null) {
2094
+ this.isLoading = true;
2095
+ try {
2096
+ const data = {
2097
+ processInstanceId: this.formStore.applicationData.processInstanceId,
2098
+ insSum: insSum,
2099
+ insSumMain: insSumMain,
2100
+ guaranteedPeriod: guaranteedPeriod,
2101
+ isOppv: isOppv,
2102
+ transferContractMonthCount: transferContractMonthCount,
2103
+ };
2104
+ const response = await this.api.pensionannuityNew.reCalculateRefund(data);
2105
+ } catch (err) {
2106
+ ErrorHandler(err);
2107
+ }
2108
+ this.isLoading = false;
2109
+ },
2110
+ async getDividendSchedule() {
2111
+ this.isLoading = true;
2112
+ try {
2113
+ const response = await this.api.pensionannuityNew.getDividendSchedule(this.formStore.applicationData.processInstanceId);
2114
+ return response;
2115
+ } catch (err) {
2116
+ ErrorHandler(err);
2117
+ return {
2118
+ "scheduleDividend": null,
2119
+ "scheduleDividend2": null
2120
+ };
2121
+ } finally {
2122
+ this.isLoading = false;
2123
+ }
2124
+ },
2125
+ async calcParentContractSums(closeContractCompanyCode: string, closeContractCompanyName: string, isContractClosed: boolean) {
2126
+ this.isLoading = true;
2127
+ try {
2128
+ const data = {
2129
+ processInstanceId: this.formStore.applicationData.processInstanceId,
2130
+ closeContractCompanyCode: closeContractCompanyCode,
2131
+ closeContractCompanyName: closeContractCompanyName,
2132
+ isContractClosed: isContractClosed,
2133
+ };
2134
+ const response = await this.api.pensionannuityNew.calcParentContractSums(data);
2135
+ } catch (err) {
2136
+ ErrorHandler(err);
2137
+ }
2138
+ this.isLoading = false;
2139
+ },
2001
2140
  async calculatePremium(data: any) {
2002
2141
  this.isLoading = true;
2003
2142
  try {
@@ -2084,11 +2223,6 @@ export const useDataStore = defineStore('data', {
2084
2223
  this.isLoading = onlyGet;
2085
2224
  try {
2086
2225
  const applicationData = await this.api.getApplicationData(taskId);
2087
- if (this.processCode !== applicationData.processCode && !this.isPension) {
2088
- this.isLoading = false;
2089
- this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
2090
- return;
2091
- }
2092
2226
  this.formStore.regNumber = applicationData.regNumber;
2093
2227
  this.formStore.applicationData = applicationData;
2094
2228
  this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
@@ -2099,13 +2233,23 @@ export const useDataStore = defineStore('data', {
2099
2233
  this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
2100
2234
  this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
2101
2235
  this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
2236
+ this.formStore.ExecutorGPH.nameRu = applicationData.insisWorkDataApp.executorGPHName;
2237
+ this.formStore.ExecutorGPH.ids = applicationData.insisWorkDataApp.executorGPH;
2102
2238
  this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
2103
2239
  this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
2104
2240
  this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
2105
2241
  this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
2242
+ if ('sourceId' in applicationData.insisWorkDataApp && applicationData.insisWorkDataApp.sourceId !== null) {
2243
+ const source = this.Source.find((i: Value) => i.id === applicationData.insisWorkDataApp.sourceId);
2244
+ this.formStore.Source = source ? source : new Value();
2245
+ } else {
2246
+ const sourceEfo = this.Source.find((i: Value) => i.id === '3f9e5327-328c-4bc7-8d28-fa25c36ba153');
2247
+ this.formStore.Source = sourceEfo ? sourceEfo : new Value();
2248
+ }
2106
2249
 
2107
2250
  const clientData = applicationData.clientApp;
2108
2251
  const insuredData: any[] = applicationData.insuredApp;
2252
+ const slaveInsuredData: any = applicationData.slave?.insuredApp[0] ?? null;
2109
2253
  const beneficiaryData: any[] = applicationData.beneficiaryApp;
2110
2254
  const beneficialOwnerData: any[] = applicationData.beneficialOwnerApp;
2111
2255
  const spokesmanData: any = applicationData.spokesmanApp;
@@ -2119,6 +2263,21 @@ export const useDataStore = defineStore('data', {
2119
2263
  this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
2120
2264
  }
2121
2265
 
2266
+ if ('pensionApp' in applicationData && applicationData.pensionApp) {
2267
+ this.formStore.pensionApp = applicationData.pensionApp;
2268
+ if ('slave' in applicationData && applicationData.slave) this.formStore.pensionApp.slave = applicationData.slave.pensionApp;
2269
+ if (setProductConditions) {
2270
+ const pensionKeysWithSpace = ['compulsoryContractAmount', 'compulsoryProfContractAmount', 'voluntaryContractAmount', 'ownFundsRaisAmount'];
2271
+ pensionKeysWithSpace.forEach(key => {
2272
+ if (/\s/g.test(this.formStore.pensionApp[key]) === false) this.formStore.pensionApp[key] = this.getNumberWithSpaces(this.formStore.pensionApp[key]);
2273
+ });
2274
+ if (this.formStore.pensionApp.slave)
2275
+ pensionKeysWithSpace.forEach(key => {
2276
+ if (/\s/g.test(this.formStore.pensionApp.slave[key]) === false)
2277
+ this.formStore.pensionApp.slave[key] = this.getNumberWithSpaces(this.formStore.pensionApp.slave[key]);
2278
+ });
2279
+ }
2280
+ }
2122
2281
  if ('finCenterData' in applicationData && !!applicationData.finCenterData) {
2123
2282
  this.formStore.finCenterData = applicationData.finCenterData;
2124
2283
  this.formStore.finCenterData.regNumber = applicationData.finCenterData.regNumber;
@@ -2183,11 +2342,6 @@ export const useDataStore = defineStore('data', {
2183
2342
  index: null,
2184
2343
  });
2185
2344
  }
2186
-
2187
- if (applicationData.slave) {
2188
- insuredData.push(applicationData.slave.insuredApp[0]);
2189
- }
2190
-
2191
2345
  if (insuredData && insuredData.length) {
2192
2346
  insuredData.forEach((member, index) => {
2193
2347
  const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
@@ -2201,6 +2355,13 @@ export const useDataStore = defineStore('data', {
2201
2355
  }
2202
2356
  });
2203
2357
  }
2358
+ if (slaveInsuredData) {
2359
+ allMembers.push({
2360
+ ...slaveInsuredData,
2361
+ key: 'slaveInsuredForm',
2362
+ index: null,
2363
+ });
2364
+ }
2204
2365
  if (beneficiaryData && beneficiaryData.length) {
2205
2366
  beneficiaryData.forEach((member, index) => {
2206
2367
  const inStore = this.formStore.beneficiaryForm.find(each => each.id == member.insisId);
@@ -2238,18 +2399,23 @@ export const useDataStore = defineStore('data', {
2238
2399
  this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
2239
2400
  if (insuredData && insuredData.length) {
2240
2401
  insuredData.forEach((each, index) => {
2241
- this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
2242
- const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
2243
- this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
2402
+ if (each) {
2403
+ this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
2404
+ const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
2405
+ this.formStore.insuredForm[index].relationDegree = relationDegree ? relationDegree : new Value();
2406
+ }
2244
2407
  });
2245
2408
  }
2246
-
2409
+ if (slaveInsuredData) this.setMembersFieldSlave();
2247
2410
  if (beneficiaryData && beneficiaryData.length) {
2248
2411
  beneficiaryData.forEach((each, index) => {
2249
2412
  this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
2250
2413
  const relationDegree = this.relations.find((i: Value) => i.ids == each.relationId);
2251
2414
  this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
2252
2415
  this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
2416
+ if (this.isGons) {
2417
+ this.formStore.beneficiaryForm[index].chooseChild = each.fromService === false ? 'Добавить выгодоприобретателя' : each.longName;
2418
+ }
2253
2419
  if (this.isLiferenta || this.isBolashak) {
2254
2420
  const insurancePay = this.insurancePay.find((i: Value) => i.id == each.beneficiaryInsurancePayId);
2255
2421
  this.formStore.beneficiaryForm[index].insurancePay = insurancePay ? insurancePay : new Value();
@@ -2321,15 +2487,32 @@ export const useDataStore = defineStore('data', {
2321
2487
  const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
2322
2488
  this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
2323
2489
 
2324
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(
2325
- applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount,
2326
- );
2327
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
2328
- applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
2329
- );
2330
- if (this.isKazyna) {
2490
+ this.formStore.productConditionsForm.requestedSumInsured = this.isGons
2491
+ ? this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount)
2492
+ : this.getNumberWithSpaces(applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount);
2493
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.isGons
2494
+ ? this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium)
2495
+ : this.getNumberWithSpaces(applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium);
2496
+
2497
+ if (this.isGons) {
2498
+ const govPremiums = await this.api.getGovernmentPremiums(String(this.formStore.applicationData.processInstanceId));
2499
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(govPremiums.totalAmount5 === null ? null : govPremiums.totalAmount5);
2500
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(govPremiums.totalAmount7 === null ? null : govPremiums.totalAmount7);
2501
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(govPremiums.statePremium5 === null ? null : govPremiums.statePremium5);
2502
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
2503
+ const currency = constants.currencyList.find(item => item.code === applicationData.policyAppDto.currency);
2504
+ this.formStore.productConditionsForm.currency = currency ? currency : new Value();
2505
+ }
2506
+
2507
+ if (this.isKazyna || this.isGons) {
2331
2508
  this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.amountInCurrency);
2332
- this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(applicationData.policyAppDto.premiumInCurrency);
2509
+ this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar =
2510
+ this.formStore.applicationData.processCode === constants.products.halykkazynaap
2511
+ ? this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.premiumInCurrency)
2512
+ : this.getNumberWithSpaces(applicationData.policyAppDto.premiumInCurrency);
2513
+ if (applicationData.policyAppDto.currency === 'USD' && applicationData.policyAppDto.amount !== null && applicationData.policyAppDto.premium !== null) {
2514
+ this.currencies.usd = applicationData.policyAppDto.currencyExchangeRate;
2515
+ }
2333
2516
  }
2334
2517
  const riskGroup = this.riskGroup.find(item => {
2335
2518
  if (applicationData.policyAppDto.riskGroup == 0) {
@@ -2410,6 +2593,7 @@ export const useDataStore = defineStore('data', {
2410
2593
  case constants.actions.signed:
2411
2594
  case constants.actions.rejectclient:
2412
2595
  case constants.actions.accept:
2596
+ case constants.actions.recalc:
2413
2597
  case constants.actions.payed: {
2414
2598
  try {
2415
2599
  const sended = await this.sendTask(taskId, action, comment);
@@ -2463,9 +2647,14 @@ export const useDataStore = defineStore('data', {
2463
2647
  }
2464
2648
  },
2465
2649
  async createInvoice() {
2466
- if (!this.formStore.applicationData.policyAppDto?.premium) return;
2650
+ const premium =
2651
+ this.isLifeBusiness || this.isGns ? this.formStore.applicationData.policyAppDto?.mainPremiumWithCommission : this.formStore.applicationData.policyAppDto?.premium;
2652
+ if (!premium) {
2653
+ this.showToaster('error', this.t('toaster.notZeroPremium'));
2654
+ return;
2655
+ }
2467
2656
  try {
2468
- const created = await this.api.createInvoice(this.formStore.applicationData.processInstanceId, this.formStore.applicationData.policyAppDto.premium);
2657
+ const created = await this.api.createInvoice(this.formStore.applicationData.processInstanceId, premium);
2469
2658
  return !!created;
2470
2659
  } catch (err) {
2471
2660
  this.isLoading = false;
@@ -2498,14 +2687,43 @@ export const useDataStore = defineStore('data', {
2498
2687
  const disabilityGroup = this.disabilityGroups.find(i => i.id === this.formStore.applicationData[whichMember].disabilityGroupId);
2499
2688
  this.formStore[whichForm].disabilityGroup = disabilityGroup ? disabilityGroup : new Value();
2500
2689
  }
2501
- if (whichForm === this.formStore.policyholderFormKey && this.isPension && 'pensionApp' in this.formStore.applicationData && !!this.formStore.applicationData.pensionApp) {
2502
- this.formStore[whichForm].bankInfo.iik = this.formStore.applicationData.pensionApp.account;
2503
- this.formStore[whichForm].bankInfo.bik = this.formStore.applicationData.pensionApp.bankBik;
2504
- const bank = this.banks.find(i => i.ids === this.formStore.applicationData.pensionApp.bankBin);
2505
- const transferCompany = this.transferContractCompanies.find(i => i.nameRu === this.formStore.applicationData.pensionApp.transferContractCompany);
2506
- this.formStore[whichForm].bankInfo.bankName = bank ? bank : new Value();
2507
- this.formStore[whichForm].bankInfo.bin = bank ? String(bank.ids) : '';
2508
- this.formStore.applicationData.pensionApp.transferContractCompany = transferCompany ? transferCompany : new Value();
2690
+ if (whichForm === this.formStore.policyholderFormKey && this.isPension && 'pensionApp' in this.formStore.applicationData && !!this.formStore.pensionApp) {
2691
+ this.formStore[whichForm].bankInfo.iik = this.formStore.pensionApp.account;
2692
+ this.formStore[whichForm].bankInfo.bik = this.formStore.pensionApp.bankBik;
2693
+ this.formStore[whichForm].bankInfo.bankName.id = this.formStore.pensionApp.bankId;
2694
+ this.formStore[whichForm].bankInfo.bankName.nameRu = this.formStore.pensionApp.bankName;
2695
+ this.formStore[whichForm].bankInfo.bin = reformatIin(this.formStore.pensionApp.bankBin);
2696
+ const transferCompany = this.transferContractCompanies.find(i => i.nameRu === this.formStore.pensionApp.transferContractCompany);
2697
+ this.formStore.pensionApp.transferContractCompany = transferCompany ? transferCompany : new Value();
2698
+ }
2699
+ },
2700
+ setMembersFieldSlave() {
2701
+ this.formStore.slaveInsuredForm.familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData.slave['insuredApp'].familyStatusId);
2702
+ this.formStore.slaveInsuredForm.signOfIPDL = this.findObject(
2703
+ 'ipdl',
2704
+ 'nameRu',
2705
+ this.formStore.applicationData.slave.insuredApp[0].isIpdl === null ? null : this.formStore.applicationData.slave.insuredApp[0].isIpdl == true ? 'Да' : 'Нет',
2706
+ );
2707
+ this.formStore.slaveInsuredForm.gotFromInsis = false;
2708
+ if (!!this.formStore.applicationData.slave.insuredApp[0].profession) this.formStore.slaveInsuredForm.job = this.formStore.applicationData.slave.insuredApp[0].profession;
2709
+ if (!!this.formStore.applicationData.slave.insuredApp[0].position) this.formStore.slaveInsuredForm.jobPosition = this.formStore.applicationData.slave.insuredApp[0].position;
2710
+ if (!!this.formStore.applicationData.slave.insuredApp[0].jobName) this.formStore.slaveInsuredForm.jobPlace = this.formStore.applicationData.slave.insuredApp[0].jobName;
2711
+ if (!!this.formStore.applicationData.slave.insuredApp[0].positionCode)
2712
+ this.formStore.slaveInsuredForm.positionCode = this.formStore.applicationData.slave.insuredApp[0].positionCode;
2713
+ if (typeof this.formStore.applicationData.slave.insuredApp[0].isDisability === 'boolean')
2714
+ this.formStore.slaveInsuredForm.isDisability = this.formStore.applicationData.slave.insuredApp[0].isDisability;
2715
+ if (!!this.formStore.applicationData.slave.insuredApp[0].disabilityGroupId) {
2716
+ const disabilityGroup = this.disabilityGroups.find(i => i.id === this.formStore.applicationData.slave.insuredApp[0].disabilityGroupId);
2717
+ this.formStore.slaveInsuredForm.disabilityGroup = disabilityGroup ? disabilityGroup : new Value();
2718
+ }
2719
+ if (this.formStore.slaveInsuredForm.bankInfo) {
2720
+ this.formStore.slaveInsuredForm.bankInfo.iik = this.formStore.pensionApp.slave.account;
2721
+ this.formStore.slaveInsuredForm.bankInfo.bik = this.formStore.pensionApp.slave.bankBik;
2722
+ this.formStore.slaveInsuredForm.bankInfo.bankName.id = this.formStore.pensionApp.slave.bankId;
2723
+ this.formStore.slaveInsuredForm.bankInfo.bankName.nameRu = this.formStore.pensionApp.slave.bankName;
2724
+ this.formStore.slaveInsuredForm.bankInfo.bin = reformatIin(this.formStore.pensionApp.slave.bankBin);
2725
+ const transferCompany = this.transferContractCompanies.find(i => i.nameRu === this.formStore.pensionApp.slave.transferContractCompany);
2726
+ this.formStore.pensionApp.slave.transferContractCompany = transferCompany ? transferCompany : new Value();
2509
2727
  }
2510
2728
  },
2511
2729
  setMembersFieldIndex(whichForm: Types.MultipleMember, whichMember: keyof typeof MemberAppCodes, index: number) {
@@ -2602,94 +2820,17 @@ export const useDataStore = defineStore('data', {
2602
2820
  };
2603
2821
  const data = prepareSignDocuments();
2604
2822
  if (type === 'qr') {
2605
- const groupId = await this.api.signQR(data);
2823
+ const groupId = await this.api.file.signQR(data);
2606
2824
  return groupId;
2607
2825
  } else if (type === 'qrXml') {
2608
- const signData = await this.api.signXml(data);
2826
+ const signData = await this.api.file.signXml(data);
2609
2827
  return signData;
2610
- } else if (type === 'signature') {
2611
- const ncaLayerClient = new NCALayerClient();
2612
- const formTemplate = new FormData();
2613
- formTemplate.append('format', 'pdf');
2614
- formTemplate.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2615
- let activeTokens;
2616
- try {
2617
- await ncaLayerClient.connect();
2618
- activeTokens = await ncaLayerClient.getActiveTokens();
2619
- const storageType = activeTokens[0] || NCALayerClient.fileStorageType;
2620
- if (this.formStore.applicationData.statusCode === 'ContractSignedFrom') {
2621
- const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2622
- const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2623
- const formData = formTemplate;
2624
- formData.append('base64EncodedSignature', base64EncodedSignature);
2625
- formData.append('name', 'PA_Contract');
2626
- try {
2627
- await this.api.uploadDigitalCertifijcate(formData);
2628
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2629
- } catch (e) {
2630
- this.showToaster('error', String(e));
2631
- return;
2632
- }
2633
- } else if (this.formStore.applicationData.statusCode === 'HeadManagerForm') {
2634
- const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2635
- const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2636
- const formData = formTemplate;
2637
- formData.append('base64EncodedSignature', base64EncodedSignature);
2638
- formData.append('name', 'PA_Contract');
2639
- try {
2640
- await this.api.uploadDigitalCertificatePensionAnnuityNew(formData);
2641
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2642
- } catch (e) {
2643
- this.showToaster('error', String(e));
2644
- return;
2645
- }
2646
- } else {
2647
- if (!!this.formStore.signedDocumentList.find(i => i.fileTypeCode === '43')?.signed) {
2648
- const statement = await this.generatePDFDocument('PA_Statement', '37', 'pdf');
2649
- const statementSignature = await ncaLayerClient.basicsSignCMS(storageType, statement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2650
- const statementData = formTemplate;
2651
- statementData.append('base64EncodedSignature', statementSignature);
2652
- statementData.append('name', 'PA_Statement');
2653
- await this.api.uploadDigitalCertifijcate(statementData);
2654
- const agreement = await this.generatePDFDocument('Agreement', '19', 'pdf');
2655
- const agreementSignature = await ncaLayerClient.basicsSignCMS(storageType, agreement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2656
- const agreementData = formTemplate;
2657
- agreementData.append('base64EncodedSignature', agreementSignature);
2658
- agreementData.append('name', 'Agreement');
2659
- await this.api.uploadDigitalCertifijcate(agreementData);
2660
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2661
- } else {
2662
- const document = {
2663
- processInstanceId: String(this.formStore.applicationData.processInstanceId),
2664
- name: 'PAEnpf_Agreement',
2665
- format: 'xml',
2666
- };
2667
- const signData = await this.api.signXml([document]);
2668
- const agreementXml = await this.api.getDocumentsByEdsXmlId(signData.data);
2669
- const wnd = window.open('about:blank', '', '_blank');
2670
- wnd?.document.write(agreementXml.data.document.documentXml);
2671
- const signedAgreement = await ncaLayerClient.signXml(storageType, agreementXml.data.document.documentXml, 'SIGNATURE', '');
2672
- const data = new FormData();
2673
- data.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2674
- data.append('xmlData', signedAgreement);
2675
- data.append('name', 'PAEnpf_Agreement');
2676
- data.append('format', 'xml');
2677
- data.append('EdsXmlId', signData.data);
2678
- await this.api.uploadXml(data);
2679
- await this.getSignedDocList(this.formStore.applicationData.processInstanceId);
2680
- this.showToaster('success', this.t('pension.consentGiven'), 3000);
2681
- }
2682
- }
2683
- } catch (error) {
2684
- this.showToaster('error', String(error));
2685
- return;
2686
- }
2687
2828
  } else {
2688
- if (this.processCode === 19 || this.processCode === 2 || this.processCode === 4) {
2689
- const result = await this.api.signBts(data);
2829
+ if (this.processCode === 19 || this.processCode === 24 || this.processCode === 25) {
2830
+ const result = await this.api.file.signBts(data);
2690
2831
  if (result.code === 0) this.formStore.signUrls = result.data;
2691
2832
  } else {
2692
- const result = await this.api.signDocument(data);
2833
+ const result = await this.api.file.signDocument(data);
2693
2834
  this.formStore.signUrls = result;
2694
2835
  }
2695
2836
  return this.formStore.signUrls;
@@ -2698,6 +2839,84 @@ export const useDataStore = defineStore('data', {
2698
2839
  ErrorHandler(err);
2699
2840
  }
2700
2841
  },
2842
+ async nclayerSign(groupId: string, signType: number, isXml: boolean = false, processInstanceId?: string) {
2843
+ try {
2844
+ const ncaLayerClient = new NCALayerClient();
2845
+ await ncaLayerClient.connect();
2846
+ const activeTokens = await ncaLayerClient.getActiveTokens();
2847
+ const storageType = activeTokens[0] || NCALayerClient.fileStorageType;
2848
+ const document = await this.getDocNew(groupId, signType, isXml);
2849
+ if (isXml) {
2850
+ const signedAgreement = await ncaLayerClient.signXml(storageType, document, 'SIGNATURE', '');
2851
+ const data = new FormData();
2852
+ data.append('processInstanceId', processInstanceId ?? String(this.formStore.applicationData.processInstanceId));
2853
+ data.append('xmlData', signedAgreement);
2854
+ data.append('name', 'PAEnpf_Agreement');
2855
+ data.append('format', 'xml');
2856
+ data.append('EdsXmlId', groupId);
2857
+ await this.api.file.uploadXml(data);
2858
+ } else {
2859
+ const base64EncodedSignature = await ncaLayerClient.createCAdESFromBase64(storageType, document, 'SIGNATURE', true);
2860
+ await this.api.file.uploadDigitalCertificateNca(groupId, { Base64EncodedSignature: base64EncodedSignature });
2861
+ }
2862
+ return true;
2863
+ } catch (err: any) {
2864
+ return err.name === 'NCALayerError' ? null : ErrorHandler(err);
2865
+ }
2866
+ },
2867
+ async getDocNew(groupId: string, documentSignType: number, xml: boolean, fileName?: string) {
2868
+ try {
2869
+ let response: any = await this.api.file.generalGetDoc(groupId, xml ? 5 : documentSignType);
2870
+ let blob;
2871
+ if (response.hasOwnProperty('data')) {
2872
+ const document = JSON.parse(response.data).Document;
2873
+ blob = new Blob([document.documentXml], {
2874
+ type: `application/xml`,
2875
+ });
2876
+ response = document.documentXml;
2877
+ } else {
2878
+ blob = new Blob([response], {
2879
+ type: `application/pdf`,
2880
+ });
2881
+ }
2882
+ const url = window.URL.createObjectURL(blob);
2883
+ if (!xml) {
2884
+ const link = document.createElement('a');
2885
+ link.href = url;
2886
+ link.setAttribute('download', fileName ?? `Документ ПА`);
2887
+ document.body.appendChild(link);
2888
+ link.click();
2889
+ }
2890
+ window.open(url, '_blank', `right=100`);
2891
+ return response;
2892
+ } catch (err) {
2893
+ ErrorHandler(err);
2894
+ }
2895
+ },
2896
+ async generateSign(taskId: string) {
2897
+ try {
2898
+ const signatories = await this.api.file.generateSign({ taskId });
2899
+ if (Array.isArray(signatories)) {
2900
+ signatories.forEach(signatory =>
2901
+ signatory.fileDatas?.sort(function (a: any, b: any) {
2902
+ return a.orderFile > b.orderFile ? 1 : b.orderFile > a.orderFile ? -1 : 0;
2903
+ }),
2904
+ );
2905
+ this.formStore.signatories = signatories;
2906
+ }
2907
+ } catch (err) {
2908
+ ErrorHandler(err);
2909
+ this.formStore.signatories = [];
2910
+ }
2911
+ },
2912
+ async generalSign(data: Types.Api.Sign.New.GeneralResponse) {
2913
+ try {
2914
+ const response = await this.api.file.generalSign(data);
2915
+ return response;
2916
+ } catch (err) {
2917
+ ErrorHandler(err);
2918
+ }
2919
+ },
2701
2920
  async downloadTemplate(documentType: number, fileType: string = 'pdf', processInstanceId?: string | number) {
2702
2921
  try {
2703
2922
  this.isButtonsLoading = true;
@@ -2764,7 +2983,7 @@ export const useDataStore = defineStore('data', {
2764
2983
  name: 'Contract',
2765
2984
  format: 'pdf',
2766
2985
  };
2767
- const response: any = await this.api.generateDocument(data);
2986
+ const response: any = await this.api.file.generateDocument(data);
2768
2987
  const blob = new Blob([response], {
2769
2988
  type: `application/pdf`,
2770
2989
  });
@@ -2847,16 +3066,10 @@ export const useDataStore = defineStore('data', {
2847
3066
  this.isLoading = false;
2848
3067
  }
2849
3068
  },
2850
- sanitize(text: string) {
2851
- return text
2852
- .replace(/\r?\n|\r/g, '')
2853
- .replace(/\\/g, '')
2854
- .replace(/"/g, '');
2855
- },
2856
3069
  async getSignedDocList(processInstanceId: string | number) {
2857
3070
  if (processInstanceId !== 0) {
2858
3071
  try {
2859
- this.formStore.signedDocumentList = await this.api.getSignedDocList({
3072
+ this.formStore.signedDocumentList = await this.api.file.getSignedDocList({
2860
3073
  processInstanceId: processInstanceId,
2861
3074
  });
2862
3075
  } catch (err) {
@@ -2923,6 +3136,15 @@ export const useDataStore = defineStore('data', {
2923
3136
  }
2924
3137
  }
2925
3138
  }
3139
+ } else if (applicationKey === 'slave') {
3140
+ if (this.formStore.slaveInsuredForm && this.formStore.applicationData.slave) {
3141
+ const localSlave = this.formStore.slaveInsuredForm;
3142
+ const applicationSlave = this.formStore.applicationData.slave.insuredApp[0];
3143
+ if ((localSlave.id === applicationSlave.insisId && applicationSlave.iin === localSlave.iin?.replace(/-/g, '')) === false) {
3144
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3145
+ return false;
3146
+ }
3147
+ }
2926
3148
  } else {
2927
3149
  if (this.formStore[localKey].some(i => i.iin !== null)) {
2928
3150
  this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
@@ -2941,6 +3163,9 @@ export const useDataStore = defineStore('data', {
2941
3163
  return true;
2942
3164
  },
2943
3165
  async validateAllMembers(taskId: string, localCheck: boolean = false) {
3166
+ const policyholderDoc = this.formStore.signedDocumentList.find(
3167
+ i => i.iin === String(this.formStore.policyholderForm.iin).replaceAll('-', '') && (i.fileTypeCode === '1' || i.fileTypeCode === '2' || i.fileTypeCode === '4'),
3168
+ );
2944
3169
  if (taskId === '0') {
2945
3170
  this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
2946
3171
  return false;
@@ -2949,6 +3174,10 @@ export const useDataStore = defineStore('data', {
2949
3174
  this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
2950
3175
  return false;
2951
3176
  }
3177
+ if (useEnv().isProduction && this.isInitiator() && this.isEfoParent && this.formStore.policyholderForm.iin && !policyholderDoc) {
3178
+ this.showToaster('error', this.t('toaster.needDigDoc', { text: 'страхователя' }));
3179
+ return false;
3180
+ }
2952
3181
  if (this.members.insuredApp.has) {
2953
3182
  if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
2954
3183
  return false;
@@ -2961,6 +3190,9 @@ export const useDataStore = defineStore('data', {
2961
3190
  }
2962
3191
  }
2963
3192
  }
3193
+ if (this.formStore.applicationData.slave && this.validateMultipleMembers(this.formStore.insuredFormKey, 'slave', 'застрахованных') === false) {
3194
+ return false;
3195
+ }
2964
3196
  if (this.members.beneficiaryApp.has) {
2965
3197
  if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
2966
3198
  return false;
@@ -3009,7 +3241,11 @@ export const useDataStore = defineStore('data', {
3009
3241
  }
3010
3242
  }
3011
3243
  if (this.controls.hasAttachment) {
3012
- const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
3244
+ const areValid =
3245
+ this.formStore.SaleChanellPolicy.nameRu &&
3246
+ this.formStore.RegionPolicy.nameRu &&
3247
+ this.formStore.AgentData.fullName &&
3248
+ (this.isPension && this.isServiceManager() ? true : this.formStore.ManagerPolicy.nameRu);
3013
3249
  if (areValid) {
3014
3250
  if (this.isLifetrip && this.formStore.AgentData.fullName === 'Без агента') {
3015
3251
  this.isLoading = false;
@@ -3041,6 +3277,27 @@ export const useDataStore = defineStore('data', {
3041
3277
  return ErrorHandler(err);
3042
3278
  }
3043
3279
  }
3280
+ if (this.isGons) {
3281
+ const { relationDegree } = this.formStore.beneficiaryForm[0];
3282
+ const siblingRelationIds = ['14', '15', '24', '25'];
3283
+ const grandchildRelationIds = ['20', '21'];
3284
+ let hasSiblingRelationId = siblingRelationIds.includes(String(relationDegree?.ids));
3285
+ let hasGrandchildRelationId = grandchildRelationIds.includes(String(relationDegree?.ids));
3286
+ const hasRelationDoc = this.formStore.signedDocumentList.filter(i => i.fileTypeCode === '46' || i.fileTypeCode === '53').length >= 2;
3287
+
3288
+ if (hasSiblingRelationId && !hasRelationDoc) {
3289
+ this.isLoading = false;
3290
+ hasSiblingRelationId = false;
3291
+ this.showToaster('error', this.t('toaster.siblingRelationDoc'), 3000);
3292
+ return false;
3293
+ }
3294
+ if (hasGrandchildRelationId && !hasRelationDoc) {
3295
+ this.isLoading = false;
3296
+ hasGrandchildRelationId = false;
3297
+ this.showToaster('error', this.t('toaster.grandchildRelationDoc'), 3000);
3298
+ return false;
3299
+ }
3300
+ }
3044
3301
  return true;
3045
3302
  },
3046
3303
  validateAnketa(whichSurvey: 'surveyByHealthBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBase' | 'surveyByCriticalBasePolicyholder') {
@@ -3077,7 +3334,12 @@ export const useDataStore = defineStore('data', {
3077
3334
  this.isLoading = true;
3078
3335
  const areMembersValid = await this.validateAllMembers(taskId);
3079
3336
  if (areMembersValid) {
3080
- if ((!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) || this.isPension) {
3337
+ if (
3338
+ (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) ||
3339
+ (this.isPension &&
3340
+ this.formStore.applicationData.pensionApp.isCalculated === true &&
3341
+ (this.formStore.applicationData.pensionApp.slave ? this.formStore.applicationData.pensionApp.slave.isCalculated === true : true))
3342
+ ) {
3081
3343
  if (this.controls.hasAnketa) {
3082
3344
  const hasCritical =
3083
3345
  this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName.match(new RegExp('Критическое заболевание Застрахованного', 'i'))) ?? null;
@@ -3085,62 +3347,62 @@ export const useDataStore = defineStore('data', {
3085
3347
  await Promise.allSettled([
3086
3348
  this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
3087
3349
  this.isClientAnketaCondition &&
3088
- this.getQuestionList(
3089
- 'health',
3090
- this.formStore.applicationData.processInstanceId,
3091
- this.formStore.applicationData.clientApp.id,
3092
- 'surveyByHealthBasePolicyholder',
3093
- 'policyholder',
3094
- ),
3350
+ this.getQuestionList(
3351
+ 'health',
3352
+ this.formStore.applicationData.processInstanceId,
3353
+ this.formStore.applicationData.clientApp.id,
3354
+ 'surveyByHealthBasePolicyholder',
3355
+ 'policyholder',
3356
+ ),
3095
3357
  ,
3096
3358
  ]);
3097
3359
  this.isClientAnketaCondition
3098
3360
  ? await Promise.allSettled([
3099
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
3100
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3101
- }),
3102
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3103
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3104
- }),
3105
- ])
3361
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3362
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3363
+ }),
3364
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3365
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3366
+ }),
3367
+ ])
3106
3368
  : await Promise.allSettled(
3107
- this.formStore.surveyByHealthBase!.body.map(async question => {
3108
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3109
- }),
3110
- );
3369
+ this.formStore.surveyByHealthBase!.body.map(async question => {
3370
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3371
+ }),
3372
+ );
3111
3373
  } else {
3112
3374
  await Promise.allSettled([
3113
3375
  this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
3114
3376
  this.getQuestionList('critical', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByCriticalBase'),
3115
3377
  this.isClientAnketaCondition &&
3116
- this.getQuestionList(
3117
- 'health',
3118
- this.formStore.applicationData.processInstanceId,
3119
- this.formStore.applicationData.clientApp.id,
3120
- 'surveyByHealthBasePolicyholder',
3121
- 'policyholder',
3122
- ),
3378
+ this.getQuestionList(
3379
+ 'health',
3380
+ this.formStore.applicationData.processInstanceId,
3381
+ this.formStore.applicationData.clientApp.id,
3382
+ 'surveyByHealthBasePolicyholder',
3383
+ 'policyholder',
3384
+ ),
3123
3385
  ]);
3124
3386
  this.isClientAnketaCondition
3125
3387
  ? await Promise.allSettled([
3126
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
3127
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3128
- }),
3129
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3130
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3131
- }),
3132
- ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3133
- await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3134
- }),
3135
- ])
3388
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3389
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3390
+ }),
3391
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3392
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3393
+ }),
3394
+ ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
3395
+ await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
3396
+ }),
3397
+ ])
3136
3398
  : await Promise.allSettled([
3137
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
3138
- await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3139
- }),
3140
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3141
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3142
- }),
3143
- ]);
3399
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
3400
+ await this.definedAnswers(question.first.id, 'surveyByHealthBase');
3401
+ }),
3402
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
3403
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
3404
+ }),
3405
+ ]);
3144
3406
  }
3145
3407
  if (this.validateAnketa('surveyByHealthBase')) {
3146
3408
  let hasCriticalAndItsValid = null;
@@ -3244,13 +3506,16 @@ export const useDataStore = defineStore('data', {
3244
3506
  if (!this.accessToken) return null;
3245
3507
  try {
3246
3508
  const decoded = jwtDecode(this.accessToken);
3247
- const data = {
3248
- userName: decoded.code,
3249
- branchName: decoded.branchCode,
3250
- bin: bin.replace(/-/g, ''),
3251
- };
3252
- const gbdulResponse = await this.api.getGbdUl(data);
3253
- return gbdulResponse;
3509
+ if (decoded) {
3510
+ const data = {
3511
+ userName: decoded.code,
3512
+ branchName: decoded.branchCode,
3513
+ bin: bin.replace(/-/g, ''),
3514
+ };
3515
+ const gbdulResponse = await this.api.getGbdUl(data);
3516
+ return gbdulResponse;
3517
+ }
3518
+ return null;
3254
3519
  } catch (err) {
3255
3520
  return ErrorHandler(err);
3256
3521
  }
@@ -3332,69 +3597,72 @@ export const useDataStore = defineStore('data', {
3332
3597
  const gender = this.gender.find((i: Value) => i.id == person.gender.code);
3333
3598
  if (gender) member.gender = gender;
3334
3599
 
3335
- const birthPlace = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.birthPlace.country.nameRu, 'i')));
3600
+ const birthPlace = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.birthPlace.country.nameRu ?? 'undefined', 'i')));
3336
3601
  if (birthPlace) member.birthPlace = birthPlace;
3337
3602
 
3338
- const countryOfCitizenship = this.citizenshipCountries.find(i => (i.nameRu as string).match(new RegExp(person.citizenship.nameRu, 'i')));
3603
+ const countryOfCitizenship = this.citizenshipCountries.find(i => (i.nameRu as string).match(new RegExp(person.citizenship.nameRu ?? 'undefined', 'i')));
3339
3604
  if (countryOfCitizenship) member.countryOfCitizenship = countryOfCitizenship;
3340
3605
 
3341
- const regCountry = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.regAddress.country.nameRu, 'i')));
3606
+ const regCountry = this.countries.find(i => (i.nameRu as string).match(new RegExp(person.regAddress.country.nameRu ?? 'undefined', 'i')));
3342
3607
  if (regCountry) member.registrationCountry = regCountry;
3343
3608
 
3344
- const regProvince = this.states.find(i => (i.nameRu as string).match(new RegExp(person.regAddress.district.nameRu, 'i')));
3609
+ const regProvince = this.states.find(i => (i.nameRu as string).match(new RegExp(person.regAddress.district.nameRu ?? 'undefined', 'i')));
3345
3610
  if (regProvince) member.registrationProvince = regProvince;
3611
+ else member.registrationProvince = new Value();
3346
3612
 
3347
- if ('city' in person.regAddress && !!person.regAddress.city) {
3348
- if (person.regAddress.city.includes(', ')) {
3349
- const personCities = person.regAddress.city.split(', ');
3613
+ let hasSetCity = false;
3614
+ let hasSetRegion = false;
3615
+ if (person.regAddress.city && String(person.regAddress.city).includes(', ')) {
3616
+ const personCities = String(person.regAddress.city).split(', ');
3617
+ for (let ind = 0; ind < personCities.length; ++ind) {
3618
+ const possibleCity = this.cities.find(i => (i.nameRu as string).includes(personCities[ind]));
3619
+ if (possibleCity) {
3620
+ member.registrationCity = possibleCity;
3621
+ hasSetCity = true;
3622
+ break;
3623
+ }
3624
+ }
3625
+ if (member.registrationCity.nameRu === null) {
3350
3626
  for (let ind = 0; ind < personCities.length; ++ind) {
3351
- const possibleCity = this.cities.find(i => (i.nameRu as string).includes(personCities[ind]));
3352
- if (possibleCity) {
3353
- member.registrationCity = possibleCity;
3627
+ const possibleRegion = this.regions.find(i => String(i.nameRu).includes(personCities[ind]));
3628
+ if (possibleRegion) {
3629
+ member.registrationRegion = possibleRegion;
3630
+ hasSetRegion = true;
3354
3631
  break;
3355
3632
  }
3356
3633
  }
3357
- if (member.registrationCity.nameRu === null) {
3358
- for (let ind = 0; ind < personCities.length; ++ind) {
3359
- const possibleRegion = this.regions.find(i => String(i.nameRu).includes(personCities[ind]));
3360
- if (possibleRegion) {
3361
- member.registrationRegion = possibleRegion;
3362
- break;
3363
- }
3364
- }
3365
- }
3366
- } else {
3367
- const regCity = this.cities.find(i => String(i.nameRu).match(new RegExp(person.regAddress.city, 'i')));
3368
- if (regCity) member.registrationCity = regCity;
3369
-
3370
- if (member.registrationCity.nameRu === null) {
3371
- const regRegion = this.regions.find(i => String(i.nameRu).match(new RegExp(person.regAddress.city, 'i')));
3372
- if (regRegion) member.registrationRegion = regRegion;
3373
- }
3374
3634
  }
3375
3635
  }
3376
3636
 
3377
- if (member.registrationCity.nameRu === null && member.registrationRegion.nameRu === null) {
3637
+ if (hasSetCity === false) {
3378
3638
  const regCity = this.cities.find(
3379
- i => String(i.nameRu).match(new RegExp(person.regAddress.region.nameRu, 'i')) || String(i.nameRu).match(new RegExp(person.regAddress.district.nameRu, 'i')),
3639
+ i =>
3640
+ String(i.nameRu).match(new RegExp(person.regAddress.city ?? 'undefined', 'i')) ||
3641
+ String(i.nameRu).match(new RegExp(person.regAddress.region.nameRu ?? 'undefined', 'i')) ||
3642
+ String(i.nameRu).match(new RegExp(person.regAddress.district.nameRu ?? 'undefined', 'i')),
3380
3643
  );
3381
3644
  if (regCity) {
3382
3645
  member.registrationCity = regCity;
3383
3646
  const regType = this.localityTypes.find(i => String(i.nameRu) === 'город');
3384
3647
  if (regType) member.registrationRegionType = regType;
3385
- } else {
3386
- const regRegion = this.regions.find(
3387
- i => String(i.nameRu).match(new RegExp(person.regAddress.region.nameRu, 'i')) || String(i.nameRu).match(new RegExp(person.regAddress.district.nameRu, 'i')),
3388
- );
3389
- if (regRegion) {
3390
- member.registrationRegion = regRegion;
3391
- const regType = this.localityTypes.find(i => String(i.nameRu) === 'село' || String(i.nameRu) === 'поселок');
3392
- if (regType) member.registrationRegionType = regType;
3393
- }
3394
- }
3648
+ } else member.registrationCity = new Value();
3395
3649
  }
3396
3650
 
3397
- if (person.regAddress.street.includes(', ')) {
3651
+ if (hasSetRegion === false) {
3652
+ const regRegion = this.regions.find(
3653
+ i =>
3654
+ String(i.nameRu).match(new RegExp(person.regAddress.city ?? 'undefined', 'i')) ||
3655
+ String(i.nameRu).match(new RegExp(person.regAddress.region.nameRu ?? 'undefined', 'i')) ||
3656
+ String(i.nameRu).match(new RegExp(person.regAddress.district.nameRu ?? 'undefined', 'i')),
3657
+ );
3658
+ if (regRegion) {
3659
+ member.registrationRegion = regRegion;
3660
+ const regType = this.localityTypes.find(i => String(i.nameRu) === 'село' || String(i.nameRu) === 'поселок');
3661
+ if (regType) member.registrationRegionType = regType;
3662
+ } else member.registrationRegion = new Value();
3663
+ }
3664
+
3665
+ if (person.regAddress.street && person.regAddress.street.includes(', ')) {
3398
3666
  const personAddress = person.regAddress.street.split(', ');
3399
3667
  const microDistrict = personAddress.find((i: string) => i.match(new RegExp('микрорайон', 'i')));
3400
3668
  const quarter = personAddress.find((i: string) => i.match(new RegExp('квартал', 'i')));
@@ -3409,19 +3677,28 @@ export const useDataStore = defineStore('data', {
3409
3677
  if (person.regAddress.flat) member.registrationNumberApartment = person.regAddress.flat;
3410
3678
 
3411
3679
  if (Array.isArray(person.documents.document)) {
3412
- const validDocument = person.documents.document.find(
3413
- i =>
3414
- new Date(i.endDate) > new Date(Date.now()) &&
3415
- i.status.code === '00' &&
3416
- (i.type.code === Enums.GBD.DocTypes['1UDL'] || i.type.code === Enums.GBD.DocTypes.VNZ || i.type.code === Enums.GBD.DocTypes.PS),
3417
- );
3680
+ const filteredDocuments = person.documents.document.filter(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00');
3681
+ const validDocument = this.isLifetrip
3682
+ ? filteredDocuments.find(i => i.type.code === CoreEnums.GBD.DocTypes.PS)
3683
+ : filteredDocuments.find(i => i.type.code === CoreEnums.GBD.DocTypes['1UDL']) ??
3684
+ filteredDocuments.find(i => i.type.code === CoreEnums.GBD.DocTypes.VNZ) ??
3685
+ filteredDocuments.find(i => i.type.code === CoreEnums.GBD.DocTypes.PS);
3418
3686
  if (validDocument) {
3419
- const documentType = this.documentTypes.find((i: Value) => i.ids === Object.keys(Enums.GBD.DocTypes)[Object.values(Enums.GBD.DocTypes).indexOf(validDocument.type.code)]);
3687
+ const documentType = this.documentTypes.find(
3688
+ (i: Value) => i.ids === Object.keys(CoreEnums.GBD.DocTypes)[Object.values(CoreEnums.GBD.DocTypes).indexOf(validDocument.type.code)],
3689
+ );
3420
3690
  if (documentType) member.documentType = documentType;
3421
3691
  if (validDocument.number) member.documentNumber = validDocument.number;
3422
3692
  if (validDocument.beginDate) member.documentDate = reformatDate(validDocument.beginDate);
3423
3693
  if (validDocument.endDate) member.documentExpire = reformatDate(validDocument.endDate);
3424
- const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
3694
+ const documentIssuer = this.documentIssuers.find(i =>
3695
+ (i.nameRu as string).match(
3696
+ new RegExp(
3697
+ validDocument.issueOrganization.code === '001' ? 'МЮ РК' : validDocument.issueOrganization.code === '002' ? 'МВД РК' : validDocument.issueOrganization.nameRu,
3698
+ 'i',
3699
+ ),
3700
+ ),
3701
+ );
3425
3702
  if (documentIssuer) member.documentIssuers = documentIssuer;
3426
3703
  }
3427
3704
  } else {
@@ -3429,9 +3706,11 @@ export const useDataStore = defineStore('data', {
3429
3706
  if (
3430
3707
  personDoc.status.code === '00' &&
3431
3708
  new Date(personDoc.endDate) > new Date(Date.now()) &&
3432
- (personDoc.type.code === Enums.GBD.DocTypes['1UDL'] || personDoc.type.code === Enums.GBD.DocTypes.VNZ || personDoc.type.code === Enums.GBD.DocTypes.PS)
3709
+ (personDoc.type.code === CoreEnums.GBD.DocTypes['1UDL'] || personDoc.type.code === CoreEnums.GBD.DocTypes.VNZ || personDoc.type.code === CoreEnums.GBD.DocTypes.PS)
3433
3710
  ) {
3434
- const documentType = this.documentTypes.find((i: Value) => i.ids === Object.keys(Enums.GBD.DocTypes)[Object.values(Enums.GBD.DocTypes).indexOf(personDoc.type.code)]);
3711
+ const documentType = this.documentTypes.find(
3712
+ (i: Value) => i.ids === Object.keys(CoreEnums.GBD.DocTypes)[Object.values(CoreEnums.GBD.DocTypes).indexOf(personDoc.type.code)],
3713
+ );
3435
3714
  if (documentType) member.documentType = documentType;
3436
3715
  const documentNumber = personDoc.number;
3437
3716
  if (documentNumber) member.documentNumber = documentNumber;
@@ -3439,7 +3718,11 @@ export const useDataStore = defineStore('data', {
3439
3718
  if (documentDate) member.documentDate = reformatDate(documentDate);
3440
3719
  const documentExpire = personDoc.endDate;
3441
3720
  if (documentExpire) member.documentExpire = reformatDate(documentExpire);
3442
- const documentIssuer = this.documentIssuers.find(i => (i.nameRu as string).match(new RegExp('МВД РК', 'i')));
3721
+ const documentIssuer = this.documentIssuers.find(i =>
3722
+ (i.nameRu as string).match(
3723
+ new RegExp(personDoc.issueOrganization.code === '001' ? 'МЮ РК' : personDoc.issueOrganization.code === '002' ? 'МВД РК' : personDoc.issueOrganization.nameRu, 'i'),
3724
+ ),
3725
+ );
3443
3726
  if (documentIssuer) member.documentIssuers = documentIssuer;
3444
3727
  }
3445
3728
  }
@@ -3463,6 +3746,22 @@ export const useDataStore = defineStore('data', {
3463
3746
  });
3464
3747
  }
3465
3748
  },
3749
+ uniqPreparePersonData(local: GroupMember) {
3750
+ const checkForNull = (value: any) => (value ? value : '');
3751
+ try {
3752
+ (Object.keys(local) as Array<keyof GroupMember>).forEach(key => {
3753
+ if (key === 'actualAddress' || key === 'legalAddress') {
3754
+ const address = `${checkForNull(local[key].country.nameRu)}, ${checkForNull(local[key].state.nameRu)},${local[key].region.nameRu ? ` ${local[key].region.nameRu},` : ''
3755
+ } ${checkForNull(local[key].regionType.nameRu)} ${checkForNull(local[key].city.nameRu)},${local[key].square ? ` квартал ${local[key].square},` : ''}${local[key].microdistrict ? ` мкр ${local[key].microdistrict},` : ''
3756
+ } ул. ${checkForNull(local[key].street)}, д. ${checkForNull(local[key].houseNumber)}`;
3757
+ local[key].longName = address;
3758
+ local[key].longNameKz = address;
3759
+ }
3760
+ });
3761
+ } catch (e) {
3762
+ ErrorHandler(e);
3763
+ }
3764
+ },
3466
3765
  async startApplicationV2(data: PolicyholderClass) {
3467
3766
  const policyholder = JSON.parse(JSON.stringify(data)) as any;
3468
3767
  this.preparePersonData(policyholder);
@@ -3478,14 +3777,17 @@ export const useDataStore = defineStore('data', {
3478
3777
  'clientData.authoritedPerson.bankInfo',
3479
3778
  'clientData.authoritedPerson.economySectorCode',
3480
3779
  'clientData.authoritedPerson.legalAddress',
3481
- 'clientData.authoritedPerson.placeOfBirth',
3482
- 'clientData.authoritedPerson.resident',
3483
3780
  'clientData.authoritedPerson.taxResidentCountry',
3484
3781
  'clientData.authoritedPerson.addTaxResidency',
3485
3782
  ]);
3486
3783
  policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3784
+ this.uniqPreparePersonData(policyholder.clientData);
3785
+ if (this.formStore.lfb.add) {
3786
+ policyholder.parentContractNumber = localStorage.getItem('policyNo');
3787
+ policyholder.parentContractId = localStorage.getItem('policyId');
3788
+ }
3487
3789
  try {
3488
- const response = await this.api.startApplication(policyholder);
3790
+ const response = await this.api.startApplication(policyholder, Number(this.processCode));
3489
3791
  this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
3490
3792
  return response.processInstanceId;
3491
3793
  } catch (err) {
@@ -3496,6 +3798,7 @@ export const useDataStore = defineStore('data', {
3496
3798
  const policyholder = JSON.parse(JSON.stringify(data)) as any;
3497
3799
  policyholder.clientData.authoritedPerson.gender = policyholder.clientData.authoritedPerson.gender.nameRu === 'Мужской' ? 1 : 2;
3498
3800
  this.preparePersonData(policyholder);
3801
+ this.uniqPreparePersonData(policyholder.clientData);
3499
3802
  try {
3500
3803
  await this.api.saveClient(this.formStore.applicationData.processInstanceId, this.formStore.lfb.clientId, policyholder);
3501
3804
  } catch (err) {
@@ -3515,7 +3818,6 @@ export const useDataStore = defineStore('data', {
3515
3818
  this.formStore.applicationData = applicationData;
3516
3819
  this.formStore.regNumber = applicationData.regNumber;
3517
3820
  this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
3518
-
3519
3821
  this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
3520
3822
  this.formStore.applicationTaskId = taskId;
3521
3823
  this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
@@ -3536,17 +3838,8 @@ export const useDataStore = defineStore('data', {
3536
3838
 
3537
3839
  this.formStore.applicationData.processInstanceId = applicationData.processInstanceId;
3538
3840
  this.formStore.lfb.policyholder.isIpdl = applicationData.clientApp.isIpdl;
3539
- this.formStore.lfb.policyholder.clientData = clientData;
3540
- this.formStore.lfb.policyholder.clientData.authoritedPerson = clientData.authoritedPerson;
3541
- this.formStore.lfb.policyholder.clientData.iin = reformatIin(clientData.iin);
3542
- this.formStore.lfb.policyholder.clientData.authoritedPerson.iin = reformatIin(clientData.authoritedPerson.iin);
3543
3841
  this.formStore.lfb.clientId = clientId;
3544
- this.formStore.lfb.policyholder.clientData.authoritedPerson.authorityDetails.date = reformatDate(clientData.authoritedPerson.authorityDetails.date);
3545
- this.formStore.lfb.policyholder.clientData.authoritedPerson.birthDate = reformatDate(clientData.authoritedPerson.birthDate) ?? '';
3546
- this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.issuedOn = reformatDate(clientData.authoritedPerson.identityDocument.issuedOn) ?? '';
3547
- this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.validUntil = reformatDate(clientData.authoritedPerson.identityDocument.validUntil) ?? '';
3548
- const gender = this.gender.find((i: Value) => i.id === clientData.authoritedPerson.gender);
3549
- this.formStore.lfb.policyholder.clientData.authoritedPerson.gender = gender ? gender : new Value();
3842
+ this.getClientData(clientData);
3550
3843
 
3551
3844
  if (clientData && clientData.activityTypes !== null) {
3552
3845
  this.formStore.lfb.policyholderActivities = clientData.activityTypes;
@@ -3566,9 +3859,8 @@ export const useDataStore = defineStore('data', {
3566
3859
  });
3567
3860
  }
3568
3861
 
3569
- if (insuredApp && insuredApp.length) {
3570
- const res = await this.newInsuredList(insuredApp);
3571
- this.formStore.lfb.clients = res;
3862
+ if (insuredApp === null) {
3863
+ await this.getInsuredsData();
3572
3864
  }
3573
3865
 
3574
3866
  if (accidentIncidents && accidentIncidents.length) {
@@ -3579,19 +3871,43 @@ export const useDataStore = defineStore('data', {
3579
3871
  });
3580
3872
  }
3581
3873
 
3874
+ this.formStore.productConditionsForm.lifeMultiply = parseProcents(applicationData.policyAppDto.lifeMultiply);
3875
+ this.formStore.productConditionsForm.lifeAdditive = parseProcents(applicationData.policyAppDto.lifeAdditive);
3876
+ this.formStore.productConditionsForm.lifeMultiplyClient = parseProcents(applicationData.policyAppDto.lifeMultiplyClient);
3877
+ this.formStore.productConditionsForm.lifeAdditiveClient = parseProcents(applicationData.policyAppDto.lifeAdditiveClient);
3878
+ this.formStore.productConditionsForm.adbMultiply = parseProcents(applicationData.policyAppDto.adbMultiply);
3879
+ this.formStore.productConditionsForm.adbAdditive = parseProcents(applicationData.policyAppDto.adbAdditive);
3880
+ this.formStore.productConditionsForm.disabilityMultiply = parseProcents(applicationData.policyAppDto.disabilityMultiply);
3881
+ this.formStore.productConditionsForm.disabilityAdditive = parseProcents(applicationData.policyAppDto.disabilityAdditive);
3882
+
3582
3883
  this.formStore.productConditionsForm.calcDate = reformatDate(applicationData.policyAppDto.calcDate);
3583
3884
  this.formStore.productConditionsForm.contractEndDate = reformatDate(applicationData.policyAppDto.contractEndDate);
3584
- this.formStore.productConditionsForm.agentCommission = applicationData.policyAppDto.agentCommission === 0 ? null : applicationData.policyAppDto.agentCommission;
3885
+ this.formStore.productConditionsForm.agentCommission = applicationData.policyAppDto.agentCommission;
3585
3886
  this.formStore.productConditionsForm.fixInsSum = this.getNumberWithSpaces(applicationData.policyAppDto.fixInsSum === 0 ? null : applicationData.policyAppDto.fixInsSum);
3586
3887
  this.formStore.productConditionsForm.coverPeriod = 12;
3587
3888
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(applicationData.policyAppDto.amount === 0 ? null : applicationData.policyAppDto.amount);
3588
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
3589
- applicationData.policyAppDto.mainPremiumWithCommission === 0 ? null : applicationData.policyAppDto.mainPremiumWithCommission,
3590
- );
3889
+ this.formStore.productConditionsForm.insurancePremiumPerMonth =
3890
+ applicationData.policyAppDto.mainPremiumWithCommission === 0 ? null : this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.mainPremiumWithCommission);
3591
3891
  const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
3592
3892
  this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
3593
3893
  const processGfot = this.processGfot.find(item => item.id == applicationData.policyAppDto.processDefinitionFgotId);
3594
3894
  this.formStore.productConditionsForm.processGfot = processGfot ? processGfot : new Value();
3895
+
3896
+ if (applicationData.parentPolicyDto !== null) {
3897
+ this.formStore.productConditionsForm.calcDate = reformatDate(applicationData.parentPolicyDto.contractInsrBegin);
3898
+ this.formStore.productConditionsForm.contractEndDate = reformatDate(applicationData.parentPolicyDto.contractInsrEnd);
3899
+ }
3900
+ if (this.formStore.lfb.add) {
3901
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.premium);
3902
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.amount);
3903
+ if (applicationData.policyAppDto.mainPremiumWithCommission > 0) {
3904
+ this.formStore.productConditionsForm.amountPaid = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.mainPremiumWithCommission);
3905
+ this.formStore.productConditionsForm.amountRefunded = null;
3906
+ } else {
3907
+ this.formStore.productConditionsForm.amountRefunded = this.getNumberWithSpacesAfterComma(applicationData.policyAppDto.mainPremiumWithCommission);
3908
+ this.formStore.productConditionsForm.amountPaid = null;
3909
+ }
3910
+ }
3595
3911
  } catch (err) {
3596
3912
  ErrorHandler(err);
3597
3913
  if (err instanceof AxiosError) {
@@ -3670,9 +3986,9 @@ export const useDataStore = defineStore('data', {
3670
3986
  return ErrorHandler(err);
3671
3987
  }
3672
3988
  },
3673
- async saveInsuredList(insuredList: any) {
3989
+ async saveInsuredList(insuredList: any, newInsureds: boolean) {
3674
3990
  try {
3675
- await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, insuredList);
3991
+ await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, newInsureds, insuredList);
3676
3992
  return true;
3677
3993
  } catch (err) {
3678
3994
  return ErrorHandler(err);
@@ -3686,6 +4002,18 @@ export const useDataStore = defineStore('data', {
3686
4002
  return ErrorHandler(err);
3687
4003
  }
3688
4004
  },
4005
+ async getInsuredsData() {
4006
+ try {
4007
+ const result = await this.api.getInsuredsData(this.formStore.applicationData.processInstanceId);
4008
+ if (result && result.length) {
4009
+ this.formStore.applicationData.insuredApp = result;
4010
+ const res = await this.newInsuredList(result);
4011
+ this.formStore.lfb.clients = res;
4012
+ }
4013
+ } catch (err) {
4014
+ return ErrorHandler(err);
4015
+ }
4016
+ },
3689
4017
  newInsuredList(list: any) {
3690
4018
  const clients = list.map((item: any, index: number) => {
3691
4019
  const client = item.insuredData;
@@ -3700,6 +4028,9 @@ export const useDataStore = defineStore('data', {
3700
4028
  premium: client.insuredPolicyData.premium,
3701
4029
  premiumWithLoad: client.insuredPolicyData.premiumWithLoad,
3702
4030
  hasAttachedFile: client.hasAttachedFile,
4031
+ insrBeginDate: client.insuredPolicyData.insrBeginDate ?? 'no',
4032
+ insrEndDate: client.insuredPolicyData.insrEndDate ?? 'no',
4033
+ tableNumber: client.tableNumber,
3703
4034
  };
3704
4035
  });
3705
4036
  return clients;
@@ -3748,7 +4079,7 @@ export const useDataStore = defineStore('data', {
3748
4079
  return false;
3749
4080
  }
3750
4081
 
3751
- if (this.formStore.lfb.beneficialOwners) {
4082
+ if (!this.formStore.lfb.add && this.formStore.lfb.beneficialOwners) {
3752
4083
  if (this.validateMultipleMembersV2('beneficialOwners', 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
3753
4084
  return false;
3754
4085
  }
@@ -3759,12 +4090,16 @@ export const useDataStore = defineStore('data', {
3759
4090
  }
3760
4091
  }
3761
4092
 
3762
- if (this.formStore.applicationData.clientApp.clientData.activityTypes === null) {
4093
+ if (!this.formStore.lfb.add && this.formStore.applicationData.clientApp.clientData.activityTypes === null) {
3763
4094
  this.showToaster('error', this.t('toaster.notSavedMember', { text: 'деятельности Страхователя' }), 3000);
3764
4095
  return false;
3765
4096
  }
3766
4097
 
3767
- if (this.formStore.lfb.clients) {
4098
+ const isHalykBank = this.formStore.lfb.policyholder.clientData.iin.replace(/-/g, '') === '940140000385';
4099
+ if (this.formStore.lfb.clients.length === 0 && !isHalykBank) {
4100
+ await this.getInsuredsData();
4101
+ }
4102
+ if (this.formStore.lfb.clients && !isHalykBank) {
3768
4103
  if (this.validateMultipleMembersV2('clients', 'insuredApp', 'застрахованных') === false) {
3769
4104
  return false;
3770
4105
  }
@@ -3775,7 +4110,7 @@ export const useDataStore = defineStore('data', {
3775
4110
  }
3776
4111
  }
3777
4112
 
3778
- if (this.formStore.lfb.clients && this.formStore.lfb.clients.length <= 10) {
4113
+ if (!this.formStore.lfb.add && this.formStore.lfb.clients && this.formStore.lfb.clients.length <= 10) {
3779
4114
  for (const client of this.formStore.lfb.clients) {
3780
4115
  if (client.hasAttachedFile === false) {
3781
4116
  this.showToaster('error', this.t('toaster.needAttachQuestionnaire'), 3000);
@@ -3784,18 +4119,75 @@ export const useDataStore = defineStore('data', {
3784
4119
  }
3785
4120
  }
3786
4121
 
3787
- if (this.formStore.productConditionsForm.insurancePremiumPerMonth === null) {
4122
+ if (!this.formStore.lfb.add && this.formStore.productConditionsForm.insurancePremiumPerMonth === null) {
3788
4123
  this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
3789
4124
  return false;
3790
4125
  }
3791
4126
 
3792
- if (this.formStore.productConditionsForm.insurancePremiumPerMonth === '0') {
4127
+ if (!this.formStore.lfb.add && this.formStore.productConditionsForm.insurancePremiumPerMonth === '0') {
3793
4128
  this.showToaster('error', this.t('toaster.notZeroPremium'), 3000);
3794
4129
  return false;
3795
4130
  }
3796
4131
 
4132
+ if (this.controls.hasAttachment) {
4133
+ const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
4134
+ if (areValid) {
4135
+ if (this.isInitiator()) {
4136
+ await this.setINSISWorkData();
4137
+ }
4138
+ } else {
4139
+ this.isLoading = false;
4140
+ this.showToaster('error', this.t('toaster.attachManagerError'), 3000);
4141
+ return false;
4142
+ }
4143
+ }
4144
+
3797
4145
  return true;
3798
4146
  },
4147
+ async getOnlineAccess(iin: string, documentType: string) {
4148
+ try {
4149
+ const data = {
4150
+ iinBin: iin.replaceAll('-', ''),
4151
+ documentType: documentType,
4152
+ };
4153
+ const response = await this.api.externalServices.getOnlineAccess(data);
4154
+ if (response.code === 'PROFILE_DIGIDOCS_INTERNAL_ERROR') {
4155
+ this.showToaster('error', this.t('toaster.notDigDoc'), 3000);
4156
+ return false;
4157
+ } else {
4158
+ return true;
4159
+ }
4160
+ } catch (err) {
4161
+ ErrorHandler(err);
4162
+ return null;
4163
+ }
4164
+ },
4165
+ async getDigitalDocuments(iin: string, processInstanceId: string, code: string) {
4166
+ try {
4167
+ const data = {
4168
+ iin: iin.replaceAll('-', ''),
4169
+ processInstanceId: processInstanceId,
4170
+ code: code.replace(/\s/g, ''),
4171
+ };
4172
+ await this.api.externalServices.getDigitalDocuments(data);
4173
+ return true;
4174
+ } catch (err) {
4175
+ ErrorHandler(err);
4176
+ return null;
4177
+ }
4178
+ },
4179
+ async updateDigitalDocumentsProfile(iin: string) {
4180
+ try {
4181
+ const data = {
4182
+ iinBin: iin.replaceAll('-', ''),
4183
+ };
4184
+ await this.api.externalServices.updateDigitalDocumentsProfile(data);
4185
+ this.showToaster('success', this.t('toaster.successProfile'), 3000);
4186
+ } catch (err) {
4187
+ ErrorHandler(err);
4188
+ return null;
4189
+ }
4190
+ },
3799
4191
  async getVariableData(processCode: number) {
3800
4192
  try {
3801
4193
  const response = await this.api.getVariableData(0, processCode);
@@ -3808,6 +4200,16 @@ export const useDataStore = defineStore('data', {
3808
4200
  return null;
3809
4201
  }
3810
4202
  },
4203
+ async getProcessDividendPeriods() {
4204
+ try {
4205
+ if (!this.processCode) return null;
4206
+ const response = await this.api.getProcessDividendPeriods(this.processCode);
4207
+ return response;
4208
+ } catch (err) {
4209
+ ErrorHandler(err);
4210
+ return null;
4211
+ }
4212
+ },
3811
4213
  async checkIIN(iin: string) {
3812
4214
  try {
3813
4215
  const response = await this.api.checkIIN(iin);
@@ -3825,6 +4227,24 @@ export const useDataStore = defineStore('data', {
3825
4227
  return ErrorHandler(err);
3826
4228
  }
3827
4229
  },
4230
+ async getBankByAccountNumber(accountNumber: string) {
4231
+ try {
4232
+ const bank = await this.api.getBankByAccountNumber(accountNumber);
4233
+ return bank;
4234
+ } catch (err) {
4235
+ ErrorHandler(err);
4236
+ }
4237
+ },
4238
+ async getContractByBin(bin: string) {
4239
+ try {
4240
+ const contract = await this.api.getContractByBin(bin);
4241
+ contract.insrBegin = reformatDate(contract.insrBegin) ?? '';
4242
+ contract.insrEnd = reformatDate(contract.insrEnd) ?? '';
4243
+ return contract;
4244
+ } catch (err) {
4245
+ ErrorHandler(err);
4246
+ }
4247
+ },
3828
4248
  async isCourseChanged(processInstanceId: string) {
3829
4249
  try {
3830
4250
  const response = await this.api.isCourseChanged(processInstanceId);
@@ -3845,8 +4265,30 @@ export const useDataStore = defineStore('data', {
3845
4265
  return ErrorHandler(err);
3846
4266
  }
3847
4267
  },
4268
+ getClientData(clientData: GroupMember) {
4269
+ this.formStore.lfb.policyholder.clientData = clientData;
4270
+ this.formStore.lfb.policyholder.clientData.authoritedPerson = clientData.authoritedPerson;
4271
+ this.formStore.lfb.policyholder.clientData.iin = reformatIin(clientData.iin);
4272
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.iin = reformatIin(clientData.authoritedPerson.iin);
4273
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.authorityDetails.date = reformatDate(clientData.authoritedPerson.authorityDetails.date as string);
4274
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.birthDate = reformatDate(clientData.authoritedPerson.birthDate) ?? '';
4275
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.issuedOn = reformatDate(clientData.authoritedPerson.identityDocument.issuedOn) ?? '';
4276
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.identityDocument.validUntil = reformatDate(clientData.authoritedPerson.identityDocument.validUntil) ?? '';
4277
+ const gender = this.gender.find((i: Value) => i.id === Number(clientData.authoritedPerson.gender));
4278
+ this.formStore.lfb.policyholder.clientData.authoritedPerson.gender = gender ? gender : new Value();
4279
+ },
4280
+ async getParentApplication(bin: string) {
4281
+ try {
4282
+ const response = await this.api.getParentApplication(bin);
4283
+ if (response) {
4284
+ this.getClientData(response.clientApp.clientData);
4285
+ }
4286
+ } catch (err) {
4287
+ return ErrorHandler(err);
4288
+ }
4289
+ },
3848
4290
  hasJobSection(whichForm: keyof typeof StoreMembers) {
3849
- if (this.isLifetrip || this.isPension) return false;
4291
+ if (this.isLifetrip || this.isPension || this.isBalam || this.isTumar) return false;
3850
4292
  switch (whichForm) {
3851
4293
  case this.formStore.beneficiaryFormKey:
3852
4294
  case this.formStore.beneficialOwnerFormKey:
@@ -3857,7 +4299,7 @@ export const useDataStore = defineStore('data', {
3857
4299
  }
3858
4300
  },
3859
4301
  hasBirthSection(whichForm: keyof typeof StoreMembers) {
3860
- if (this.isGons || this.isPension) return false;
4302
+ if (this.isPension) return false;
3861
4303
  switch (whichForm) {
3862
4304
  case this.formStore.beneficiaryFormKey:
3863
4305
  return false;
@@ -3865,18 +4307,6 @@ export const useDataStore = defineStore('data', {
3865
4307
  return true;
3866
4308
  }
3867
4309
  },
3868
- hasPlaceSection(whichForm: keyof typeof StoreMembers) {
3869
- switch (whichForm) {
3870
- default:
3871
- return true;
3872
- }
3873
- },
3874
- hasDocumentSection(whichForm: keyof typeof StoreMembers) {
3875
- switch (whichForm) {
3876
- default:
3877
- return true;
3878
- }
3879
- },
3880
4310
  hasContactSection(whichForm: keyof typeof StoreMembers) {
3881
4311
  if (this.isGons || this.isPension) return false;
3882
4312
  switch (whichForm) {
@@ -3885,7 +4315,7 @@ export const useDataStore = defineStore('data', {
3885
4315
  }
3886
4316
  },
3887
4317
  hasBankSection(whichForm: keyof typeof StoreMembers) {
3888
- if (!this.isPension) return false;
4318
+ if (!this.isPension || Number(this.formStore.applicationData.processCode) === 24) return false;
3889
4319
  switch (whichForm) {
3890
4320
  case 'beneficiaryForm':
3891
4321
  return false;
@@ -3894,7 +4324,7 @@ export const useDataStore = defineStore('data', {
3894
4324
  }
3895
4325
  },
3896
4326
  hasAdditionalDocumentsSection(whichForm: keyof typeof StoreMembers) {
3897
- if (!this.isPension) return false;
4327
+ if (!this.isPension || Number(this.formStore.applicationData.processCode) === 24) return false;
3898
4328
  switch (whichForm) {
3899
4329
  case 'beneficiaryForm':
3900
4330
  return false;
@@ -3913,44 +4343,5 @@ export const useDataStore = defineStore('data', {
3913
4343
  return false;
3914
4344
  }
3915
4345
  },
3916
- hasPercentageOfPayoutAmount() {
3917
- return true;
3918
- },
3919
- hasAccess() {
3920
- const baseAccessRoles = this.isAdmin() || this.isSupport() || this.isAnalyst() || this.isDrn();
3921
- return {
3922
- invoiceInfo: this.isAdmin(),
3923
- toLKA: this.isAgent() || baseAccessRoles,
3924
- toAML: this.isCompliance() || baseAccessRoles,
3925
- toAULETTI: this.isAgentAuletti() || baseAccessRoles,
3926
- toLKA_A: this.isAgentAuletti() || baseAccessRoles,
3927
- toEFO:
3928
- this.isManager() ||
3929
- this.isAgent() ||
3930
- this.isAgentMycar() ||
3931
- this.isManagerHalykBank() ||
3932
- this.isHeadManager() ||
3933
- this.isServiceManager() ||
3934
- this.isUnderwriter() ||
3935
- this.isActuary() ||
3936
- this.isAdmin() ||
3937
- this.isCompliance() ||
3938
- this.isAnalyst() ||
3939
- this.isUpk() ||
3940
- this.isFinCenter() ||
3941
- this.isSupervisor() ||
3942
- this.isSupport() ||
3943
- this.isDrn() ||
3944
- this.isUrp() ||
3945
- this.isUsns() ||
3946
- this.isAccountant() ||
3947
- this.isBranchDirector() ||
3948
- this.isUSNSACCINS() ||
3949
- this.isDsuio() ||
3950
- this.isAdjuster() ||
3951
- this.isDsoDirector() ||
3952
- this.isAccountantDirector(),
3953
- };
3954
- },
3955
4346
  },
3956
4347
  });