diff --git a/src/lib/components/FinancialSection.svelte b/src/lib/components/FinancialSection.svelte new file mode 100644 index 00000000..e26dbaa8 --- /dev/null +++ b/src/lib/components/FinancialSection.svelte @@ -0,0 +1,425 @@ + + + + +
+
+
+
+
+
+

+ {removeCompanyStrings($displayCompanyName)} + {title} +

+
+ +
+ {#if financialData?.length > 0} +
+ + Financials in {financialData?.at(0)?.reportedCurrency}. Fiscal + year is + {data?.getProfileData?.fiscalYearRange}. + +
+ + + +
+ + + + + + + Select time frame + + + + ($timeFrame = "5Y")} + class="cursor-pointer sm:hover:bg-gray-300 dark:sm:hover:bg-primary" + > + 5 years + + ($timeFrame = "10Y")} + class="cursor-pointer sm:hover:bg-gray-300 dark:sm:hover:bg-primary" + > + 10 years + + ($timeFrame = "MAX")} + class="cursor-pointer sm:hover:bg-gray-300 dark:sm:hover:bg-primary" + > + Max + + + + +
+ + +
+
+ {#if $coolMode} +
+ {#each fields as item, i} + + {/each} +
+ {:else} +
+ + + + + {#each financialData as item} + {#if $selectedTimePeriod === "annual"} + + {:else} + + {/if} + {/each} + + + + {#each financialData as item} + + {/each} + + + + + + +
Fiscal Year + {"FY" + " " + item?.fiscalYear} + + {item?.period + " " + item?.fiscalYear} +
Period Ending + {new Date(item?.date).toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + })} +
+
+ {/if} + {/if} +
+
+
+
+
+
diff --git a/src/lib/components/FinancialTable.svelte b/src/lib/components/FinancialTable.svelte index a5fc4aeb..5e82c29b 100644 --- a/src/lib/components/FinancialTable.svelte +++ b/src/lib/components/FinancialTable.svelte @@ -264,10 +264,7 @@ {/each} - +
import "../app.css"; import "../app.pcss"; - //import { partytownSnippet } from "@builder.io/partytown/integration"; + import { partytownSnippet } from "@builder.io/partytown/integration"; import { Toaster } from "svelte-sonner"; import "@bprogress/core/css"; import { BProgress } from "@bprogress/core"; @@ -248,7 +248,7 @@ - + diff --git a/src/routes/stocks/[tickerID]/financials/+page.svelte b/src/routes/stocks/[tickerID]/financials/+page.svelte index f4baf749..1cb0a4bd 100644 --- a/src/routes/stocks/[tickerID]/financials/+page.svelte +++ b/src/routes/stocks/[tickerID]/financials/+page.svelte @@ -5,6 +5,7 @@ coolMode, timeFrame, selectedTimePeriod, + screenWidth, } from "$lib/store"; import { removeCompanyStrings } from "$lib/utils"; import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js"; @@ -12,11 +13,16 @@ //import * as XLSX from 'xlsx'; import FinancialTable from "$lib/components/FinancialTable.svelte"; import FinancialChart from "$lib/components/FinancialChart.svelte"; + import TableMode from "lucide-svelte/icons/grid-2x2"; + import ChartMode from "lucide-svelte/icons/chart-column-increasing"; + import Download from "lucide-svelte/icons/download"; + import { goto } from "$app/navigation"; import SEO from "$lib/components/SEO.svelte"; export let data; + let switchDate = false; let tableList = []; let processedData = {}; @@ -125,21 +131,34 @@ const getCurrentYear = () => new Date()?.getFullYear(); - const filterStatement = (fullStatement, timeFrame) => { + const filterStatement = (fullStatement, timeFrame, switchDate) => { const currentYear = getCurrentYear(); + let filtered = [...(fullStatement || [])]; + switch (timeFrame) { case "5Y": - return fullStatement?.filter( + filtered = filtered.filter( (item) => currentYear - parseInt(item?.fiscalYear) < 5, ); + break; case "10Y": - return fullStatement?.filter( + filtered = filtered.filter( (item) => currentYear - parseInt(item?.fiscalYear) < 10, ); - default: - return fullStatement; + break; } + + // Sort by date depending on switchDate + filtered.sort((a, b) => { + const dateA = new Date(a.date || a.fiscalDate || a.fiscalYear); + const dateB = new Date(b.date || b.fiscalDate || b.fiscalYear); + return switchDate + ? dateA - dateB // earliest to latest + : dateB - dateA; // latest to earliest + }); + + return filtered; }; fullStatement = data?.getData; @@ -267,7 +286,7 @@ fullStatement = data?.getData?.annual; } - financialData = filterStatement(fullStatement, $timeFrame); + financialData = filterStatement(fullStatement, $timeFrame, switchDate); preprocessFinancialData(); } } @@ -291,30 +310,11 @@

{removeCompanyStrings($displayCompanyName)} Income Statement

-
{#if financialData?.length > 0} -
+
@@ -323,31 +323,43 @@ {data?.getProfileData?.fiscalYearRange}.
- -
+ {/if} + + +
diff --git a/src/routes/stocks/[tickerID]/financials/balance-sheet/+page.svelte b/src/routes/stocks/[tickerID]/financials/balance-sheet/+page.svelte index e56b5518..35e38a68 100644 --- a/src/routes/stocks/[tickerID]/financials/balance-sheet/+page.svelte +++ b/src/routes/stocks/[tickerID]/financials/balance-sheet/+page.svelte @@ -442,7 +442,7 @@ class="w-56 h-fit max-h-72 overflow-y-auto scroller" > Select time frame diff --git a/src/routes/stocks/[tickerID]/financials/cash-flow/+page.svelte b/src/routes/stocks/[tickerID]/financials/cash-flow/+page.svelte index 18c7cfd5..7ad8405f 100644 --- a/src/routes/stocks/[tickerID]/financials/cash-flow/+page.svelte +++ b/src/routes/stocks/[tickerID]/financials/cash-flow/+page.svelte @@ -26,131 +26,111 @@ const statementConfig = [ { propertyName: "netIncome", - growthPropertyName: "growthNetIncome", label: "Net Income", text: "Net income is a company's accounting profits after subtracting all costs and expenses from the revenue. It is also called earnings, profits.", }, { propertyName: "depreciationAndAmortization", - growthPropertyName: "growthDepreciationAndAmortization", label: "Depreciation & Amortization", text: "Depreciation and amortization are accounting methods for calculating how the value of a business's assets change over time. Depreciation refers to physical assets, while amortization refers to intangible assets.", }, { propertyName: "stockBasedCompensation", - growthPropertyName: "growthStockBasedCompensation", label: "Stock-Based Compensation", text: "Stock-based compensation is the value of stocks issued for the purpose of compensating the executives and employees of a company.", }, { propertyName: "otherWorkingCapital", - growthPropertyName: "growthOtherWorkingCapital", label: "Other Working Capital", text: "Other working capital represents miscellaneous changes in short-term assets and liabilities that don't have specific categories, affecting the company's available cash.", }, { propertyName: "otherNonCashItems", - growthPropertyName: "growthOtherNonCashItems", label: "Other Non-Cash Items", text: "Other Non-Cash Items refers to non-cash transactions or adjustments that impact the company's financial performance but don't involve actual cash flows. These can include items like depreciation, amortization, or changes in the fair value of investments.", }, { propertyName: "deferredIncomeTax", - growthPropertyName: "growthDeferredIncomeTax", label: "Deferred Income Tax", text: "Deferred income tax refers to future tax liabilities or assets resulting from differences in how a company reports income for tax purposes versus financial reporting. It represents the amount of income tax that will be paid or saved in the future due to these differences.", }, { propertyName: "changeInWorkingCapital", - growthPropertyName: "growthChangeInWorkingCapital", label: "Change in Working Capital", text: "Change in working capital is the difference between a company's short-term assets and liabilities over a specific period, reflecting how much cash flow is impacted by these changes.", }, { propertyName: "netCashProvidedByOperatingActivities", - growthPropertyName: "growthNetCashProvidedByOperatingActivites", label: "Operating Cash Flow", text: "Operating cash flow, also called cash flow from operating activities, measures the amount of cash that a company generates from normal business activities. It is the amount of cash left after all cash income has been received, and all cash expenses have been paid.", }, { propertyName: "capitalExpenditure", - growthPropertyName: "growthCapitalExpenditure", label: "Capital Expenditures", text: "Capital expenditures are also called payments for property, plants and equipment. It measures cash spent on long-term assets that will be used to run the business, such as manufacturing equipment, real estate and others.", }, { propertyName: "acquisitionsNet", - growthPropertyName: "growthAcquisitionsNet", - label: "Acquisitions", + label: "Cash Acquisitions", text: "The amount of cash spent on acquiring other businesses.", }, { propertyName: "purchasesOfInvestments", - growthPropertyName: "growthPurchasesOfInvestments", label: "Purchase of Investments", text: "Purchase of Investments refers to the acquisition of financial assets like stocks or bonds by a company, typically for investment purposes. It represents an outflow of cash used to buy these investments.", }, { propertyName: "salesMaturitiesOfInvestments", - growthPropertyName: "growthSalesMaturitiesOfInvestments", label: "Sales Maturities Of Investments", text: "Sales Maturities of Investments signifies the selling or maturity of financial assets like stocks or bonds by a company. It represents an inflow of cash resulting from these investment activities.", }, { propertyName: "otherInvestingActivities", - growthPropertyName: "growthOtherInvestingActivites", label: "Other Investing Acitivies", text: "Other investing activities are investing activities that do not belong to any of the categories we mentioned so far.", }, { propertyName: "netCashProvidedByInvestingActivities", - growthPropertyName: "growthNetCashUsedForInvestingActivites", label: "Investing Cash Flow", text: "Investing cash flow is the total change in cash from buying and selling investments and long-term assets.", }, { propertyName: "netDebtIssuance", - growthPropertyName: "growthDebtRepayment", label: "Debt Repayment", text: "Debt Repayment is the process of paying off loans or debt obligations. It represents an outflow of cash as the company reduces its outstanding debt.", }, { propertyName: "commonStockRepurchased", - growthPropertyName: "growthCommonStockRepurchased", label: "Common Stock Repurchased", text: "The cash gained from issuing shares, or cash spent on repurchasing shares via share buybacks. A positive number implies that the company issued more shares than it repurchased. A negative number implies that the company bought back shares.", }, { propertyName: "netDividendsPaid", - growthPropertyName: "growthDividendsPaid", label: "Dividend Paid", text: "The total amount paid out as cash dividends to shareholders.", }, { propertyName: "otherFinancingActivities", - growthPropertyName: "growthOtherFinancingActivities", label: "Other Financial Acitivies", text: "Other financial activities includes miscellaneous financial transactions beyond regular operations that impact a company's cash flow.", }, { propertyName: "netCashProvidedByFinancingActivities", - growthPropertyName: "growthNetCashProvidedByFinancingActivities", label: "Financial Cash Flow", text: "Financing cash flow is the total change in cash through financing activities. This includes dividend payments, share issuance and repurchases, changes in debt levels and others.", }, { propertyName: "netChangeInCash", - growthPropertyName: "growthNetChangeInCash", label: "Net Cash Flow", text: "Net cash flow is the sum of the operating, investing and financing cash flow numbers. It is the change in cash and equivalents on the company's balance sheet during the accounting period. It is often shown as increase/decrease in cash and equivalents on the cash flow statement.", }, { propertyName: "freeCashFlow", - growthPropertyName: "growthFreeCashFlow", label: "Free Cash Flow", text: "Free cash flow is the cash remaining after the company spends on everything required to maintain and grow the business. It is calculated by subtracting capital expenditures from operating cash flow.", }, ]; + const fields = statementConfig.map((item) => ({ label: item.label, key: item.propertyName, @@ -405,7 +385,7 @@ class="w-56 h-fit max-h-72 overflow-y-auto scroller" > Select time frame diff --git a/src/routes/stocks/[tickerID]/financials/ratios/+page.svelte b/src/routes/stocks/[tickerID]/financials/ratios/+page.svelte index 747ce208..25b62d23 100644 --- a/src/routes/stocks/[tickerID]/financials/ratios/+page.svelte +++ b/src/routes/stocks/[tickerID]/financials/ratios/+page.svelte @@ -395,7 +395,7 @@ class="w-56 h-fit max-h-72 overflow-y-auto scroller" > Select time frame diff --git a/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte b/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte index 57d32715..c2bf8f12 100644 --- a/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte +++ b/src/routes/stocks/[tickerID]/statistics/market-cap/+page.svelte @@ -576,7 +576,7 @@ class="w-56 h-fit max-h-72 overflow-y-auto scroller" > Select time frame