diff --git a/.env.template b/.env.template index 1ec4f8c..cc6a4fd 100644 --- a/.env.template +++ b/.env.template @@ -1,17 +1,22 @@ IAM_URL="" + WML_URL="" +WML_PROJECT_ID="" MODEL_ID="" -PROJECT_ID="" +DISCOVERY_PROJECT_ID="" DECODING_METHOD="" MAX_NEW_TOKENS="" REPETITION_PENALTY="" + DISCOVERY_URL="" DISCOVERY_VERSION="" +KYC_SUMMARY_BASE_PATH="" CRA_BASE_PATH="" CRA_USERNAME="" CRA_PASSWORD="" +CRA_API_KEY="" WML_API_KEY="" diff --git a/src/models/kyc-case.model.ts b/src/models/kyc-case.model.ts index 40ab0a9..b107135 100644 --- a/src/models/kyc-case.model.ts +++ b/src/models/kyc-case.model.ts @@ -92,10 +92,10 @@ export const createEmptyCase = (): KycCaseModel => { id: 'new', customer: { name: '', - countryOfResidence: 'US', + countryOfResidence: 'United States', personalIdentificationNumber: '', - industryType: '', - entityType: '', + industryType: 'Private Limited Company', + entityType: 'Growing of rice', }, status: 'New', documents: [], diff --git a/src/services/kyc-case/kyc-case-management.mock.ts b/src/services/kyc-case/kyc-case-management.mock.ts index 2286259..6e58f9d 100644 --- a/src/services/kyc-case/kyc-case-management.mock.ts +++ b/src/services/kyc-case/kyc-case-management.mock.ts @@ -1,6 +1,6 @@ import {BehaviorSubject, Observable} from "rxjs"; -import mime from 'mime'; -import streamToBlob from 'stream-to-blob'; +import {getType} from 'mime'; +import * as streamToBlob from 'stream-to-blob'; import * as Stream from "stream"; import {CaseNotFound, KycCaseManagementApi} from "./kyc-case-management.api"; @@ -47,7 +47,7 @@ const initialValue: KycCaseModel[] = [ id: '2', customer: { name: 'Jane Doe', - countryOfResidence: 'CA', + countryOfResidence: 'Canada', personalIdentificationNumber: 'AB1458690', entityType: 'Sole Trader', industryType: 'Extraction of crude petroleum', @@ -294,12 +294,15 @@ export class KycCaseManagementMock implements KycCaseManagementApi { const api = Cp4adminCustomerRiskAssessmentCustomerRiskAssessmentApiFactory(config); + const body = { + nonPersonalEntityType: kycCase.customer.entityType, + nonPersonalGeographyType: kycCase.customer.countryOfResidence, + nonPersonalIndustryType: kycCase.customer.industryType, + }; + + console.log('Getting customer risk assessment: ', body) return api - .customerRiskAssessmentRiskAssessment({ - nonPersonalEntityType: kycCase.customer.entityType, - nonPersonalGeographyType: kycCase.customer.countryOfResidence, - nonPersonalIndustryType: kycCase.customer.industryType, - }) + .customerRiskAssessmentRiskAssessment(body) .then(result => result.data) .then(riskAssessment => ({ score: riskAssessment.customerRiskAssessmentScore || 0, @@ -309,16 +312,17 @@ export class KycCaseManagementMock implements KycCaseManagementApi { async summarizeCase(kycCase: KycCaseModel): Promise { const config = kycCaseSummaryConfig(); + const options = {baseURL: process.env.KYC_SUMMARY_BASE_PATH}; const api = DefaultApiFactory(config); const financialDoc: DocumentModel | undefined = this.findFinancialDoc(kycCase.documents) if (financialDoc) { - const fileContents: Blob = await streamToBlob(financialDoc.content, mime.getType(financialDoc.path)); - await api.uploadFinancialsPostForm(fileContents); + const fileContents: Blob = new Blob([financialDoc.content], {type: getType(financialDoc.name)}); + await api.uploadFinancialsPostForm(fileContents, options); } - const result = await api.requestSummaryPost({entity: kycCase.customer.name}) + const result = await api.requestSummaryPost({entity: kycCase.customer.name}, options); console.log('Summarize result: ', {summary: result.data}); @@ -327,7 +331,15 @@ export class KycCaseManagementMock implements KycCaseManagementApi { findFinancialDoc(documents: DocumentModel[]): DocumentModel | undefined { const financialDocRegEx = /.*financial.*/ig + const annualDocRegEx = /.*annual.*/ig + + const doc = first(documents + .filter(doc => financialDocRegEx.test(doc.name) || annualDocRegEx.test(doc.name))) + + if (doc) { + return doc; + } - return first(documents.filter(doc => financialDocRegEx.test(doc.name))) + return documents.length > 0 ? documents[0] : undefined; } } diff --git a/src/services/menu-options/menu-options.mock.ts b/src/services/menu-options/menu-options.mock.ts index e707a54..9405225 100644 --- a/src/services/menu-options/menu-options.mock.ts +++ b/src/services/menu-options/menu-options.mock.ts @@ -2,11 +2,7 @@ import {MenuOptionsApi} from "./menu-options.api"; import {FormOptionModel} from "../../models"; import {parseCsv} from "../../utils"; -const countryTypesCsv = `Code,description,risk_weight, -XG,EU Organisations,LOW, -NULL,Missing Data,MEDIUM, -NOT_FOUND,Data Not Recognised,MEDIUM, -XH,Other International Org.,LOW, +const countryTypesCsv = `XH,Other International Org.,LOW, QU,Unknown,MEDIUM, XB,Abu Dhabi,HIGH, AF,Afghanistan,REFER-SANCTIONS, @@ -268,8 +264,7 @@ ZR,Zaire (Democratic Republic Of Congo),REFER-SANCTIONS, ZM,Zambia,HIGH, ZW,Zimbabwe,REFER-SANCTIONS,` -const industryTypesCsv = `Code,Division,Industry ,Strategic Rating, -01.11,Growing of non-perennial crops,"Growing of cereals (except rice), leguminous crops and oil seeds",MEDIUM, +const industryTypesCsv = `01.11,Growing of non-perennial crops,"Growing of cereals (except rice), leguminous crops and oil seeds",MEDIUM, 01.12,Growing of non-perennial crops,Growing of rice,LOW, 01.13,Growing of non-perennial crops,"Growing of vegetables and melons, roots and tubers",MEDIUM, 01.14,Growing of non-perennial crops,Growing of sugar cane,LOW, @@ -1008,9 +1003,7 @@ const industryTypesCsv = `Code,Division,Industry ,Strategic Rating, NOT_FOUND,,Data Not Recognised,HIGH, NULL,,MISSING DATA,HIGH, `; -const entityTypesCsv = ` -code,description,risk_weight -01,Private Limited Company,MEDIUM +const entityTypesCsv = `01,Private Limited Company,MEDIUM 02,Sole Trader,MEDIUM 03,Limited Liability Partnership,MEDIUM 04,Clubs,HIGH @@ -1035,14 +1028,15 @@ export class MenuOptionsMock implements MenuOptionsApi { return countryTypes; } - return entityTypes = countryTypesCsv + return countryTypes = countryTypesCsv .split('\n') .map(parseCsv) + .filter((_, index) => index !== 0) .map(values => ({ value: '' + values[1], text: '' + values[1], })) - .filter(val => val.value !== 'code'); + .filter(val => val.text !== 'description') } async getEntityTypes(): Promise { @@ -1053,11 +1047,12 @@ export class MenuOptionsMock implements MenuOptionsApi { return entityTypes = entityTypesCsv .split('\n') .map(parseCsv) + .filter((_, index) => index !== 0) .map(values => ({ value: '' + values[1], text: '' + values[1], })) - .filter(val => val.value !== 'code'); + .filter(val => val.value !== 'Code'); } async getIndustries(): Promise { @@ -1068,10 +1063,11 @@ export class MenuOptionsMock implements MenuOptionsApi { return industryTypes = industryTypesCsv .split('\n') .map(parseCsv) + .filter((_, index) => index !== 0) .map(values => ({ value: '' + values[2], text: '' + values[2], })) - .filter(val => val.value !== 'Code'); + .filter(val => val.text !== 'Division'); } } \ No newline at end of file