1662 lines
76 KiB
PHP
1662 lines
76 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature\Business;
|
||
|
||
use App\Models\Auth\Permission;
|
||
use Illuminate\Support\Carbon;
|
||
use Illuminate\Support\Facades\DB;
|
||
use Tests\Feature\FeatureTestCase;
|
||
|
||
class NonStoreAccountMonitorTest extends FeatureTestCase
|
||
{
|
||
protected function setUp(): void
|
||
{
|
||
parent::setUp();
|
||
Carbon::setTestNow('2026-11-17 10:30:00');
|
||
|
||
$this->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',
|
||
'company_plan' => '保留',
|
||
'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' => '企业支付宝',
|
||
'company_plan' => '保留',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 50000,
|
||
'daily_available' => 50000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '不保留银行公司',
|
||
'account_short' => '不保留华夏',
|
||
'account_type' => '公户',
|
||
'bank_name' => '华夏银行常州分行',
|
||
'account_no' => '131500000001',
|
||
'company_plan' => '不保留',
|
||
'account_should_keep' => '否',
|
||
'current_balance' => 30000,
|
||
'daily_available' => 30000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '不保留网商公司',
|
||
'account_short' => '不保留网商',
|
||
'account_type' => '网商银行',
|
||
'account_no' => 'wangshang@example.com',
|
||
'company_plan' => '不保留',
|
||
'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('<h2>账户总览</h2>', $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('.nsm-dialog.is-column-filter-open', $html);
|
||
$this->assertStringContainsString(
|
||
"mount.classList.add('is-column-filter-open');",
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString('const availableAbove = Math.max(0, rect.top - gap - margin);', $html);
|
||
$this->assertStringContainsString('const placeAbove = availableBelow < Math.min(preferredHeight, 220)', $html);
|
||
$this->assertStringContainsString('搜索全部账户的筛选项', $html);
|
||
$this->assertStringContainsString('data-nsm-filter-apply', $html);
|
||
$this->assertStringContainsString('data-nsm-filter-sort="asc"', $html);
|
||
$this->assertStringContainsString('data-nsm-filter-sort="desc"', $html);
|
||
$this->assertGreaterThanOrEqual(8, substr_count($html, 'data-detail-column-picker-toggle'));
|
||
$this->assertStringContainsString('data-detail-column-table', $html);
|
||
$this->assertStringContainsString(
|
||
'caiwu.non-store-accounts.detail.bank-inline.columns.v2',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
'caiwu.non-store-accounts.detail.nsm-alipay-drilldown.columns.v2',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString('data-detail-column="current_balance"', $html);
|
||
$this->assertStringContainsString('data-detail-column="balance_updated_at">余额更新时间</th>', $html);
|
||
$this->assertStringContainsString('const initializeDetailColumnPickers', $html);
|
||
$this->assertStringContainsString(
|
||
"const rows = bankInlineDetail.querySelectorAll('[data-bank-detail-row]');",
|
||
$html,
|
||
);
|
||
$this->assertStringNotContainsString(
|
||
"const bankInlineRows = root.querySelectorAll('[data-bank-detail-row]');",
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
"row.dataset.bankVisible = matchesBankFilter ? '1' : '0';",
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
"const matchesBankFilter = row.dataset.bankVisible !== '0';",
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
"table?.dispatchEvent(new CustomEvent('nsm-bank-filter-change'));",
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString('const hasServerColumns = headers.some(', $html);
|
||
$this->assertStringContainsString('if (!hasServerColumns) {', $html);
|
||
$this->assertStringContainsString(
|
||
'弹窗内明细已经包含全部行,筛选和排序后继续留在当前弹窗。',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString('查看处理进度清单', $html);
|
||
$this->assertStringContainsString('银企直连', $html);
|
||
$this->assertStringContainsString('非银企直连', $html);
|
||
$this->assertStringContainsString('15.00 万元', $html);
|
||
$this->assertStringContainsString('4.20 万元', $html);
|
||
$this->assertStringContainsString('<span>期末总余额</span>', $html);
|
||
$this->assertStringContainsString('<strong>15.00</strong>', $html);
|
||
$this->assertStringContainsString('<span>可用金额</span>', $html);
|
||
$this->assertStringContainsString('<strong>13.00</strong>', $html);
|
||
$this->assertStringContainsString('<span>不可用金额</span>', $html);
|
||
$this->assertStringContainsString('<strong>2.00</strong>', $html);
|
||
$this->assertStringContainsString('<span>保留账户数</span>', $html);
|
||
}
|
||
|
||
public function test_retained_dialog_amounts_follow_the_selected_period(): void
|
||
{
|
||
DB::connection('business_mirror')->table('fin_flow_summary_account_sources')
|
||
->where('account_short', '保留直连工行')
|
||
->update(['data_source' => '手动']);
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_account_opening')->insert([
|
||
'account_short' => '保留直连工行',
|
||
'opening_date' => '2026-10-17',
|
||
'opening_balance' => 80000,
|
||
]);
|
||
$connection->table('fin_transactions')->insert([
|
||
[
|
||
'txn_date' => '2026-10-31',
|
||
'account_short' => '保留直连工行',
|
||
'detail' => '保留账户十月收入',
|
||
'income' => 10000,
|
||
'expense' => 0,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'retained-period-october-income'),
|
||
'synced_at' => '2026-10-31 10:00:00',
|
||
'created_at' => '2026-10-31 10:00:00',
|
||
'updated_at' => '2026-10-31 10:00:00',
|
||
],
|
||
[
|
||
'txn_date' => '2026-11-01',
|
||
'account_short' => '保留直连工行',
|
||
'detail' => '保留账户十一月收入',
|
||
'income' => 20000,
|
||
'expense' => 0,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'retained-period-november-income'),
|
||
'synced_at' => '2026-11-01 10:00:00',
|
||
'created_at' => '2026-11-01 10:00:00',
|
||
'updated_at' => '2026-11-01 10:00:00',
|
||
],
|
||
[
|
||
'txn_date' => '2026-11-01',
|
||
'account_short' => '保留直连工行',
|
||
'detail' => '保留账户十一月支出',
|
||
'income' => 0,
|
||
'expense' => 10000,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'retained-period-november-expense'),
|
||
'synced_at' => '2026-11-01 10:00:00',
|
||
'created_at' => '2026-11-01 10:00:00',
|
||
'updated_at' => '2026-11-01 10:00:00',
|
||
],
|
||
]);
|
||
|
||
$response = $this->loginAs()->get($this->pageUrl([
|
||
'period_from' => '2026-10-01',
|
||
'period_to' => '2026-10-31',
|
||
'retained' => 1,
|
||
]))->assertOk();
|
||
|
||
$response->assertSee('data-retained-period-form', false);
|
||
$response->assertSee('data-retained-period-submit', false);
|
||
$response->assertSee('data-retained-period-status', false);
|
||
$response->assertSeeText('正在重新计算...');
|
||
$response->assertSeeText('查询时间段');
|
||
$response->assertSee('name="period_from" value="2026-10-01"', false);
|
||
$response->assertSee('name="period_to" value="2026-10-31"', false);
|
||
$response->assertSee('data-retained-period-from="2026-10-01"', false);
|
||
$response->assertSee('data-retained-period-to="2026-10-31"', false);
|
||
$response->assertSee('data-retained-period-total="140000"', false);
|
||
$response->assertSee('data-retained-period-available="120000"', false);
|
||
$response->assertSee('data-retained-period-blocked="20000"', false);
|
||
|
||
$this->loginAs()->get($this->pageUrl([
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
'retained' => 1,
|
||
]))
|
||
->assertOk()
|
||
->assertSee('data-retained-period-total="150000"', false)
|
||
->assertSee('data-retained-period-available="130000"', false)
|
||
->assertSee('data-retained-period-blocked="20000"', false);
|
||
}
|
||
|
||
public function test_direct_account_income_expense_and_balance_follow_bank_bills(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '招行账单测试公司',
|
||
'account_short' => '招行账单测试',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行常州分行',
|
||
'account_no' => '5199050000000099',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 999,
|
||
'daily_available' => 999,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_bank_direct_bills')->insert([
|
||
[
|
||
'bank_name' => '招商银行',
|
||
'company_name' => '招行账单测试公司',
|
||
'account_short' => '招行账单测试',
|
||
'account_no' => '5199050000000099',
|
||
'txn_date' => '2026-10-31',
|
||
'txn_at' => '2026-10-31 18:00:00',
|
||
'record_code' => 'BILL-OPEN',
|
||
'income' => 0,
|
||
'expense' => 0,
|
||
'balance' => 100000,
|
||
'imported_at' => null,
|
||
'row_key' => hash('sha256', 'bill-open'),
|
||
],
|
||
[
|
||
'bank_name' => '招商银行',
|
||
'company_name' => '招行账单测试公司',
|
||
'account_short' => '招行账单测试',
|
||
'account_no' => '5199050000000099',
|
||
'txn_date' => '2026-11-02',
|
||
'txn_at' => '2026-11-02 09:00:00',
|
||
'record_code' => 'BILL-IN',
|
||
'income' => 50000,
|
||
'expense' => 0,
|
||
'balance' => 150000,
|
||
'imported_at' => null,
|
||
'row_key' => hash('sha256', 'bill-in'),
|
||
],
|
||
[
|
||
'bank_name' => '招商银行',
|
||
'company_name' => '招行账单测试公司',
|
||
'account_short' => '招行账单测试',
|
||
'account_no' => '5199050000000099',
|
||
'txn_date' => '2026-11-03',
|
||
'txn_at' => '2026-11-03 10:00:00',
|
||
'record_code' => 'BILL-OUT',
|
||
'income' => 0,
|
||
'expense' => 20000,
|
||
'balance' => 130000,
|
||
'imported_at' => '2026-11-03 11:45:00',
|
||
'row_key' => hash('sha256', 'bill-out'),
|
||
],
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
'flow_date' => '2026-11-02',
|
||
'account_short' => '招行账单测试',
|
||
'opening_balance' => 1,
|
||
'inflow' => 999999,
|
||
'outflow' => 0,
|
||
'closing_balance' => 1000999,
|
||
]);
|
||
$connection->table('fin_transactions')->insert([
|
||
'row_key' => hash('sha256', 'direct-account-ignored-transaction'),
|
||
'txn_date' => '2026-11-03',
|
||
'account_short' => '招行账单测试',
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'income' => 888888,
|
||
'expense' => 0,
|
||
]);
|
||
|
||
$response = $this->loginAs()->get($this->pageUrl([
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
'retained' => 1,
|
||
]))->assertOk();
|
||
|
||
$response->assertSee('data-retained-period-total="280000"', false);
|
||
$response->assertSee('data-retained-period-available="260000"', false);
|
||
$response->assertSeeText('招行账单测试');
|
||
$response->assertSeeText('130,000.00');
|
||
$response->assertSeeText('余额更新时间');
|
||
$response->assertSeeText('2026-11-03 11:45');
|
||
|
||
$accountHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'account_category' => 'bank',
|
||
'account_search' => '招行账单测试',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('招行账单测试', $accountHtml);
|
||
$this->assertStringContainsString('余额更新时间', $accountHtml);
|
||
$this->assertStringContainsString('2026-11-03 11:45', $accountHtml);
|
||
$this->assertMatchesRegularExpression(
|
||
'/招行账单测试.*?20,000\.00.*?50,000\.00.*?130,000\.00/s',
|
||
$accountHtml,
|
||
);
|
||
}
|
||
|
||
public function test_locked_monthly_opening_does_not_follow_previous_daily_flow(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '期初锁定公司',
|
||
'account_short' => '期初锁定账户',
|
||
'account_type' => '公户',
|
||
'bank_name' => '中国银行常州分行',
|
||
'account_no' => '6200000000000001',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 312.44,
|
||
'daily_available' => 312.44,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_account_opening')->insert([
|
||
'account_short' => '期初锁定账户',
|
||
'opening_date' => '2026-11-01',
|
||
'opening_balance' => 412.44,
|
||
'remark' => '系统锁定:2026-10-31 最后一笔实际余额',
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
[
|
||
'flow_date' => '2026-10-31',
|
||
'company_name' => '期初锁定公司',
|
||
'account_short' => '期初锁定账户',
|
||
'opening_balance' => -99999,
|
||
'inflow' => 0,
|
||
'outflow' => 0,
|
||
'closing_balance' => -99999,
|
||
],
|
||
[
|
||
'flow_date' => '2026-11-02',
|
||
'company_name' => '期初锁定公司',
|
||
'account_short' => '期初锁定账户',
|
||
'opening_balance' => 412.44,
|
||
'inflow' => 0,
|
||
'outflow' => 100,
|
||
'closing_balance' => 312.44,
|
||
],
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'account_category' => 'bank',
|
||
'account_search' => '期初锁定账户',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('期初锁定账户', $html);
|
||
$this->assertStringContainsString('412.44', $html);
|
||
$this->assertStringNotContainsString('-99,999.00', $html);
|
||
}
|
||
|
||
public function test_missing_monthly_opening_is_not_calculated_from_zero(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '缺失期初公司',
|
||
'account_short' => '缺失期初工行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '工商银行',
|
||
'account_no' => '6222000099990001',
|
||
'company_plan' => '保留',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 0,
|
||
'daily_available' => 0,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '缺失期初工行',
|
||
'data_source' => '手动',
|
||
'updated_by' => '测试',
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
'flow_date' => '2026-11-10',
|
||
'company_name' => '缺失期初公司',
|
||
'account_short' => '缺失期初工行',
|
||
'opening_balance' => 0,
|
||
'inflow' => 98765.43,
|
||
'outflow' => 0,
|
||
'closing_balance' => 98765.43,
|
||
]);
|
||
$connection->table('fin_transactions')->insert([
|
||
'txn_date' => '2026-11-10',
|
||
'account_short' => '缺失期初工行',
|
||
'detail' => '无期初收入',
|
||
'income' => 98765.43,
|
||
'expense' => 0,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'missing-monthly-opening-income'),
|
||
'synced_at' => '2026-11-10 10:00:00',
|
||
'created_at' => '2026-11-10 10:00:00',
|
||
'updated_at' => '2026-11-10 10:00:00',
|
||
]);
|
||
|
||
$this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_search' => '缺失期初工行',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk();
|
||
|
||
request()->merge([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_search' => '缺失期初工行',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]);
|
||
$page = app(\Modules\EcommerceFinance\View\NonStoreAccountMonitorPageData::class)->page();
|
||
$row = collect($page['fundOverview']['bank_accounts'])
|
||
->firstWhere('account_short', '缺失期初工行');
|
||
|
||
$this->assertNotNull($row);
|
||
$this->assertNull($row['opening_balance']);
|
||
$this->assertNull($row['closing_balance']);
|
||
$this->assertNull($row['current_balance']);
|
||
$this->assertSame('missing_opening', $row['balance_source']);
|
||
$this->assertFalse($row['monthly_opening_locked']);
|
||
}
|
||
|
||
public function test_wangshang_account_balance_uses_bank_bills_instead_of_transaction_flows(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '网商余额同步公司',
|
||
'account_short' => '网商余额同步测试',
|
||
'account_type' => '网商银行',
|
||
'bank_name' => '浙江网商银行',
|
||
'account_no' => '8888888000000999',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 1234,
|
||
'daily_available' => 1234,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_bank_direct_bills')->insert([
|
||
[
|
||
'bank_name' => '网商银行',
|
||
'company_name' => '网商余额同步公司',
|
||
'account_short' => '网商余额同步测试',
|
||
'account_no' => '8888888000000999',
|
||
'txn_date' => '2026-11-02',
|
||
'txn_at' => '2026-11-02 09:00:00',
|
||
'record_code' => 'WS-BALANCE-1',
|
||
'income' => 200,
|
||
'expense' => 0,
|
||
'balance' => 200,
|
||
'imported_at' => null,
|
||
'row_key' => hash('sha256', 'ws-balance-1'),
|
||
],
|
||
[
|
||
'bank_name' => '网商银行',
|
||
'company_name' => '网商余额同步公司',
|
||
'account_short' => '网商余额同步测试',
|
||
'account_no' => '8888888000000999',
|
||
'txn_date' => '2026-11-03',
|
||
'txn_at' => '2026-11-03 09:00:00',
|
||
'record_code' => 'WS-BALANCE-2',
|
||
'income' => 100,
|
||
'expense' => 0,
|
||
'balance' => 300,
|
||
'imported_at' => '2026-11-03 10:28:00',
|
||
'row_key' => hash('sha256', 'ws-balance-2'),
|
||
],
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
'flow_date' => '2026-11-03',
|
||
'account_short' => '网商余额同步测试',
|
||
'opening_balance' => 999000,
|
||
'inflow' => 999,
|
||
'outflow' => 0,
|
||
'closing_balance' => 999999,
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'wangshang',
|
||
'account_search' => '网商余额同步测试',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('网商余额同步测试', $html);
|
||
$this->assertStringContainsString('300.00', $html);
|
||
$this->assertStringContainsString('余额更新时间', $html);
|
||
$this->assertStringContainsString('2026-11-03 10:28', $html);
|
||
$this->assertStringNotContainsString('999,999.00', $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('<td>银行账户</td>', $html);
|
||
$this->assertStringContainsString('<td>支付宝</td>', $html);
|
||
$this->assertStringContainsString('data-bank-drilldown-open', $html);
|
||
$this->assertStringContainsString('data-bank-drilldown', $html);
|
||
$this->assertStringNotContainsString('data-bank-count-menu', $html);
|
||
$this->assertStringContainsString('data-bank-mode="matrix"', $html);
|
||
$this->assertStringContainsString('data-bank-panel="matrix"', $html);
|
||
$this->assertStringContainsString('aria-controls="nsm-bank-drilldown"', $html);
|
||
$this->assertStringContainsString('aria-expanded="false"', $html);
|
||
$this->assertStringContainsString('data-connection-toggle="bank_matrix"', $html);
|
||
$this->assertStringContainsString('data-connection-panel="bank_matrix"', $html);
|
||
$this->assertStringContainsString('aria-controls="nsm-connection-panel-bank-matrix"', $html);
|
||
$this->assertStringContainsString('data-bank-connection-matrix', $html);
|
||
$this->assertStringContainsString('data-bank-inline-detail', $html);
|
||
$this->assertStringContainsString('data-bank-inline-close', $html);
|
||
$this->assertStringContainsString('data-bank-detail-open', $html);
|
||
$this->assertStringContainsString('data-bank-detail-row', $html);
|
||
$this->assertStringContainsString('<th scope="col">银行类型</th>', $html);
|
||
$this->assertStringContainsString('<th scope="col" class="num">银企直连</th>', $html);
|
||
$this->assertStringContainsString('<th scope="col" class="num">非银企直连</th>', $html);
|
||
$this->assertStringContainsString('<th scope="col" class="num">账户合计</th>', $html);
|
||
$this->assertStringContainsString('<th scope="col" class="num">当前余额</th>', $html);
|
||
$this->assertStringContainsString('个人卡不计入银企直连', $html);
|
||
$this->assertStringContainsString('direct=direct', $html);
|
||
$this->assertStringContainsString('direct=non_direct', $html);
|
||
$this->assertStringContainsString('showBankInlineDetail', $html);
|
||
$this->assertStringContainsString('bankMatrixSummary.hidden = true', $html);
|
||
$this->assertStringContainsString('bankInlineDetail.hidden = false', $html);
|
||
$this->assertStringContainsString("row.dataset.accountType !== '个人卡'", $html);
|
||
$this->assertStringContainsString('收起明细', $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('<td>旧网银钱包</td>', $retainedDialog);
|
||
$this->assertStringNotContainsString('data-platform-account-open="legacy_wallet"', $retainedDialog);
|
||
$this->assertStringNotContainsString('data-platform-account-detail="legacy_wallet"', $retainedDialog);
|
||
$this->assertStringContainsString('<td>旧网银钱包</td>', $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('data-bank-plan-bank="工商银行"', $html);
|
||
$this->assertStringNotContainsString('bank_group=%E5%8D%8E%E5%A4%8F%E9%93%B6%E8%A1%8C', $html);
|
||
}
|
||
|
||
public function test_bank_matrix_uses_requested_summary_columns_and_keeps_personal_cards_non_direct(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
[
|
||
'company_name' => '招商直连公司',
|
||
'account_short' => '保留招商直连公户',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行上海分行',
|
||
'account_no' => '310000000101',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 20000,
|
||
'daily_available' => 20000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '华夏个人卡公司',
|
||
'account_short' => '保留华夏个人卡',
|
||
'account_type' => '个人卡',
|
||
'bank_name' => '华夏银行常州分行',
|
||
'account_no' => '310000000102',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 3000,
|
||
'daily_available' => 3000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '华夏非直连公司',
|
||
'account_short' => '保留华夏非直连公户',
|
||
'account_type' => '公户',
|
||
'bank_name' => '华夏银行上海分行',
|
||
'account_no' => '310000000104',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 4000,
|
||
'daily_available' => 4000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '农业非直连公司',
|
||
'account_short' => '保留农业非直连',
|
||
'account_type' => '公户',
|
||
'bank_name' => '农业银行上海分行',
|
||
'account_no' => '310000000103',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 5000,
|
||
'daily_available' => 5000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
]);
|
||
$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' => '测试'],
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
|
||
$this->assertSame(1, preg_match(
|
||
'/<table\b[^>]*\bdata-bank-connection-matrix\b[^>]*>(.*?)<\/table>/s',
|
||
$html,
|
||
$matrixMatch,
|
||
));
|
||
$matrix = $matrixMatch[1];
|
||
|
||
$this->assertStringNotContainsString('data-bank-group="direct"', $matrix);
|
||
$this->assertStringNotContainsString('data-bank-group="non_direct"', $matrix);
|
||
$this->assertStringNotContainsString('银企直连银行', $matrix);
|
||
$this->assertStringNotContainsString('非银企直连银行', $matrix);
|
||
$this->assertStringContainsString('data-bank-name="华夏银行"', $html);
|
||
$this->assertStringContainsString('data-bank-connection="non_direct"', $html);
|
||
$this->assertStringContainsString('data-bank-detail-scope="personal_card"', $html);
|
||
$this->assertStringContainsString('data-account-type="个人卡"', $html);
|
||
$this->assertLessThan(strpos($matrix, '华夏银行'), strpos($matrix, '工商银行'));
|
||
$this->assertLessThan(strpos($matrix, '农业银行'), strpos($matrix, '招商银行'));
|
||
$this->assertLessThan(strpos($matrix, '个人卡'), strpos($matrix, '农业银行'));
|
||
$this->assertMatchesRegularExpression(
|
||
'/<tr data-bank-row="non_direct">\s*<td>\s*<button\b[^>]*>\s*华夏银行\s*<\/button>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*0\s*<\/a>\s*<\/td>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*1\s*<\/a>\s*<\/td>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*1\s*<\/a>/s',
|
||
$matrix,
|
||
);
|
||
$this->assertMatchesRegularExpression(
|
||
'/<tr data-bank-row="non_direct">\s*<td>\s*<button\b[^>]*>\s*个人卡\s*<\/button>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*0\s*<\/a>\s*<\/td>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*1\s*<\/a>\s*<\/td>.*?'
|
||
. '<td class="num">\s*<a\b[^>]*>\s*1\s*<\/a>/s',
|
||
$matrix,
|
||
);
|
||
$this->assertMatchesRegularExpression(
|
||
'/<tr data-bank-row="direct">\s*<td>\s*<button\b[^>]*>\s*招商银行\s*<\/button>\s*'
|
||
. '<span class="nsm-connection-badge">已直连<\/span>/s',
|
||
$matrix,
|
||
);
|
||
}
|
||
|
||
public function test_bank_name_inline_summary_splits_retained_accounts_by_company_plan(): void
|
||
{
|
||
DB::connection('business_mirror')->table('fin_accounts')->insert([
|
||
[
|
||
'company_name' => '招商规划保留公司',
|
||
'account_short' => '招商规划保留',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行上海分行',
|
||
'account_no' => '310000000201',
|
||
'company_plan' => '保留',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 11000,
|
||
'daily_available' => 11000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '招商规划不保留公司',
|
||
'account_short' => '招商规划不保留',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行上海分行',
|
||
'account_no' => '310000000202',
|
||
'company_plan' => '不保留',
|
||
'account_should_keep' => '暂时保留',
|
||
'current_balance' => 22000,
|
||
'daily_available' => 22000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
[
|
||
'company_name' => '招商规划未填写公司',
|
||
'account_short' => '招商规划未填写',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行上海分行',
|
||
'account_no' => '310000000203',
|
||
'company_plan' => null,
|
||
'account_should_keep' => '暂时保留',
|
||
'current_balance' => 33000,
|
||
'daily_available' => 33000,
|
||
'blocked_amount' => 0,
|
||
],
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('data-bank-plan-open', $html);
|
||
$this->assertStringContainsString('data-bank-plan-bank="招商银行"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-retained-count="1"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-retained-amount="11000.00"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-unretained-count="1"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-unretained-amount="22000.00"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-unspecified-count="1"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-unspecified-amount="33000.00"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-total-count="3"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-total-amount="66000.00"', $html);
|
||
$this->assertStringContainsString('data-bank-plan-detail', $html);
|
||
$this->assertStringContainsString('class="nsm-bank-plan-inline-row"', $html);
|
||
$this->assertStringContainsString('aria-controls="nsm-bank-plan-', $html);
|
||
$this->assertStringContainsString('公司规划保留', $html);
|
||
$this->assertStringContainsString('公司规划不保留', $html);
|
||
$this->assertStringContainsString('data-bank-plan-unspecified', $html);
|
||
$this->assertStringContainsString('toggleBankPlanDetail', $html);
|
||
$this->assertStringContainsString('hideBankPlanDetails', $html);
|
||
$this->assertStringNotContainsString('data-bank-plan-dialog', $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('<td>其他账户</td>', $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' => 'fund-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('<input type="hidden" name="ledger_embed" value="1">', $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('>支付宝账号</th>', $alipayHtml);
|
||
$this->assertStringContainsString('>商户号</th>', $alipayHtml);
|
||
$this->assertStringContainsString('保留手动支付宝', $alipayHtml);
|
||
$this->assertStringNotContainsString('不保留华夏', $alipayHtml);
|
||
$this->assertStringNotContainsString('>开户城市/网点</th>', $alipayHtml);
|
||
|
||
$bankHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'direct' => 'direct',
|
||
'account_category' => 'bank',
|
||
'bank_group' => '工商银行',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('>账号</th>', $bankHtml);
|
||
$this->assertStringContainsString('>开户行</th>', $bankHtml);
|
||
$this->assertStringContainsString('>开户城市/网点</th>', $bankHtml);
|
||
$this->assertStringContainsString('>公司规划</th>', $bankHtml);
|
||
$this->assertStringContainsString('>单笔限额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>日限额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>月限额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>年限额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>期初余额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>当期支出</th>', $bankHtml);
|
||
$this->assertStringContainsString('>当期收入</th>', $bankHtml);
|
||
$this->assertStringContainsString('>期末余额</th>', $bankHtml);
|
||
$this->assertStringContainsString('>操作</th>', $bankHtml);
|
||
$this->assertStringContainsString('展示全部', $bankHtml);
|
||
$this->assertStringContainsString('50,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('<option value="工商银行" selected>', $bankHtml);
|
||
$this->assertStringNotContainsString('保留手动支付宝', $bankHtml);
|
||
$this->assertStringContainsString('data-column-storage-key="caiwu.non-store-accounts.columns.', $bankHtml);
|
||
}
|
||
|
||
public function test_company_plan_columns_are_available_on_every_account_tab(): void
|
||
{
|
||
foreach (['all', 'bank', 'alipay', 'wangshang', 'other'] as $category) {
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'account_category' => $category,
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('data-column="company_plan"', $html);
|
||
$this->assertStringContainsString('>公司规划</th>', $html);
|
||
$this->assertStringContainsString('data-column="keep_label"', $html);
|
||
$this->assertStringContainsString('>是否保留</th>', $html);
|
||
}
|
||
}
|
||
|
||
public function test_account_archive_contains_retained_and_temporarily_retained_accounts(): void
|
||
{
|
||
DB::connection('business_mirror')->table('fin_accounts')->insert([
|
||
'company_name' => '暂时保留测试公司',
|
||
'account_short' => '暂时保留华夏',
|
||
'account_type' => '公户',
|
||
'bank_name' => '华夏银行常州分行',
|
||
'account_no' => '131500000099',
|
||
'company_plan' => '不保留',
|
||
'account_should_keep' => '暂时保留',
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'all',
|
||
'account_category' => 'all',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('保留直连工行', $html);
|
||
$this->assertStringContainsString('保留手动支付宝', $html);
|
||
$this->assertStringContainsString('暂时保留华夏', $html);
|
||
$this->assertStringNotContainsString('不保留华夏', $html);
|
||
$this->assertStringNotContainsString('不保留网商', $html);
|
||
$this->assertStringContainsString('>公司规划</th>', $html);
|
||
$this->assertMatchesRegularExpression(
|
||
'/<td[^>]*data-column="company_plan"[^>]*>.*?<span[^>]*>保留<\/span>.*?<\/td>/s',
|
||
$html,
|
||
);
|
||
$this->assertMatchesRegularExpression(
|
||
'/<td[^>]*data-column="company_plan"[^>]*>.*?<span[^>]*>不保留<\/span>.*?<\/td>/s',
|
||
$html,
|
||
);
|
||
$this->assertMatchesRegularExpression(
|
||
'/<td[^>]*data-column="keep_label"[^>]*>.*?<span[^>]*>暂时保留<\/span>.*?<\/td>/s',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString('data-ledger-add-company', $html);
|
||
$this->assertStringContainsString('新增公司/账户', $html);
|
||
$this->assertMatchesRegularExpression('/重置.*data-ledger-add-company/s', $html);
|
||
$this->assertSame(1, preg_match(
|
||
'/<button\b[^>]*\bdata-ledger-add-company\b[^>]*>/s',
|
||
$html,
|
||
$addCompanyButton,
|
||
));
|
||
$this->assertStringNotContainsString('data-return-url=', $addCompanyButton[0]);
|
||
$this->assertSame(1, preg_match(
|
||
'/<section class="nsm-page-head">.*?<\/section>/s',
|
||
$html,
|
||
$pageHead,
|
||
));
|
||
$this->assertStringNotContainsString('data-ledger-add-company', $pageHead[0]);
|
||
$this->assertStringNotContainsString('name="keep"', $html);
|
||
}
|
||
|
||
public function test_account_column_filters_apply_before_pagination_across_all_retained_accounts(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
for ($index = 1; $index <= 110; $index++) {
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => sprintf('分页占位公司%03d', $index),
|
||
'account_short' => sprintf('分页占位工行%03d', $index),
|
||
'account_type' => '公户',
|
||
'bank_name' => '中国工商银行上海分行',
|
||
'account_no' => sprintf('900000%06d', $index),
|
||
'account_should_keep' => '是',
|
||
'current_balance' => $index,
|
||
'daily_available' => $index,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
}
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '跨页目标公司甲',
|
||
'account_short' => '彰崚中行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '中国银行常州崔桥支行',
|
||
'account_no' => '491045005185',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 1,
|
||
'daily_available' => 1,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
'flow_date' => '2026-11-01',
|
||
'account_short' => '彰崚中行',
|
||
'opening_balance' => 123456.78,
|
||
'inflow' => 0,
|
||
'outflow' => 0,
|
||
'closing_balance' => 123456.78,
|
||
]);
|
||
$connection->table('fin_account_opening')->insert([
|
||
'account_short' => '彰崚中行',
|
||
'opening_date' => '2026-11-01',
|
||
'opening_balance' => 123456.78,
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_column_filters' => json_encode([
|
||
'account_display_short' => ['彰崚中行'],
|
||
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR),
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('跨页目标公司甲', $html);
|
||
$this->assertStringContainsString('彰崚中行', $html);
|
||
$this->assertSame(1, preg_match(
|
||
'/<table\b[^>]*\bdata-account-table\b[^>]*>.*?<\/table>/s',
|
||
$html,
|
||
$tableMatch,
|
||
));
|
||
$this->assertStringNotContainsString('分页占位公司001', $tableMatch[0]);
|
||
$this->assertStringContainsString('全部账户 · 已选', $html);
|
||
$this->assertStringContainsString('data-nsm-filter-key="account_display_short"', $html);
|
||
$this->assertStringContainsString(
|
||
'const matchingValues = activeFilter.values.filter(',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
'activeFilter.selection = new Set(matchingValues);',
|
||
$html,
|
||
);
|
||
$this->assertStringContainsString(
|
||
'if (event.isComposing || event.keyCode === 229) return;',
|
||
$html,
|
||
);
|
||
$this->assertSame(1, preg_match(
|
||
'/const serverColumnFilterValues = (.*?);\s*const serverColumnFilters/s',
|
||
$html,
|
||
$filterValuesMatch,
|
||
));
|
||
$serverFilterValues = json_decode($filterValuesMatch[1], true, 512, JSON_THROW_ON_ERROR);
|
||
$this->assertContains('彰崚中行', $serverFilterValues['account_display_short']);
|
||
$this->assertContains('分页占位工行001', $serverFilterValues['account_display_short']);
|
||
|
||
$balanceFilteredHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_column_filters' => json_encode([
|
||
'opening_balance' => ['123,456.78'],
|
||
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR),
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('跨页目标公司甲', $balanceFilteredHtml);
|
||
$this->assertSame(1, preg_match(
|
||
'/<table\b[^>]*\bdata-account-table\b[^>]*>.*?<\/table>/s',
|
||
$balanceFilteredHtml,
|
||
$balanceTableMatch,
|
||
));
|
||
$this->assertStringNotContainsString('分页占位公司001', $balanceTableMatch[0]);
|
||
}
|
||
|
||
public function test_non_direct_account_archive_rolls_period_closing_from_opening_income_and_expense(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_flow_summary_account_sources')
|
||
->where('account_short', '保留直连工行')
|
||
->update(['data_source' => '手动']);
|
||
$connection->table('fin_daily_flows')
|
||
->where('account_short', '保留直连工行')
|
||
->where('flow_date', '2026-11-01')
|
||
->update(['closing_balance' => 999999]);
|
||
$connection->table('fin_account_opening')->insert([
|
||
'account_short' => '保留直连工行',
|
||
'opening_date' => '2026-11-01',
|
||
'opening_balance' => 90000,
|
||
]);
|
||
$connection->table('fin_daily_flows')->insert([
|
||
'flow_date' => '2026-11-02',
|
||
'account_short' => '保留直连工行',
|
||
'opening_balance' => 555555,
|
||
'inflow' => 0,
|
||
'outflow' => 5000,
|
||
'closing_balance' => 888888,
|
||
]);
|
||
|
||
$twoDayHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-02',
|
||
]))->assertOk()->getContent();
|
||
$this->assertStringContainsString('90,000.00', $twoDayHtml);
|
||
$this->assertStringContainsString('15,000.00', $twoDayHtml);
|
||
$this->assertStringContainsString('20,000.00', $twoDayHtml);
|
||
$this->assertStringContainsString('95,000.00', $twoDayHtml);
|
||
|
||
$firstDayHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-01',
|
||
]))->assertOk()->getContent();
|
||
$this->assertStringContainsString('100,000.00', $firstDayHtml);
|
||
$this->assertStringNotContainsString('95,000.00', $firstDayHtml);
|
||
}
|
||
|
||
public function test_retained_non_direct_bank_current_balance_rolls_from_transactions_not_bank_balance_adjustment(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '总览独立滚动公司',
|
||
'account_short' => '总览独立滚动工行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '工商银行',
|
||
'account_no' => '6222000077770001',
|
||
'company_plan' => '保留',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 999,
|
||
'daily_available' => 999,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '总览独立滚动工行',
|
||
'data_source' => '手动',
|
||
'updated_by' => '测试',
|
||
]);
|
||
$connection->table('fin_account_opening')->insert([
|
||
'account_short' => '总览独立滚动工行',
|
||
'opening_date' => '2026-10-17',
|
||
'opening_balance' => 100,
|
||
]);
|
||
$connection->table('fin_transactions')->insert([
|
||
[
|
||
'txn_date' => '2026-11-10',
|
||
'account_short' => '总览独立滚动工行',
|
||
'detail' => '总览收入',
|
||
'income' => 20,
|
||
'expense' => 0,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'overview-non-direct-income'),
|
||
'synced_at' => '2026-11-10 10:00:00',
|
||
'created_at' => '2026-11-10 10:00:00',
|
||
'updated_at' => '2026-11-10 10:00:00',
|
||
],
|
||
[
|
||
'txn_date' => '2026-11-11',
|
||
'account_short' => '总览独立滚动工行',
|
||
'detail' => '总览支出',
|
||
'income' => 0,
|
||
'expense' => 5,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'row_key' => hash('sha256', 'overview-non-direct-expense'),
|
||
'synced_at' => '2026-11-11 10:00:00',
|
||
'created_at' => '2026-11-11 10:00:00',
|
||
'updated_at' => '2026-11-11 10:00:00',
|
||
],
|
||
]);
|
||
$connection->table('fin_bank_balance_current_adjustments')->insert([
|
||
'account_short' => '总览独立滚动工行',
|
||
'adjustment_amount' => 50,
|
||
'updated_by' => '出纳测试',
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_search' => '总览独立滚动工行',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('总览独立滚动工行', $html);
|
||
$this->assertStringContainsString('115.00', $html);
|
||
$this->assertStringNotContainsString('999.00', $html);
|
||
$this->assertStringNotContainsString('165.00', $html);
|
||
$this->assertSame(
|
||
999.0,
|
||
(float) $connection->table('fin_accounts')
|
||
->where('account_short', '总览独立滚动工行')
|
||
->value('current_balance'),
|
||
);
|
||
}
|
||
|
||
public function test_bank_direct_available_balance_overrides_closing_balance_up_to_period_end(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$accountId = (int) $connection->table('fin_accounts')
|
||
->where('account_short', '保留直连工行')
|
||
->value('id');
|
||
foreach ([
|
||
['balance_date' => '2026-11-10', 'balance_at' => '2026-11-10 17:00:00', 'available_balance' => 110000],
|
||
['balance_date' => '2026-11-19', 'balance_at' => '2026-11-19 17:08:04', 'available_balance' => 123456.78],
|
||
] as $snapshot) {
|
||
$connection->table('fin_bank_direct_balance_snapshots')->insert($snapshot + [
|
||
'finance_account_id' => $accountId,
|
||
'bank_name' => '华夏银行',
|
||
'account_no' => '100200300400',
|
||
'account_name' => '保留直连工行',
|
||
'account_short' => '保留直连工行',
|
||
'company_name' => '保留直连公司',
|
||
'currency' => '人民币',
|
||
'account_balance' => $snapshot['available_balance'],
|
||
'source' => 'bank-direct',
|
||
'source_file_name' => '银行余额.xlsx',
|
||
'source_sha256' => str_repeat('a', 64),
|
||
'imported_at' => '2026-11-19 18:00:00',
|
||
'created_at' => '2026-11-19 18:00:00',
|
||
'updated_at' => '2026-11-19 18:00:00',
|
||
]);
|
||
}
|
||
|
||
$beforeLatestSnapshot = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-18',
|
||
]))->assertOk()->getContent();
|
||
$this->assertStringContainsString('110,000.00', $beforeLatestSnapshot);
|
||
|
||
$throughLatestSnapshot = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
$this->assertStringContainsString('123,456.78', $throughLatestSnapshot);
|
||
}
|
||
|
||
public function test_latest_bank_bill_balance_wins_over_direct_balance_snapshot(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$accountId = (int) $connection->table('fin_accounts')->insertGetId([
|
||
'company_name' => '账单优先测试公司',
|
||
'account_short' => '账单优先招行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行常州分行',
|
||
'account_no' => '5199050000000888',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 999,
|
||
'daily_available' => 999,
|
||
'blocked_amount' => 0,
|
||
]);
|
||
$connection->table('fin_bank_direct_balance_snapshots')->insert([
|
||
'finance_account_id' => $accountId,
|
||
'bank_name' => '招商银行',
|
||
'account_no' => '5199050000000888',
|
||
'account_name' => '账单优先招行',
|
||
'account_short' => '账单优先招行',
|
||
'company_name' => '账单优先测试公司',
|
||
'currency' => '人民币',
|
||
'balance_date' => '2026-11-20',
|
||
'balance_at' => '2026-11-20 18:00:00',
|
||
'account_balance' => 123456.78,
|
||
'available_balance' => 120000,
|
||
'source' => 'bank-direct',
|
||
'source_file_name' => '银行余额.xlsx',
|
||
'source_sha256' => str_repeat('c', 64),
|
||
'imported_at' => '2026-11-20 18:30:00',
|
||
'created_at' => '2026-11-20 18:30:00',
|
||
'updated_at' => '2026-11-20 18:30:00',
|
||
]);
|
||
$connection->table('fin_bank_direct_bills')->insert([
|
||
'bank_name' => '招商银行',
|
||
'finance_account_id' => $accountId,
|
||
'company_name' => '账单优先测试公司',
|
||
'account_short' => '账单优先招行',
|
||
'account_no' => '5199050000000888',
|
||
'txn_date' => '2026-11-19',
|
||
'txn_at' => '2026-11-19 17:08:04',
|
||
'record_code' => 'BANK-BILL-WINS',
|
||
'income' => 0,
|
||
'expense' => 0,
|
||
'balance' => 130000,
|
||
'row_key' => hash('sha256', 'bank-bill-wins'),
|
||
]);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'account_search' => '账单优先招行',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('130,000.00', $html);
|
||
$this->assertStringNotContainsString('123,456.78', $html);
|
||
}
|
||
|
||
public function test_direct_snapshot_ignores_next_day_transaction_details(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$accountId = (int) $connection->table('fin_accounts')
|
||
->where('account_short', '保留直连工行')
|
||
->value('id');
|
||
$connection->table('fin_bank_direct_balance_snapshots')->insert([
|
||
'finance_account_id' => $accountId,
|
||
'bank_name' => '华夏银行',
|
||
'account_no' => '100200300400',
|
||
'account_name' => '保留直连工行',
|
||
'account_short' => '保留直连工行',
|
||
'company_name' => '保留直连公司',
|
||
'currency' => '人民币',
|
||
'balance_date' => '2026-11-16',
|
||
'balance_at' => '2026-11-16 23:59:00',
|
||
'account_balance' => 123456.78,
|
||
'available_balance' => 120000,
|
||
'source' => 'bank-direct',
|
||
'source_file_name' => '银行余额.xlsx',
|
||
'source_sha256' => str_repeat('b', 64),
|
||
'imported_at' => '2026-11-17 09:00:00',
|
||
'created_at' => '2026-11-17 09:00:00',
|
||
'updated_at' => '2026-11-17 09:00:00',
|
||
]);
|
||
foreach ([
|
||
[
|
||
'row_key' => hash('sha256', 'direct-before-snapshot'),
|
||
'txn_date' => '2026-11-16',
|
||
'account_short' => '保留直连工行',
|
||
'income' => 0,
|
||
'expense' => 2000,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'created_at' => '2026-11-17 09:30:00',
|
||
'updated_at' => '2026-11-17 09:30:00',
|
||
],
|
||
[
|
||
'row_key' => hash('sha256', 'direct-next-day-income'),
|
||
'txn_date' => '2026-11-17',
|
||
'account_short' => '保留直连工行',
|
||
'income' => 2000,
|
||
'expense' => 0,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'created_at' => '2026-11-17 10:15:00',
|
||
'updated_at' => '2026-11-17 10:15:00',
|
||
],
|
||
[
|
||
'row_key' => hash('sha256', 'direct-next-day-expense'),
|
||
'txn_date' => '2026-11-17',
|
||
'account_short' => '保留直连工行',
|
||
'income' => 0,
|
||
'expense' => 1000,
|
||
'source' => 'manual',
|
||
'source_value' => null,
|
||
'created_at' => '2026-11-17 10:20:00',
|
||
'updated_at' => '2026-11-17 10:20:00',
|
||
],
|
||
] as $transaction) {
|
||
$connection->table('fin_transactions')->insert($transaction);
|
||
}
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
|
||
$retainedDialog = $this->dialogHtml($html, 'data-retained-dialog');
|
||
|
||
$this->assertStringContainsString('123,456.78', $retainedDialog);
|
||
$this->assertStringContainsString('120,000.00', $retainedDialog);
|
||
$this->assertStringContainsString('3,456.78', $retainedDialog);
|
||
|
||
$accountArchive = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'bank',
|
||
'period_from' => '2026-11-01',
|
||
'period_to' => '2026-11-30',
|
||
]))->assertOk()->getContent();
|
||
$this->assertStringContainsString('123,456.78', $accountArchive);
|
||
}
|
||
|
||
public function test_unretained_tasks_have_a_standalone_processing_page(): void
|
||
{
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'unretained_tasks',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('不保留账户处理进度', $html);
|
||
$this->assertStringContainsString('需要处理的账户清单', $html);
|
||
$this->assertStringContainsString('不保留华夏', $html);
|
||
$this->assertStringContainsString('不保留网商', $html);
|
||
$this->assertStringContainsString('财务甲乙', $html);
|
||
$this->assertStringContainsString('已完成', $html);
|
||
$this->assertStringContainsString('进行中', $html);
|
||
$this->assertStringNotContainsString('保留直连工行', $html);
|
||
}
|
||
|
||
public function test_direct_connection_tasks_only_include_retained_bank_accounts(): void
|
||
{
|
||
$connection = DB::connection('business_mirror');
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '保留手动银行公司',
|
||
'account_short' => '保留手动招行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '招商银行上海分行',
|
||
'account_no' => '310000000001',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 25000,
|
||
'daily_available' => 25000,
|
||
'blocked_amount' => 0,
|
||
'owner' => '李四',
|
||
]);
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '不纳入直连银行公司',
|
||
'account_short' => '保留手动建行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '中国建设银行上海分行',
|
||
'account_no' => '310000000002',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 10000,
|
||
'daily_available' => 10000,
|
||
'blocked_amount' => 0,
|
||
'owner' => '王五',
|
||
]);
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '等待接入中行公司',
|
||
'account_short' => '保留手动中行',
|
||
'account_type' => '公户',
|
||
'bank_name' => '中国银行常州分行',
|
||
'account_no' => '320000000001',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 5000,
|
||
'daily_available' => 5000,
|
||
'blocked_amount' => 0,
|
||
'owner' => '赵六',
|
||
]);
|
||
$connection->table('fin_accounts')->insert([
|
||
'company_name' => '个人卡不接直连公司',
|
||
'account_short' => '保留中行个人卡',
|
||
'account_type' => '个人卡',
|
||
'bank_name' => '中国银行常州分行',
|
||
'account_no' => '320000000099',
|
||
'account_should_keep' => '是',
|
||
'current_balance' => 3000,
|
||
'daily_available' => 3000,
|
||
'blocked_amount' => 0,
|
||
'owner' => '钱七',
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '保留手动招行',
|
||
'data_source' => '手动',
|
||
'updated_by' => '测试',
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '保留手动建行',
|
||
'data_source' => '手动',
|
||
'updated_by' => '测试',
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '保留手动中行',
|
||
'data_source' => '手动',
|
||
'updated_by' => '测试',
|
||
]);
|
||
$connection->table('fin_flow_summary_account_sources')->insert([
|
||
'account_short' => '保留中行个人卡',
|
||
'data_source' => '银企直连',
|
||
'updated_by' => '测试',
|
||
]);
|
||
|
||
$overviewHtml = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
|
||
$this->assertStringContainsString('等待接入', $overviewHtml);
|
||
$this->assertStringContainsString('查看直连处理清单', $overviewHtml);
|
||
$this->assertStringContainsString('direct_task_state=non_direct', $overviewHtml);
|
||
|
||
$html = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'direct_tasks',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('银企直连处理清单', $html);
|
||
$this->assertStringContainsString('华夏银行、中国银行、招商银行', $html);
|
||
$this->assertStringNotContainsString('保留直连工行', $html);
|
||
$this->assertStringContainsString('保留手动招行', $html);
|
||
$this->assertStringContainsString('保留手动中行', $html);
|
||
$this->assertStringContainsString('已银企直连', $html);
|
||
$this->assertStringContainsString('进度待维护', $html);
|
||
$this->assertStringNotContainsString('保留手动建行', $html);
|
||
$this->assertStringNotContainsString('保留中行个人卡', $html);
|
||
$this->assertStringNotContainsString('保留手动支付宝', $html);
|
||
$this->assertStringNotContainsString('不保留华夏', $html);
|
||
$this->assertStringNotContainsString('不保留网商', $html);
|
||
}
|
||
|
||
public function test_account_archive_return_link_opens_retained_overview_dialog(): void
|
||
{
|
||
$accountsHtml = $this->loginAs()->get($this->pageUrl([
|
||
'view' => 'accounts',
|
||
'keep' => 'retained',
|
||
'account_category' => 'alipay',
|
||
]))->assertOk()->getContent();
|
||
|
||
$retainedOverviewUrl = route('business.pages.show', [
|
||
'company_id' => $this->company->id,
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]) . '?tab=overview&retained=1';
|
||
|
||
$this->assertStringContainsString('href="' . e($retainedOverviewUrl) . '"', $accountsHtml);
|
||
|
||
$overviewHtml = $this->loginAs()->get($this->pageUrl([
|
||
'retained' => 1,
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertStringContainsString('data-open-retained-on-load="1"', $overviewHtml);
|
||
$this->assertStringContainsString('openRetainedDialog();', $overviewHtml);
|
||
$this->assertStringContainsString('window.history.replaceState', $overviewHtml);
|
||
}
|
||
|
||
public function test_non_store_account_page_is_available_from_ledger_tabs(): void
|
||
{
|
||
$this->loginAs();
|
||
|
||
$reports = collect(\App\Utilities\SidebarMenu::groups($this->user))
|
||
->firstWhere('title', '经营报表');
|
||
|
||
$this->assertNotNull($reports);
|
||
$this->assertFalse(collect($reports['items'])->contains(
|
||
static fn (array $item): bool => $item['page'] === 'non-store-accounts',
|
||
));
|
||
|
||
$html = $this->loginAs()->get(route('business.pages.show', [
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]))->assertOk()->getContent();
|
||
|
||
$this->assertSame(1, preg_match('/<nav class="ledger-tabbar"[^>]*>(.*?)<\/nav>/s', $html, $tabBar));
|
||
$this->assertMatchesRegularExpression(
|
||
'/<button[^>]*data-ledger-tab="overview"[^>]*>.*?账户总览.*?<\/button>/s',
|
||
$tabBar[1],
|
||
);
|
||
$this->assertStringContainsString('账户总览', $tabBar[1]);
|
||
$this->assertStringNotContainsString('href=', $tabBar[1]);
|
||
$this->assertLessThan(
|
||
strpos($tabBar[1], 'data-ledger-tab="shops"'),
|
||
strpos($tabBar[1], 'data-ledger-tab="overview"'),
|
||
);
|
||
|
||
$overviewHtml = $this->loginAs()->get(route('business.pages.show', [
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]) . '?tab=overview')
|
||
->assertOk()
|
||
->assertSee('data-non-store-monitor', false)
|
||
->assertSeeText('账户总览')
|
||
->assertSeeText('保留账户')
|
||
->getContent();
|
||
$this->assertStringContainsString(
|
||
'data-current-url="' . e(route('business.pages.show', [
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]) . '?tab=overview') . '"',
|
||
$overviewHtml,
|
||
);
|
||
$this->assertStringContainsString('登录已过期,请重新登录后继续操作。', $overviewHtml);
|
||
|
||
$this->get(route('business.pages.show', [
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]) . '?tab=overview&ledger_overview_partial=1')
|
||
->assertOk()
|
||
->assertSee('id="ledger-panel-overview"', false)
|
||
->assertSee('data-non-store-monitor', false)
|
||
->assertDontSee('data-ledger-tab="overview"', false);
|
||
}
|
||
|
||
private function pageUrl(array $parameters = []): string
|
||
{
|
||
$url = route('business.pages.show', [
|
||
'company_id' => $this->company->id,
|
||
'section' => 'financial-operations',
|
||
'page' => 'ledger',
|
||
]);
|
||
$query = ['tab' => 'overview', 'ledger_overview_partial' => '1', ...$parameters];
|
||
|
||
return $url . '?' . http_build_query($query);
|
||
}
|
||
|
||
private function dialogHtml(string $html, string $attribute): string
|
||
{
|
||
$this->assertSame(1, preg_match(
|
||
'/<dialog[^>]*\b' . preg_quote($attribute, '/') . '\b[^>]*>.*?<\/dialog>/s',
|
||
$html,
|
||
$matches,
|
||
));
|
||
|
||
return $matches[0];
|
||
}
|
||
}
|