fix: 将账户基本信息移入账户资金汇总 (#1141)

将账户基本信息卡片索引迁入账户资金汇总,并移除账户总表中的入口。
This commit is contained in:
shanshi 2026-11-12 19:09:54 +08:00
parent 951e553fae
commit 4c3d382633
5 changed files with 103 additions and 65 deletions

View File

@ -88,11 +88,11 @@ class FinanceLedgerPageData
$openingDate = (string) config('finance_ledger.opening_date', '2026-10-17');
$transactionView = $this->transactionView();
$requestedFlowView = trim((string) request('flows_view', 'summary'));
$flowView = in_array($requestedFlowView, ['summary', 'bank', 'non_store', 'wangshang', 'wallet', 'daily'], true)
$flowView = in_array($requestedFlowView, ['summary', 'bank', 'non_store', 'wangshang', 'wallet', 'daily', 'basic'], true)
? $requestedFlowView
: 'summary';
$requestedAccountView = trim((string) request('accounts_view', 'all'));
$accountView = in_array($requestedAccountView, ['all', 'basic', 'bank', 'non_store', 'wangshang', 'wallet', 'other'], true)
$accountView = in_array($requestedAccountView, ['all', 'bank', 'non_store', 'wangshang', 'wallet', 'other'], true)
? $requestedAccountView
: 'all';
$flowPeriod = $this->dateRange('flows');
@ -101,21 +101,16 @@ class FinanceLedgerPageData
$sourcePeriod = $this->dateRange('sources');
$accountDisplayLabels = $this->accountDisplayLabels();
$accounts = $accountView === 'basic'
? [
'rows' => collect(),
'summary' => [
'count' => 0,
'unretained' => 0,
'current_balance' => 0,
'balance' => 0,
'blocked' => 0,
],
]
: $this->accounts($accountView, $accountDisplayLabels);
$accounts = $this->accounts($accountView, $accountDisplayLabels);
$shops = $this->shops();
$availableBreakdown = $this->availableBreakdown($shops);
$flows = $this->flows($flowPeriod, $flowView, $accountDisplayLabels);
$flows = $flowView === 'basic'
? [
'rows' => collect(),
'summary' => ['count' => 0, 'opening' => 0, 'inflow' => 0, 'outflow' => 0, 'closing' => 0],
'custom_fields' => [],
]
: $this->flows($flowPeriod, $flowView, $accountDisplayLabels);
$transactions = $this->transactions($transactionView['account_short'], $transactionPeriod);
$transactionViewIsIndependent = (bool) ($transactionView['independent'] ?? false);
$transactionViewAccountExists = $transactionViewIsIndependent
@ -132,7 +127,7 @@ class FinanceLedgerPageData
'ledgerAccountView' => $accountView,
'ledgerAccounts' => $accounts['rows'],
'ledgerAccountSummary' => $accounts['summary'],
'ledgerAccountTypeCards' => $accountView === 'basic' ? $this->accountTypeCards() : [],
'ledgerAccountTypeCards' => $flowView === 'basic' ? $this->accountTypeCards() : [],
'ledgerShops' => $shops['rows'],
'ledgerShopSummary' => $shops['summary'],
'ledgerShopBalanceDate' => $shops['balance_date'] ?? null,

View File

@ -72,6 +72,8 @@
'accounts_filter_value',
'accounts_sort',
'accounts_direction',
'flows_view',
'txns_view',
])
->filter(static fn ($value): bool => is_scalar($value) || $value === null)
->all();
@ -92,7 +94,7 @@
$currentMonthEnd = now()->endOfMonth()->toDateString();
$flowPeriod = $ledgerFlowPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd];
$flowView = $ledgerFlowView ?? 'summary';
$flowUsesAccountSummary = $flowView !== 'daily';
$flowUsesAccountSummary = ! in_array($flowView, ['daily', 'basic'], true);
$flowSummaryCustomFields = $ledgerFlowSummaryCustomFields ?? [];
$transactionPeriod = $ledgerTransactionPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd];
$mappingPeriod = $ledgerMappingPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd];
@ -117,7 +119,15 @@
$transactionDateHeaderOptions = $ledgerTransactionDateHeaderOptions ?? [];
$optionMap = static fn (array $values): array => array_combine($values, $values) ?: [];
$flowViewQuery = collect(request()->query())
->except(['flows_page', 'flows_filter_column', 'flows_filter_value', 'flows_sort', 'flows_direction'])
->except([
'flows_page',
'flows_filter_column',
'flows_filter_value',
'flows_sort',
'flows_direction',
'accounts_view',
'txns_view',
])
->filter(static fn ($value): bool => is_scalar($value) || $value === null)
->all();
$flowViewUrl = static fn (string $view): string => $ledgerPageUrl . '?' . http_build_query(array_merge(
@ -125,14 +135,21 @@
['tab' => 'flows', 'flows_view' => $view],
));
$transactionViewQuery = collect(request()->query())
->except(['txns_page', 'txns_filter_column', 'txns_filter_value', 'txns_sort', 'txns_direction'])
->except([
'txns_page',
'txns_filter_column',
'txns_filter_value',
'txns_sort',
'txns_direction',
'accounts_view',
'flows_view',
])
->filter(static fn ($value): bool => is_scalar($value) || $value === null)
->all();
$transactionViewUrl = static fn (string $view): string => $ledgerPageUrl . '?' . http_build_query(array_merge(
$transactionViewQuery,
['tab' => 'transactions', 'txns_view' => $view],
));
$accountBasicViewUrl = $accountViewUrl('basic');
$flowSummaryEditDate = now()->toDateString();
if (($flowPeriod['to'] ?? null) !== null && $flowSummaryEditDate > $flowPeriod['to']) {
$flowSummaryEditDate = $flowPeriod['to'];
@ -705,34 +722,6 @@
{{-- 账户总表 --}}
<section class="ledger-panel" id="ledger-panel-accounts" role="tabpanel" data-ledger-panel="accounts" @if ($activeTab !== 'accounts') hidden @endif>
@if ($accountView === 'basic')
<div class="ledger-account-basic-home">
<header class="ledger-account-basic-home__header">
<div>
<h3>账户基本信息</h3>
<p>点击账户类型卡片查看对应账户资料;每种账户只展示自己需要的表头。</p>
</div>
<a class="ledger-btn" href="{{ $flowViewUrl('summary') }}"><span class="material-icons-outlined" aria-hidden="true">arrow_back</span>返回账户资金汇总</a>
</header>
<div class="ledger-account-type-grid">
@foreach ($ledgerAccountTypeCards as $card)
<a class="ledger-account-type-card" href="{{ $accountViewUrl($card['view']) }}" data-account-type-card="{{ $card['view'] }}">
<span class="ledger-account-type-card__icon material-icons-outlined" aria-hidden="true">{{ $card['icon'] }}</span>
<div class="ledger-account-type-card__title">
<strong>{{ $card['title'] }}</strong>
<span class="material-icons-outlined" aria-hidden="true">arrow_forward</span>
</div>
<p>{{ $card['description'] }}</p>
<dl>
<div><dt>账户数</dt><dd>{{ number_format((int) $card['count']) }}</dd></div>
<div><dt>可用金额</dt><dd>{{ $moneyWan($card['available']) }} 万</dd></div>
<div><dt>不可用金额</dt><dd>{{ $moneyWan($card['blocked']) }} 万</dd></div>
</dl>
</a>
@endforeach
</div>
</div>
@else
<form class="ledger-toolbar" method="GET" action="{{ $tabUrl('accounts') }}">
<input type="hidden" name="tab" value="accounts">
<input type="hidden" name="accounts_view" value="{{ $accountView }}">
@ -773,7 +762,6 @@
<a class="ledger-subtab {{ $accountView === 'wangshang' ? 'is-active' : '' }}" href="{{ $accountViewUrl('wangshang') }}" @if ($accountView === 'wangshang') aria-current="page" @endif>网商银行</a>
<a class="ledger-subtab {{ $accountView === 'wallet' ? 'is-active' : '' }}" href="{{ $accountViewUrl('wallet') }}" @if ($accountView === 'wallet') aria-current="page" @endif>网银账户</a>
<a class="ledger-subtab {{ $accountView === 'other' ? 'is-active' : '' }}" href="{{ $accountViewUrl('other') }}" @if ($accountView === 'other') aria-current="page" @endif>其他账户</a>
<a class="ledger-subtab" href="{{ $accountBasicViewUrl }}">账户基本信息</a>
</nav>
@if ($canEditAccounts)
<dialog class="ledger-company-dialog" data-ledger-company-dialog data-ledger-accounts-url="{{ $accountViewResetUrl }}" aria-labelledby="ledger-company-dialog-title">
@ -1086,7 +1074,6 @@
'paginationKey' => 'accounts',
'paginationLabel' => '账户总表分页',
])
@endif
</section>
{{-- 店铺台账 --}}
@ -1137,6 +1124,7 @@
{{-- 账户资金汇总 --}}
<section class="ledger-panel" id="ledger-panel-flows" role="tabpanel" data-ledger-panel="flows" @if ($activeTab !== 'flows') hidden @endif>
@if ($flowView !== 'basic')
<form class="ledger-toolbar" method="GET" action="{{ $tabUrl('flows') }}">
<input type="hidden" name="tab" value="flows">
<input type="hidden" name="flows_view" value="{{ $flowView }}">
@ -1152,14 +1140,13 @@
<div class="ledger-field"><label for="flows-account">账户简称</label><input id="flows-account" name="flows_account" list="ledger-account-list" value="{{ request('flows_account') }}" placeholder="输入或选择"></div>
<div class="ledger-actions"><button class="ledger-btn primary" type="submit"><span class="material-icons-outlined">search</span>查询</button><a class="ledger-btn" href="{{ $tabUrl('flows') }}"><span class="material-icons-outlined">refresh</span>重置</a></div>
</form>
@endif
@include('business.pages.financial-ledger.partials.account-home-tabs')
@if ($flowUsesAccountSummary && $canEditAccounts)
<span class="ledger-flow-grid-actions">
<button class="ledger-btn" type="button" title="新增一个账户汇总行" data-ledger-flow-summary-add-row data-return-url="{{ $flowViewUrl($flowView) }}"><span class="material-icons-outlined" aria-hidden="true">playlist_add</span>新增行</button>
<button class="ledger-btn" type="button" title="在账户资金汇总末尾新增一个自定义列" data-ledger-flow-summary-add-column><span class="material-icons-outlined" aria-hidden="true">view_column</span>新增列</button>
</span>
@endif
</nav>
@if ($flowView === 'basic')
@include('business.pages.financial-ledger.partials.account-type-cards', [
'accountTypeCardsBackUrl' => $flowViewUrl('summary'),
])
@else
<div class="ledger-summary">
<div class="ledger-summary__item"><span>{{ $flowView === 'daily' ? '流水条数' : '账户数' }}</span><b>{{ number_format((int) ($ledgerFlowSummary['count'] ?? 0)) }}</b></div>
<div class="ledger-summary__item"><span>期初余额合计(万元)</span><b title="所选期间开始时的期初余额合计:{{ $moneyYuanTitle($ledgerFlowSummary['opening'] ?? 0) }}">{{ $moneyWan($ledgerFlowSummary['opening'] ?? 0) }}</b></div>
@ -1259,6 +1246,7 @@
'paginationLabel' => $flowView === 'daily' ? '每日资金流水分页' : '账户资金汇总分页',
])
</div>
@endif
</section>
{{-- 动账明细 --}}

