Fix annual financial selector and QCOM standardization
This commit is contained in:
@@ -61,6 +61,7 @@ type GetCompanyFinancialsInput = {
|
||||
type StandardizedStatementBundlePayload = {
|
||||
rows: StandardizedFinancialRow[];
|
||||
trendSeries: CompanyFinancialStatementsResponse['trendSeries'];
|
||||
categories: CompanyFinancialStatementsResponse['categories'];
|
||||
};
|
||||
|
||||
type FilingDocumentRef = {
|
||||
@@ -281,7 +282,8 @@ async function buildStatementSurfaceBundle(input: {
|
||||
if (!statement || (statement !== 'income' && statement !== 'balance' && statement !== 'cash_flow')) {
|
||||
return {
|
||||
rows: [],
|
||||
trendSeries: []
|
||||
trendSeries: [],
|
||||
categories: []
|
||||
} satisfies StandardizedStatementBundlePayload;
|
||||
}
|
||||
|
||||
@@ -289,7 +291,7 @@ async function buildStatementSurfaceBundle(input: {
|
||||
rows: input.faithfulRows,
|
||||
statement,
|
||||
periods: input.periods,
|
||||
facts: input.facts.filter((fact) => fact.statement === statement)
|
||||
facts: input.facts
|
||||
});
|
||||
|
||||
const payload = {
|
||||
@@ -297,7 +299,8 @@ async function buildStatementSurfaceBundle(input: {
|
||||
trendSeries: buildTrendSeries({
|
||||
surfaceKind: input.surfaceKind,
|
||||
statementRows: standardizedRows
|
||||
})
|
||||
}),
|
||||
categories: buildFinancialCategories(standardizedRows, input.surfaceKind)
|
||||
} satisfies StandardizedStatementBundlePayload;
|
||||
|
||||
await writeFinancialBundle({
|
||||
@@ -520,7 +523,7 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
ticker,
|
||||
window: 'all',
|
||||
filingTypes: [...filingTypes],
|
||||
limit: 2000
|
||||
limit: 10000
|
||||
});
|
||||
|
||||
if (isStatementSurface(input.surfaceKind)) {
|
||||
@@ -546,12 +549,13 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
: buildRows(selection.snapshots, statement, selection.selectedPeriodIds);
|
||||
|
||||
const factsForStatement = allFacts.facts.filter((fact) => fact.statement === statement);
|
||||
const factsForStandardization = allFacts.facts;
|
||||
const standardizedPayload = await buildStatementSurfaceBundle({
|
||||
surfaceKind: input.surfaceKind as Extract<FinancialSurfaceKind, 'income_statement' | 'balance_sheet' | 'cash_flow_statement'>,
|
||||
cadence: input.cadence,
|
||||
periods,
|
||||
faithfulRows,
|
||||
facts: factsForStatement,
|
||||
facts: factsForStandardization,
|
||||
snapshots: selection.snapshots
|
||||
});
|
||||
|
||||
@@ -561,7 +565,7 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
rows: buildRows(selection.snapshots, statement, selection.selectedPeriodIds),
|
||||
statement: statement as Extract<FinancialStatementKind, 'income' | 'balance' | 'cash_flow'>,
|
||||
periods: selection.periods,
|
||||
facts: factsForStatement
|
||||
facts: factsForStandardization
|
||||
}),
|
||||
selection.periods,
|
||||
periods,
|
||||
@@ -581,7 +585,7 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
: { facts: [], nextCursor: null };
|
||||
|
||||
const dimensionBreakdown = input.includeDimensions
|
||||
? buildDimensionBreakdown(factsForStatement, periods, faithfulRows, standardizedRows)
|
||||
? buildDimensionBreakdown(factsForStandardization, periods, faithfulRows, standardizedRows)
|
||||
: null;
|
||||
|
||||
return {
|
||||
@@ -605,7 +609,7 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
surfaceKind: input.surfaceKind,
|
||||
statementRows: standardizedRows
|
||||
}),
|
||||
categories: [],
|
||||
categories: standardizedPayload.categories,
|
||||
availability: {
|
||||
adjusted: false,
|
||||
customMetrics: false
|
||||
@@ -654,19 +658,19 @@ export async function getCompanyFinancials(input: GetCompanyFinancialsInput): Pr
|
||||
rows: buildRows(incomeSelection.snapshots, 'income', incomeSelection.selectedPeriodIds),
|
||||
statement: 'income',
|
||||
periods: incomeSelection.periods,
|
||||
facts: allFacts.facts.filter((fact) => fact.statement === 'income')
|
||||
facts: allFacts.facts
|
||||
});
|
||||
const balanceQuarterlyRows = rekeyRowsByFilingId(buildStandardizedRows({
|
||||
rows: buildRows(balanceSelection.snapshots, 'balance', balanceSelection.selectedPeriodIds),
|
||||
statement: 'balance',
|
||||
periods: balanceSelection.periods,
|
||||
facts: allFacts.facts.filter((fact) => fact.statement === 'balance')
|
||||
facts: allFacts.facts
|
||||
}), balanceSelection.periods, incomeSelection.periods);
|
||||
const cashFlowQuarterlyRows = rekeyRowsByFilingId(buildStandardizedRows({
|
||||
rows: buildRows(cashFlowSelection.snapshots, 'cash_flow', cashFlowSelection.selectedPeriodIds),
|
||||
statement: 'cash_flow',
|
||||
periods: cashFlowSelection.periods,
|
||||
facts: allFacts.facts.filter((fact) => fact.statement === 'cash_flow')
|
||||
facts: allFacts.facts
|
||||
}), cashFlowSelection.periods, incomeSelection.periods);
|
||||
|
||||
const incomeRows = input.cadence === 'ltm'
|
||||
|
||||
Reference in New Issue
Block a user