diff --git a/Memory.md b/Memory.md index 47ab059..ec340f5 100644 --- a/Memory.md +++ b/Memory.md @@ -59,4 +59,9 @@ ## 修復平均成本顯示 Bug與分紅獨立統計 (Task 35) - 修復了平均成本在前端顯示為空的問題:`totalBuyQuantity` 在 BUY 交易處理中從未累加,導致 `avgCost` 計算時除數為零而永遠返回 0。現在在 BUY 時正確執行 `totalBuyQuantity += quantity`。 - 將分紅邏輯從已實現盈虧中剝離,建立獨立的累計分紅統計維度:新增 `accumulatedDividendsCny` 字段,DIVIDEND 交易不再混入 `realizedPnlCny`,而是獨立累加至 `accumulatedDividendsCny`。 -- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。 \ No newline at end of file +- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。 + +## 升級 Dashboard 資產卡片 UI (Task 36) +- 升級了 Dashboard 資產卡片 UI,新增累計分紅展示,並優化了成本數據的格式化判斷邏輯。 +- 修復了 `avgCostFormatted` 的判空邏輯,將 `Big.eq(0)` 修正為 `Big.eq('0')`,確保當 `pos.avgCost` 存在且不為 0 時能正確格式化,不再顯示 `¥-`。 +- 在資產卡片中新增「累計分紅」行,展示 `accumulatedDividendsCny` 數據,保持與其它 CNY 數據一致的 `opacity-50` 樣式。 \ No newline at end of file diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 65f9edc..4f61b41 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -67,11 +67,12 @@ export default async function DashboardPage() { const posPnl = new Big(pos.pnlCny); const posPnlPositive = posPnl.gte(0); const formattedPosPnl = formatAmount(pos.pnlCny); + const formattedDividends = formatAmount(pos.accumulatedDividendsCny); const posPnlNative = new Big(pos.pnlNative); const posPnlNativePositive = posPnlNative.gte(0); - const avgCostFormatted = !new Big(pos.avgCost).eq(0) && pos.avgCost !== '0' ? formatAmount(pos.avgCost) : '-'; + const avgCostFormatted = !new Big(pos.avgCost).eq('0') ? formatAmount(pos.avgCost) : '-'; const dilutedCostFormatted = !new Big(pos.dilutedCost).eq(0) && pos.dilutedCost !== '0' ? formatAmount(pos.dilutedCost) : '-'; return ( @@ -141,6 +142,12 @@ export default async function DashboardPage() { {posPnlPositive ? '+' : ''}{formattedPosPnl} +
+ 累計分紅 + + {formattedDividends} + +