Skip to content

Commit

Permalink
feat(quoteSummary/assetProfile): complete (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Feb 1, 2021
1 parent 0930f33 commit e95dbc8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
49 changes: 48 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
},
"companyOfficers": {
"items": {
"$ref": "#/definitions/CompanyOfficer"
"$ref": "#/definitions/CompanyOfficerJson"
},
"type": "array"
},
Expand Down Expand Up @@ -571,6 +571,53 @@
"type": "object"
},
"CompanyOfficer": {
"additionalProperties": false,
"properties": {
"age": {
"type": "number"
},
"exercisedValue": {
"type": [
"number",
"null"
]
},
"fiscalYear": {
"type": "number"
},
"maxAge": {
"type": "number"
},
"name": {
"type": "string"
},
"title": {
"type": "string"
},
"totalPay": {
"type": [
"number",
"null"
]
},
"unexercisedValue": {
"type": [
"number",
"null"
]
},
"yearBorn": {
"type": "number"
}
},
"required": [
"maxAge",
"name",
"title"
],
"type": "object"
},
"CompanyOfficerJson": {
"additionalProperties": false,
"properties": {
"age": {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/transformField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ const formats: {[key:string]:Function} = {
rawNumberObj(input: { raw: number; fmt?: string }) {
if (typeof input !== 'object')
throw new Error("transformField(input, format), format=rawNumberObj but typeof input !== 'object'");
if (typeof input.raw !== 'number')
if (typeof input.raw !== 'number') {
if (Object.keys(input).length === 0)
return null;
throw new Error("transformField(input, format), format=rawNumberObj but typeof input.raw !== 'number'");
}
return input.raw;
},

Expand Down
14 changes: 11 additions & 3 deletions src/modules/quoteSummary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* 1) Spaces: 4 to 2
* ~~2) Wrapped in a module~~ <--- undid this after tooling issues.
* 3) Alphabeticalize QuoteSummaryResult
* 4) RawNumberObj type, and transforms: result, resultJson.
*/

export interface QuoteSummaryResultJson {
Expand Down Expand Up @@ -64,7 +65,7 @@ export interface AssetProfileJson {
sector: string;
longBusinessSummary: string;
fullTimeEmployees: number;
companyOfficers: CompanyOfficer[];
companyOfficers: CompanyOfficerJson[];
auditRisk: number;
boardRisk: number;
compensationRisk: number;
Expand All @@ -76,12 +77,14 @@ export interface AssetProfileJson {
address2?: string;
fax?: string;
}
export interface AssetProfile extends Omit<AssetProfileJson,"governanceEpochDate"|"compensationAsOfEpochDate"> {
export interface AssetProfile extends Omit<AssetProfileJson,
"governanceEpochDate"|"compensationAsOfEpochDate"|"companyOfficers"> {
governanceEpochDate: Date;
compensationAsOfEpochDate?: Date;
companyOfficers: CompanyOfficer[];
}

export interface CompanyOfficer {
export interface CompanyOfficerJson {
maxAge: number;
name: string;
age?: number;
Expand All @@ -92,6 +95,11 @@ export interface CompanyOfficer {
exercisedValue?: RawNumberObj;
unexercisedValue?: RawNumberObj;
}
export interface CompanyOfficer extends Omit<CompanyOfficerJson,"totalPay"|"exercisedValue"|"unexercisedValue"> {
totalPay?: number|null;
exercisedValue?: number|null;
unexercisedValue?: number|null;
}

export interface BalanceSheetHistory {
balanceSheetStatements: BalanceSheetStatement[];
Expand Down
7 changes: 7 additions & 0 deletions src/modules/quoteSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export const fieldTransformMap = {
assetProfile: {
governanceEpochDate: 'epoch',
compensationAsOfEpochDate: 'epoch',
companyOfficers: [
{
totalPay: "rawNumberObj",
exercisedValue: "rawNumberObj",
unexercisedValue: "rawNumberObj",
}
]
},
balanceSheetHistory: {
balanceSheetStatements: [ { endDate: 'dateObj' } ],
Expand Down

0 comments on commit e95dbc8

Please sign in to comment.