View File

@ -10,5 +10,11 @@
@endif
@endforeach
<a class="ledger-subtab {{ $activeTab === 'flows' && $flowView === 'daily' ? 'is-active' : '' }}" href="{{ $flowViewUrl('daily') }}" @if ($activeTab === 'flows' && $flowView === 'daily') aria-current="page" @endif>按日流水</a>
<a class="ledger-subtab" href="{{ $accountBasicViewUrl }}">账户基本信息</a>
<a class="ledger-subtab {{ $activeTab === 'flows' && $flowView === 'basic' ? 'is-active' : '' }}" href="{{ $flowViewUrl('basic') }}" @if ($activeTab === 'flows' && $flowView === 'basic') aria-current="page" @endif>账户基本信息</a>
@if ($activeTab === 'flows' && $flowUsesAccountSummary && $canEditAccounts)
<span class="ledger-flow-grid-actions">
<button class="ledger-btn" type="button" title="新增一个账户汇总行" data-ledger-flow-summary-add-row data-return-url="{{ $flowViewUrl($flowView) }}"><span class="material-icons-outlined" aria-hidden="true">playlist_add</span>新增行</button>
<button class="ledger-btn" type="button" title="在账户资金汇总末尾新增一个自定义列" data-ledger-flow-summary-add-column><span class="material-icons-outlined" aria-hidden="true">view_column</span>新增列</button>
</span>
@endif
</nav>

