feat: 精简其他账户信息并纳入独立账户 (#1207)
This commit is contained in:
parent
c4157ed7d5
commit
81fd0465e4
@ -106,6 +106,7 @@ class FinanceLedgerPageData
|
||||
'中信' => '中信银行',
|
||||
'杭州银行' => '杭州银行',
|
||||
'杭州' => '杭州银行',
|
||||
'微信' => '微信',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
@ -207,11 +208,19 @@ class FinanceLedgerPageData
|
||||
*/
|
||||
private function accounts(string $view = 'all', array $accountDisplayLabels = []): array
|
||||
{
|
||||
$query = FinanceLedgerIndependentAccounts::exclude(
|
||||
$this->db()->table('fin_accounts as a'),
|
||||
$query = $this->db()->table('fin_accounts as a');
|
||||
if ($view !== 'other') {
|
||||
$query = FinanceLedgerIndependentAccounts::exclude($query, 'a.account_short');
|
||||
}
|
||||
$this->applyAccountCategoryScope(
|
||||
$query,
|
||||
$view,
|
||||
'a.account_short',
|
||||
'a.account_type',
|
||||
true,
|
||||
'a.bank_name',
|
||||
$view === 'other',
|
||||
);
|
||||
$this->applyAccountCategoryScope($query, $view, 'a.account_short', 'a.account_type', true, 'a.bank_name');
|
||||
$keyword = trim((string) request('accounts_q', ''));
|
||||
if ($keyword !== '') {
|
||||
$query->where(function (Builder $builder) use ($keyword): void {
|
||||
@ -352,10 +361,10 @@ class FinanceLedgerPageData
|
||||
$cards = [];
|
||||
|
||||
foreach (self::ACCOUNT_TYPE_VIEWS as $view => $definition) {
|
||||
$query = FinanceLedgerIndependentAccounts::exclude(
|
||||
$this->db()->table('fin_accounts as a'),
|
||||
'a.account_short',
|
||||
);
|
||||
$query = $this->db()->table('fin_accounts as a');
|
||||
if ($view !== 'other') {
|
||||
$query = FinanceLedgerIndependentAccounts::exclude($query, 'a.account_short');
|
||||
}
|
||||
$this->applyAccountCategoryScope(
|
||||
$query,
|
||||
$view,
|
||||
@ -363,6 +372,7 @@ class FinanceLedgerPageData
|
||||
'a.account_type',
|
||||
true,
|
||||
'a.bank_name',
|
||||
$view === 'other',
|
||||
);
|
||||
$summary = $query->selectRaw(
|
||||
'COUNT(*) AS account_count,'
|
||||
@ -766,6 +776,7 @@ class FinanceLedgerPageData
|
||||
string $accountTypeColumn,
|
||||
bool $separateWangshangBank = false,
|
||||
?string $bankNameColumn = null,
|
||||
bool $includeIndependentAccounts = false,
|
||||
): void {
|
||||
if ($view === 'bank') {
|
||||
$query->where(function (Builder $scope) use ($accountShortColumn, $accountTypeColumn): void {
|
||||
@ -831,32 +842,43 @@ class FinanceLedgerPageData
|
||||
}
|
||||
});
|
||||
} elseif ($view === 'other') {
|
||||
$query->where(function (Builder $scope) use ($accountShortColumn, $accountTypeColumn, $bankNameColumn): void {
|
||||
$scope->where(function (Builder $account) use ($accountShortColumn): void {
|
||||
$account->whereNull($accountShortColumn)
|
||||
->orWhere(function (Builder $name) use ($accountShortColumn): void {
|
||||
$name->where($accountShortColumn, 'not like', '%支付宝%')
|
||||
->where($accountShortColumn, 'not like', '%网商%')
|
||||
->where($accountShortColumn, 'not like', '%钱包%');
|
||||
});
|
||||
})->where(function (Builder $accountType) use ($accountTypeColumn): void {
|
||||
$accountType->whereNull($accountTypeColumn)
|
||||
->orWhere(function (Builder $type) use ($accountTypeColumn): void {
|
||||
$type->where($accountTypeColumn, 'not like', '%支付宝%')
|
||||
->where($accountTypeColumn, 'not like', '%网商%')
|
||||
->where($accountTypeColumn, 'not like', '%钱包%');
|
||||
});
|
||||
});
|
||||
if ($bankNameColumn !== null) {
|
||||
$scope->where(function (Builder $bankName) use ($bankNameColumn): void {
|
||||
$bankName->whereNull($bankNameColumn)
|
||||
->orWhere($bankNameColumn, '')
|
||||
->orWhere($bankNameColumn, '/');
|
||||
$bankAffiliation = $this->bankAffiliationSqlExpression($this->rawQualifiedColumn($accountShortColumn));
|
||||
$query->where(function (Builder $scope) use (
|
||||
$accountShortColumn,
|
||||
$accountTypeColumn,
|
||||
$bankNameColumn,
|
||||
$includeIndependentAccounts,
|
||||
$bankAffiliation,
|
||||
): void {
|
||||
$scope->where(function (Builder $regular) use ($accountShortColumn, $accountTypeColumn, $bankNameColumn, $bankAffiliation): void {
|
||||
$regular->where(function (Builder $account) use ($accountShortColumn): void {
|
||||
$account->whereNull($accountShortColumn)
|
||||
->orWhere(function (Builder $name) use ($accountShortColumn): void {
|
||||
$name->where($accountShortColumn, 'not like', '%支付宝%')
|
||||
->where($accountShortColumn, 'not like', '%网商%')
|
||||
->where($accountShortColumn, 'not like', '%钱包%');
|
||||
});
|
||||
})->where(function (Builder $accountType) use ($accountTypeColumn): void {
|
||||
$accountType->whereNull($accountTypeColumn)
|
||||
->orWhere(function (Builder $type) use ($accountTypeColumn): void {
|
||||
$type->where($accountTypeColumn, 'not like', '%支付宝%')
|
||||
->where($accountTypeColumn, 'not like', '%网商%')
|
||||
->where($accountTypeColumn, 'not like', '%钱包%');
|
||||
});
|
||||
});
|
||||
if ($bankNameColumn !== null) {
|
||||
$regular->where(function (Builder $bankName) use ($bankNameColumn): void {
|
||||
$bankName->whereNull($bankNameColumn)
|
||||
->orWhere($bankNameColumn, '')
|
||||
->orWhere($bankNameColumn, '/');
|
||||
});
|
||||
}
|
||||
$regular->whereRaw($bankAffiliation . " = ''");
|
||||
});
|
||||
if ($includeIndependentAccounts) {
|
||||
$scope->orWhereIn($accountShortColumn, FinanceLedgerIndependentAccounts::names());
|
||||
}
|
||||
});
|
||||
$bankAffiliation = $this->bankAffiliationSqlExpression($this->rawQualifiedColumn($accountShortColumn));
|
||||
$query->whereRaw($bankAffiliation . " = ''");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -307,6 +307,15 @@
|
||||
['remark', '备注', 'text'],
|
||||
];
|
||||
}
|
||||
if ($standaloneAccountView === 'other') {
|
||||
$ledgerTableHeaders['accounts'] = [
|
||||
['company_name', '公司名称', 'text'],
|
||||
['account_short', '账户简称', 'text'],
|
||||
['bank_affiliation', '所属银行', 'enum', ['options' => $optionMap($accountBankOptions)]],
|
||||
['account_status', '账户状态', 'enum', ['options' => $accountStatusOptions, 'headerClass' => 'ledger-status-column']],
|
||||
['account_no', '登录账号', 'text'],
|
||||
];
|
||||
}
|
||||
$accountTableColumnCount = count($ledgerTableHeaders['accounts']);
|
||||
@endphp
|
||||
|
||||
@ -1358,6 +1367,28 @@
|
||||
</td>
|
||||
<td>{{ $row->alipay_store_name }}</td>
|
||||
<td>{{ $row->remark }}</td>
|
||||
@elseif ($standaloneAccountView === 'other')
|
||||
<td>{{ $row->company_name }}</td>
|
||||
<td>
|
||||
{{ $accountDisplayShort }}
|
||||
@if ($canEditAccounts)
|
||||
<button class="ledger-row-edit" type="button" title="编辑账户 {{ $accountDisplayShort }}" aria-label="编辑账户 {{ $accountDisplayShort }}" data-ledger-account-edit data-edit-url="{{ route('business.financial-ledger.accounts.edit', ['id' => $row->id]) }}" data-save-url="{{ route('business.financial-ledger.accounts.update', ['id' => $row->id]) }}"><span class="material-icons-outlined" aria-hidden="true">edit</span></button>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $row->bank_affiliation ?: '未填写' }}</td>
|
||||
<td class="ledger-status-column">
|
||||
@if ($canEditAccountStatus)
|
||||
<span class="ledger-status-badge ledger-account-readonly" data-account-edit-display data-account-status-display data-status="{{ $row->account_status }}">{{ $accountStatusOptions[$row->account_status] ?? '正常' }}</span>
|
||||
<select class="ledger-inline-select ledger-status-select ledger-account-editor" data-account-editor data-account-status data-account-short="{{ $row->account_short }}" data-status="{{ $row->account_status }}" data-url="{{ route('business.financial-ledger.accounts.status') }}" aria-label="账户 {{ $row->account_short }} 状态" disabled>
|
||||
@foreach ($accountStatusOptions as $statusCode => $statusLabel)
|
||||
<option value="{{ $statusCode }}" @selected($row->account_status === $statusCode)>{{ $statusLabel }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<span class="ledger-status-badge ledger-account-readonly" data-status="{{ $row->account_status }}">{{ $accountStatusOptions[$row->account_status] ?? '正常' }}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $row->account_no }}</td>
|
||||
@else
|
||||
<td>{{ $row->company_name }}</td>
|
||||
<td>
|
||||
|
||||
@ -650,6 +650,71 @@ class FinanceLedgerHeaderControlsTest extends FeatureTestCase
|
||||
$this->assertStringNotContainsString('data-flow-summary-account="账户甲"', $walletFlowHtml);
|
||||
}
|
||||
|
||||
public function test_other_account_basic_page_only_uses_five_login_fields(): void
|
||||
{
|
||||
DB::connection('business_mirror')->table('fin_accounts')->insert([
|
||||
[
|
||||
'company_name' => '其他账户公司',
|
||||
'account_short' => '其他账户登录测试',
|
||||
'bank_name' => '/',
|
||||
'account_type' => '其他',
|
||||
'account_no' => 'other-login@example.com',
|
||||
'current_balance' => 0,
|
||||
'daily_available' => 0,
|
||||
'blocked_amount' => 0,
|
||||
],
|
||||
[
|
||||
'company_name' => '朱俊祥',
|
||||
'account_short' => '朱俊祥支付宝',
|
||||
'bank_name' => '支付宝',
|
||||
'account_type' => '其他',
|
||||
'account_no' => 'zhujunxiang-alipay',
|
||||
'current_balance' => 0,
|
||||
'daily_available' => 0,
|
||||
'blocked_amount' => 0,
|
||||
],
|
||||
[
|
||||
'company_name' => '朱俊祥',
|
||||
'account_short' => '朱俊祥微信',
|
||||
'bank_name' => '微信',
|
||||
'account_type' => '其他',
|
||||
'account_no' => 'zhujunxiang-wechat',
|
||||
'current_balance' => 0,
|
||||
'daily_available' => 0,
|
||||
'blocked_amount' => 0,
|
||||
],
|
||||
]);
|
||||
|
||||
$html = $this->loginAs()->get(route('business.financial-ledger.account-basic', [
|
||||
'company_id' => $this->company->id,
|
||||
'view' => 'other',
|
||||
]))->assertOk()->getContent();
|
||||
|
||||
preg_match(
|
||||
'/<table class="ledger-table ledger-accounts-table">.*?<thead>\s*<tr>(.*?)<\/tr>\s*<\/thead>/s',
|
||||
$html,
|
||||
$headerMatch,
|
||||
);
|
||||
$headerHtml = $headerMatch[1] ?? '';
|
||||
|
||||
$this->assertSame(5, substr_count($headerHtml, '<th'));
|
||||
preg_match_all('/data-ledger-header-field="([^"]+)"/', $headerHtml, $fieldMatches);
|
||||
preg_match_all('/data-ledger-header-label>([^<]+)<\/span>/', $headerHtml, $labelMatches);
|
||||
$this->assertSame(
|
||||
['company_name', 'account_short', 'bank_affiliation', 'account_status', 'account_no'],
|
||||
$fieldMatches[1] ?? [],
|
||||
);
|
||||
$this->assertSame(
|
||||
['公司名称', '账户简称', '所属银行', '账户状态', '登录账号'],
|
||||
array_map('trim', $labelMatches[1] ?? []),
|
||||
);
|
||||
$this->assertTrue(str_contains($html, 'other-login@example.com'));
|
||||
$this->assertTrue(str_contains($html, 'data-ledger-account-row="朱俊祥支付宝"'));
|
||||
$this->assertTrue(str_contains($html, 'data-ledger-account-row="朱俊祥微信"'));
|
||||
$this->assertTrue(str_contains($html, 'zhujunxiang-alipay'));
|
||||
$this->assertTrue(str_contains($html, 'zhujunxiang-wechat'));
|
||||
}
|
||||
|
||||
public function test_account_directory_bank_affiliation_filter_uses_account_short_suffix(): void
|
||||
{
|
||||
DB::connection('business_mirror')->table('fin_accounts')->insert([
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user