From cb6a441be986bb53cdb75a785bf7af546473c0d9 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 29 Aug 2024 13:33:53 +0200 Subject: [PATCH] bugfixing % change financinal statements --- .../stats/balance-sheet/+page.svelte | 36 +++++----- .../[tickerID]/stats/cash-flow/+page.svelte | 36 +++++----- .../[tickerID]/stats/income/+page.svelte | 71 ++++++++++--------- .../[tickerID]/stats/ratios/+page.svelte | 36 +++++----- 4 files changed, 98 insertions(+), 81 deletions(-) diff --git a/src/routes/stocks/[tickerID]/stats/balance-sheet/+page.svelte b/src/routes/stocks/[tickerID]/stats/balance-sheet/+page.svelte index 8bf61d9c..5dad06a8 100644 --- a/src/routes/stocks/[tickerID]/stats/balance-sheet/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/balance-sheet/+page.svelte @@ -609,22 +609,26 @@ $: { - {#if index+1-tableList?.length === 0} - - - {:else} - {#if (item?.value- tableList[index+1]?.value) > 0} - - +{(((item?.value-tableList[index+1]?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else if (item?.value - tableList[index+1]?.value ) < 0} - - -{(Math?.abs((tableList[index+1]?.value - item?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else} - - - {/if} - {/if} - + {#if index + 1 - tableList?.length === 0} + - + {:else} + {#if (item?.value === 0 && tableList[index+1]?.value < 0)} + -100.00% + {:else if (item?.value === 0 && tableList[index+1]?.value > 0)} + 100.00% + {:else if ((item?.value - tableList[index+1]?.value) > 0)} + + {(((item?.value - tableList[index+1]?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else if ((item?.value - tableList[index+1]?.value) < 0)} + + -{(Math?.abs((tableList[index+1]?.value - item?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else} + - + {/if} + {/if} + {/each} diff --git a/src/routes/stocks/[tickerID]/stats/cash-flow/+page.svelte b/src/routes/stocks/[tickerID]/stats/cash-flow/+page.svelte index 5f7e9255..70141b86 100644 --- a/src/routes/stocks/[tickerID]/stats/cash-flow/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/cash-flow/+page.svelte @@ -565,22 +565,26 @@ $: { - {#if index+1-tableList?.length === 0} - - - {:else} - {#if (item?.value- tableList[index+1]?.value) > 0} - - +{(((item?.value-tableList[index+1]?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else if (item?.value - tableList[index+1]?.value ) < 0} - - -{(Math?.abs((tableList[index+1]?.value - item?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else} - - - {/if} - {/if} - + {#if index + 1 - tableList?.length === 0} + - + {:else} + {#if (item?.value === 0 && tableList[index+1]?.value < 0)} + -100.00% + {:else if (item?.value === 0 && tableList[index+1]?.value > 0)} + 100.00% + {:else if ((item?.value - tableList[index+1]?.value) > 0)} + + {(((item?.value - tableList[index+1]?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else if ((item?.value - tableList[index+1]?.value) < 0)} + + -{(Math?.abs((tableList[index+1]?.value - item?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else} + - + {/if} + {/if} + {/each} diff --git a/src/routes/stocks/[tickerID]/stats/income/+page.svelte b/src/routes/stocks/[tickerID]/stats/income/+page.svelte index d1e20197..c574c965 100644 --- a/src/routes/stocks/[tickerID]/stats/income/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/income/+page.svelte @@ -519,41 +519,46 @@ $: { {#each tableList as item, index} - - + + + + + {item?.date} + + + + {abbreviateNumber(item?.value)} + + + + {item?.value-tableList[index+1]?.value !== 0 ? abbreviateNumber((item?.value-tableList[index+1]?.value)?.toFixed(2)) : '-'} + + + + {#if index + 1 - tableList?.length === 0} + - + {:else} + {#if (item?.value === 0 && tableList[index+1]?.value < 0)} + -100.00% + {:else if (item?.value === 0 && tableList[index+1]?.value > 0)} + 100.00% + {:else if ((item?.value - tableList[index+1]?.value) > 0)} + + {(((item?.value - tableList[index+1]?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else if ((item?.value - tableList[index+1]?.value) < 0)} + + -{(Math?.abs((tableList[index+1]?.value - item?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else} + - + {/if} + {/if} + - - {item?.date} - - - {abbreviateNumber(item?.value)} - - - - {item?.value-tableList[index+1]?.value !== 0 ? abbreviateNumber((item?.value-tableList[index+1]?.value)?.toFixed(2)) : '-'} - - - - {#if index+1-tableList?.length === 0} - - - {:else} - {#if (item?.value- tableList[index+1]?.value) > 0} - - +{(((item?.value-tableList[index+1]?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else if (item?.value - tableList[index+1]?.value ) < 0} - - -{(Math?.abs((tableList[index+1]?.value - item?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else} - - - {/if} - {/if} - - - - {/each} + + {/each} diff --git a/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte b/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte index 40411715..61407136 100644 --- a/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte +++ b/src/routes/stocks/[tickerID]/stats/ratios/+page.svelte @@ -503,22 +503,26 @@ $: { - {#if index+1-tableList?.length === 0} - - - {:else} - {#if (item?.value- tableList[index+1]?.value) > 0} - - +{(((item?.value-tableList[index+1]?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else if (item?.value - tableList[index+1]?.value ) < 0} - - -{(Math?.abs((tableList[index+1]?.value - item?.value) / item?.value) * 100 )?.toFixed(2)}% - - {:else} - - - {/if} - {/if} - + {#if index + 1 - tableList?.length === 0} + - + {:else} + {#if (item?.value === 0 && tableList[index+1]?.value < 0)} + -100.00% + {:else if (item?.value === 0 && tableList[index+1]?.value > 0)} + 100.00% + {:else if ((item?.value - tableList[index+1]?.value) > 0)} + + {(((item?.value - tableList[index+1]?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else if ((item?.value - tableList[index+1]?.value) < 0)} + + -{(Math?.abs((tableList[index+1]?.value - item?.value) / Math.abs(item?.value)) * 100)?.toFixed(2)}% + + {:else} + - + {/if} + {/if} + {/each}