sec-edgar-api
Version:
Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.
40 lines (39 loc) • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveCashFlowOperating = void 0;
var helpers_1 = require("./helpers");
// TODO: make this more accurate.
function resolveCashFlowOperating(report) {
if (report.cashFlowOperating !== null)
return;
var _a = report.getReportsFiscalYearByPeriod(), FY = _a.FY, Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
var cashFlowOperatingFY = FY ? FY.cashFlowOperating : null;
if (cashFlowOperatingFY !== null) {
var roundToPlaces = (0, helpers_1.getRoundToPlaces)(cashFlowOperatingFY);
// all reports that get estimated must be resolved to make sure the estimated values add up to the TTM value
for (var _i = 0, _b = [Q1, Q2, Q3, Q4]; _i < _b.length; _i++) {
var rep = _b[_i];
if (rep && rep.cashFlowOperating === null) {
var cashFlowOperating = getCashFlowOperating(rep);
if (cashFlowOperating === null)
continue;
report.cashFlowOperating = (0, helpers_1.round)(cashFlowOperating, roundToPlaces);
}
}
}
else {
report.cashFlowOperating = getCashFlowOperating(report);
}
}
exports.resolveCashFlowOperating = resolveCashFlowOperating;
function getCashFlowOperating(report) {
var reportPrev = report.getReportOffset(-1, report.fiscalPeriod === 'FY' ? 'ANNUAL' : 'QUARTERLY');
if (!reportPrev)
return null;
var _a = report, incomeNet = _a.incomeNet, expenseDepreciation = _a.expenseDepreciation, cashFlowWorkingCapitalNonCash = _a.cashFlowWorkingCapitalNonCash;
var cashFlowWorkingCapitalNonCashPrev = reportPrev.cashFlowWorkingCapitalNonCash;
if (cashFlowWorkingCapitalNonCash === null || cashFlowWorkingCapitalNonCashPrev === null)
return null;
var changeInWorkingCapitalNonCash = cashFlowWorkingCapitalNonCash - cashFlowWorkingCapitalNonCashPrev;
return incomeNet + expenseDepreciation - changeInWorkingCapitalNonCash;
}