diff --git a/modules/EcommerceFinance/View/FinanceLedgerPageData.php b/modules/EcommerceFinance/View/FinanceLedgerPageData.php index 2d8099b9..00b4de27 100644 --- a/modules/EcommerceFinance/View/FinanceLedgerPageData.php +++ b/modules/EcommerceFinance/View/FinanceLedgerPageData.php @@ -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 . " = ''"); } } diff --git a/resources/views/business/pages/financial-ledger/ledger.blade.php b/resources/views/business/pages/financial-ledger/ledger.blade.php index 1537e8f1..626d0a69 100644 --- a/resources/views/business/pages/financial-ledger/ledger.blade.php +++ b/resources/views/business/pages/financial-ledger/ledger.blade.php @@ -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 @@
| ([^<]+)<\/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([ |
|---|