View File

@ -0,0 +1,26 @@
<div class="ledger-account-basic-home">
<header class="ledger-account-basic-home__header">
<div>
<h3>账户基本信息</h3>
<p>点击账户类型卡片查看对应账户资料;每种账户只展示自己需要的表头。</p>
</div>
<a class="ledger-btn" href="{{ $accountTypeCardsBackUrl }}"><span class="material-icons-outlined" aria-hidden="true">arrow_back</span>返回</a>
</header>
<div class="ledger-account-type-grid">
@foreach ($ledgerAccountTypeCards as $card)
<a class="ledger-account-type-card" href="{{ $accountViewUrl($card['view']) }}" data-account-type-card="{{ $card['view'] }}">
<span class="ledger-account-type-card__icon material-icons-outlined" aria-hidden="true">{{ $card['icon'] }}</span>
<div class="ledger-account-type-card__title">
<strong>{{ $card['title'] }}</strong>
<span class="material-icons-outlined" aria-hidden="true">arrow_forward</span>
</div>
<p>{{ $card['description'] }}</p>
<dl>
<div><dt>账户数</dt><dd>{{ number_format((int) $card['count']) }}</dd></div>
<div><dt>可用金额</dt><dd>{{ $moneyWan($card['available']) }} 万</dd></div>
<div><dt>不可用金额</dt><dd>{{ $moneyWan($card['blocked']) }} 万</dd></div>
</dl>
</a>
@endforeach
</div>
</div>

