hl-core 0.0.9-beta.10 → 0.0.9-beta.12

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.
@@ -44,6 +44,7 @@ export const useDataStore = defineStore('data', {
44
44
  isLiferenta: state => state.product === 'liferenta',
45
45
  isGons: state => state.product === 'gons',
46
46
  isKazyna: state => state.product === 'halykkazyna',
47
+ isDas: state => state.product === 'daskamkorlyk',
47
48
  isCalculator: state => state.product === 'calculator',
48
49
  isCheckContract: state => state.product === 'checkcontract',
49
50
  isCheckContragent: state => state.product === 'checkcontragent',
@@ -1285,46 +1286,37 @@ export const useDataStore = defineStore('data', {
1285
1286
  surveyType: 'health' | 'critical',
1286
1287
  processInstanceId: string | number,
1287
1288
  insuredId: any,
1288
- baseField: string,
1289
- secondaryField: string,
1289
+ baseField: 'surveyByHealthBase' | 'surveyByCriticalBase' | 'surveyByHealthBasePolicyholder' | 'surveyByCriticalBasePolicyholder',
1290
1290
  whichMember: 'insured' | 'policyholder' = 'insured',
1291
1291
  ) {
1292
- //@ts-ignore
1293
- if (!this.formStore[baseField] || (this.formStore[baseField] && !this.formStore[baseField].length)) {
1292
+ if (!this.formStore[baseField]) {
1294
1293
  try {
1295
- if (whichMember === 'insured') {
1296
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1297
- this.api.getQuestionList(surveyType, processInstanceId, insuredId),
1298
- this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1299
- ]);
1300
- if (baseQuestions.status === 'fulfilled') {
1301
- //@ts-ignore
1302
- this.formStore[baseField] = baseQuestions.value;
1303
- }
1304
- if (secondaryQuestions.status === 'fulfilled') {
1305
- //@ts-ignore
1306
- this.formStore[secondaryField] = secondaryQuestions;
1307
- }
1308
- }
1309
- if (whichMember === 'policyholder') {
1310
- const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1311
- this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1312
- this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1313
- ]);
1314
- if (baseQuestions.status === 'fulfilled') {
1315
- //@ts-ignore
1316
- this.formStore[baseField] = baseQuestions.value;
1317
- }
1318
- if (secondaryQuestions.status === 'fulfilled') {
1319
- //@ts-ignore
1320
- this.formStore[secondaryField] = secondaryQuestions;
1294
+ const [baseQuestions, secondaryQuestions] = await Promise.allSettled([
1295
+ whichMember === 'insured'
1296
+ ? this.api.getQuestionList(surveyType, processInstanceId, insuredId)
1297
+ : this.api.getClientQuestionList(surveyType, processInstanceId, insuredId),
1298
+ whichMember === 'insured'
1299
+ ? this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId)
1300
+ : this.api.getClientQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
1301
+ ,
1302
+ ]);
1303
+ if (baseQuestions.status === 'fulfilled') {
1304
+ this.formStore[baseField] = baseQuestions.value;
1305
+ }
1306
+ if (secondaryQuestions.status === 'fulfilled') {
1307
+ const baseAnketa = this.formStore[baseField];
1308
+ if (baseAnketa && baseAnketa.body && baseAnketa.body.length) {
1309
+ baseAnketa.body.forEach(i => {
1310
+ if (i.first.definedAnswers === 'Y' && i.second === null && secondaryQuestions.value) {
1311
+ i.second = structuredClone(secondaryQuestions.value);
1312
+ }
1313
+ });
1321
1314
  }
1322
1315
  }
1323
1316
  } catch (err) {
1324
- console.log(err);
1317
+ ErrorHandler(err);
1325
1318
  }
1326
1319
  }
1327
- //@ts-ignore
1328
1320
  return this.formStore[baseField];
1329
1321
  },
1330
1322
  getNumberWithSpaces(n: any) {
@@ -1541,7 +1533,7 @@ export const useDataStore = defineStore('data', {
1541
1533
  calculationData.amountInCurrency = getNumber(String(this.formStore.productConditionsForm.requestedSumInsuredInDollar));
1542
1534
  calculationData.currencyExchangeRate = this.currencies.usd;
1543
1535
  }
1544
- if (this.isLiferenta) {
1536
+ if (this.isLiferenta || product === 'liferenta') {
1545
1537
  calculationData.guaranteedPaymentPeriod = this.formStore.productConditionsForm.guaranteedPeriod || 0;
1546
1538
  calculationData.annuityTypeId = (this.formStore.productConditionsForm.typeAnnuityInsurance.id as string) ?? undefined;
1547
1539
  calculationData.paymentPeriod = Number(this.formStore.productConditionsForm.termAnnuityPayments);
@@ -1558,9 +1550,15 @@ export const useDataStore = defineStore('data', {
1558
1550
  this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1559
1551
  }
1560
1552
  }
1561
- if (this.isLiferenta) {
1553
+ if (this.isLiferenta || product === 'liferenta') {
1562
1554
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(calculationResponse.annuityMonthPay);
1563
1555
  }
1556
+ if (this.isGons || product === 'gons') {
1557
+ this.formStore.productConditionsForm.totalAmount5 = this.getNumberWithSpaces(calculationResponse.totalAmount5);
1558
+ this.formStore.productConditionsForm.totalAmount7 = this.getNumberWithSpaces(calculationResponse.totalAmount7);
1559
+ this.formStore.productConditionsForm.statePremium5 = this.getNumberWithSpaces(calculationResponse.statePremium5);
1560
+ this.formStore.productConditionsForm.statePremium7 = this.getNumberWithSpaces(calculationResponse.statePremium7);
1561
+ }
1564
1562
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1565
1563
  } catch (err) {
1566
1564
  ErrorHandler(err);
@@ -1596,6 +1594,7 @@ export const useDataStore = defineStore('data', {
1596
1594
  if (this.isLiferenta) {
1597
1595
  this.formStore.productConditionsForm.amountAnnuityPayments = this.getNumberWithSpaces(applicationData.policyAppDto.annuityMonthPay);
1598
1596
  }
1597
+
1599
1598
  this.showToaster('success', this.t('toaster.calculated'), 1000);
1600
1599
  } catch (err) {
1601
1600
  ErrorHandler(err);
@@ -2087,6 +2086,9 @@ export const useDataStore = defineStore('data', {
2087
2086
  const recalculatedValue = await this.api.reCalculate(data);
2088
2087
  if (!!recalculatedValue) {
2089
2088
  await this.getApplicationData(taskId, false, false, false, true);
2089
+ if (this.isGons) {
2090
+ this.formStore.productConditionsForm.isRecalculated = true;
2091
+ }
2090
2092
  this.showToaster(
2091
2093
  'success',
2092
2094
  `${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
@@ -2247,104 +2249,97 @@ export const useDataStore = defineStore('data', {
2247
2249
  if (!anketa) return false;
2248
2250
  const list = anketa.body;
2249
2251
  if (!list || (list && list.length === 0)) return false;
2250
- let notAnswered = 0;
2251
- for (let x = 0; x < list.length; x++) {
2252
- if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
2253
- notAnswered = notAnswered + 1;
2252
+ const isAnketaValid = ref<boolean>(true);
2253
+ list.forEach(i => {
2254
+ if ((i.first.definedAnswers === 'N' && !i.first.answerText) || (i.first.definedAnswers === 'Y' && !i.first.answerName)) {
2255
+ isAnketaValid.value = false;
2256
+ return false;
2254
2257
  }
2255
- }
2256
- return notAnswered === 0;
2258
+ if (this.controls.isSecondAnketaRequired && i.first.definedAnswers === 'Y' && i.first.answerName?.match(new RegExp('Да', 'i'))) {
2259
+ if (i.second && i.second.length) {
2260
+ const isValid = i.second.every(second => (second.definedAnswers === 'N' ? !!second.answerText : !!second.answerName));
2261
+ if (!isValid) {
2262
+ isAnketaValid.value = false;
2263
+ this.showToaster('info', this.t('toaster.emptySecondAnketa', { text: i.first.name }), 5000);
2264
+ return false;
2265
+ }
2266
+ } else {
2267
+ // TODO уточнить
2268
+ }
2269
+ }
2270
+ });
2271
+ return isAnketaValid.value;
2257
2272
  },
2258
2273
  async validateAllForms(taskId: string) {
2259
2274
  this.isLoading = true;
2260
2275
  const areMembersValid = await this.validateAllMembers(taskId);
2261
2276
  if (areMembersValid) {
2262
2277
  if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
2263
- const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
2264
- if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i'))) {
2278
+ const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName.match(new RegExp('Критическое заболевание Застрахованного', 'i'))) ?? null;
2279
+ if (hasCritical === null || (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')))) {
2265
2280
  await Promise.allSettled([
2266
- this.getQuestionList(
2267
- 'health',
2268
- this.formStore.applicationData.processInstanceId,
2269
- this.formStore.applicationData.insuredApp[0].id,
2270
- 'surveyByHealthBase',
2271
- 'surveyByHealthSecond',
2272
- ),
2273
- this.getQuestionList(
2274
- 'critical',
2275
- this.formStore.applicationData.processInstanceId,
2276
- this.formStore.applicationData.insuredApp[0].id,
2277
- 'surveyByCriticalBase',
2278
- 'surveyByCriticalSecond',
2279
- ),
2281
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2280
2282
  this.isClientAnketaCondition &&
2281
2283
  this.getQuestionList(
2282
2284
  'health',
2283
2285
  this.formStore.applicationData.processInstanceId,
2284
2286
  this.formStore.applicationData.clientApp.id,
2285
2287
  'surveyByHealthBasePolicyholder',
2286
- 'surveyByHealthSecond',
2287
2288
  'policyholder',
2288
2289
  ),
2290
+ ,
2289
2291
  ]);
2290
2292
  this.isClientAnketaCondition
2291
2293
  ? await Promise.allSettled([
2292
2294
  ...this.formStore.surveyByHealthBase!.body.map(async question => {
2293
2295
  await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2294
2296
  }),
2295
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2296
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2297
- }),
2298
2297
  ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2299
2298
  await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2300
2299
  }),
2301
2300
  ])
2302
- : await Promise.allSettled([
2303
- ...this.formStore.surveyByHealthBase!.body.map(async question => {
2301
+ : await Promise.allSettled(
2302
+ this.formStore.surveyByHealthBase!.body.map(async question => {
2304
2303
  await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2305
2304
  }),
2306
- ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2307
- await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2308
- }),
2309
- ]);
2305
+ );
2310
2306
  } else {
2311
2307
  await Promise.allSettled([
2312
- this.getQuestionList(
2313
- 'health',
2314
- this.formStore.applicationData.processInstanceId,
2315
- this.formStore.applicationData.insuredApp[0].id,
2316
- 'surveyByHealthBase',
2317
- 'surveyByHealthSecond',
2318
- ),
2308
+ this.getQuestionList('health', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByHealthBase'),
2309
+ this.getQuestionList('critical', this.formStore.applicationData.processInstanceId, this.formStore.applicationData.insuredApp[0].id, 'surveyByCriticalBase'),
2319
2310
  this.isClientAnketaCondition &&
2320
2311
  this.getQuestionList(
2321
2312
  'health',
2322
2313
  this.formStore.applicationData.processInstanceId,
2323
2314
  this.formStore.applicationData.clientApp.id,
2324
2315
  'surveyByHealthBasePolicyholder',
2325
- 'surveyByHealthSecond',
2326
2316
  'policyholder',
2327
2317
  ),
2328
- ,
2329
2318
  ]);
2330
2319
  this.isClientAnketaCondition
2331
2320
  ? await Promise.allSettled([
2332
2321
  ...this.formStore.surveyByHealthBase!.body.map(async question => {
2333
2322
  await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2334
2323
  }),
2324
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2325
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2326
+ }),
2335
2327
  ...this.formStore.surveyByHealthBasePolicyholder!.body.map(async question => {
2336
2328
  await this.definedAnswers(question.first.id, 'surveyByHealthBasePolicyholder');
2337
2329
  }),
2338
2330
  ])
2339
- : await Promise.allSettled(
2340
- this.formStore.surveyByHealthBase!.body.map(async question => {
2331
+ : await Promise.allSettled([
2332
+ ...this.formStore.surveyByHealthBase!.body.map(async question => {
2341
2333
  await this.definedAnswers(question.first.id, 'surveyByHealthBase');
2342
2334
  }),
2343
- );
2335
+ ...this.formStore.surveyByCriticalBase!.body.map(async question => {
2336
+ await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
2337
+ }),
2338
+ ]);
2344
2339
  }
2345
2340
  if (this.validateAnketa('surveyByHealthBase')) {
2346
2341
  let hasCriticalAndItsValid = null;
2347
- if (hasCritical && hasCritical.coverSumName !== 'не включено') {
2342
+ if (hasCritical && hasCritical.coverSumName.match(new RegExp('не включено', 'i')) === null) {
2348
2343
  if (this.validateAnketa('surveyByCriticalBase')) {
2349
2344
  hasCriticalAndItsValid = true;
2350
2345
  } else {
package/store/rules.ts CHANGED
@@ -5,6 +5,7 @@ const t = i18n.t;
5
5
 
6
6
  export const rules = {
7
7
  recalculationMultiply: [(v: any) => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher', { text: '100' })],
8
+ recalculationMultiplyBetween: [(v: any) => (v !== null && v !== '' && v >= 100 && v <= 200) || t('toaster.recalculationMultiplyBetween', { floor: '100', ceil: '200' })],
8
9
  recalculationAdditive: [(v: any) => (v !== null && v !== '' && v <= 100 && v >= 0) || t('toaster.valueShouldBeBetween', { floor: '0', ceil: '100' })],
9
10
  required: [(v: any) => !!v || t('rules.required')],
10
11
  objectRequired: [
package/types/enum.ts CHANGED
@@ -17,6 +17,7 @@ export enum Actions {
17
17
  register = 'register',
18
18
  send = 'send',
19
19
  affiliate = 'affiliate',
20
+ template = 'template',
20
21
  }
21
22
 
22
23
  export enum PostActions {
@@ -81,3 +82,8 @@ export enum MemberAppCodes {
81
82
  beneficialOwnerApp = 'beneficialOwnerApp',
82
83
  spokesmanApp = 'spokesmanApp',
83
84
  }
85
+
86
+ export enum Methods {
87
+ GET = 'GET',
88
+ POST = 'POST',
89
+ }
package/types/index.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { RouteLocationNormalizedLoaded, RouteLocationNormalized } from 'vue-router';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { Methods } from './enum';
2
4
 
3
5
  export {};
4
6
 
@@ -18,7 +20,8 @@ declare global {
18
20
  | 'lka'
19
21
  | 'mycar'
20
22
  | 'checkcontract'
21
- | 'checkcontragent';
23
+ | 'checkcontragent'
24
+ | 'daskamkorlyk';
22
25
  type MemberKeys = keyof ReturnType<typeof useFormStore>;
23
26
  type MemberFormTypes = 'policyholderForm' | 'insuredForm' | 'beneficiaryForm' | 'beneficialOwnerForm' | 'policyholdersRepresentativeForm' | 'productConditionsForm';
24
27
  type SingleMember = 'policyholderForm' | 'policyholdersRepresentativeForm';
@@ -141,7 +144,7 @@ declare global {
141
144
 
142
145
  type AnketaBody = {
143
146
  first: EachAnketa;
144
- second: any[] | null;
147
+ second: AnketaSecond[] | null;
145
148
  };
146
149
 
147
150
  type EachAnketa = {
@@ -251,6 +254,10 @@ declare global {
251
254
  type RecalculationResponseType = {
252
255
  amount: number;
253
256
  premium: number;
257
+ statePremium5?: number;
258
+ statePremium7?: number;
259
+ totalAmount5?: number;
260
+ totalAmount7?: number;
254
261
  mainCoverPremium: number;
255
262
  addCovers: AddCover[];
256
263
  amountInCurrency: number;
@@ -258,7 +265,7 @@ declare global {
258
265
  annuityMonthPay: string | number | null;
259
266
  };
260
267
 
261
- type AddCover = {
268
+ interface AddCover {
262
269
  id: string | null;
263
270
  processInstanceId: string;
264
271
  coverTypeId: string;
@@ -270,7 +277,7 @@ declare global {
270
277
  amount: number;
271
278
  premium: number;
272
279
  isMigrate: boolean;
273
- };
280
+ }
274
281
 
275
282
  type SignUrlType = {
276
283
  uri: string;
@@ -414,7 +421,7 @@ declare global {
414
421
  stateName?: string;
415
422
  cityCode?: string | number;
416
423
  cityName?: string;
417
- regionCode?: string | number |null;
424
+ regionCode?: string | number | null;
418
425
  regionName?: string | null;
419
426
  streetName?: string;
420
427
  blockNumber?: string;
@@ -518,4 +525,8 @@ declare global {
518
525
  managerPolicyName?: string;
519
526
  insuranceProgramType?: string;
520
527
  };
528
+
529
+ interface AxiosRequestLocalConfig extends AxiosRequestConfig {
530
+ method: Methods | keyof typeof Methods;
531
+ }
521
532
  }