From 01ef6181d9484129d38673062f62cc41bebccfcb Mon Sep 17 00:00:00 2001 From: shanshi <3316401569@qq.com> Date: Mon, 16 Nov 2026 17:23:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E8=B5=84=E9=87=91=E6=A6=82=E8=A7=88=E4=B8=8E=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 变更 - 将账户汇总收敛为账户数、资金概览和待办处理进度。 - 本期资金与当前余额合并到一个弹窗,展示银行余额条形图和四列明细。 - 银行明细按所属银行、当前余额、可用金额、不可用金额展示,并在表尾合计。 - 不保留账户和不可用金额账户分别使用独立进度与左右页签,不在汇总页展开待处理明细。 ## 验证 - FinanceLedgerBankCategoryDialogTest:6 项通过,74 个断言。 - FinanceLedgerAccountKeepTodoTest:10 项通过,144 个断言。 - FinanceLedgerAccountStatusTest:19 项通过,338 个断言。 - FinanceLedgerFlowSummarySpreadsheetTest:6 项通过,73 个断言。 - 本地真实页面验证 1,144 个账户下的布局、页签切换和资金概览弹窗。 --- .../View/FinanceLedgerPageData.php | 135 ++++++ .../pages/financial-ledger/ledger.blade.php | 391 +++++++++++++++++- .../FinanceLedgerBankCategoryDialogTest.php | 141 +++++++ 3 files changed, 657 insertions(+), 10 deletions(-) diff --git a/modules/EcommerceFinance/View/FinanceLedgerPageData.php b/modules/EcommerceFinance/View/FinanceLedgerPageData.php index c431be32..2d8099b9 100644 --- a/modules/EcommerceFinance/View/FinanceLedgerPageData.php +++ b/modules/EcommerceFinance/View/FinanceLedgerPageData.php @@ -900,6 +900,9 @@ class FinanceLedgerPageData 'a.account_type', 'a.account_should_keep', 'a.company_plan', + 'a.current_balance', + 'a.daily_available', + 'a.blocked_amount', ]); $accountShorts = $accountRows ->pluck('account_short') @@ -909,6 +912,7 @@ class FinanceLedgerPageData ->values() ->all(); $accountSources = $this->flowSummaryAccountSources($accountShorts); + $keepProgresses = $this->flowSummaryKeepProgresses($accountShorts); $flowQuery = FinanceLedgerIndependentAccounts::exclude($this->db()->table('fin_daily_flows')) ->whereIn('account_short', $accountShorts) @@ -971,6 +975,10 @@ class FinanceLedgerPageData 'bank_direct_connection' => $bankDirectConnection, 'account_should_keep' => $accountShouldKeep, 'data_source' => $rawDataSource !== '' ? $rawDataSource : null, + 'current_balance' => round((float) ($account->current_balance ?? 0), 2), + 'available_balance' => round((float) ($account->daily_available ?? 0), 2), + 'blocked_balance' => round((float) ($account->blocked_amount ?? 0), 2), + 'keep_progress' => $keepProgresses[$accountShort] ?? 'not_started', 'opening_balance' => $latestBeforePeriod !== null ? round((float) $latestBeforePeriod->closing_balance, 2) : ($firstInPeriod === null ? null : round((float) $firstInPeriod->opening_balance, 2)), @@ -1000,6 +1008,29 @@ class FinanceLedgerPageData $pageRows = array_slice($rows, ($page - 1) * 100, 100); $this->attachFlowSummaryCustomValues($pageRows, $customFields); $bankCategories = $this->flowSummaryBankCategories($rows); + $unavailableProgress = $this->flowSummaryUnavailableProgress($rows); + $unretainedRows = array_values(array_filter( + $rows, + static fn (array $row): bool => ($row['account_should_keep'] ?? '') === FinanceLedgerAccountShouldKeep::NO, + )); + $unretainedProgress = [ + 'count' => count($unretainedRows), + 'completed' => count(array_filter( + $unretainedRows, + static fn (array $row): bool => ($row['keep_progress'] ?? '') === 'completed', + )), + 'in_progress' => count(array_filter( + $unretainedRows, + static fn (array $row): bool => ($row['keep_progress'] ?? '') === 'in_progress', + )), + 'not_started' => count(array_filter( + $unretainedRows, + static fn (array $row): bool => ! in_array(($row['keep_progress'] ?? ''), ['completed', 'in_progress'], true), + )), + ]; + $unretainedProgress['percent'] = $unretainedProgress['count'] > 0 + ? round($unretainedProgress['completed'] / $unretainedProgress['count'] * 100, 1) + : 0.0; $paginator = new LengthAwarePaginator( array_map(static fn (array $row): object => (object) $row, $pageRows), $total, @@ -1020,6 +1051,11 @@ class FinanceLedgerPageData 'inflow' => round(array_sum(array_column($rows, 'inflow')), 2), 'outflow' => round(array_sum(array_column($rows, 'outflow')), 2), 'closing' => round(array_sum(array_map(static fn (array $row): float => (float) ($row['closing_balance'] ?? 0), $rows)), 2), + 'current_balance' => round(array_sum(array_column($rows, 'current_balance')), 2), + 'available' => round(array_sum(array_column($rows, 'available_balance')), 2), + 'blocked' => round(array_sum(array_column($rows, 'blocked_balance')), 2), + 'unavailable_progress' => $unavailableProgress, + 'unretained_progress' => $unretainedProgress, 'bank_categories' => $bankCategories, ], 'custom_fields' => $customFields, @@ -1053,6 +1089,9 @@ class FinanceLedgerPageData 'non_direct_count' => 0, 'total_count' => 0, 'balance' => 0.0, + 'current_balance' => 0.0, + 'available_balance' => 0.0, + 'blocked_balance' => 0.0, 'retained_count' => 0, 'unretained_count' => 0, ]; @@ -1060,6 +1099,9 @@ class FinanceLedgerPageData $categories[$category]['total_count']++; $categories[$category]['balance'] += (float) ($row['closing_balance'] ?? 0); + $categories[$category]['current_balance'] += (float) ($row['current_balance'] ?? 0); + $categories[$category]['available_balance'] += (float) ($row['available_balance'] ?? 0); + $categories[$category]['blocked_balance'] += (float) ($row['blocked_balance'] ?? 0); $directConnection = trim((string) ($row['bank_direct_connection'] ?? '')); if ($directConnection === '是') { $categories[$category]['direct_count']++; @@ -1081,6 +1123,9 @@ class FinanceLedgerPageData $categoryRows = array_values(array_map(static function (array $row): array { $row['balance'] = round((float) $row['balance'], 2); + $row['current_balance'] = round((float) $row['current_balance'], 2); + $row['available_balance'] = round((float) $row['available_balance'], 2); + $row['blocked_balance'] = round((float) $row['blocked_balance'], 2); return $row; }, $categories)); @@ -1101,6 +1146,9 @@ class FinanceLedgerPageData 'non_direct_count' => array_sum(array_column($categoryRows, 'non_direct_count')), 'total_count' => array_sum(array_column($categoryRows, 'total_count')), 'balance' => round(array_sum(array_column($categoryRows, 'balance')), 2), + 'current_balance' => round(array_sum(array_column($categoryRows, 'current_balance')), 2), + 'available_balance' => round(array_sum(array_column($categoryRows, 'available_balance')), 2), + 'blocked_balance' => round(array_sum(array_column($categoryRows, 'blocked_balance')), 2), 'retained_count' => array_sum(array_column($categoryRows, 'retained_count')), 'unretained_count' => array_sum(array_column($categoryRows, 'unretained_count')), ]; @@ -1113,6 +1161,93 @@ class FinanceLedgerPageData ]; } + /** + * @param list $accountShorts + * @return array + */ + private function flowSummaryKeepProgresses(array $accountShorts): array + { + if ($accountShorts === [] || ! $this->db()->getSchemaBuilder()->hasTable('fin_account_keep_todos')) { + return []; + } + + return $this->db()->table('fin_account_keep_todos') + ->whereIn('account_short', $accountShorts) + ->pluck('current_progress', 'account_short') + ->map(static function (mixed $progress): string { + $value = trim((string) $progress); + + return in_array($value, ['completed', 'in_progress'], true) ? $value : 'not_started'; + }) + ->all(); + } + + /** + * 不使用“账户是否保留”字段,单独统计账户状态异常形成的不可用金额待办。 + * + * @param array> $rows + * @return array{count:int,completed:int,in_progress:int,incomplete:int,not_started:int,handled:int,percent:float} + */ + private function flowSummaryUnavailableProgress(array $rows): array + { + $progress = [ + 'count' => 0, + 'completed' => 0, + 'in_progress' => 0, + 'incomplete' => 0, + 'not_started' => 0, + 'handled' => 0, + 'percent' => 0.0, + ]; + $accountShorts = array_values(array_unique(array_filter(array_map( + static fn (array $row): string => trim((string) ($row['account_short'] ?? '')), + $rows, + )))); + if ($accountShorts === [] + || ! $this->db()->getSchemaBuilder()->hasTable('fin_account_statuses') + || ! $this->db()->getSchemaBuilder()->hasTable('fin_account_todos')) { + return $progress; + } + + $abnormalStatuses = array_values(array_diff( + array_keys(FinanceLedgerAccountStatus::OPTIONS), + [FinanceLedgerAccountStatus::NORMAL], + )); + $abnormalShorts = $this->db()->table('fin_account_statuses') + ->whereIn('account_short', $accountShorts) + ->whereIn('status', $abnormalStatuses) + ->pluck('account_short') + ->map(static fn (mixed $value): string => (string) $value) + ->all(); + if ($abnormalShorts === []) { + return $progress; + } + + $abnormalLookup = array_flip($abnormalShorts); + $todoStatuses = $this->db()->table('fin_account_todos') + ->whereIn('account_short', $abnormalShorts) + ->pluck('completion_status', 'account_short'); + foreach ($rows as $row) { + $accountShort = trim((string) ($row['account_short'] ?? '')); + if (! isset($abnormalLookup[$accountShort])) { + continue; + } + + $progress['count']++; + $status = trim((string) ($todoStatuses[$accountShort] ?? 'not_started')); + if (! in_array($status, ['completed', 'in_progress', 'incomplete', 'not_started'], true)) { + $status = 'not_started'; + } + $progress[$status]++; + } + $progress['handled'] = $progress['completed'] + $progress['in_progress'] + $progress['incomplete']; + $progress['percent'] = $progress['count'] > 0 + ? round($progress['handled'] / $progress['count'] * 100, 1) + : 0.0; + + return $progress; + } + /** * @param list $accountShorts * @return array diff --git a/resources/views/business/pages/financial-ledger/ledger.blade.php b/resources/views/business/pages/financial-ledger/ledger.blade.php index ffae5b47..d59b8228 100644 --- a/resources/views/business/pages/financial-ledger/ledger.blade.php +++ b/resources/views/business/pages/financial-ledger/ledger.blade.php @@ -519,6 +519,71 @@ .ledger-summary__scope { margin-left:.25rem; color:var(--vip-content-muted, #595959); font-size:.62rem; font-style:normal; font-weight:500; } .ledger-summary__item span { overflow:hidden; color:var(--vip-content-muted, #595959); font-size:.68rem; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; } .ledger-summary__item b { overflow:hidden; color:var(--vip-content-ink, #171717); font-size:.92rem; font-variant-numeric:tabular-nums; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; } + .ledger-flow-overview { display:grid; grid-template-columns:minmax(7.5rem,.55fr) minmax(34rem,2.7fr) minmax(21rem,1.2fr); margin-bottom:.85rem; overflow:hidden; border:1px solid var(--vip-border, #D8D2C7); border-radius:.65rem; background:#fff; } + .ledger-flow-overview__section { display:flex; min-width:0; flex-direction:column; gap:.45rem; padding:.78rem .9rem; border-right:1px solid #e8e3da; background:#fff; color:var(--vip-content-ink, #171717); } + .ledger-flow-overview__section:last-child { border-right:0; } + .ledger-flow-overview__section--button { align-items:flex-start; border-top:0; border-bottom:0; border-left:0; font:inherit; text-align:left; cursor:pointer; transition:background .15s ease; } + .ledger-flow-overview__section--button:hover { background:var(--vip-content-accent-soft, #F7F0DE); } + .ledger-flow-overview__section--button:focus-visible { position:relative; z-index:1; outline:2px solid var(--vip-content-accent-dark, #856632); outline-offset:-2px; } + .ledger-flow-overview__header { display:flex; min-width:0; align-items:center; justify-content:space-between; gap:.6rem; } + .ledger-flow-overview__header h4 { margin:0; font-size:.72rem; line-height:1.35; } + .ledger-flow-overview__header > span { overflow:hidden; color:var(--vip-content-muted, #595959); font-size:.61rem; text-overflow:ellipsis; white-space:nowrap; } + .ledger-flow-overview__label { color:var(--vip-content-muted, #595959); font-size:.68rem; font-weight:500; } + .ledger-flow-overview__account-count { color:var(--vip-content-ink, #171717); font-size:1.22rem; font-variant-numeric:tabular-nums; line-height:1.2; } + .ledger-flow-overview__hint { color:var(--vip-content-accent-dark, #856632); font-size:.62rem; font-weight:600; } + .ledger-flow-overview__metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); min-width:0; margin-top:auto; padding-top:.45rem; border-top:1px solid #e8e3da; } + .ledger-flow-overview__metric { display:grid; min-width:0; gap:.14rem; padding:.38rem .6rem; border-right:1px solid #e8e3da; } + .ledger-flow-overview__metric:first-child { padding-left:0; } + .ledger-flow-overview__metric:last-child { padding-right:0; border-right:0; } + .ledger-flow-overview__metric span { color:var(--vip-content-muted, #595959); font-size:.61rem; } + .ledger-flow-overview__metric b { overflow:hidden; color:var(--vip-content-ink, #171717); font-size:.82rem; font-variant-numeric:tabular-nums; text-overflow:ellipsis; white-space:nowrap; } + .ledger-flow-overview__current { display:grid; grid-template-columns:minmax(8rem,.7fr) minmax(0,1.3fr); gap:.65rem; align-items:center; margin-top:.15rem; padding-top:.5rem; border-top:1px solid #e8e3da; } + .ledger-flow-overview__current-copy { display:grid; gap:.12rem; } + .ledger-flow-overview__current-copy > span { color:var(--vip-content-muted, #595959); font-size:.61rem; } + .ledger-flow-overview__balance { display:flex; align-items:baseline; gap:.3rem; margin-top:.05rem; } + .ledger-flow-overview__balance b { color:var(--vip-content-ink, #171717); font-size:1.14rem; font-variant-numeric:tabular-nums; line-height:1.2; } + .ledger-flow-overview__balance span { color:var(--vip-content-muted, #595959); font-size:.62rem; } + .ledger-flow-overview__balance-parts { display:flex; flex-wrap:wrap; gap:.25rem .75rem; color:var(--vip-content-muted, #595959); font-size:.63rem; } + .ledger-flow-overview__balance-parts b { font-variant-numeric:tabular-nums; } + .ledger-flow-overview__balance-parts .is-available b { color:var(--vip-success, #53793E); } + .ledger-flow-overview__balance-parts .is-blocked b { color:var(--vip-danger, #B80000); } + .ledger-flow-overview__split { display:flex; height:.42rem; overflow:hidden; border-radius:999px; background:#e8e3da; } + .ledger-flow-overview__split i { display:block; height:100%; } + .ledger-flow-overview__split .is-available { background:var(--vip-success, #53793E); } + .ledger-flow-overview__split .is-blocked { background:var(--vip-danger, #B80000); } + .ledger-flow-overview__action { align-self:flex-start; padding:0; border:0; background:transparent; color:var(--vip-content-accent-dark, #856632); font:inherit; font-size:.64rem; font-weight:700; text-decoration:none; cursor:pointer; } + .ledger-flow-overview__action:hover { text-decoration:underline; } + .ledger-flow-overview__action:focus-visible { outline:2px solid var(--vip-content-accent-dark, #856632); outline-offset:2px; } + .ledger-flow-overview__progress-head { display:flex; align-items:baseline; justify-content:space-between; gap:.5rem; } + .ledger-flow-overview__progress-head b { color:var(--vip-content-ink, #171717); font-size:.94rem; font-variant-numeric:tabular-nums; } + .ledger-flow-overview__progress-head span { color:var(--vip-content-muted, #595959); font-size:.62rem; } + .ledger-flow-overview__progress-track { height:.48rem; overflow:hidden; border-radius:999px; background:#e8e3da; } + .ledger-flow-overview__progress-bar { display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,var(--vip-content-accent, #B9954F),var(--vip-content-accent-dark, #856632)); } + .ledger-flow-overview__progress-stats { display:flex; flex-wrap:wrap; gap:.22rem .72rem; color:var(--vip-content-muted, #595959); font-size:.61rem; } + .ledger-flow-overview__progress-stats b { margin-left:.12rem; color:var(--vip-content-ink, #171717); font-variant-numeric:tabular-nums; } + .ledger-flow-overview__progress-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.18rem; padding:.18rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.45rem; background:#f7f4ed; } + .ledger-flow-overview__progress-tab { min-width:0; height:1.7rem; padding:0 .35rem; border:0; border-radius:.32rem; background:transparent; color:var(--vip-content-muted, #595959); font:inherit; font-size:.63rem; font-weight:600; cursor:pointer; } + .ledger-flow-overview__progress-tab:hover { color:var(--vip-content-accent-dark, #856632); } + .ledger-flow-overview__progress-tab.is-active { background:var(--vip-content-accent-dark, #856632); color:#fff; } + .ledger-flow-overview__progress-tab:focus-visible { outline:2px solid var(--vip-content-accent-dark, #856632); outline-offset:1px; } + .ledger-flow-overview__progress-panel { display:grid; gap:.5rem; } + .ledger-flow-overview__progress-panel[hidden] { display:none !important; } + .ledger-flow-overview__progress-panel .ledger-flow-overview__action { margin-top:auto; } + @media (max-width: 1320px) { + .ledger-flow-overview { grid-template-columns:repeat(2,minmax(0,1fr)); } + .ledger-flow-overview__section--funds { border-right:0; } + .ledger-flow-overview__section--progress { grid-column:1/-1; border-top:1px solid #e8e3da; } + } + @media (max-width: 760px) { + .ledger-flow-overview { grid-template-columns:1fr; } + .ledger-flow-overview__section { border-top:1px solid #e8e3da; border-right:0; } + .ledger-flow-overview__section:first-child { border-top:0; } + .ledger-flow-overview__metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } + .ledger-flow-overview__metric:nth-child(2) { border-right:0; } + .ledger-flow-overview__metric:nth-child(n+3) { padding-top:.5rem; border-top:1px solid #e8e3da; } + .ledger-flow-overview__current { grid-template-columns:1fr; } + .ledger-flow-overview__section--progress { grid-column:auto; } + } .ledger-available-dialog { width:min(36rem, calc(100vw - 2rem)); max-height:calc(100vh - 2rem); padding:0; overflow:auto; border:1px solid var(--vip-border, #D8D2C7); border-radius:.75rem; background:#fff; color:var(--vip-content-ink, #171717); box-shadow:0 8px 24px rgba(23,23,23,.18); } .ledger-available-dialog--wide { width:min(64rem, calc(100vw - 2rem)); } .ledger-available-dialog::backdrop { background:rgba(5,5,6,.46); } @@ -551,6 +616,50 @@ .ledger-bank-category-table tbody tr:hover { background:#fbf8ef; } .ledger-bank-category-table tfoot td { border-top:1px solid var(--vip-border, #D8D2C7); border-bottom:0; background:#fcfaf5; font-weight:600; } .ledger-bank-category-note { margin:.75rem 0 0; color:var(--vip-content-muted, #595959); font-size:.68rem; line-height:1.55; } + .ledger-balance-kpis { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); margin-bottom:1rem; border-top:1px solid #e8e3da; border-bottom:1px solid #e8e3da; } + .ledger-balance-kpis--four { grid-template-columns:repeat(4,minmax(0,1fr)); } + .ledger-balance-kpi { display:grid; gap:.2rem; padding:.7rem .85rem; border-right:1px solid #e8e3da; } + .ledger-balance-kpi:last-child { border-right:0; } + .ledger-balance-kpi span { color:var(--vip-content-muted, #595959); font-size:.66rem; } + .ledger-balance-kpi strong { color:var(--vip-content-ink, #171717); font-size:.9rem; font-variant-numeric:tabular-nums; } + .ledger-balance-section-title { display:flex; align-items:baseline; justify-content:space-between; gap:.75rem; margin:.15rem 0 .35rem; } + .ledger-balance-section-title:not(:first-child) { margin-top:1rem; } + .ledger-balance-section-title h4 { margin:0; font-size:.76rem; } + .ledger-balance-section-title span { color:var(--vip-content-muted, #595959); font-size:.64rem; } + .ledger-balance-distribution { display:grid; grid-template-columns:minmax(0,1.08fr) minmax(26rem,.92fr); gap:1.1rem; align-items:start; } + .ledger-balance-panel { min-width:0; } + .ledger-balance-panel + .ledger-balance-panel { padding-left:1.1rem; border-left:1px solid #e8e3da; } + .ledger-balance-panel__header { display:flex; align-items:baseline; justify-content:space-between; gap:.75rem; margin-bottom:.65rem; } + .ledger-balance-panel__header h4 { margin:0; font-size:.76rem; } + .ledger-balance-panel__header span { color:var(--vip-content-muted, #595959); font-size:.64rem; } + .ledger-balance-chart { display:grid; max-height:25rem; gap:.48rem; overflow:auto; padding-right:.2rem; } + .ledger-balance-chart__row { display:grid; grid-template-columns:5.6rem minmax(7rem,1fr) 4.8rem; align-items:center; gap:.45rem; min-height:1.55rem; } + .ledger-balance-chart__label { overflow:hidden; color:var(--vip-content-muted, #595959); font-size:.66rem; text-overflow:ellipsis; white-space:nowrap; } + .ledger-balance-chart__track { height:.58rem; overflow:hidden; border-radius:999px; background:#e8e3da; } + .ledger-balance-chart__bar { display:block; width:0; height:100%; border-radius:999px; background:linear-gradient(90deg,var(--vip-content-accent, #B9954F),var(--vip-content-accent-dark, #856632)); } + .ledger-balance-chart__bar.is-negative { background:var(--vip-danger, #B80000); } + .ledger-balance-chart__value { color:var(--vip-content-ink, #171717); font-size:.66rem; font-variant-numeric:tabular-nums; text-align:right; white-space:nowrap; } + .ledger-balance-detail-table { width:100%; min-width:0; table-layout:fixed; border-collapse:collapse; font-variant-numeric:tabular-nums; } + .ledger-balance-detail-table th:first-child, + .ledger-balance-detail-table td:first-child { width:28%; } + .ledger-balance-detail-table th:not(:first-child), + .ledger-balance-detail-table td:not(:first-child) { width:24%; } + .ledger-balance-detail-table th, + .ledger-balance-detail-table td { padding:.45rem .4rem; border-bottom:1px solid #e8e3da; font-size:.68rem; text-align:right; white-space:nowrap; } + .ledger-balance-detail-table th { background:var(--vip-content-accent-soft, #F7F0DE); color:var(--vip-content-muted, #595959); font-weight:600; } + .ledger-balance-detail-table th:first-child, + .ledger-balance-detail-table td:first-child { position:static; background:inherit; text-align:left; } + .ledger-balance-detail-table tbody tr:hover { background:#fbf8ef; } + .ledger-balance-detail-table tfoot td { background:#fcfaf5; font-weight:700; } + .ledger-balance-detail-table tbody tr:last-child td { border-bottom:0; } + @media (max-width: 1000px) { + .ledger-balance-distribution { grid-template-columns:1fr; } + .ledger-balance-kpis { grid-template-columns:1fr; } + .ledger-balance-kpis--four { grid-template-columns:repeat(2,minmax(0,1fr)); } + .ledger-balance-kpi { border-right:0; border-bottom:1px solid #e8e3da; } + .ledger-balance-kpi:last-child { border-bottom:0; } + .ledger-balance-panel + .ledger-balance-panel { padding-top:1rem; padding-left:0; border-top:1px solid #e8e3da; border-left:0; } + } .ledger-table.ledger-flow-summary-table th, .ledger-table.ledger-flow-summary-table td { padding:.34rem .42rem; } .ledger-table.ledger-flow-summary-table tbody td { height:2.15rem; vertical-align:middle; } @@ -1387,17 +1496,146 @@ 'accountTypeCardsBackUrl' => $flowViewUrl('summary'), ]) @else -
- @if ($flowView === 'daily') + @if ($flowView === 'daily') +
流水条数{{ number_format((int) ($ledgerFlowSummary['count'] ?? 0)) }}
- @else - - @endif -
期初余额合计(万元){{ $moneyWan($ledgerFlowSummary['opening'] ?? 0) }}
-
当期入账(万元){{ $moneyWan($ledgerFlowSummary['inflow'] ?? 0) }}
-
当期出账(万元){{ $moneyWan($ledgerFlowSummary['outflow'] ?? 0) }}
-
期末余额合计(万元){{ $moneyWan($ledgerFlowSummary['closing'] ?? 0) }}
-
+
期初余额合计(万元){{ $moneyWan($ledgerFlowSummary['opening'] ?? 0) }}
+
当期入账(万元){{ $moneyWan($ledgerFlowSummary['inflow'] ?? 0) }}
+
当期出账(万元){{ $moneyWan($ledgerFlowSummary['outflow'] ?? 0) }}
+
期末余额合计(万元){{ $moneyWan($ledgerFlowSummary['closing'] ?? 0) }}
+
+ @else + @php + $unretainedProgress = $ledgerFlowSummary['unretained_progress'] ?? [ + 'count' => 0, + 'completed' => 0, + 'in_progress' => 0, + 'not_started' => 0, + 'percent' => 0.0, + ]; + $availableBalanceTotal = (float) ($ledgerFlowSummary['available'] ?? 0); + $blockedBalanceTotal = (float) ($ledgerFlowSummary['blocked'] ?? 0); + $balanceCompositionTotal = max(0.0, $availableBalanceTotal + $blockedBalanceTotal); + $availableBalancePercent = $balanceCompositionTotal > 0 + ? max(0.0, $availableBalanceTotal / $balanceCompositionTotal * 100) + : 0.0; + $blockedBalancePercent = $balanceCompositionTotal > 0 + ? max(0.0, $blockedBalanceTotal / $balanceCompositionTotal * 100) + : 0.0; + $unretainedCount = (int) ($unretainedProgress['count'] ?? 0); + $unretainedCompleted = (int) ($unretainedProgress['completed'] ?? 0); + $unretainedInProgress = (int) ($unretainedProgress['in_progress'] ?? 0); + $unretainedNotStarted = (int) ($unretainedProgress['not_started'] ?? 0); + $unretainedPercent = (float) ($unretainedProgress['percent'] ?? 0); + $unavailableProgress = $ledgerFlowSummary['unavailable_progress'] ?? [ + 'count' => 0, + 'completed' => 0, + 'in_progress' => 0, + 'incomplete' => 0, + 'not_started' => 0, + 'handled' => 0, + 'percent' => 0.0, + ]; + $unavailableCount = (int) ($unavailableProgress['count'] ?? 0); + $unavailableCompleted = (int) ($unavailableProgress['completed'] ?? 0); + $unavailableInProgress = (int) ($unavailableProgress['in_progress'] ?? 0); + $unavailableIncomplete = (int) ($unavailableProgress['incomplete'] ?? 0); + $unavailableNotStarted = (int) ($unavailableProgress['not_started'] ?? 0); + $unavailableHandled = (int) ($unavailableProgress['handled'] ?? 0); + $unavailablePercent = (float) ($unavailableProgress['percent'] ?? 0); + @endphp +
+ +
+
+

