From 8c2ab2df07324b28e631773722f0bc9a3a1951b2 Mon Sep 17 00:00:00 2001 From: shanshi <3316401569@qq.com> Date: Mon, 30 Nov 2026 14:28:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=B4=A6=E6=88=B7=E8=BF=9E=E6=8E=A5=E6=96=B9=E5=BC=8F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/financial-operations/non-store-accounts.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/business/pages/financial-operations/non-store-accounts.blade.php b/resources/views/business/pages/financial-operations/non-store-accounts.blade.php index 7f98a81b..8c591488 100644 --- a/resources/views/business/pages/financial-operations/non-store-accounts.blade.php +++ b/resources/views/business/pages/financial-operations/non-store-accounts.blade.php @@ -45,7 +45,7 @@ 'to' => (string) ($period['to'] ?? now()->endOfMonth()->toDateString()), ]); }; - $accountStorageKey = 'caiwu.non-store-accounts.columns.v6.' + $accountStorageKey = 'caiwu.non-store-accounts.columns.v7.' . auth()->id() . '.' . company_id() . '.' . ($accountFilters['category'] ?? 'all'); @endphp @@ -4085,7 +4085,7 @@ const pickerButton = root.querySelector('[data-column-picker-toggle]'); const columnPanel = root.querySelector('[data-column-panel]'); const toggles = [...root.querySelectorAll('[data-column-toggle]')]; - const storageKey = table.dataset.columnStorageKey || 'caiwu.non-store-accounts.columns.v6'; + const storageKey = table.dataset.columnStorageKey || 'caiwu.non-store-accounts.columns.v7'; const readStoredColumns = () => { try { -- 2.47.2 From 3c23a1d4d53fb90042abbe80625696303d8a22d7 Mon Sep 17 00:00:00 2001 From: shanshi <3316401569@qq.com> Date: Mon, 30 Nov 2026 15:22:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=9D=E6=8C=81=E6=8B=9B=E5=95=86?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E8=87=AA=E5=8A=A8=E7=9B=B4=E8=BF=9E=E5=88=A4?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Business/FinanceLedger.php | 11 +++++++++- .../FinanceLedgerBankDirectAccounts.php | 4 ++-- .../FinanceLedgerFlowSummaryDataSource.php | 15 ++++++++++--- .../FinanceLedgerFlowSummaryEditor.php | 2 +- .../View/NonStoreAccountMonitorPageData.php | 5 +++-- .../Business/FinanceLedgerManualEditTest.php | 22 +++++++++++++++++++ .../Business/NonStoreAccountMonitorTest.php | 1 + 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Business/FinanceLedger.php b/app/Http/Controllers/Business/FinanceLedger.php index 8156241d..f856e610 100644 --- a/app/Http/Controllers/Business/FinanceLedger.php +++ b/app/Http/Controllers/Business/FinanceLedger.php @@ -2192,11 +2192,20 @@ class FinanceLedger extends Controller $account = $editor->update($id, $data); if ($connectionLabel !== '' && ! FinanceLedgerIndependentAccounts::contains((string) ($account['account_short'] ?? ''))) { + $autoDirect = str_contains( + (string) ($account['account_short'] ?? '') . ' ' . (string) ($account['bank_name'] ?? ''), + '招商', + ) || str_contains( + (string) ($account['account_short'] ?? '') . ' ' . (string) ($account['bank_name'] ?? ''), + '招行', + ); $flowSummaryEditor->updateSource( (string) $account['account_short'], $connectionLabel === FinanceLedgerFlowSummaryDataSource::DIRECT ? FinanceLedgerFlowSummaryDataSource::DIRECT - : FinanceLedgerFlowSummaryDataSource::MANUAL, + : ($autoDirect + ? FinanceLedgerFlowSummaryDataSource::NON_DIRECT + : FinanceLedgerFlowSummaryDataSource::MANUAL), ); } $account['status'] = FinanceLedgerAccountStatus::normalize((string) $data['status']); diff --git a/app/Utilities/FinanceLedgerBankDirectAccounts.php b/app/Utilities/FinanceLedgerBankDirectAccounts.php index 738e0a36..526909bc 100644 --- a/app/Utilities/FinanceLedgerBankDirectAccounts.php +++ b/app/Utilities/FinanceLedgerBankDirectAccounts.php @@ -42,12 +42,12 @@ final class FinanceLedgerBankDirectAccounts continue; } - $dataSource = FinanceLedgerFlowSummaryDataSource::normalize($sources[$accountShort] ?? null); + $dataSource = FinanceLedgerFlowSummaryDataSource::stored($sources[$accountShort] ?? null); if ($dataSource === FinanceLedgerFlowSummaryDataSource::DIRECT) { $direct[$accountShort] = true; continue; } - if ($dataSource === FinanceLedgerFlowSummaryDataSource::MANUAL) { + if ($dataSource === FinanceLedgerFlowSummaryDataSource::NON_DIRECT) { continue; } diff --git a/app/Utilities/FinanceLedgerFlowSummaryDataSource.php b/app/Utilities/FinanceLedgerFlowSummaryDataSource.php index fa7c1582..a30b0250 100644 --- a/app/Utilities/FinanceLedgerFlowSummaryDataSource.php +++ b/app/Utilities/FinanceLedgerFlowSummaryDataSource.php @@ -14,20 +14,29 @@ final class FinanceLedgerFlowSummaryDataSource public const OPTIONS = [self::MANUAL, self::DIRECT]; + public const STORED_OPTIONS = [self::MANUAL, self::DIRECT, self::NON_DIRECT]; + public const CONNECTION_OPTIONS = [self::NON_DIRECT, self::DIRECT]; public static function normalize(mixed $value): string + { + $text = self::stored($value); + + return $text === self::NON_DIRECT ? self::MANUAL : $text; + } + + public static function stored(mixed $value): string { $text = trim((string) ($value ?? '')); - return in_array($text, self::OPTIONS, true) ? $text : ''; + return in_array($text, self::STORED_OPTIONS, true) ? $text : ''; } public static function connectionLabel(mixed $value, bool $autoDirect = false): string { - return match (self::normalize($value)) { + return match (self::stored($value)) { self::DIRECT => self::DIRECT, - self::MANUAL => self::NON_DIRECT, + self::NON_DIRECT => self::NON_DIRECT, default => $autoDirect ? self::DIRECT : self::NON_DIRECT, }; } diff --git a/modules/EcommerceFinance/Services/FinanceLedgerFlowSummaryEditor.php b/modules/EcommerceFinance/Services/FinanceLedgerFlowSummaryEditor.php index da3322d0..54d773dc 100644 --- a/modules/EcommerceFinance/Services/FinanceLedgerFlowSummaryEditor.php +++ b/modules/EcommerceFinance/Services/FinanceLedgerFlowSummaryEditor.php @@ -271,7 +271,7 @@ class FinanceLedgerFlowSummaryEditor $accountShort = preg_replace('/\s+/u', ' ', trim($accountShort)) ?? trim($accountShort); $text = trim((string) ($value ?? '')); $text = preg_replace('/\s+/u', ' ', $text) ?? $text; - if ($text !== '' && ! in_array($text, FinanceLedgerFlowSummaryDataSource::OPTIONS, true)) { + if ($text !== '' && ! in_array($text, FinanceLedgerFlowSummaryDataSource::STORED_OPTIONS, true)) { throw ValidationException::withMessages([ 'value' => '数据来源只能选择“手动”或“银企直连”。', ]); diff --git a/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php b/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php index b97f7155..be3374e1 100644 --- a/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php +++ b/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php @@ -526,12 +526,13 @@ final class NonStoreAccountMonitorPageData $account->account_should_keep ?? null, $companyPlan, ); - $dataSource = FinanceLedgerFlowSummaryDataSource::normalize( + $storedDataSource = FinanceLedgerFlowSummaryDataSource::stored( $sources[$accountShort] ?? null, ); + $dataSource = FinanceLedgerFlowSummaryDataSource::normalize($storedDataSource); $isDirect = $accountType !== '个人卡' && FinanceLedgerFlowSummaryDataSource::connectionLabel( - $dataSource, + $storedDataSource, $platformLabel === '招商银行', ) === FinanceLedgerFlowSummaryDataSource::DIRECT; $usesBankBalance = $isDirect || $category === self::CATEGORY_WANGSHANG; diff --git a/tests/Feature/Business/FinanceLedgerManualEditTest.php b/tests/Feature/Business/FinanceLedgerManualEditTest.php index 7d45875a..4d760f1d 100644 --- a/tests/Feature/Business/FinanceLedgerManualEditTest.php +++ b/tests/Feature/Business/FinanceLedgerManualEditTest.php @@ -155,6 +155,28 @@ class FinanceLedgerManualEditTest extends FeatureTestCase ], 'business_mirror'); } + public function test_cmb_account_can_be_explicitly_marked_non_direct_without_losing_override(): void + { + $this->loginAs()->postJson($this->accountUpdateUrl(), [ + 'company_name' => '手动编辑测试公司', + 'account_short' => '手动编辑测试账户', + 'account_type' => '公户', + 'connection_label' => '非银企直连', + 'status' => 'normal', + 'bank_name' => '招商银行上海分行', + ])->assertOk() + ->assertJsonPath('account.connection_label', '非银企直连'); + + $this->assertDatabaseHas('fin_flow_summary_account_sources', [ + 'account_short' => '手动编辑测试账户', + 'data_source' => '非银企直连', + ], 'business_mirror'); + + $this->loginAs()->get($this->accountEditUrl()) + ->assertOk() + ->assertJsonPath('account.connection_label', '非银企直连'); + } + public function test_daily_flow_override_cascades_and_can_reset_to_automatic(): void { $this->loginAs()->get($this->flowEditUrl('2026-10-18')) diff --git a/tests/Feature/Business/NonStoreAccountMonitorTest.php b/tests/Feature/Business/NonStoreAccountMonitorTest.php index 74729952..ed80f2b6 100644 --- a/tests/Feature/Business/NonStoreAccountMonitorTest.php +++ b/tests/Feature/Business/NonStoreAccountMonitorTest.php @@ -824,6 +824,7 @@ class NonStoreAccountMonitorTest extends FeatureTestCase ], ]); $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' => '测试'], -- 2.47.2