UNPKG

sec-edgar-api

Version:

Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.

39 lines (38 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveCashFlowCapex = void 0; var helpers_1 = require("./helpers"); /** * This only an estimate. splits remaining capex between quarters if FY has capex, or adds quarterly capex if Quarters have it */ function resolveCashFlowCapex(report) { var _a, _b, _c; if (report.cashFlowCapex !== null) return; var isFY = report.fiscalPeriod === 'FY'; var reportPrev = report.getReportOffset(-1, isFY ? 'ANNUAL' : 'QUARTERLY'); var _d = report.getReportsFiscalYearByPeriod(), FY = _d.FY, Q1 = _d.Q1, Q2 = _d.Q2, Q3 = _d.Q3, Q4 = _d.Q4; if (FY === null) { report.cashFlowCapex = (_a = reportPrev === null || reportPrev === void 0 ? void 0 : reportPrev.cashFlowCapex) !== null && _a !== void 0 ? _a : null; return; } var sumQuarters = [Q1, Q2, Q3, Q4].reduce(function (sum, rep) { var _a; return sum + ((_a = rep === null || rep === void 0 ? void 0 : rep.cashFlowCapex) !== null && _a !== void 0 ? _a : 0); }, 0); var reportsQuarterlyWithoutCapex = [Q1, Q2, Q3, Q4].filter(function (rep) { return rep && rep.cashFlowCapex === null; }); if (isFY) { if (reportsQuarterlyWithoutCapex.length === 0) report.cashFlowCapex = sumQuarters; return; } var reportTTMOrPrev = (_c = (_b = report.getReportOffset(0, 'ANNUAL')) !== null && _b !== void 0 ? _b : report.getReportOffset(-1, 'ANNUAL')) !== null && _c !== void 0 ? _c : report.getReportOffset(-1, 'QUARTERLY'); var roundToPlaces = (0, helpers_1.getRoundToPlaces)(Number(reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.cashFlowCapex)); var cashFlowCapexFY = FY.cashFlowCapex; if (cashFlowCapexFY !== null) { (0, helpers_1.splitValueBetweenReports)({ key: 'cashFlowCapex', reports: reportsQuarterlyWithoutCapex, roundToPlaces: roundToPlaces, value: cashFlowCapexFY - sumQuarters, }); } } exports.resolveCashFlowCapex = resolveCashFlowCapex;