资金概览(万元)

+ +
+
+
+ 期初余额 + {{ $moneyWan($ledgerFlowSummary['opening'] ?? 0) }} +
+
+ 当期收入 + {{ $moneyWan($ledgerFlowSummary['inflow'] ?? 0) }} +
+
+ 当期支出 + {{ $moneyWan($ledgerFlowSummary['outflow'] ?? 0) }} +
+
+ 期末余额 + {{ $moneyWan($ledgerFlowSummary['closing'] ?? 0) }} +
+
+
+
+ 当前余额 · {{ $flowPeriod['from'] ?? '—' }} 至 {{ $flowPeriod['to'] ?? '—' }} +
+ {{ $moneyWan($ledgerFlowSummary['current_balance'] ?? 0) }} + 万元 +
+
+
+
+ 可用 {{ $moneyWan($availableBalanceTotal) }} + 不可用 {{ $moneyWan($blockedBalanceTotal) }} +
+
+ + +
+ 可用 {{ number_format($availableBalancePercent, 1) }}% · 不可用 {{ number_format($blockedBalancePercent, 1) }}% +
+
+
+
+
+

待办处理进度

+
+
+ + +
+
+
+ {{ number_format($unretainedPercent, 1) }}% + 已完成 {{ number_format($unretainedCompleted) }} / {{ number_format($unretainedCount) }} 户 +
+
+ +
+
+ 已完成 {{ number_format($unretainedCompleted) }} + 进行中 {{ number_format($unretainedInProgress) }} + 待开始 {{ number_format($unretainedNotStarted) }} +
+ 查看全部 +
+ +
+
+ @endif @if ($flowView !== 'daily') @php $bankCategoryBreakdown = $ledgerFlowSummary['bank_categories'] ?? [ @@ -1406,6 +1644,11 @@ 'direct_unset_count' => 0, 'keep_unset_count' => 0, ]; + $balanceDistribution = collect($bankCategoryBreakdown['categories'])->sortByDesc('current_balance')->values(); + $balanceDistributionTotal = round((float) ($bankCategoryBreakdown['totals']['current_balance'] ?? ($ledgerFlowSummary['current_balance'] ?? 0)), 2); + $balanceDistributionAvailable = round((float) ($bankCategoryBreakdown['totals']['available_balance'] ?? ($ledgerFlowSummary['available'] ?? 0)), 2); + $balanceDistributionBlocked = round((float) ($bankCategoryBreakdown['totals']['blocked_balance'] ?? ($ledgerFlowSummary['blocked'] ?? 0)), 2); + $balanceDistributionMax = (float) ($balanceDistribution->map(static fn (array $category): float => abs((float) ($category['current_balance'] ?? 0)))->max() ?? 0); @endphp
@@ -1481,6 +1724,88 @@
+ +
+
+
+

