hl-core 0.0.7-beta.17 → 0.0.7-beta.18

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.
package/api/index.ts CHANGED
@@ -449,6 +449,21 @@ export class ApiClass {
449
449
  });
450
450
  }
451
451
 
452
+ async calculateWithoutApplication(data: any) {
453
+ return this.axiosCall({
454
+ method: Methods.POST,
455
+ url: `/${this.productUrl}/api/Application/Calculate`,
456
+ data: data,
457
+ });
458
+ }
459
+
460
+ async getDefaultCalculationData() {
461
+ return this.axiosCall({
462
+ method: Methods.GET,
463
+ url: `/${this.productUrl}/api/Application/DefaultCalculatorValues`,
464
+ });
465
+ }
466
+
452
467
  async reCalculate(data: any) {
453
468
  return this.axiosCall({
454
469
  method: Methods.POST,
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div class="flex flex-col justify-between rounded-lg" :class="[$libStyles.whiteBg]">
3
+ <span v-if="title" class="p-4" :class="[$libStyles.textTitle]">{{ title }}</span>
4
+ <span v-if="subtitle" class="p-4 text-[#99A3B3] border-t-[1px]" :class="[$libStyles.textSimple]">{{ subtitle }}</span>
5
+ </div>
6
+ </template>
7
+
8
+ <script lang="ts">
9
+ export default defineComponent({
10
+ props: {
11
+ title: {
12
+ type: String,
13
+ },
14
+ subtitle: {
15
+ type: String,
16
+ },
17
+ },
18
+ });
19
+ </script>
@@ -886,11 +886,12 @@ export default {
886
886
  watch(
887
887
  () => member.value.percentageOfPayoutAmount,
888
888
  val => {
889
- if (val) {
890
- if (val < 0) {
889
+ const percentage = typeof val === 'string' ? Number(val) : val;
890
+ if (percentage) {
891
+ if (percentage < 0) {
891
892
  member.value.percentageOfPayoutAmount = 0;
892
893
  dataStore.showToaster('error', dataStore.t('toaster.incorrectInput'), 1000);
893
- } else if (val > 100) {
894
+ } else if (percentage > 100) {
894
895
  member.value.percentageOfPayoutAmount = 100;
895
896
  dataStore.showToaster('error', dataStore.t('toaster.incorrectInput'), 1000);
896
897
  }
@@ -1,42 +1,342 @@
1
1
  <template>
2
2
  <section class="flex flex-col gap-4 px-[10px]">
3
- <v-form ref="vForm" @submit="submitForm">
3
+ <v-form ref="vForm" @submit="submitForm" class="max-h-[82svh] overflow-y-scroll">
4
+ <base-form-section v-if="$dataStore.isGons" :title="$t('productConditionsForm.requestedProductConditions')" :class="[$libStyles.textSimple]">
5
+ <base-form-text-section
6
+ class="mb-4"
7
+ title="Инвалидность I или II группы по причине несчастного случая, начиная с третьего года по любой причине, с освобождением от уплаты страховых взносов"
8
+ subtitle="Равна страховой сумме по основному покрытию"
9
+ ></base-form-text-section>
10
+ <base-form-text-section
11
+ title="Если лицо, назначенное Выгодоприобретателем, на дату осуществления Страховщиком страховой выплаты не достигло совершеннолетия (восемнадцатилетнего возраста), страховая
12
+ выплата подлежит осуществлению:"
13
+ subtitle="Если несовершеннолетний не достиг возраста 14 лет - законному представителю в соответствии с законодательством Республики Казахстан"
14
+ ></base-form-text-section>
15
+ </base-form-section>
4
16
  <base-form-section :title="$t('generalConditions')">
17
+ <div v-if="isRecalculation && $route.params.taskId === '0'">
18
+ <base-form-input
19
+ v-model="formStore.productConditionsForm.signDate"
20
+ maska="##.##.####"
21
+ :clearable="false"
22
+ :readonly="true"
23
+ :label="$t('form.signDate')"
24
+ append-inner-icon="mdi mdi-calendar-blank-outline"
25
+ ></base-form-input>
26
+ <base-form-input
27
+ v-model="formStore.productConditionsForm.birthDate"
28
+ maska="##.##.####"
29
+ :readonly="isDisabled"
30
+ :clearable="!isDisabled"
31
+ :label="$t('form.birthDate')"
32
+ :rules="$rules.required.concat($rules.birthDate)"
33
+ append-inner-icon="mdi mdi-calendar-blank-outline"
34
+ ></base-form-input>
35
+ <base-panel-input
36
+ v-model="formStore.productConditionsForm.gender"
37
+ :value="formStore.productConditionsForm.gender.nameRu"
38
+ :readonly="isDisabled"
39
+ :clearable="!isDisabled"
40
+ :label="$t('form.gender')"
41
+ :rules="$rules.objectRequired"
42
+ append-inner-icon="mdi mdi-chevron-right"
43
+ @append="openPanel($t('form.gender'), $dataStore.gender, 'gender')"
44
+ ></base-panel-input>
45
+ </div>
46
+ <base-form-input
47
+ v-model="formStore.productConditionsForm.coverPeriod"
48
+ maska="#*"
49
+ :readonly="isDisabled"
50
+ :clearable="!isDisabled"
51
+ :rules="$rules.required.concat($rules.numbers, $rules.coverPeriodFrom3to20)"
52
+ :label="$t('productConditionsForm.coverPeriodFrom3to20')"
53
+ ></base-form-input>
54
+ <base-panel-input
55
+ v-model="formStore.productConditionsForm.paymentPeriod"
56
+ :value="formStore.productConditionsForm.paymentPeriod.nameRu"
57
+ :readonly="isDisabled"
58
+ :clearable="!isDisabled"
59
+ :rules="$rules.objectRequired"
60
+ :label="$t('productConditionsForm.processPaymentPeriod')"
61
+ append-inner-icon="mdi mdi-chevron-right"
62
+ @append="openPanel($t('productConditionsForm.processPaymentPeriod'), $dataStore.processPaymentPeriod, 'paymentPeriod', $dataStore.getProcessPaymentPeriod)"
63
+ ></base-panel-input>
5
64
  <base-form-input
6
65
  v-model="formStore.productConditionsForm.requestedSumInsured"
7
- :rules="$dataStore.rules.numbers"
66
+ :readonly="isDisabled"
67
+ :clearable="!isDisabled"
68
+ :rules="requestedSumInsured"
8
69
  :label="$t('productConditionsForm.requestedSumInsured')"
9
70
  ></base-form-input>
10
71
  <base-form-input
11
72
  v-model="formStore.productConditionsForm.insurancePremiumPerMonth"
12
- :rules="$dataStore.rules.numbers"
73
+ :readonly="isDisabled"
74
+ :clearable="!isDisabled"
75
+ :rules="insurancePremiumPerMonth"
13
76
  :label="$t('productConditionsForm.insurancePremiumAmount')"
14
77
  ></base-form-input>
15
78
  </base-form-section>
16
79
  </v-form>
17
- <base-btn :text="$t('buttons.calculate')" @click="submitForm"></base-btn>
80
+ <base-btn
81
+ v-if="!isDisabled && isTask && ($dataStore.isInitiator() || $dataStore.isUnderwriter())"
82
+ :loading="isCalculating"
83
+ :text="$t('buttons.calculate')"
84
+ @click="submitForm"
85
+ ></base-btn>
86
+ <Teleport v-if="isPanelOpen" to="#panel-actions">
87
+ <div :class="[$libStyles.scrollPage]" class="flex flex-col items-center">
88
+ <base-rounded-input v-model="searchQuery" :label="$t('labels.search')" class="w-full p-2" :hide-details="true"></base-rounded-input>
89
+ <div v-if="panelList && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
90
+ <base-panel-select-item :text="$t('form.notChosen')" :selected="panelValue.nameRu === null" @click="pickPanelValue(new Value())"></base-panel-select-item>
91
+ <base-panel-select-item
92
+ v-for="(item, index) of panelList.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
93
+ :key="index"
94
+ :text="item.nameRu as string"
95
+ :selected="item.nameRu === panelValue.nameRu"
96
+ @click="pickPanelValue(item)"
97
+ ></base-panel-select-item>
98
+ </div>
99
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
100
+ </div>
101
+ </Teleport>
18
102
  </section>
19
103
  </template>
20
104
 
21
105
  <script lang="ts">
106
+ import { Value } from '@/composables/classes';
107
+
22
108
  export default defineComponent({
23
- setup() {
24
- const formStore = useFormStore();
109
+ props: {
110
+ isRecalculation: {
111
+ type: Boolean,
112
+ default: false,
113
+ },
114
+ },
115
+ setup(props) {
25
116
  const vForm = ref<any>();
117
+ const route = useRoute();
118
+ const router = useRouter();
119
+ const formStore = useFormStore();
120
+ const dataStore = useDataStore();
121
+ const memberStore = useMemberStore();
122
+
123
+ const isCalculating = ref<boolean>(false);
124
+ const isPanelLoading = ref<boolean>(false);
125
+ const isPanelOpen = ref<boolean>(false);
126
+ const panelValue = ref<Value>(new Value());
127
+ const panelList = ref<Value[]>([]);
128
+ const currentPanel = ref<keyof typeof formStore.productConditionsForm>();
129
+ const searchQuery = ref<string>('');
130
+ const whichSum = ref<'insurancePremiumPerMonth' | 'requestedSumInsured' | ''>('');
131
+
132
+ const isUnderwriterForm = computed(() => {
133
+ if (route.params.taskId === '0 ' || props.isRecalculation === true) {
134
+ return false;
135
+ } else {
136
+ return formStore.applicationData.statusCode === 'UnderwriterForm';
137
+ }
138
+ });
139
+ const isDisabled = computed(() => !memberStore.isStatementEditible(formStore.productConditionsFormKey));
140
+ const isTask = computed(() => (route.params.taskId === '0' && props.isRecalculation === true) || dataStore.isTask());
141
+ const insurancePremiumPerMonth = computed(() => (!!formStore.productConditionsForm.insurancePremiumPerMonth ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
142
+ const requestedSumInsured = computed(() => (!!formStore.productConditionsForm.requestedSumInsured ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
143
+
144
+ const pickPanelValue = (item: Value) => {
145
+ if (!isDisabled.value) {
146
+ dataStore.panel.open = false;
147
+ isPanelOpen.value = false;
148
+ // @ts-ignore
149
+ formStore.productConditionsForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
150
+ } else {
151
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
152
+ }
153
+ };
154
+
155
+ const openPanel = async (title: string, list: Value[], key: string, asyncFunction?: Function, filterKey?: string) => {
156
+ if (!isDisabled.value) {
157
+ searchQuery.value = '';
158
+ currentPanel.value = key as keyof typeof formStore.productConditionsForm;
159
+ isPanelOpen.value = true;
160
+ dataStore.panelAction = null;
161
+ dataStore.panel.open = true;
162
+ dataStore.panel.title = title;
163
+
164
+ let newList = list;
165
+ if (asyncFunction) {
166
+ isPanelLoading.value = true;
167
+ newList = await asyncFunction(filterKey, formStore.productConditionsFormKey);
168
+ }
169
+ panelList.value = newList;
170
+ // @ts-ignore
171
+ panelValue.value = formStore.productConditionsForm[currentPanel.value];
172
+ isPanelLoading.value = false;
173
+ } else {
174
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
175
+ }
176
+ };
177
+
178
+ const pickCalculation = async (type: 'insurancePremiumPerMonth' | 'requestedSumInsured') => {
179
+ if (!type) return false;
180
+ whichSum.value = type;
181
+ await submitForm();
182
+ };
26
183
 
27
184
  const submitForm = async () => {
28
185
  vForm.value.validate().then(async (v: { valid: Boolean; errors: any }) => {
29
- console.log(v);
186
+ if (v.valid) {
187
+ if (whichSum.value === 'requestedSumInsured') {
188
+ formStore.productConditionsForm.insurancePremiumPerMonth = null;
189
+ }
190
+ if (whichSum.value === 'insurancePremiumPerMonth') {
191
+ formStore.productConditionsForm.requestedSumInsured = null;
192
+ }
193
+ if (formStore.productConditionsForm.requestedSumInsured !== '' && formStore.productConditionsForm.requestedSumInsured != null) {
194
+ formStore.productConditionsForm.insurancePremiumPerMonth = null;
195
+ if (props.isRecalculation) whichSum.value = 'requestedSumInsured';
196
+ }
197
+ if (formStore.productConditionsForm.insurancePremiumPerMonth !== '' && formStore.productConditionsForm.insurancePremiumPerMonth != null) {
198
+ formStore.productConditionsForm.requestedSumInsured = null;
199
+ if (props.isRecalculation) whichSum.value = 'insurancePremiumPerMonth';
200
+ }
201
+
202
+ if (!whichSum.value && isUnderwriterForm.value === false) {
203
+ dataStore.showToaster('error', dataStore.t('toaster.emptyProductConditions'));
204
+ return;
205
+ }
206
+
207
+ if (isUnderwriterForm.value) {
208
+ type recalculationInfo = {
209
+ lifeMultiply: string | null;
210
+ lifeAdditive: string | null;
211
+ adbMultiply: string | null;
212
+ adbAdditive: string | null;
213
+ disabilityMultiply: string | null;
214
+ disabilityAdditive: string | null;
215
+ amount?: number | null;
216
+ premium?: number | null;
217
+ riskGroup?: string | number | null;
218
+ };
219
+ const recalculationData: recalculationInfo = (({ lifeMultiply, lifeAdditive, adbMultiply, adbAdditive, disabilityMultiply, disabilityAdditive }) => ({
220
+ lifeMultiply,
221
+ lifeAdditive,
222
+ adbMultiply,
223
+ adbAdditive,
224
+ disabilityMultiply,
225
+ disabilityAdditive,
226
+ }))(formStore.productConditionsForm);
227
+ Object.keys(recalculationData).forEach(key => {
228
+ // @ts-ignore
229
+ recalculationData[key] = formatProcents(recalculationData[key]);
230
+ });
231
+ recalculationData.amount = Number(formStore.productConditionsForm.requestedSumInsured?.replace(/\s/g, ''));
232
+ recalculationData.premium = Number(formStore.productConditionsForm.insurancePremiumPerMonth?.replace(/\s/g, ''));
233
+ recalculationData.riskGroup = formStore.productConditionsForm.riskGroup?.id ? formStore.productConditionsForm.riskGroup.id : 1;
234
+ isCalculating.value = true;
235
+ await dataStore.reCalculate(formStore.applicationData.processInstanceId, recalculationData, route.params.taskId, whichSum.value);
236
+ }
237
+ isCalculating.value = true;
238
+ if (props.isRecalculation) {
239
+ await dataStore.calculateWithoutApplication(true);
240
+ } else {
241
+ if (dataStore.isProcessEditable(formStore.applicationData.statusCode)) {
242
+ await dataStore.calculate(route.params.taskId);
243
+ }
244
+ }
245
+ isCalculating.value = false;
246
+ } else {
247
+ const errors = document.querySelector('.v-input--error');
248
+ if (errors) {
249
+ const errorText = errors.querySelector('.v-label.v-field-label');
250
+ if (errorText) {
251
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField').replace('{text}', errorText.innerHTML?.replace(/[-<>!//.]/g, '')));
252
+ } else {
253
+ const errorFieldText = errors.querySelector('.v-input__control');
254
+ if (errorFieldText) {
255
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField').replace('{text}', errorFieldText.innerHTML?.replace(/[-<>!//.]/g, '')));
256
+ }
257
+ }
258
+ errors.scrollIntoView({
259
+ behavior: 'smooth',
260
+ block: 'center',
261
+ inline: 'nearest',
262
+ });
263
+ }
264
+ }
30
265
  });
31
266
  };
32
267
 
268
+ onMounted(async () => {
269
+ if (props.isRecalculation === true) {
270
+ if (route.params.taskId === '0') {
271
+ const defaultData = await dataStore.getDefaultCalculationData(true);
272
+ dataStore.additionalInsuranceTermsWithout = defaultData.addCovers;
273
+ formStore.productConditionsForm.requestedSumInsured = defaultData.amount;
274
+ formStore.productConditionsForm.insurancePremiumPerMonth = defaultData.premium;
275
+ formStore.productConditionsForm.processIndexRate = dataStore.processIndexRate.find(i => i.id === defaultData.indexRateId);
276
+ formStore.productConditionsForm.paymentPeriod = dataStore.processPaymentPeriod.find(i => i.id == defaultData.paymentPeriodId);
277
+ formStore.productConditionsForm.signDate = reformatDate(defaultData.signDate);
278
+ }
279
+ }
280
+ if (!!formStore.productConditionsForm.insurancePremiumPerMonth) {
281
+ whichSum.value = 'insurancePremiumPerMonth';
282
+ }
283
+ if (!!formStore.productConditionsForm.requestedSumInsured) {
284
+ whichSum.value = 'requestedSumInsured';
285
+ }
286
+ });
287
+
288
+ watch(
289
+ () => formStore.productConditionsForm.requestedSumInsured,
290
+ val => {
291
+ if (!val && whichSum.value == 'requestedSumInsured') whichSum.value = '';
292
+ if (val && whichSum.value != 'insurancePremiumPerMonth') {
293
+ whichSum.value = 'requestedSumInsured';
294
+ formStore.productConditionsForm.requestedSumInsured = dataStore.getNumberWithSpaces(val);
295
+ }
296
+ },
297
+ );
298
+ watch(
299
+ () => formStore.productConditionsForm.insurancePremiumPerMonth,
300
+ val => {
301
+ if (!val && whichSum.value == 'insurancePremiumPerMonth') whichSum.value = '';
302
+ if (val && whichSum.value != 'requestedSumInsured') {
303
+ whichSum.value = 'insurancePremiumPerMonth';
304
+ formStore.productConditionsForm.insurancePremiumPerMonth = dataStore.getNumberWithSpaces(val);
305
+ }
306
+ },
307
+ );
308
+ watch(
309
+ () => formStore.productConditionsForm.amountOfInsurancePremium,
310
+ val => {
311
+ if (val) formStore.productConditionsForm.amountOfInsurancePremium = dataStore.getNumberWithSpaces(val);
312
+ },
313
+ );
314
+
33
315
  return {
34
316
  // State
35
317
  formStore,
36
318
  vForm,
319
+ isCalculating,
320
+ isPanelLoading,
321
+ isPanelOpen,
322
+ panelValue,
323
+ panelList,
324
+ searchQuery,
325
+ whichSum,
326
+ Value,
327
+
328
+ // Computed
329
+ isTask,
330
+ isDisabled,
331
+ isUnderwriterForm,
332
+ insurancePremiumPerMonth,
333
+ requestedSumInsured,
37
334
 
38
335
  // Functions
39
336
  submitForm,
337
+ pickPanelValue,
338
+ openPanel,
339
+ pickCalculation,
40
340
  };
41
341
  },
42
342
  });
@@ -407,7 +407,7 @@ export class Member extends Person {
407
407
  email: string | null;
408
408
  address: string | null;
409
409
  familyStatus: Value;
410
- isTerror: Value | null;
410
+ isTerror: null;
411
411
  relationDegree: Value;
412
412
  isDisability: Value;
413
413
  disabilityGroup: Value | null;
@@ -586,7 +586,7 @@ export class Member extends Person {
586
586
  this.email = null;
587
587
  this.address = null;
588
588
  this.familyStatus = new Value();
589
- this.isTerror = new Value();
589
+ this.isTerror = null;
590
590
  this.relationDegree = new Value();
591
591
  this.isDisability = new Value();
592
592
  this.disabilityGroup = null;
@@ -669,6 +669,9 @@ export class PolicyholdersRepresentativeForm extends Member {
669
669
  }
670
670
 
671
671
  export class ProductConditions {
672
+ signDate: string | null;
673
+ birthDate: string | null;
674
+ gender: Value;
672
675
  insuranceCase: string | null;
673
676
  coverPeriod: string | null;
674
677
  payPeriod: string | null;
@@ -727,6 +730,9 @@ export class ProductConditions {
727
730
  riskGroup = new Value(),
728
731
  riskGroup2 = new Value(),
729
732
  ) {
733
+ this.signDate = null;
734
+ this.birthDate = null;
735
+ this.gender = new Value();
730
736
  this.insuranceCase = insuranceCase;
731
737
  this.coverPeriod = coverPeriod;
732
738
  this.payPeriod = payPeriod;
@@ -15,6 +15,10 @@ const xmlParser = new XMLParser({
15
15
  },
16
16
  });
17
17
 
18
+ export const getNumber = (number: string) => {
19
+ return number ? Number(number.replace(/\s/g, '')) : null;
20
+ };
21
+
18
22
  export const formatDate = (date: string) => {
19
23
  if (date) {
20
24
  const data = date.split('.');
@@ -38,7 +38,7 @@ const openSettings = async () => {
38
38
 
39
39
  const onLink = async (item: MenuItem) => {
40
40
  if (dataStore.menu.onLink) await dataStore.menu.onLink(item);
41
- dataStore.menu.selectedItem = item;
41
+ if (typeof item.disabled === 'boolean' ? !item.disabled : true) dataStore.menu.selectedItem = item;
42
42
  };
43
43
 
44
44
  const onBack = async (item: MenuItem) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hl-core",
3
- "version": "0.0.7-beta.17",
3
+ "version": "0.0.7-beta.18",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "nuxt.config.ts",
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
2
2
  import { t } from './messages';
3
3
  import { rules } from './rules';
4
4
  import { Toast, Types, Positions, ToastOptions } from './toast';
5
- import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern } from '../composables';
5
+ import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber } from '../composables';
6
6
  import { DataStoreClass, Contragent } from '../composables/classes';
7
7
  import { ApiClass } from '@/api';
8
8
  import { useFormStore } from './form.store';
@@ -831,16 +831,21 @@ export const useDataStore = defineStore('data', {
831
831
  await this.api.deleteMember('Spokesman', this.formStore.applicationData.processInstanceId);
832
832
  }
833
833
  data.migrationCard = member.migrationCard;
834
- data.migrationCardIssueDate = formatDate(member.migrationCardIssueDate);
835
- data.migrationCardExpireDate = formatDate(member.migrationCardExpireDate);
834
+ const migrationCardIssueDate = formatDate(member.migrationCardIssueDate);
835
+ if (migrationCardIssueDate) data.migrationCardIssueDate = migrationCardIssueDate.toISOString();
836
+ const migrationCardExpireDate = formatDate(member.migrationCardExpireDate);
837
+ if (migrationCardExpireDate) data.migrationCardExpireDate = migrationCardExpireDate.toISOString();
836
838
  data.confirmDocType = member.confirmDocType;
837
839
  data.confirmDocNumber = member.confirmDocNumber;
838
- data.confirmDocIssueDate = formatDate(member.migrationCardIssueDate);
839
- data.confirmDocExpireDate = formatDate(member.migrationCardExpireDate);
840
+ const confirmDocIssueDate = formatDate(member.confirmDocIssueDate);
841
+ if (confirmDocIssueDate) data.confirmDocIssueDate = confirmDocIssueDate.toISOString();
842
+ const confirmDocExpireDate = formatDate(member.confirmDocExpireDate);
843
+ if (confirmDocExpireDate) data.confirmDocExpireDate = confirmDocExpireDate.toISOString();
840
844
  data.clientLongName = this.formStore.applicationData.clientApp.longName;
841
845
  data.notaryLongName = member.notaryLongName;
842
846
  data.notaryLicenseNumber = member.notaryLicenseNumber;
843
- data.notaryLicenseDate = formatDate(member.notaryLicenseDate);
847
+ const notaryLicenseDate = formatDate(member.notaryLicenseDate);
848
+ if (notaryLicenseDate) data.notaryLicenseDate = notaryLicenseDate.toISOString();
844
849
  data.notaryLicenseIssuer = member.notaryLicenseIssuer;
845
850
  data.jurLongName = member.jurLongName;
846
851
  data.fullNameRod = member.fullNameRod;
@@ -1322,7 +1327,7 @@ export const useDataStore = defineStore('data', {
1322
1327
  id: this.affilationResolution.id,
1323
1328
  processInstanceId: this.affilationResolution.processInstanceId,
1324
1329
  number: this.affilationResolution.number,
1325
- date: formatDate(this.affilationResolution.date),
1330
+ date: formatDate(this.affilationResolution.date)?.toISOString(),
1326
1331
  };
1327
1332
  try {
1328
1333
  this.isLoading = true;
@@ -1372,6 +1377,46 @@ export const useDataStore = defineStore('data', {
1372
1377
  console.log(err);
1373
1378
  }
1374
1379
  },
1380
+ async getDefaultCalculationData(showLoader = false) {
1381
+ this.isLoading = showLoader;
1382
+ try {
1383
+ const calculationData = await this.api.getDefaultCalculationData();
1384
+ return calculationData;
1385
+ } catch (err) {
1386
+ ErrorHandler(err);
1387
+ } finally {
1388
+ this.isLoading = false;
1389
+ }
1390
+ },
1391
+ async calculateWithoutApplication(showLoader = false) {
1392
+ this.isLoading = showLoader;
1393
+ try {
1394
+ const calculationData = {
1395
+ signDate: formatDate(this.formStore.productConditionsForm.signDate)?.toISOString(),
1396
+ birthDate: formatDate(this.formStore.productConditionsForm.birthDate)?.toISOString(),
1397
+ gender: this.formStore.productConditionsForm.gender.id,
1398
+ amount: getNumber(this.formStore.productConditionsForm.requestedSumInsured),
1399
+ premium: getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonth),
1400
+ coverPeriod: this.formStore.productConditionsForm.coverPeriod,
1401
+ payPeriod: this.formStore.productConditionsForm.coverPeriod,
1402
+ indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
1403
+ ? this.formStore.productConditionsForm.processIndexRate.id
1404
+ : this.processIndexRate.find(i => i.code === '0')?.id,
1405
+ paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1406
+ addCovers: this.additionalInsuranceTermsWithout,
1407
+ };
1408
+ const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
1409
+ this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1410
+ this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1411
+ this.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1412
+ this.showToaster('success', this.t('toaster.calculated'), 1000);
1413
+ } catch (err) {
1414
+ ErrorHandler(err);
1415
+ } finally {
1416
+ this.isLoading = false;
1417
+ return !!this.formStore.productConditionsForm.requestedSumInsured && !!this.formStore.productConditionsForm.insurancePremiumPerMonth;
1418
+ }
1419
+ },
1375
1420
  async calculate(taskId) {
1376
1421
  this.isLoading = true;
1377
1422
  try {
@@ -1846,8 +1891,6 @@ export const useDataStore = defineStore('data', {
1846
1891
  )}₸`,
1847
1892
  4000,
1848
1893
  );
1849
- } else {
1850
- ErrorHandler(err);
1851
1894
  }
1852
1895
  } catch (err) {
1853
1896
  console.log(err);
@@ -1877,7 +1920,7 @@ export const useDataStore = defineStore('data', {
1877
1920
  const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
1878
1921
  const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
1879
1922
  if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
1880
- this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1923
+ this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1881
1924
  return false;
1882
1925
  }
1883
1926
  if (localKey === this.formStore.beneficiaryFormKey) {
@@ -1892,15 +1935,15 @@ export const useDataStore = defineStore('data', {
1892
1935
  }
1893
1936
  } else {
1894
1937
  if (this.formStore[localKey].some(i => i.iin !== null)) {
1895
- this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1938
+ this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1896
1939
  return false;
1897
1940
  }
1898
1941
  if (this.formStore.applicationData[applicationKey].length !== 0) {
1899
- this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1942
+ this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1900
1943
  return false;
1901
1944
  } else {
1902
1945
  if (this.formStore[localKey][0].iin !== null) {
1903
- this.showToaster('error', this.t('toaster.notSavedMember', { text: text }), 3000);
1946
+ this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
1904
1947
  return false;
1905
1948
  }
1906
1949
  }
@@ -1913,7 +1956,7 @@ export const useDataStore = defineStore('data', {
1913
1956
  return false;
1914
1957
  }
1915
1958
  if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
1916
- this.showToaster('error', this.t('toaster.notSavedMember', { text: 'страхователя' }), 3000);
1959
+ this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
1917
1960
  return false;
1918
1961
  }
1919
1962
  if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
@@ -261,7 +261,7 @@ export const useMemberStore = defineStore('members', {
261
261
  this.dataStore.showToaster('success', this.dataStore.t('toaster.successOtp'), 3000);
262
262
  }
263
263
  } else {
264
- this.dataStore.showToaster('error', this.dataStore.t('error.snoOtpResponse'), 3000);
264
+ this.dataStore.showToaster('error', this.dataStore.t('error.noOtpResponse'), 3000);
265
265
  return { otpStatus };
266
266
  }
267
267
  }
package/store/messages.ts CHANGED
@@ -205,6 +205,7 @@ export const messages = {
205
205
  coverPeriod: 'Срок',
206
206
  requestedSumInsured: 'Запрашиваемая сумма',
207
207
  insurancePremiumPerMonth: 'Премия в месяц',
208
+ noStatementCalculator: 'Калькулятор стоимости без ввода данных',
208
209
  agreement: 'Согласие',
209
210
  clientsStatement: 'Заявление клиента',
210
211
  document: 'Документ',
@@ -229,6 +230,7 @@ export const messages = {
229
230
  processIndexRate: 'Запрашиваемый размер коэффициента индексации (от 3% до 7%)',
230
231
  processPaymentPeriod: 'Периодичность оплаты страховой премии:',
231
232
  requestedSumInsured: 'Страховая сумма',
233
+ sumInsured: 'Страховая сумма',
232
234
  insurancePremiumPerMonth: 'Страховая премия',
233
235
  hint: 'Сумма рассчитывается автоматически',
234
236
  additional: 'Дополнительные условия страхования',
@@ -342,6 +344,7 @@ export const messages = {
342
344
  firstName: 'Имя',
343
345
  middleName: 'Отчество',
344
346
  birthDate: 'Дата рождения',
347
+ signDate: 'Дата расчета',
345
348
  age: 'Возраст',
346
349
  gender: 'Пол',
347
350
  familyStatus: 'Семейное положение',
package/store/rules.js CHANGED
@@ -2,7 +2,7 @@ import { t } from './messages';
2
2
  import { formatDate } from '../composables';
3
3
 
4
4
  export const rules = {
5
- recalculationMultiply: [v => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher', { text: 100 })],
5
+ recalculationMultiply: [v => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher').replace('{text}', '100')],
6
6
  recalculationAdditive: [
7
7
  v =>
8
8
  (v !== null && v !== '' && v <= 100 && v >= 0) ||
@@ -110,6 +110,20 @@ export const rules = {
110
110
  return t('rules.coverPeriod');
111
111
  }
112
112
  return true;
113
+ } else {
114
+ return t('rules.coverPeriod');
115
+ }
116
+ },
117
+ ],
118
+ coverPeriodFrom3to20: [
119
+ v => {
120
+ if (v !== null) {
121
+ if (v < 3 || v > 20) {
122
+ return t('productConditionsForm.coverPeriodFrom3to20');
123
+ }
124
+ return true;
125
+ } else {
126
+ return t('productConditionsForm.coverPeriodFrom3to20');
113
127
  }
114
128
  },
115
129
  ],