hl-core 0.0.10-beta.20 → 0.0.10-beta.21

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.
@@ -279,7 +279,7 @@ export const useDataStore = defineStore('data', {
279
279
  if (!file.id) return;
280
280
  try {
281
281
  this.isLoading = true;
282
- await this.api.getFile(file.id).then((response: any) => {
282
+ await this.api.file.getFile(file.id).then((response: any) => {
283
283
  if (!['pdf', 'docx'].includes(fileType)) {
284
284
  const blob = new Blob([response], { type: `image/${fileType}` });
285
285
  const url = window.URL.createObjectURL(blob);
@@ -320,7 +320,7 @@ export const useDataStore = defineStore('data', {
320
320
  },
321
321
  async deleteFile(data: DocumentItem) {
322
322
  try {
323
- await this.api.deleteFile(data);
323
+ await this.api.file.deleteFile(data);
324
324
  this.showToaster('success', this.t('toaster.fileWasDeleted'), 3000);
325
325
  } catch (err) {
326
326
  ErrorHandler(err);
@@ -329,7 +329,7 @@ export const useDataStore = defineStore('data', {
329
329
  async uploadFiles(data: FormData, load: boolean = false) {
330
330
  this.isLoading = load;
331
331
  try {
332
- await this.api.uploadFiles(data);
332
+ await this.api.file.uploadFiles(data);
333
333
  return true;
334
334
  } catch (err) {
335
335
  return ErrorHandler(err);
@@ -339,14 +339,23 @@ export const useDataStore = defineStore('data', {
339
339
  },
340
340
  async getContragent(member: Member, load: boolean = true, showToaster: boolean = true) {
341
341
  this.isLoading = load;
342
- if (!member.iin) return;
343
- try {
344
- const queryData = {
345
- firstName: '',
346
- lastName: '',
347
- middleName: '',
348
- iin: member.iin.replace(/-/g, ''),
349
- };
342
+ const isNonResident = this.isPension && member.signOfResidency.ids === '500011.2';
343
+ if (!member.iin || (isNonResident && (!member.firstName || !member.lastName))) return;
344
+ try {
345
+ const queryData = isNonResident
346
+ ? {
347
+ firstName: member.firstName ?? '',
348
+ lastName: member.lastName ?? '',
349
+ middleName: member.middleName ?? '',
350
+ iin: member.iin ? member.iin.replace(/-/g, '') : '',
351
+ birthDate: member.birthDate ? formatDate(member.birthDate)?.toISOString() ?? '' : '',
352
+ }
353
+ : {
354
+ firstName: '',
355
+ lastName: '',
356
+ middleName: '',
357
+ iin: member.iin ? member.iin.replace(/-/g, '') : '',
358
+ };
350
359
  const contragentResponse = await this.api.getContragent(queryData);
351
360
  if (contragentResponse.totalItems > 0) {
352
361
  if (contragentResponse.items.length === 1) {
@@ -355,12 +364,13 @@ export const useDataStore = defineStore('data', {
355
364
  const sortedByRegistrationDate = contragentResponse.items.sort(
356
365
  (left, right) => new Date(right.registrationDate).getMilliseconds() - new Date(left.registrationDate).getMilliseconds(),
357
366
  );
358
- await this.serializeContragentData(member, sortedByRegistrationDate[0]);
367
+ if (!isNonResident) await this.serializeContragentData(member, sortedByRegistrationDate[0]);
359
368
  }
360
369
  member.gotFromInsis = true;
361
370
  } else {
362
371
  if (showToaster) this.showToaster('error', this.t('toaster.notFoundUser'));
363
372
  }
373
+ if (isNonResident) return contragentResponse;
364
374
  } catch (err) {
365
375
  ErrorHandler(err);
366
376
  }
@@ -530,13 +540,15 @@ export const useDataStore = defineStore('data', {
530
540
  }
531
541
  },
532
542
  async alreadyInInsis(member: Member) {
533
- if (!member.iin) return null;
543
+ const isNonResident = this.isPension && member.signOfResidency.ids === '500011.2';
544
+ if (!member.iin || (isNonResident && (!member.firstName || !member.lastName))) return;
534
545
  try {
535
546
  const queryData = {
536
- iin: member.iin.replaceAll('-', ''),
547
+ iin: !!member.iin ? member.iin.replaceAll('-', '') : '',
537
548
  firstName: !!member.firstName ? member.firstName : '',
538
549
  lastName: !!member.lastName ? member.lastName : '',
539
550
  middleName: !!member.middleName ? member.middleName : '',
551
+ birthDate: !!member.birthDate ? formatDate(member.birthDate)?.toISOString() ?? '' : '',
540
552
  };
541
553
  const contragent = await this.api.getContragent(queryData);
542
554
  if (contragent.totalItems > 0) {
@@ -2070,11 +2082,6 @@ export const useDataStore = defineStore('data', {
2070
2082
  index: null,
2071
2083
  });
2072
2084
  }
2073
-
2074
- if (applicationData.slave) {
2075
- insuredData.push(applicationData.slave.insuredApp[0]);
2076
- }
2077
-
2078
2085
  if (insuredData && insuredData.length) {
2079
2086
  insuredData.forEach((member, index) => {
2080
2087
  const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
@@ -2489,94 +2496,17 @@ export const useDataStore = defineStore('data', {
2489
2496
  };
2490
2497
  const data = prepareSignDocuments();
2491
2498
  if (type === 'qr') {
2492
- const groupId = await this.api.signQR(data);
2499
+ const groupId = await this.api.file.signQR(data);
2493
2500
  return groupId;
2494
2501
  } else if (type === 'qrXml') {
2495
- const signData = await this.api.signXml(data);
2502
+ const signData = await this.api.file.signXml(data);
2496
2503
  return signData;
2497
- } else if (type === 'signature') {
2498
- const ncaLayerClient = new NCALayerClient();
2499
- const formTemplate = new FormData();
2500
- formTemplate.append('format', 'pdf');
2501
- formTemplate.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2502
- let activeTokens;
2503
- try {
2504
- await ncaLayerClient.connect();
2505
- activeTokens = await ncaLayerClient.getActiveTokens();
2506
- const storageType = activeTokens[0] || NCALayerClient.fileStorageType;
2507
- if (this.formStore.applicationData.statusCode === 'ContractSignedFrom') {
2508
- const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2509
- const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2510
- const formData = formTemplate;
2511
- formData.append('base64EncodedSignature', base64EncodedSignature);
2512
- formData.append('name', 'PA_Contract');
2513
- try {
2514
- await this.api.uploadDigitalCertifijcate(formData);
2515
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2516
- } catch (e) {
2517
- this.showToaster('error', String(e));
2518
- return;
2519
- }
2520
- } else if (this.formStore.applicationData.statusCode === 'HeadManagerForm') {
2521
- const document = await this.generatePDFDocument('PA_Contract', '38', 'pdf');
2522
- const base64EncodedSignature = await ncaLayerClient.basicsSignCMS(storageType, document, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2523
- const formData = formTemplate;
2524
- formData.append('base64EncodedSignature', base64EncodedSignature);
2525
- formData.append('name', 'PA_Contract');
2526
- try {
2527
- await this.api.uploadDigitalCertificatePensionAnnuityNew(formData);
2528
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2529
- } catch (e) {
2530
- this.showToaster('error', String(e));
2531
- return;
2532
- }
2533
- } else {
2534
- if (!!this.formStore.signedDocumentList.find(i => i.fileTypeCode === '43')?.signed) {
2535
- const statement = await this.generatePDFDocument('PA_Statement', '37', 'pdf');
2536
- const statementSignature = await ncaLayerClient.basicsSignCMS(storageType, statement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2537
- const statementData = formTemplate;
2538
- statementData.append('base64EncodedSignature', statementSignature);
2539
- statementData.append('name', 'PA_Statement');
2540
- await this.api.uploadDigitalCertifijcate(statementData);
2541
- const agreement = await this.generatePDFDocument('Agreement', '19', 'pdf');
2542
- const agreementSignature = await ncaLayerClient.basicsSignCMS(storageType, agreement, NCALayerClient.basicsCMSParams, NCALayerClient.basicsSignerSignAny);
2543
- const agreementData = formTemplate;
2544
- agreementData.append('base64EncodedSignature', agreementSignature);
2545
- agreementData.append('name', 'Agreement');
2546
- await this.api.uploadDigitalCertifijcate(agreementData);
2547
- await this.handleTask('accept', String(this.formStore.applicationTaskId));
2548
- } else {
2549
- const document = {
2550
- processInstanceId: String(this.formStore.applicationData.processInstanceId),
2551
- name: 'PAEnpf_Agreement',
2552
- format: 'xml',
2553
- };
2554
- const signData = await this.api.signXml([document]);
2555
- const agreementXml = await this.api.getDocumentsByEdsXmlId(signData.data);
2556
- const wnd = window.open('about:blank', '', '_blank');
2557
- wnd?.document.write(agreementXml.data.document.documentXml);
2558
- const signedAgreement = await ncaLayerClient.signXml(storageType, agreementXml.data.document.documentXml, 'SIGNATURE', '');
2559
- const data = new FormData();
2560
- data.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2561
- data.append('xmlData', signedAgreement);
2562
- data.append('name', 'PAEnpf_Agreement');
2563
- data.append('format', 'xml');
2564
- data.append('EdsXmlId', signData.data);
2565
- await this.api.uploadXml(data);
2566
- await this.getSignedDocList(this.formStore.applicationData.processInstanceId);
2567
- this.showToaster('success', this.t('pension.consentGiven'), 3000);
2568
- }
2569
- }
2570
- } catch (error) {
2571
- this.showToaster('error', String(error));
2572
- return;
2573
- }
2574
2504
  } else {
2575
2505
  if (this.processCode === 19 || this.processCode === 2 || this.processCode === 4) {
2576
- const result = await this.api.signBts(data);
2506
+ const result = await this.api.file.signBts(data);
2577
2507
  if (result.code === 0) this.formStore.signUrls = result.data;
2578
2508
  } else {
2579
- const result = await this.api.signDocument(data);
2509
+ const result = await this.api.file.signDocument(data);
2580
2510
  this.formStore.signUrls = result;
2581
2511
  }
2582
2512
  return this.formStore.signUrls;
@@ -2585,6 +2515,84 @@ export const useDataStore = defineStore('data', {
2585
2515
  ErrorHandler(err);
2586
2516
  }
2587
2517
  },
2518
+ async nclayerSign(groupId: string, signType: number, isXml: boolean = false) {
2519
+ try {
2520
+ const ncaLayerClient = new NCALayerClient();
2521
+ await ncaLayerClient.connect();
2522
+ const activeTokens = await ncaLayerClient.getActiveTokens();
2523
+ const storageType = activeTokens[0] || NCALayerClient.fileStorageType;
2524
+ const document = await this.getFileNew(groupId, signType, isXml);
2525
+ if (isXml) {
2526
+ const signedAgreement = await ncaLayerClient.signXml(storageType, document, 'SIGNATURE', '');
2527
+ const data = new FormData();
2528
+ data.append('processInstanceId', String(this.formStore.applicationData.processInstanceId));
2529
+ data.append('xmlData', signedAgreement);
2530
+ data.append('name', 'PAEnpf_Agreement');
2531
+ data.append('format', 'xml');
2532
+ data.append('EdsXmlId', groupId);
2533
+ await this.api.file.uploadXml(data);
2534
+ } else {
2535
+ const base64EncodedSignature = await ncaLayerClient.createCAdESFromBase64(storageType, document, 'SIGNATURE', true);
2536
+ await this.api.file.uploadDigitalCertificateNca(groupId, { Base64EncodedSignature: base64EncodedSignature });
2537
+ }
2538
+ return true;
2539
+ } catch (err) {
2540
+ ErrorHandler(err);
2541
+ return false;
2542
+ }
2543
+ },
2544
+ async getFileNew(groupId: string, documentSignType: number, xml: boolean, fileName?: string) {
2545
+ try {
2546
+ let response: any = await this.api.file.generalGetFile(groupId, xml ? 5 : documentSignType);
2547
+ let blob;
2548
+ if (response.hasOwnProperty('data')) {
2549
+ const document = JSON.parse(response.data).Document;
2550
+ blob = new Blob([document.documentXml], {
2551
+ type: `application/xml`,
2552
+ });
2553
+ response = document.documentXml;
2554
+ } else {
2555
+ blob = new Blob([response], {
2556
+ type: `application/pdf`,
2557
+ });
2558
+ }
2559
+ const url = window.URL.createObjectURL(blob);
2560
+ if (!xml) {
2561
+ const link = document.createElement('a');
2562
+ link.href = url;
2563
+ link.setAttribute('download', fileName ?? `Документ ПА`);
2564
+ document.body.appendChild(link);
2565
+ link.click();
2566
+ }
2567
+ window.open(url, '_blank', `right=100`);
2568
+ return response;
2569
+ } catch (err) {
2570
+ ErrorHandler(err);
2571
+ }
2572
+ },
2573
+ async generateSign(taskId: string) {
2574
+ try {
2575
+ const signatories = await this.api.file.generateSign({ taskId });
2576
+ if (Array.isArray(signatories)) {
2577
+ signatories.forEach(signatory =>
2578
+ signatory.fileDatas?.sort(function (a: any, b: any) {
2579
+ return a.orderFile > b.orderFile ? 1 : b.orderFile > a.orderFile ? -1 : 0;
2580
+ }),
2581
+ );
2582
+ this.formStore.signatories = signatories;
2583
+ }
2584
+ } catch (err) {
2585
+ ErrorHandler(err);
2586
+ }
2587
+ },
2588
+ async generalSign(data: Types.Api.Sign.New.GeneralResponse) {
2589
+ try {
2590
+ const response = await this.api.file.generalSign(data);
2591
+ return response;
2592
+ } catch (err) {
2593
+ ErrorHandler(err);
2594
+ }
2595
+ },
2588
2596
  async downloadTemplate(documentType: number, fileType: string = 'pdf', processInstanceId?: string | number) {
2589
2597
  try {
2590
2598
  this.isButtonsLoading = true;
@@ -2651,7 +2659,7 @@ export const useDataStore = defineStore('data', {
2651
2659
  name: 'Contract',
2652
2660
  format: 'pdf',
2653
2661
  };
2654
- const response: any = await this.api.generateDocument(data);
2662
+ const response: any = await this.api.file.generateDocument(data);
2655
2663
  const blob = new Blob([response], {
2656
2664
  type: `application/pdf`,
2657
2665
  });
@@ -2737,7 +2745,7 @@ export const useDataStore = defineStore('data', {
2737
2745
  async getSignedDocList(processInstanceId: string | number) {
2738
2746
  if (processInstanceId !== 0) {
2739
2747
  try {
2740
- this.formStore.signedDocumentList = await this.api.getSignedDocList({
2748
+ this.formStore.signedDocumentList = await this.api.file.getSignedDocList({
2741
2749
  processInstanceId: processInstanceId,
2742
2750
  });
2743
2751
  } catch (err) {
package/types/enum.ts CHANGED
@@ -51,6 +51,9 @@ export enum Actions {
51
51
 
52
52
  payed = 'payed',
53
53
  payedCustom = 'payedCustom',
54
+
55
+ rejectDocument = 'rejectDocument',
56
+ rejectDocumentCustom = 'rejectDocumentCustom',
54
57
  }
55
58
 
56
59
  export enum PostActions {
@@ -164,4 +167,13 @@ export namespace CoreEnums {
164
167
  'SBI' = 'SBI',
165
168
  }
166
169
  }
170
+ export namespace Sign {
171
+ export enum Types {
172
+ electronic = 1,
173
+ scans = 2,
174
+ qr = 3,
175
+ qrXml = 5,
176
+ nclayer = 6,
177
+ }
178
+ }
167
179
  }
package/types/index.ts CHANGED
@@ -388,6 +388,7 @@ export type GetContragentRequest = {
388
388
  lastName: string;
389
389
  middleName: string;
390
390
  iin: string;
391
+ birthDate?: string;
391
392
  };
392
393
 
393
394
  export type GetContragentResponse = {
@@ -879,6 +880,47 @@ export namespace Api {
879
880
  name: string;
880
881
  };
881
882
  }
883
+
884
+ export namespace Sign {
885
+ export namespace New {
886
+ export type Request = {
887
+ taskId: string;
888
+ };
889
+ export type Type = {
890
+ documentSignType: string;
891
+ documentSignTypeName: string;
892
+ documentSignTypeValue: number;
893
+ };
894
+ export type FileDatas = {
895
+ fileName: string;
896
+ fileType: number;
897
+ orderFile: number;
898
+ isSigned: boolean;
899
+ signTypes: Api.Sign.New.Type[];
900
+ };
901
+ export type GeneralResponse = {
902
+ contragentId?: string | null;
903
+ contragentType?: number;
904
+ fileDatas?: FileDatas[];
905
+ iin?: string | null;
906
+ longName?: string | null;
907
+ personId?: number;
908
+ signType?: number | null;
909
+ signatureDocumentGroupId?: string | null;
910
+ taskId: string;
911
+ };
912
+ export type Response = {
913
+ edsXmlId: string | null;
914
+ iin: string | null;
915
+ longName: string | null;
916
+ phoneNumber: string | null;
917
+ shortUri: string | null;
918
+ signIds: { id: string; fileType: string }[];
919
+ signatureDocumentGroupId: string | null;
920
+ uri: string | null;
921
+ };
922
+ }
923
+ }
882
924
  }
883
925
 
884
926
  export namespace Dicts {