资金概览

+

{{ $flowPeriod['from'] ?? '—' }} 至 {{ $flowPeriod['to'] ?? '—' }},同时展示本期资金和当前余额;沿用当前公司、账户简称和数据来源筛选。

+
+ +
+
+
+

本期资金

+ 单位:万元 +
+
+
期初余额{{ $moneyWan($ledgerFlowSummary['opening'] ?? 0) }}
+
当期收入{{ $moneyWan($ledgerFlowSummary['inflow'] ?? 0) }}
+
当期支出{{ $moneyWan($ledgerFlowSummary['outflow'] ?? 0) }}
+
期末余额{{ $moneyWan($ledgerFlowSummary['closing'] ?? 0) }}
+
+
+

当前余额

+ 末项为期末余额,当前余额取账户当前值 +
+
+
当前余额合计{{ $moneyWan($balanceDistributionTotal) }} 万元
+
可用金额{{ $moneyWan($balanceDistributionAvailable) }} 万元
+
不可用金额{{ $moneyWan($balanceDistributionBlocked) }} 万元
+
+
+
+

余额条形图

按当前余额从高到低
+ +
+
+

银行分布明细

金额单位:万元
+
+ + + + @forelse ($balanceDistribution as $category) + @php + $categoryBalance = (float) ($category['current_balance'] ?? 0); + @endphp + + + + + + + @empty + + @endforelse + + +
所属银行当前余额可用金额不可用金额
{{ $category['bank_category'] }}{{ $moneyWan($categoryBalance) }}{{ $moneyWan($category['available_balance'] ?? 0) }}{{ $moneyWan($category['blocked_balance'] ?? 0) }}
当前筛选没有银行余额明细。
总金额{{ $moneyWan($balanceDistributionTotal) }}{{ $moneyWan($balanceDistributionAvailable) }}{{ $moneyWan($balanceDistributionBlocked) }}
+
+
+
+
+
+ +
+
+
@endif
@@ -3640,6 +3965,52 @@ bankCategoryDialog?.addEventListener('close', () => { bankCategoryTrigger?.setAttribute('aria-expanded', 'false'); }); + const balanceDistributionTrigger = page.querySelector('[data-ledger-balance-distribution-trigger]'); + const balanceDistributionDialog = page.querySelector('[data-ledger-balance-distribution-dialog]'); + const openBalanceDistributionDialog = () => { + if (!balanceDistributionDialog) return; + if (typeof balanceDistributionDialog.showModal === 'function') { + balanceDistributionDialog.showModal(); + } else { + balanceDistributionDialog.setAttribute('open', ''); + } + balanceDistributionTrigger?.setAttribute('aria-expanded', 'true'); + balanceDistributionDialog.querySelector('[data-ledger-balance-distribution-close]')?.focus(); + }; + const closeBalanceDistributionDialog = () => { + if (!balanceDistributionDialog?.open) return; + if (typeof balanceDistributionDialog.close === 'function') { + balanceDistributionDialog.close(); + } else { + balanceDistributionDialog.removeAttribute('open'); + } + balanceDistributionTrigger?.setAttribute('aria-expanded', 'false'); + balanceDistributionTrigger?.focus(); + }; + balanceDistributionTrigger?.addEventListener('click', openBalanceDistributionDialog); + page.querySelectorAll('[data-ledger-balance-distribution-close], [data-ledger-balance-distribution-footer-close]') + .forEach((button) => button.addEventListener('click', closeBalanceDistributionDialog)); + balanceDistributionDialog?.addEventListener('click', (event) => { + if (event.target === balanceDistributionDialog) closeBalanceDistributionDialog(); + }); + balanceDistributionDialog?.addEventListener('close', () => { + balanceDistributionTrigger?.setAttribute('aria-expanded', 'false'); + }); + const progressTabs = Array.from(page.querySelectorAll('[data-ledger-progress-tab]')); + const progressPanels = Array.from(page.querySelectorAll('[data-ledger-progress-panel]')); + const activateProgressTab = (target) => { + progressTabs.forEach((tab) => { + const selected = tab.dataset.ledgerProgressTab === target; + tab.classList.toggle('is-active', selected); + tab.setAttribute('aria-selected', selected ? 'true' : 'false'); + }); + progressPanels.forEach((panel) => { + panel.hidden = panel.dataset.ledgerProgressPanel !== target; + }); + }; + progressTabs.forEach((tab) => { + tab.addEventListener('click', () => activateProgressTab(tab.dataset.ledgerProgressTab)); + }); const bankCategorySort = bankCategoryDialog?.querySelector('[data-ledger-bank-category-sort="balance"]'); bankCategorySort?.addEventListener('click', () => { const tableBody = bankCategoryDialog?.querySelector('.ledger-bank-category-table tbody'); diff --git a/tests/Feature/Business/FinanceLedgerBankCategoryDialogTest.php b/tests/Feature/Business/FinanceLedgerBankCategoryDialogTest.php index 39f4d017..c6960a02 100644 --- a/tests/Feature/Business/FinanceLedgerBankCategoryDialogTest.php +++ b/tests/Feature/Business/FinanceLedgerBankCategoryDialogTest.php @@ -126,6 +126,147 @@ class FinanceLedgerBankCategoryDialogTest extends FeatureTestCase ]); } + public function test_fund_overview_opens_combined_period_and_current_balance_dialog(): void + { + $response = $this->loginAs()->get($this->pageUrl([ + 'flows_from' => '2026-10-01', + 'flows_to' => '2026-10-31', + ])); + + $html = $response->assertOk()->getContent(); + $checks = [ + 'trigger' => 'data-ledger-balance-distribution-trigger', + 'dialog control' => 'aria-controls="ledger-balance-distribution-dialog"', + 'dialog title' => '资金概览', + 'period title' => '

本期资金

', + 'current title' => '

当前余额

', + 'chart title' => '余额条形图', + 'detail title' => '银行分布明细', + 'bank detail column' => '', + 'total row label' => '', + 'icbc chart bar' => 'data-ledger-current-balance-chart-bar="工商银行"', + 'cmb chart bar' => 'data-ledger-current-balance-chart-bar="招商银行"', + 'trigger handler' => 'balanceDistributionTrigger?.addEventListener(\'click\', openBalanceDistributionDialog)', + ]; + foreach ($checks as $label => $needle) { + $this->assertTrue(str_contains($html, $needle), $label . ' is missing'); + } + + $this->assertTrue( + strpos($html, $checks['icbc chart bar']) < strpos($html, $checks['cmb chart bar']), + 'chart bars are not ordered by balance descending', + ); + $this->assertMatchesRegularExpression( + '/
所属银行
总金额
.*?(?:
[^<]+<\/th>){4}<\/tr><\/thead>/s', + $html, + ); + $this->assertDoesNotMatchRegularExpression( + '/.*?
账户数<\/th>/s', + $html, + ); + } + + public function test_summary_uses_compact_fund_overview_and_two_independent_progress_tabs(): void + { + $connection = DB::connection('business_mirror'); + $connection->table('fin_accounts')->insert([ + 'company_name' => '弹窗测试公司', + 'account_short' => '弹窗建设建行', + 'account_should_keep' => '否', + 'current_balance' => 4400.50, + 'daily_available' => 4000, + 'blocked_amount' => 400.50, + ]); + $connection->table('fin_daily_flows')->insert([ + 'flow_date' => '2026-10-17', + 'company_name' => '弹窗测试公司', + 'account_short' => '弹窗建设建行', + 'opening_balance' => 4400.50, + 'inflow' => 0, + 'outflow' => 0, + 'closing_balance' => 4400.50, + ]); + $connection->table('fin_account_keep_todos')->insert([ + [ + 'account_short' => '弹窗工商1工行', + 'current_progress' => 'completed', + 'updated_by' => '测试', + ], + [ + 'account_short' => '弹窗建设建行', + 'current_progress' => 'in_progress', + 'updated_by' => '测试', + ], + ]); + $connection->table('fin_account_statuses')->insert([ + [ + 'account_short' => '弹窗工商1工行', + 'status' => 'online_banking_abnormal', + 'updated_by' => '测试', + ], + [ + 'account_short' => '弹窗建设建行', + 'status' => 'limited', + 'updated_by' => '测试', + ], + ]); + $connection->table('fin_account_todos')->insert([ + [ + 'account_short' => '弹窗工商1工行', + 'completion_status' => 'in_progress', + 'updated_by' => '测试', + ], + [ + 'account_short' => '弹窗建设建行', + 'completion_status' => 'completed', + 'updated_by' => '测试', + ], + ]); + + $html = $this->loginAs()->get($this->pageUrl([ + 'flows_company' => '弹窗测试公司', + 'flows_from' => '2026-10-01', + 'flows_to' => '2026-10-31', + ]))->assertOk()->getContent(); + + foreach ([ + 'data-ledger-flow-overview', + '资金概览(万元)', + '当前余额', + '待办处理进度', + 'data-ledger-progress-tab="unretained"', + 'data-ledger-progress-tab="unavailable"', + 'data-ledger-progress-panel="unretained"', + 'data-ledger-progress-panel="unavailable"', + "activateProgressTab(tab.dataset.ledgerProgressTab)", + 'data-ledger-current-total="11000.5"', + 'data-ledger-current-available="10600"', + 'data-ledger-current-blocked="400.5"', + 'data-ledger-unavailable-progress', + 'data-unavailable-total="2"', + 'data-unavailable-completed="1"', + 'data-unavailable-in-progress="1"', + 'data-unavailable-incomplete="0"', + 'data-unavailable-not-started="0"', + '已跟进 2 / 2', + '不保留账户', + 'data-unretained-total="2"', + 'data-unretained-completed="1"', + 'data-unretained-in-progress="1"', + 'data-unretained-not-started="0"', + '已完成 1 / 2', + '进行中 1', + '待开始 0', + '可用 1.06', + '不可用 0.04', + 'data-ledger-current-balance-chart-bar="工商银行"', + 'data-ledger-current-balance-chart-bar="建设银行"', + ] as $needle) { + $this->assertStringContainsString($needle, $html); + } + $this->assertStringNotContainsString('待处理明细', $html); + } + public function test_bank_view_uses_data_source_and_summary_adds_keep_column(): void { $this->loginAs()->get($this->pageUrl([