user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail(),
);
$connection = DB::connection('business_mirror');
foreach ([
[
'company_name' => '保留直连公司',
'account_short' => '保留直连工行',
'account_type' => '公户',
'bank_name' => '中国工商银行上海分行',
'account_no' => '100200300400',
'single_limit' => '50000',
'daily_limit' => '100000',
'monthly_limit' => '500000',
'yearly_limit' => '5000000',
'account_should_keep' => '是',
'current_balance' => 100000,
'daily_available' => 80000,
'blocked_amount' => 20000,
'owner' => '张三',
'remark' => '保留账户备注',
],
[
'company_name' => '保留手动公司',
'account_short' => '保留手动支付宝',
'account_type' => '支付宝',
'account_no' => 'alipay@example.com',
'alipay_merchant_no' => '20880001',
'alipay_account_kind' => '企业支付宝',
'account_should_keep' => '是',
'current_balance' => 50000,
'daily_available' => 50000,
'blocked_amount' => 0,
],
[
'company_name' => '不保留银行公司',
'account_short' => '不保留华夏',
'account_type' => '公户',
'bank_name' => '华夏银行常州分行',
'account_no' => '131500000001',
'account_should_keep' => '否',
'current_balance' => 30000,
'daily_available' => 30000,
'blocked_amount' => 0,
],
[
'company_name' => '不保留网商公司',
'account_short' => '不保留网商',
'account_type' => '网商银行',
'account_no' => 'wangshang@example.com',
'account_should_keep' => '否',
'current_balance' => 12000,
'daily_available' => 10000,
'blocked_amount' => 2000,
],
] as $account) {
$connection->table('fin_accounts')->insert($account);
}
$connection->table('fin_flow_summary_account_sources')->insert([
['account_short' => '保留直连工行', 'data_source' => '银企直连', 'updated_by' => '测试'],
['account_short' => '保留手动支付宝', 'data_source' => '手动', 'updated_by' => '测试'],
['account_short' => '不保留华夏', 'data_source' => '手动', 'updated_by' => '测试'],
['account_short' => '不保留网商', 'data_source' => '手动', 'updated_by' => '测试'],
]);
foreach ([
[
'account_short' => '不保留华夏',
'owner_name' => '财务甲乙',
'started_at' => '2026-11-16',
'completed_at' => '2026-11-17',
'current_progress' => 'completed',
'updated_by' => '测试',
],
[
'account_short' => '不保留网商',
'owner_name' => '财务丙',
'started_at' => '2026-11-17',
'current_progress' => 'in_progress',
'updated_by' => '测试',
],
] as $task) {
$connection->table('fin_account_keep_todos')->insert($task);
}
$connection->table('fin_daily_flows')->insert([
[
'flow_date' => '2026-10-31',
'account_short' => '保留直连工行',
'opening_balance' => 80000,
'inflow' => 10000,
'outflow' => 0,
'closing_balance' => 90000,
],
[
'flow_date' => '2026-11-01',
'account_short' => '保留直连工行',
'opening_balance' => 90000,
'inflow' => 20000,
'outflow' => 10000,
'closing_balance' => 100000,
],
]);
}
protected function tearDown(): void
{
Carbon::setTestNow();
parent::tearDown();
}
public function test_overview_separates_retained_and_unretained_accounts(): void
{
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
$this->assertStringContainsString('
账户总览
', $html);
$this->assertStringContainsString('保留账户资金总览', $html);
$this->assertStringContainsString('data-retained-open', $html);
$this->assertStringContainsString('data-unretained-open', $html);
$this->assertStringContainsString('data-unretained-dialog', $html);
$this->assertStringContainsString('data-unretained-distribution', $html);
$this->assertStringContainsString('保留账户', $html);
$this->assertStringContainsString('不保留账户', $html);
$this->assertStringContainsString('旧网银钱包', $html);
$this->assertStringContainsString('nsm-column-filter-panel', $html);
$this->assertStringContainsString('width: min(13rem, calc(100vw - 1rem))', $html);
$this->assertStringContainsString('width: min(17rem, calc(100vw - 1rem))', $html);
$this->assertStringContainsString('filterPanel.style.maxHeight', $html);
$this->assertStringContainsString('nsm-column-filter-panel.is-options-open', $html);
$this->assertStringContainsString('模糊搜索筛选项', $html);
$this->assertStringContainsString('data-nsm-filter-sort="asc"', $html);
$this->assertStringContainsString('data-nsm-filter-sort="desc"', $html);
$this->assertStringContainsString('查看处理进度清单', $html);
$this->assertStringContainsString('银企直连', $html);
$this->assertStringContainsString('非银企直连', $html);
$this->assertStringContainsString('15.00 万元', $html);
$this->assertStringContainsString('4.20 万元', $html);
$this->assertStringContainsString('当前总余额', $html);
$this->assertStringContainsString('15.00', $html);
$this->assertStringContainsString('可用金额', $html);
$this->assertStringContainsString('13.00', $html);
$this->assertStringContainsString('不可用金额', $html);
$this->assertStringContainsString('2.00', $html);
$this->assertStringContainsString('保留账户数', $html);
}
public function test_fund_overview_is_inside_retained_dialog_and_groups_by_platform(): void
{
DB::connection('business_mirror')->table('fin_accounts')->insert([
'company_name' => '保留网商公司',
'account_short' => '保留网商账户',
'account_type' => '网商银行',
'account_should_keep' => '是',
'current_balance' => 8000,
'daily_available' => 8000,
'blocked_amount' => 0,
]);
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
$this->assertStringNotContainsString('data-fund-overview-open', $html);
$this->assertStringNotContainsString('data-fund-distribution-dialog', $html);
$this->assertStringContainsString('data-retained-fund-overview', $html);
$this->assertStringContainsString('data-retained-fund-distribution', $html);
$this->assertStringContainsString('账户平台资金分布', $html);
$this->assertStringContainsString('余额占比', $html);
$this->assertStringContainsString('银行账户 | ', $html);
$this->assertStringContainsString('支付宝 | ', $html);
$this->assertStringContainsString('data-bank-drilldown-open', $html);
$this->assertStringContainsString('data-bank-drilldown', $html);
$this->assertStringContainsString('data-bank-count-menu', $html);
$this->assertStringContainsString('data-bank-mode="all"', $html);
$this->assertStringContainsString('data-bank-mode="direct"', $html);
$this->assertStringContainsString('data-bank-panel="all"', $html);
$this->assertStringContainsString('data-bank-panel="direct"', $html);
$this->assertStringContainsString('aria-controls="nsm-bank-drilldown"', $html);
$this->assertStringContainsString('aria-expanded="false"', $html);
$this->assertStringContainsString('data-connection-toggle="direct"', $html);
$this->assertStringContainsString('data-connection-panel="direct"', $html);
$this->assertStringContainsString('data-connection-toggle="non_direct"', $html);
$this->assertStringContainsString('data-connection-panel="non_direct"', $html);
$this->assertStringContainsString('data-connection-toggle="bank_category"', $html);
$this->assertStringContainsString('data-connection-panel="bank_category"', $html);
$this->assertStringContainsString('aria-controls="nsm-connection-panel-bank-category"', $html);
$this->assertStringContainsString('data-platform-account-open="alipay"', $html);
$this->assertStringContainsString('data-platform-account-detail="alipay"', $html);
$this->assertStringContainsString('data-platform-account-open="wangshang"', $html);
$this->assertStringContainsString('data-platform-account-detail="wangshang"', $html);
$retainedDialog = $this->dialogHtml($html, 'data-retained-dialog');
$unretainedDialog = $this->dialogHtml($html, 'data-unretained-dialog');
$this->assertStringNotContainsString('旧网银钱包 | ', $retainedDialog);
$this->assertStringNotContainsString('data-platform-account-open="legacy_wallet"', $retainedDialog);
$this->assertStringNotContainsString('data-platform-account-detail="legacy_wallet"', $retainedDialog);
$this->assertStringContainsString('旧网银钱包 | ', $unretainedDialog);
$this->assertStringContainsString('data-platform-account-open="legacy_wallet"', $unretainedDialog);
$this->assertStringContainsString('data-platform-account-detail="legacy_wallet"', $unretainedDialog);
$this->assertStringContainsString('data-account-archive-open', $html);
$this->assertStringContainsString('account_category=all', $html);
$this->assertStringContainsString('工商银行 | ', $html);
$this->assertStringNotContainsString('bank_group=%E5%8D%8E%E5%A4%8F%E9%93%B6%E8%A1%8C', $html);
}
public function test_independent_monthly_accounts_are_included_as_other_accounts(): void
{
$connection = DB::connection('business_mirror');
$connection->table('fin_accounts')->insert([
[
'company_name' => '朱俊祥',
'account_short' => '朱俊祥支付宝',
'account_type' => '支付宝',
'account_should_keep' => '是',
'current_balance' => 10000,
'daily_available' => 10000,
'blocked_amount' => 0,
],
[
'company_name' => '朱俊祥',
'account_short' => '朱俊祥微信',
'account_type' => null,
'account_should_keep' => '是',
'current_balance' => 20000,
'daily_available' => 20000,
'blocked_amount' => 0,
],
]);
$overviewHtml = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
$this->assertStringContainsString('其他账户 | ', $overviewHtml);
$this->assertStringContainsString('data-platform-account-open="other"', $overviewHtml);
$this->assertStringContainsString('data-platform-account-detail="other"', $overviewHtml);
$this->assertStringContainsString('aria-controls="nsm-other-drilldown"', $overviewHtml);
$this->assertStringContainsString('data-independent-account-open', $overviewHtml);
$this->assertStringContainsString('data-independent-account-view="zhu-junxiang-alipay"', $overviewHtml);
$this->assertStringContainsString('data-independent-account-view="zhu-junxiang-wechat"', $overviewHtml);
$this->assertStringContainsString('data-independent-account-frame', $overviewHtml);
$this->assertStringContainsString('ledger_embed=1', $overviewHtml);
$this->assertStringContainsString('朱俊祥支付宝', $overviewHtml);
$this->assertStringContainsString('朱俊祥微信', $overviewHtml);
$otherAccountsHtml = $this->loginAs()->get($this->pageUrl([
'view' => 'accounts',
'keep' => 'retained',
'account_category' => 'other',
]))->assertOk()->getContent();
$this->assertStringContainsString('朱俊祥支付宝', $otherAccountsHtml);
$this->assertStringContainsString('朱俊祥微信', $otherAccountsHtml);
$this->assertStringNotContainsString('保留手动支付宝', $otherAccountsHtml);
$embeddedHtml = $this->loginAs()->get(route('business.pages.show', [
'section' => 'financial-operations',
'page' => 'ledger',
]) . '?tab=transactions&txns_view=zhu-junxiang-alipay&ledger_embed=1')
->assertOk()
->getContent();
$this->assertStringContainsString('data-ledger-embed="1"', $embeddedHtml);
$this->assertStringContainsString('html[data-ledger-embed]', $embeddedHtml);
$this->assertStringContainsString('', $embeddedHtml);
$this->assertStringContainsString('txns_view=zhu-junxiang-alipay&ledger_embed=1', $embeddedHtml);
$this->assertStringContainsString('当前为“朱俊祥支付宝”独立账单页', $embeddedHtml);
}
public function test_legacy_wallet_accounts_are_always_unretained(): void
{
DB::connection('business_mirror')->table('fin_accounts')->insert([
'company_name' => '旧钱包公司',
'account_short' => '测试旧网银钱包',
'account_type' => '旧网银钱包',
'company_plan' => '保留',
'account_should_keep' => '是',
'current_balance' => 1234.56,
'daily_available' => 1234.56,
'blocked_amount' => 0,
]);
$overviewHtml = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
$retainedDialog = $this->dialogHtml($overviewHtml, 'data-retained-dialog');
$unretainedDialog = $this->dialogHtml($overviewHtml, 'data-unretained-dialog');
$this->assertStringNotContainsString('旧网银钱包', $retainedDialog);
$this->assertStringNotContainsString('测试旧网银钱包', $retainedDialog);
$this->assertStringContainsString('data-platform-account-open="legacy_wallet"', $unretainedDialog);
$this->assertStringContainsString('测试旧网银钱包', $unretainedDialog);
$retainedHtml = $this->loginAs()->get($this->pageUrl([
'view' => 'accounts',
'account_category' => 'all',
]))->assertOk()->getContent();
$this->assertStringNotContainsString('测试旧网银钱包', $retainedHtml);
$this->assertStringNotContainsString('value="legacy_wallet"', $retainedHtml);
$this->assertStringNotContainsString('account_category=legacy_wallet', $retainedHtml);
$unretainedHtml = $this->loginAs()->get($this->pageUrl([
'view' => 'unretained_tasks',
'task_category' => 'legacy_wallet',
]))->assertOk()->getContent();
$this->assertStringContainsString('测试旧网银钱包', $unretainedHtml);
}
public function test_account_view_switches_columns_with_account_type(): void
{
$alipayHtml = $this->loginAs()->get($this->pageUrl([
'view' => 'accounts',
'account_category' => 'alipay',
]))->assertOk()->getContent();
$this->assertStringContainsString('账户档案', $alipayHtml);
$this->assertStringContainsString('>支付宝账号', $alipayHtml);
$this->assertStringContainsString('>商户号', $alipayHtml);
$this->assertStringContainsString('保留手动支付宝', $alipayHtml);
$this->assertStringNotContainsString('不保留华夏', $alipayHtml);
$this->assertStringNotContainsString('>开户城市/网点', $alipayHtml);
$bankHtml = $this->loginAs()->get($this->pageUrl([
'view' => 'accounts',
'keep' => 'retained',
'direct' => 'direct',
'account_category' => 'bank',
'bank_group' => '工商银行',
]))->assertOk()->getContent();
$this->assertStringContainsString('>账号', $bankHtml);
$this->assertStringContainsString('>开户行', $bankHtml);
$this->assertStringContainsString('>开户城市/网点', $bankHtml);
$this->assertStringContainsString('>单笔限额', $bankHtml);
$this->assertStringContainsString('>日限额', $bankHtml);
$this->assertStringContainsString('>月限额', $bankHtml);
$this->assertStringContainsString('>年限额', $bankHtml);
$this->assertStringContainsString('>期初余额', $bankHtml);
$this->assertStringContainsString('>当期支出', $bankHtml);
$this->assertStringContainsString('>当期收入', $bankHtml);
$this->assertStringContainsString('>期末余额', $bankHtml);
$this->assertStringContainsString('>操作', $bankHtml);
$this->assertStringContainsString('展示全部', $bankHtml);
$this->assertStringContainsString('50,000.00', $bankHtml);
$this->assertStringContainsString('90,000.00', $bankHtml);
$this->assertStringContainsString('10,000.00', $bankHtml);
$this->assertStringContainsString('20,000.00', $bankHtml);
$this->assertStringContainsString('100,000.00', $bankHtml);
$this->assertStringContainsString('data-ledger-account-edit', $bankHtml);
$this->assertStringContainsString('保留直连工行', $bankHtml);
$this->assertStringContainsString('name="bank_group"', $bankHtml);
$this->assertStringContainsString('