hl-core 0.0.9-beta.25 → 0.0.9-beta.26

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.
@@ -3,7 +3,7 @@ import { rules } from './rules';
3
3
  import { i18n } from '../configs/i18n';
4
4
  import { Toast, Types, Positions, ToastOptions } from './toast';
5
5
  import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate } from '../composables';
6
- import { DataStoreClass, Contragent, DocumentItem, Member, Value, CountryValue, PolicyholderV2 } from '../composables/classes';
6
+ import { DataStoreClass, Contragent, DocumentItem, Member, Value, CountryValue, MemberV2, PolicyholderActivity, BeneficialOwner } from '../composables/classes';
7
7
  import { ApiClass } from '../api';
8
8
  import { useFormStore } from './form.store';
9
9
  import { AxiosError } from 'axios';
@@ -1018,6 +1018,11 @@ export const useDataStore = defineStore('data', {
1018
1018
  conditionsData.policyAppDto.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
1019
1019
  conditionsData.policyAppDto.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
1020
1020
  }
1021
+ if (this.isLifeBusiness) {
1022
+ conditionsData.policyAppDto.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1023
+ conditionsData.policyAppDto.fixInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1024
+ conditionsData.policyAppDto.tariffId = String(this.formStore.productConditionsForm.processTariff.id);
1025
+ }
1021
1026
  return conditionsData;
1022
1027
  },
