ca-mfe-page-scoring-ui
Version:
This is a react shell for the SPGI Platform MFE implementation
461 lines (411 loc) • 12.6 kB
text/typescript
import { useTranslation } from 'react-i18next';
export const constants = {
// LANUGAGE_TRANSLATIONS_SERVICE: process.env.LANGUAGE_RESOURCE_URL,
};
export const ifZero = val => val === -0 ? 0 : val;
export enum platforms {
CIQ = 'CIQ_DATA_API',
CIQPROP = 'CIQ_PROP_DATA_API',
CIQPro = 'CIQ_PRO',
CIQUNLINK = 'CIQ_CS_DATA_SOURCE'
}
export enum trackerStatus {
NOT_SELECTED = 'notSelected',
SELECTED = 'selected',
ACTIVE = 'active',
COMPLETED = 'completed'
}
export enum stepValidationStatus {
NOT_VALIDATED = 'notValidated',
VALID = 'valid',
INVALID = 'invalid',
}
export enum restatementType {
LP = 'LP',
LC = 'LC'
}
export enum stepIds {
SCORING_SELECTION = 'scoringSelection',
COMPANY_DATA_INPUTS = 'companyDataInputs',
SCORING_INPUTS = 'scoringInputs',
ADJUSTMENTS = 'adjustments',
SIZE_ADJUSTMENTS = 'sizeAdjustments',
QUALITATIVE_ADJUSTMENTS = 'qualitativeAdjustments',
PARENT_ADJUSTMENTS = 'parentAdjustments',
GOVERNMENT_SUPPORT = 'governmentSupport',
Pd_ADJUSTMENTS = 'pdAdjustments',
RG_SCORE = 'rgScore',
ADDITIONAL_ANALYSIS = 'additionalAnalysis',
MACRO_SCENARIOS = 'macroScenarios',
LOSS_STATS = 'lossStats',
ADDITIONAL_ADJUSTMENTS = 'additionalAdjustments',
MAX_LIMIT = 'maxLimit'
}
export enum rgScoreIds {
BENCHMARK = 'rgBenchmark',
STANDALONE = 'standalone',
SIZE_ADJ = 'sizeAdjustment',
Q_ADJ = 'qAdjustment',
Parent_ADJ = 'parentAdjustment',
GOV_ADJ = 'govAdjustment',
PD_ADJ = 'pdAdjustment'
}
export enum modelFamily {
Risk_Gauge = 'RG'
}
export enum industryType {
Corp = 'CORP',
Financial = 'FINANCIAL'
}
export enum compType {
Public = 'Public Company',
Private = 'Private Company'
}
export const stepProgressDirection = {
BACKWARD: 'backward',
FORWARD: 'forward',
CURRENT: 'current'
};
export enum compInfoType {
PeriodType = 1,
FinancialStatement = 2,
DataSource = 3,
Currency = 4,
SelectPeriod = 5,
AsOfDate = 6
}
export const defaultCurrencyCode = 'USD';
export const extractedDataFromPage = 'ReportViewer';
export const periodTypeConstants = [
{ label: 'FY', value: 'Financial Year' },
{ label: 'LTM', value: 'LTM' }
];
export const dataSourceConstants = [
{ label: 'S&P CapitalIQ', value: '1'},
{ label: 'Proprietary Data', value: '0'},
{ label: 'Extracted', value: '2'}
];
export enum financialsType {
WithoutFinancials = '1',
WithFinancials = '0'
}
export const financialsRadio =[
{
label: 'With Financials',
value: '0'
},
{
label: 'Without Financials',
value: '1'
}
];
export const financialQuarter = [
{ label: 'FQ1', value: '1', displayText: 'Mar 31' },
{ label: 'FQ2', value: '2', displayText: 'Jun 30' },
{ label: 'FQ3', value: '3', displayText: 'Sep 30' },
{ label: 'FQ4', value: '4', displayText: 'Dec 31' }
];
export const selectPeriodConstants = [
{ value: 'FY2023', label: 'FY2023' },
{ value: 'FY2022', label: 'FY2022' },
{ value: 'FY2021', label: 'FY2021' },
{ value: 'FY2020', label: 'FY2020' },
{ value: 'FY2019', label: 'FY2019' },
{ value: 'FY2018', label: 'FY2018' }
];
export const CompanyTypeOption = () => {
const { t } = useTranslation();
const companyType = [{
value:'1',
label: t('scoringui:companyType:publicCorporate'),
type: industryType.Corp,
isPublic: true
},
{
value:'2',
label: t('scoringui:companyType:privateCorporate'),
type: industryType.Corp,
isPublic: false
},
{
value:'3',
label: t('scoringui:companyType:publicFinancial'),
type: industryType.Financial,
isPublic: true
},
{
value:'4',
label: t('scoringui:companyType:privateFinancial'),
type: industryType.Financial,
isPublic: false
}];
return companyType;
};
export enum compInputType {
CompanyType = 1,
Country = 2,
Industry = 3,
AsOfDate = 4
}
export const scoreOptionsTypes = {
type1: [
{ value: 'a', label: 'a', id: 6 },
{ value: 'a-', label: 'a-', id: 7 },
{ value: 'bbb+', label: 'bbb+', id: 8 },
{ value: 'bbb', label: 'bbb', id: 9 },
{ value: 'bbb-', label: 'bbb-', id: 10 },
{ value: 'bb+', label: 'bb+', id: 11 },
{ value: 'bb', label: 'bb', id: 12 },
{ value: 'bb-', label: 'bb-', id: 13 },
{ value: 'b+', label: 'b+', id: 14 },
{ value: 'b', label: 'b', id: 15 },
{ value: 'b-', label: 'b-', id: 16 }
],
type2: [
{ value: 'aaa', label: 'aaa', id: 1 },
{ value: 'aa+', label: 'aa+', id: 2 },
{ value: 'aa', label: 'aa', id: 3 },
{ value: 'aa-', label: 'aa-', id: 4 },
{ value: 'a+', label: 'a+', id: 5 },
{ value: 'a', label: 'a', id: 6 },
{ value: 'a-', label: 'a-', id: 7 },
{ value: 'bbb+', label: 'bbb+', id: 8 },
{ value: 'bbb', label: 'bbb', id: 9 },
{ value: 'bbb-', label: 'bbb-', id: 10 },
{ value: 'bb+', label: 'bb+', id: 11 },
{ value: 'bb', label: 'bb', id: 12 },
{ value: 'bb-', label: 'bb-', id: 13 },
{ value: 'b+', label: 'b+', id: 14 },
{ value: 'b', label: 'b', id: 15 },
{ value: 'b-', label: 'b-', id: 16 },
{ value: 'ccc+', label: 'ccc+', id: 17 },
{ value: 'ccc', label: 'ccc', id: 18 },
{ value: 'ccc- or worse', label: 'ccc- or worse', id: 19 }
],
type3: [
{
label: 'Very Low Risk',
value: 'Very Low Risk',
id: 1
},
{
label: 'Very Low to Low Risk',
value: 'Very Low to Low Risk',
id: 1.5
},
{
label: 'Low Risk',
value: 'Low Risk',
id: 2
},
{
label: 'Low to Intermediate Risk',
value: 'Low to Intermediate Risk',
id: 2.5
},
{
label: 'Intermediate Risk',
value: 'Intermediate Risk',
id: 3
},
{
label: 'Intermediate to Moderate Risk',
value: 'Intermediate to Moderate Risk',
id: 3.5
},
{
label: 'Moderate Risk',
value: 'Moderate Risk',
id: 4
},
{
label: 'Moderate to High Risk',
value: 'Moderate to High Risk',
id: 4.5
},
{
label: 'High Risk',
value: 'High Risk',
id: 5
},
{
label: 'High to Very High Risk',
value: 'High to Very High Risk',
id: 5.5
},
{
label: 'Very High Risk',
value: 'Very High Risk',
id: 6
}
]
};
export const analytictsNameType = {
ECONOMIC_RISK_SCORE: 'type1',
INDUSTRY_RISK_SCORE: 'type1',
SCORE_BICRS: 'type1',
CTRYRISKSCORE_v2: 'type2',
CTRYRISKSCORE_v3: 'type2',
CORP_INDUSTRY_RISK_SCORE_v2: 'type2',
IICRA: 'type3'
};
export const nonFinancialInputAnalytics = [
'CONSUMER_PRICE_INDEX_GROWTH'
];
export const positiveMetrics = [
'TOTAL_EMPLOYEES',
'TOTAL_ASSETS',
'TOTASSETS_IMPUTED',
'TOTAL_ASSETS_PARENT'
];
export const validateNumericsRegEx = '^\\s*[-+]?(\\d+(\\.\\d*)?|\\.\\d+)\\s*$';
export const validateNegativeNumericsRegEx = '^\\s*([-](0*\\.\\d*[1-9]+\\d*|[1-9]\\d*(\\.\\d+)?)|[-]?0*(\\.0*)?)\\s*$';
export const validatePositiveNumericsRegEx = '^\\s*0*(0*\\.\\d*[1-9]+\\d*|[1-9]\\d*(\\.\\d+)?)\\s*$';
export const getRegexPatterns = () => {
const validateNumeric = `^(?=.{1,20}$)\\(?-?(
\\d{1,10}(\\.\\d{0,6})?|
\\d{11}(\\.\\d{0,5})?|
\\d{12}(\\.\\d{0,4})?|
\\d{13}(\\.\\d{0,3})?|
\\d{14}(\\.\\d{0,2})?|
\\d{15}(\\.\\d{0,1})?|
\\d{16})\\)?$`.replace(/\s+/g, '');
const positiveNumeric = `^(?=.{1,18}$)(
\\d{1,10}(\\.\\d{0,6})?|
\\d{11}(\\.\\d{0,5})?|
\\d{12}(\\.\\d{0,4})?|
\\d{13}(\\.\\d{0,3})?|
\\d{14}(\\.\\d{0,2})?|
\\d{15}(\\.\\d{0,1})?|
\\d{16})\\)?$`.replace(/\s+/g, '');
const negativeNumeric = '^\\s*([-|(](0*\\.\\d{1,6}|[1-9]\\d{0,12}(\\.\\d{1,6})?)\\)?)\\s*$';
const percentageNumeric = '^\\s*(0*(100(?:\\.0{1,6})?|\\d{1,2}(?:\\.\\d{0,6})?))\\s*$';
return {
validateNumeric,
positiveNumeric,
negativeNumeric,
percentageNumeric
};
};
export const financialGroupItemCodes = {
incomeStatement: 'INCOME_STATEMENT',
balanceSheet: 'BALANCE_SHEET',
cashFlow: 'CASH_FLOW',
supplemental: 'SUPPLEMENTAL'
};
export const noDataCaseColorMapping = [
{ color: '#737676', risktype: 'Default' },
{ color: '#737676', risktype: 'Selective Default' },
{ color: '#737676', risktype: 'Very High Risk' },
{ color: '#999999', risktype: 'High Risk' },
{ color: '#AFAFAF', risktype: 'Moderately High Risk' },
{ color: '#BFBFBF', risktype: 'Intermediate Risk' },
{ color: '#E3E3E3', risktype: 'Low Risk' },
{ color: '#EBEBEB', risktype: 'Very Low Risk' }
];
export enum supportExpectations {
POSITIVE = 'Positive',
NEUTRAL = 'Neutral',
NEGATIVE = 'Negative'
}
export const SupportExpectations = () => {
const { t } = useTranslation();
return [
{ label: t('scoringui:GovernmentSupport:positive'), value: supportExpectations.POSITIVE.toUpperCase() },
{ label: t('scoringui:GovernmentSupport:neutral'), value: supportExpectations.NEUTRAL.toUpperCase() },
{ label: t('scoringui:GovernmentSupport:negative'), value: supportExpectations.NEGATIVE.toUpperCase() }
];
};
export const focusFinancialInputs = [
'TOTAL_REVENUE', 'PUBLISHED_NET_INCOME', 'OPERATING_INCOME','TOTAL_ASSETS'
];
export const rgWidgetMfe = '/rgWidget/remoteEntry.js';
export const dateFormat = 'YYYY-MM-DD';
export const REQTYPES = {
ZERO: 0,
ONE: 1, // Always Mandatory
TEN: 10, // Optional Imputation=true, Mandatory Imputation=false
THREE: 3, // When Imputation=true and isPrivateCompany Then Mandatory
FOUR: 4 // When Imputation=true and isPrivateCompany then Optional
};
export const totalRevenueName = 'TOTAL_REVENUE';
export const totalAssetsName = 'TOTAL_ASSETS';
export const ScoringSelDisabledTexts = {
[stepIds.QUALITATIVE_ADJUSTMENTS]: `Qualitative Adjustments are not supported if the
Company Type selected is a Public or Private Financial Institution.`,
[stepIds.PARENT_ADJUSTMENTS]: `Parent Company Support overlay is not available if you
are scoring a Private Company without financials.`,
[stepIds.GOVERNMENT_SUPPORT]: `Government Support overlay is not available if you are
scoring a Private Company without financials. Government Support is also not
available for some Countries and Industries.`
};
export const negativeScoringInputs = [
'INTEREST_EXPENSE',
'LOAN_LOSS_RESERVES',
'CAPITAL_EXPENDITURES',
'TOTAL_DIVIDENDS_PAID'
];
export const rg_3UploadProps = [
'ADJ_ASSETS',
'ADJ_REVENUE',
'ADJ_TOTAL_EMPLOYEES',
'CAPITAL_STRUCTURE',
'CAPITAL_STRUCTURE_RATIONALE',
'COMPANY_COUNTRY_CODE',
'COMPANY_INDUSTRY_CODE',
'COMPANY_STATE_CODE',
'COMPANY_TYPE',
'COMPETITIVE_POSITION',
'COMPETITIVE_POSITION_RATIONALE',
'CONSUMER_PRICE_INDEX_GROWTH',
'CORP_INDUSTRY_RISK_SCORE_v2',
'CTRYRISKSCORE_v3',
'DIVERSIFICATION',
'DIVERSIFICATION_RATIONALE',
'ECONOMIC_RISK_SCORE',
'FINANCIAL_POLICY',
'FINANCIAL_POLICY_RATIONALE',
'GICS_CODE_PARENT',
'GOVERNMENT_OWNERSHIP',
'GROSS_DOMESTIC_PRODUCT',
'IICRA',
'INDUSTRY_RISK_SCORE',
'QUALITY_OF_MANAGEMENT',
'PAYMENT_BEHAVIOR',
'PAYMENT_BEHAVIOR_RATIONALE',
'POPULATION',
'QUALITY_OF_MANAGEMENT_RATIONALE',
'SCORE_BICRS',
'STANDALONE_PD_PARENT',
'SUPPORT_EXPECTATION',
'TOTAL_EMPLOYEES'
];
export enum PRIMARY_SCORE_TYPE {
'ONE_TO_HUNDRED' = 'ONE_HUNDRED',
'LETTER_GRADE' = 'LETTER_GRADE',
'PD_PERCENT' = 'PD'
}
export const getScoreTypeKey = {
[PRIMARY_SCORE_TYPE.ONE_TO_HUNDRED]: 'oneToHundred',
[PRIMARY_SCORE_TYPE.LETTER_GRADE]: 'letterGradeNotch',
[PRIMARY_SCORE_TYPE.PD_PERCENT]: 'rawPd'
};
export const letterGradeScores = ['d','c','cc','ccc-','ccc','ccc+','b-','b','b+','bb-','bb','bb+','bbb-','bbb','bbb+',
'a-','a','a+','aa-','aa','aa+','aaa'];
export const proSpreadScaleId = {
absolute: 1,
thousands: 2,
lac: 13,
millions: 3,
billions: 4
};
export const scalesNeedingModification = [
proSpreadScaleId.absolute,
proSpreadScaleId.thousands,
proSpreadScaleId.lac,
proSpreadScaleId.billions
];
export const proSpreadPeriodMapping = {
1: periodTypeConstants[0].label,
4: periodTypeConstants[1].label
};