diff --git a/app/Utilities/SidebarPermissions.php b/app/Utilities/SidebarPermissions.php index 897655ac..b3806f53 100644 --- a/app/Utilities/SidebarPermissions.php +++ b/app/Utilities/SidebarPermissions.php @@ -412,6 +412,12 @@ class SidebarPermissions $normalized[] = 'financial-operations/shop-flows'; } + // 「过账数据」紧随店铺应收账款展示;旧权限配置没有新菜单键时, + // 能访问应收账款的任意页面即可继续看到这个同级入口。 + if ($normalizedKey === 'store-receivables' || str_starts_with($normalizedKey, 'store-receivables/')) { + $normalized[] = 'posting-data'; + } + foreach (self::FINAL_SECTION_KEYS as $sectionKey => $finalSectionKey) { if ($normalizedKey === $sectionKey) { $normalized[] = $finalSectionKey; diff --git a/tests/Feature/SystemSettings/UserPermissionsTest.php b/tests/Feature/SystemSettings/UserPermissionsTest.php index bf486809..aba4007f 100644 --- a/tests/Feature/SystemSettings/UserPermissionsTest.php +++ b/tests/Feature/SystemSettings/UserPermissionsTest.php @@ -135,6 +135,26 @@ class UserPermissionsTest extends FeatureTestCase $this->get(route('system-settings.sidebar.edit', ['subject' => 'user_'.$target->id]))->assertOk()->assertSeeText('自定义权限'); } + public function test_posting_data_follows_store_receivables_permissions(): void + { + $regular = $this->account('user'); + $subject = 'user_'.$regular->id; + + foreach (['store-receivables', 'store-receivables/actual-reconciliation'] as $receivablePermission) { + setting()->set('system.sidebar_permissions', [ + 'configured' => [$subject], + 'subjects' => [$subject => [$receivablePermission]], + ]); + + $allowed = SidebarPermissions::allowedKeys($regular); + $navigation = SidebarPermissions::navigationFor($regular); + + $this->assertContains('posting-data', $allowed); + $this->assertSame(['store-receivables', 'posting-data'], array_column($navigation, 'slug')); + $this->assertSame([], $navigation[1]['pages']); + } + } + public function test_refund_export_requires_a_separate_operation_grant_when_page_access_is_limited(): void { $target = $this->account('user');