1023
1028
  async clearAddCovers(coverCode: number, coverValue: string) {
@@ -1242,7 +1247,7 @@ export const useDataStore = defineStore('data', {
1242
1247
  return this.cities;
1243
1248
  }
1244
1249
  },
1245
- async getCitiesEfo(key?: string, member?: PolicyholderV2, parentKey?: string) {
1250
+ async getCitiesEfo(key?: string, member?: MemberV2, parentKey?: string) {
1246
1251
  if (this.isLifeBusiness) {
1247
1252
  await this.getFromApi('cities', 'getCities');
1248
1253
  //@ts-ignore
@@ -1670,15 +1675,15 @@ export const useDataStore = defineStore('data', {
1670
1675
  calculationData.annuityPaymentPeriodId = (this.formStore.productConditionsForm.periodAnnuityPayment.id as string) ?? undefined;
1671
1676
  }
1672
1677
  if (this.isLifeBusiness || product === 'lifebusiness') {
1673
- calculationData.clients = this.formStore.lfb.insurers;
1674
- calculationData.insrCount = this.formStore.lfb.insurers.length;
1678
+ calculationData.clients = this.formStore.lfb.clients;
1679
+ calculationData.insrCount = this.formStore.lfb.clients.length;
1675
1680
  calculationData.insTermInMonth = Number(this.formStore.productConditionsForm.coverPeriod);
1676
1681
  calculationData.fixInsSum = getNumber(String(this.formStore.productConditionsForm.requestedSumInsured));
1677
1682
  calculationData.agentCommission = this.formStore.productConditionsForm.processTariff.id;
1678
1683
  }
1679
1684
  const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1680
- this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1681
- this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1685
+ if (calculationResponse.amount) this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1686
+ if (calculationResponse.premium) this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1682
1687
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1683
1688
  if (this.isKazyna || product === 'halykkazyna') {
1684
1689
  if (this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar != null) {
@@ -1700,7 +1705,7 @@ export const useDataStore = defineStore('data', {
1700
1705
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.mainPremium);
1701
1706
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1702
1707
  if (calculationResponse.clients) {
1703
- this.formStore.lfb.insurers = calculationResponse.clients;
1708
+ this.formStore.lfb.clients = calculationResponse.clients;
1704
1709
  }
1705
1710
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1706
1711
  return calculationResponse;
@@ -1747,6 +1752,9 @@ export const useDataStore = defineStore('data', {
1747
1752
  this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(govPremiums.statePremium5 === null ? null : govPremiums.statePremium5);
1748
1753
  this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(govPremiums.statePremium7 === null ? null : govPremiums.statePremium7);
1749
1754
  }
1755
+ if (this.isLifeBusiness) {
1756
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result.value);
1757
+ }
1750
1758
 
1751
1759
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1752
1760
  } catch (err) {
@@ -2277,12 +2285,38 @@ export const useDataStore = defineStore('data', {
2277
2285
  ErrorHandler(err);
2278
2286
  }
2279
2287
  },
2288
+ async downloadTemplate() {
2289
+ try {
2290
+ this.isButtonsLoading = true;
2291
+ const response: any = await this.api.downloadTemplate();
2292
+ const blob = new Blob([response], {
2293
+ type: `application/pdf`,
2294
+ });
2295
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2296
+ const url = window.URL.createObjectURL(blob);
2297
+ const link = document.createElement('a');
2298
+ link.href = url;
2299
+ link.setAttribute('download', this.formStore.regNumber + ' Договор страхования');
2300
+ document.body.appendChild(link);
2301
+ link.click();
2302
+ } catch (err) {
2303
+ ErrorHandler(err);
2304
+ }
2305
+ this.isButtonsLoading = false;
2306
+ },
2307
+ async sendTemplateToEmail(email: string) {
2308
+ try {
2309
+ this.isButtonsLoading = true;
2310
+ await this.api.sendTemplateToEmail(email);
2311
+ this.showToaster('info', this.t('toaster.needToSignContract'), 100000);
2312
+ } catch (err) {
2313
+ ErrorHandler(err);
2314
+ }
2315
+ this.isButtonsLoading = false;
2316
+ },
2280
2317
  async generateDocument() {
2281
2318
  try {
2282
2319
  this.isButtonsLoading = true;
2283
- if (this.formStore.signUrls.length) {
2284
- return this.formStore.signUrls;
2285
- }
2286
2320
  this.formStore.needToScanSignedContract = true;
2287
2321
  const data: SignDataType = {
2288
2322
  processInstanceId: String(this.formStore.applicationData.processInstanceId),
@@ -2935,6 +2969,241 @@ export const useDataStore = defineStore('data', {
2935
2969
  const economySectorCode = this.economySectorCode.find((i: Value) => i.ids === '500003.9');
2936
2970
  if (economySectorCode) member.economySectorCode = economySectorCode;
2937
2971
  },
2972
+ async startApplicationV2(policyholder: MemberV2) {
2973
+ if (!policyholder.personalData.iin) return false;
2974
+ try {
2975
+ const response = await this.api.startApplication(policyholder);
2976
+ this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
2977
+ return response.processInstanceId;
2978
+ } catch (err) {
2979
+ return ErrorHandler(err);
2980
+ }
2981
+ },
2982
+ async saveClient(policyholder: MemberV2) {
2983
+ try {
2984
+ this.formStore.applicationData.clientApp.clientData = policyholder;
2985
+ const response = await this.api.saveClient(this.formStore.applicationData.processInstanceId, this.formStore.lfb.clientId, this.formStore.applicationData.clientApp);
2986
+ return response;
2987
+ } catch (err) {
2988
+ return ErrorHandler(err);
2989
+ }
2990
+ },
2991
+ async getApplicationDataV2(taskId: string) {
2992
+ this.isLoading = true;
2993
+ try {
2994
+ const applicationData = await this.api.getApplicationData(taskId);
2995
+ if (this.processCode !== applicationData.processCode) {
2996
+ this.isLoading = false;
2997
+ this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
2998
+ return;
2999
+ }
3000
+
3001
+ this.formStore.applicationData = applicationData;
3002
+ this.formStore.regNumber = applicationData.regNumber;
3003
+ this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
3004
+
3005
+ this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
3006
+ this.formStore.applicationTaskId = taskId;
3007
+ this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
3008
+ this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
3009
+ this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
3010
+ this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
3011
+ this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
3012
+ this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
3013
+
3014
+ this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
3015
+ this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
3016
+
3017
+ const { clientData } = applicationData.clientApp;
3018
+ const beneficialOwnerApp = applicationData.beneficialOwnerApp;
3019
+ const insuredApp = applicationData.insuredApp;
3020
+ const accidentIncidents = applicationData.accidentIncidentDtos;
3021
+ const clientId = applicationData.clientApp.id;
3022
+
3023
+ this.formStore.applicationData.processInstanceId = applicationData.processInstanceId;
3024
+ this.formStore.lfb.policyholder = clientData;
3025
+ this.formStore.lfb.clientId = clientId;
3026
+ this.formStore.lfb.policyholder.clientPower.date = reformatDate(clientData.clientPower.date);
3027
+ this.formStore.lfb.accidentIncidents = accidentIncidents;
3028
+
3029
+ if (clientData && clientData.activityTypes !== null) {
3030
+ this.formStore.lfb.policyholderActivities = clientData.activityTypes;
3031
+ }
3032
+
3033
+ if (beneficialOwnerApp && beneficialOwnerApp.length) {
3034
+ this.formStore.lfb.beneficialOwners = beneficialOwnerApp;
3035
+ }
3036
+
3037
+ if (insuredApp && insuredApp.length) {
3038
+ const res = await this.newInsuredList(insuredApp);
3039
+ this.formStore.lfb.clients = res;
3040
+ }
3041
+
3042
+ this.formStore.productConditionsForm.coverPeriod = 12;
3043
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(
3044
+ applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount,
3045
+ );
3046
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
3047
+ applicationData.policyAppDto.mainPremium === 0 ? null : applicationData.policyAppDto.mainPremium,
3048
+ );
3049
+ const paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
3050
+ this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
3051
+ const processTariff = this.processTariff.find(item => item.id == applicationData.policyAppDto.tariffId);
3052
+ this.formStore.productConditionsForm.processTariff = processTariff ? processTariff : new Value();
3053
+ } catch (err) {
3054
+ ErrorHandler(err);
3055
+ if (err instanceof AxiosError) {
3056
+ this.sendToParent(constants.postActions.toHomePage, err.response?.data);
3057
+ this.isLoading = false;
3058
+ return false;
3059
+ }
3060
+ }
3061
+ this.isLoading = false;
3062
+ },
3063
+ async saveAccidentIncidents(data: AccidentIncidents[]) {
3064
+ try {
3065
+ const response = await this.api.saveAccidentIncidents(this.formStore.applicationData.processInstanceId, data);
3066
+ return response;
3067
+ } catch (err) {
3068
+ return ErrorHandler(err);
3069
+ }
3070
+ },
3071
+ async saveClientAcivityTypes(data: PolicyholderActivity[]) {
3072
+ try {
3073
+ const response = await this.api.saveClientAcivityTypes(this.formStore.applicationData.clientApp.id, data);
3074
+ return response;
3075
+ } catch (err) {
3076
+ return ErrorHandler(err);
3077
+ }
3078
+ },
3079
+ async saveBeneficialOwnerList(beneficialOwnerList: BeneficialOwner[]) {
3080
+ try {
3081
+ const response = await this.api.saveBeneficialOwnerList(this.formStore.applicationData.processInstanceId, beneficialOwnerList);
3082
+ return response;
3083
+ } catch (err) {
3084
+ return ErrorHandler(err);
3085
+ }
3086
+ },
3087
+ async saveBeneficialOwner(beneficialOwner: BeneficialOwner) {
3088
+ try {
3089
+ const response = await this.api.saveBeneficialOwner(this.formStore.applicationData.processInstanceId, beneficialOwner.id, beneficialOwner);
3090
+ return response;
3091
+ } catch (err) {
3092
+ return ErrorHandler(err);
3093
+ }
3094
+ },
3095
+ async saveInsuredList(insuredList: any) {
3096
+ try {
3097
+ const response = await this.api.saveInsuredList(this.formStore.applicationData.processInstanceId, insuredList);
3098
+ return response;
3099
+ } catch (err) {
3100
+ return ErrorHandler(err);
3101
+ }
3102
+ },
3103
+ async saveInsured(insuredId: any) {
3104
+ try {
3105
+ const response = await this.api.saveInsured(this.formStore.applicationData.processInstanceId, insuredId.id, insuredId);
3106
+ return response;
3107
+ } catch (err) {
3108
+ return ErrorHandler(err);
3109
+ }
3110
+ },
3111
+ newInsuredList(list: any) {
3112
+ const clients = list.map((item: any, index: number) => {
3113
+ const client = item.insuredData;
3114
+ return {
3115
+ id: index,
3116
+ fullName: client.personalData.longName,
3117
+ sex: client.personalData.sex,
3118
+ position: item.position,
3119
+ birthDate: client.personalData.birthDate,
3120
+ iin: client.personalData.iin,
3121
+ insSum: client.insuredPolicyData.insSum,
3122
+ premium: client.insuredPolicyData.premium,
3123
+ };
3124
+ });
3125
+ return clients;
3126
+ },
3127
+ validateMultipleMembersV2(localKey: string, applicationKey: keyof typeof this.formStore.applicationData, text: string) {
3128
+ // @ts-ignore
3129
+ if (this.formStore.lfb[localKey].length === this.formStore.applicationData[applicationKey].length) {
3130
+ // @ts-ignore
3131
+ if (this.formStore.lfb[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
3132
+ // @ts-ignore
3133
+ const localMembers = [...this.formStore.lfb[localKey]].sort((a, b) => Number(a.id) - Number(b.id));
3134
+ const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.id - b.id);
3135
+ if (localMembers.every((each, index) => applicationMembers[index].iin === each.iin?.replace(/-/g, '')) === false) {
3136
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3137
+ return false;
3138
+ }
3139
+ }
3140
+ } else {
3141
+ // @ts-ignore
3142
+ if (this.formStore.lfb[localKey].some(i => i.iin !== null)) {
3143
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3144
+ return false;
3145
+ }
3146
+ if (this.formStore.applicationData[applicationKey].length !== 0) {
3147
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3148
+ return false;
3149
+ } else {
3150
+ // @ts-ignore
3151
+ if (this.formStore.lfb[localKey][0].iin !== null) {
3152
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
3153
+ return false;
3154
+ }
3155
+ }
3156
+ }
3157
+ return true;
3158
+ },
3159
+ async validateAllFormsV2(taskId: string) {
3160
+ this.isLoading = true;
3161
+ if (taskId === '0') {
3162
+ this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
3163
+ return false;
3164
+ }
3165
+
3166
+ if (this.formStore.applicationData.clientApp.iin !== this.formStore.applicationData.clientApp.iin) {
3167
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
3168
+ return false;
3169
+ }
3170
+
3171
+ if (this.formStore.lfb.beneficialOwners) {
3172
+ if (this.validateMultipleMembersV2('beneficialOwners', 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
3173
+ return false;
3174
+ }
3175
+ const inStatement = this.formStore.lfb.beneficialOwners.every(i => i.id !== null);
3176
+ if (inStatement === false) {
3177
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.beneficialOwner') }));
3178
+ return false;
3179
+ }
3180
+ }
3181
+
3182
+ if (this.formStore.lfb.policyholderActivities) {
3183
+ if (this.formStore.lfb.policyholderActivities.length !== this.formStore.applicationData.clientApp.clientData.activityTypes.length) {
3184
+ this.showToaster('error', this.t('toaster.notSavedMember', { text: 'деятельности Страхователя' }), 3000);
3185
+ return false;
3186
+ }
3187
+ }
3188
+
3189
+ if (this.formStore.lfb.clients) {
3190
+ if (this.validateMultipleMembersV2('clients', 'insuredApp', 'застрахованных') === false) {
3191
+ return false;
3192
+ }
3193
+ const inStatement = this.formStore.lfb.clients.every(i => i.id !== null);
3194
+ if (inStatement === false) {
3195
+ this.showToaster('error', this.t('toaster.requiredMember', { text: this.t('toaster.insured') }));
3196
+ return false;
3197
+ }
3198
+ }
3199
+
3200
+ if (!this.formStore.productConditionsForm.insurancePremiumPerMonth && !this.formStore.productConditionsForm.requestedSumInsured) {
3201
+ this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
3202
+ return false;
3203
+ }
3204
+
3205
+ return true;
3206
+ },
2938
3207
  async checkIIN(iin: number) {
2939
3208
  try {
2940
3209
  const response = await this.api.checkIIN(iin);
@@ -11,7 +11,9 @@ export const useFormStore = defineStore('forms', {
11
11
  this.lfb.policyholderActivities.push(new PolicyholderActivity());
12
12
  }
13
13
  if (whichMember === 'beneficialOwner') {
14
- this.lfb.beneficialOwners.push(new BeneficialOwner());
14
+ if (this.lfb.beneficialOwners.length !== 3) {
15
+ this.lfb.beneficialOwners.push(new BeneficialOwner());
16
+ }
15
17
  }
16
18
  },
17
19
  },
package/types/index.ts CHANGED
@@ -262,8 +262,9 @@ declare global {
262
262
  insSumType?: number;
263
263
  insSumMultiplier?: number;
264
264
  fixInsSum?: number | null;
265
- agentCommission?: string | number | null;
265
+ tariffId?: string | number | null;
266
266
  clients?: ClientV2[];
267
+ agentCommission?: any;
267
268
  };
268
269
 
269
270
  interface ClientV2 {
@@ -529,7 +530,6 @@ declare global {
529
530
  underwritingType?: number;
530
531
  annualIncome?: number | null;
531
532
  calcDirect?: number;
532
- tariffId?: string;
533
533
  tariffName?: string;
534
534
  riskGroup?: number;
535
535
  riskGroup2?: number;
@@ -558,6 +558,9 @@ declare global {
558
558
  tripInsurancePeriod?: string | number | null;
559
559
  startDate?: string | null;
560
560
  endDate?: string | null;
561
+ insTermInMonth?: number | null;
562
+ fixInsSum?: number | string | null;
563
+ tariffId?: string | null;
561
564
  };
562
565
 
563
566
  type InsisWorkDataApp = {
@@ -621,10 +624,43 @@ declare global {
621
624
  name: string;
622
625
  };
623
626
 
627
+ type AccidentIncidents = {
628
+ id: string | null;
629
+ processInstanceId: string | null;
630
+ coverTypeId: string | null;
631
+ coverTypeName: string | null;
632
+ coverTypeCode: number | null;
633
+ count: number | null;
634
+ amount: number | null;
635
+ shortDescription: string | null;
636
+ };
637
+
624
638
  type GovPremiums = {
625
639
  statePremium5: number | null;
626
640
  statePremium7: number | null;
627
641
  totalAmount5: number | null;
628
642
  totalAmount7: number | null;
629
643
  };
644
+
645
+ type LabelSize = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
646
+
647
+ type Label = {
648
+ value: string;
649
+ hideInMobile: Boolean;
650
+ size: LabelSize;
651
+ };
652
+
653
+ type Entry = {
654
+ value: string;
655
+ formatType?: 'iin' | 'fullName' | 'phone' | 'digits';
656
+ };
657
+
658
+ type FormBlock = {
659
+ title: string;
660
+ redirectPath: string;
661
+ key?: string;
662
+ disabled: boolean;
663
+ labels: Label[];
664
+ entries: Entry[];
665
+ };
630
666
  }