View File

@ -131,7 +131,8 @@ class FinanceLedgerNavigationTest extends FeatureTestCase
['账户汇总', '银行账户', '支付宝', '网商银行', '网银账户', '朱俊祥支付宝', '朱俊祥微信', '按日流水', '账户基本信息'],
array_map(static fn (string $label): string => trim(html_entity_decode(strip_tags($label))), $flowTabLabels[1] ?? [])
);
$this->assertStringContainsString('accounts_view=basic', $flowTabs[1]);
$this->assertStringContainsString('flows_view=basic', $flowTabs[1]);
$this->assertStringNotContainsString('账户基本信息', preg_match('/<nav class="ledger-subtabbar" aria-label="账户总表账户分类">(.*?)<\/nav>/s', $html, $accountTabs) ? $accountTabs[1] : '');
$this->assertStringNotContainsString('>全部账户</a>', $html);
}
@ -142,7 +143,7 @@ class FinanceLedgerNavigationTest extends FeatureTestCase
$html = $this->get(route('business.pages.show', [
'section' => 'financial-operations',
'page' => 'ledger',
]) . '?tab=accounts&accounts_view=basic')
]) . '?tab=flows&flows_view=basic')
->assertOk()
->assertSeeText('账户基本信息')
->assertSeeText('银行账户')
@ -154,12 +155,34 @@ class FinanceLedgerNavigationTest extends FeatureTestCase
->assertSee('data-account-type-card="non_store"', false)
->assertSee('data-account-type-card="wangshang"', false)
->assertSee('data-account-type-card="wallet"', false)
->assertSee('data-account-type-card="other"', false)
->assertDontSee('导出录入模板');
->assertSee('data-account-type-card="other"', false);
$this->assertStringContainsString('accounts_view=bank', $html->getContent());
$this->assertStringContainsString('accounts_view=wallet', $html->getContent());
$this->assertStringContainsString('accounts_view=other', $html->getContent());
$content = $html->getContent();
$accountsStart = strpos($content, 'id="ledger-panel-accounts"');
$shopsStart = strpos($content, 'id="ledger-panel-shops"', $accountsStart ?: 0);
$flowsStart = strpos($content, 'id="ledger-panel-flows"', $shopsStart ?: 0);
$transactionsStart = strpos($content, 'id="ledger-panel-transactions"', $flowsStart ?: 0);
$this->assertIsInt($accountsStart);
$this->assertIsInt($shopsStart);
$this->assertIsInt($flowsStart);
$this->assertIsInt($transactionsStart);
$this->assertStringNotContainsString(
'data-account-type-card=',
substr($content, $accountsStart, $shopsStart - $accountsStart),
);
$this->assertStringContainsString(
'data-account-type-card="bank"',
substr($content, $flowsStart, $transactionsStart - $flowsStart),
);
$this->assertMatchesRegularExpression(
'/aria-selected="true"[^>]*data-ledger-tab="flows"|data-ledger-tab="flows"[^>]*aria-selected="true"/',
$content,
);
$this->assertStringContainsString('accounts_view=bank', $content);
$this->assertStringContainsString('accounts_view=wallet', $content);
$this->assertStringContainsString('accounts_view=other', $content);
}
public function test_legacy_independent_company_reconciliation_permission_follows_the_renamed_page(): void