修复终版应付款项权限联动 #196
@ -11,6 +11,11 @@ class SidebarPermissions
|
||||
'refunds/small-payment-work-orders' => 'financial-operations/small-payment-work-orders',
|
||||
];
|
||||
|
||||
private const FINAL_SECTION_KEYS = [
|
||||
'supplier-payables' => 'supplier-payables-final',
|
||||
'courier-payables' => 'courier-payables-final',
|
||||
];
|
||||
|
||||
public static function settings(): array
|
||||
{
|
||||
$value = setting('system.sidebar_permissions', []);
|
||||
@ -140,7 +145,14 @@ class SidebarPermissions
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$key = (string) $key;
|
||||
$normalized[] = self::LEGACY_PAGE_KEYS[$key] ?? $key;
|
||||
$normalizedKey = self::LEGACY_PAGE_KEYS[$key] ?? $key;
|
||||
$normalized[] = $normalizedKey;
|
||||
|
||||
foreach (self::FINAL_SECTION_KEYS as $sectionKey => $finalSectionKey) {
|
||||
if ($normalizedKey === $sectionKey || str_starts_with($normalizedKey, $sectionKey . '/')) {
|
||||
$normalized[] = $finalSectionKey;
|
||||
}
|
||||
}
|
||||
|
||||
if ($key === 'refunds') {
|
||||
$normalized[] = self::LEGACY_PAGE_KEYS['refunds/small-payment-work-orders'];
|
||||
|
||||
@ -175,6 +175,52 @@ class UserPermissionsTest extends FeatureTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_payables_final_entries_follow_their_base_section_permissions(): void
|
||||
{
|
||||
$regular = $this->account('user');
|
||||
$subject = 'user_' . $regular->id;
|
||||
setting()->set('system.sidebar_permissions', [
|
||||
'configured' => [$subject],
|
||||
'subjects' => [$subject => ['supplier-payables', 'courier-payables']],
|
||||
]);
|
||||
|
||||
$this->assertEqualsCanonicalizing(
|
||||
['supplier-payables', 'supplier-payables-final', 'courier-payables', 'courier-payables-final'],
|
||||
SidebarPermissions::allowedKeys($regular)
|
||||
);
|
||||
|
||||
$navigation = SidebarPermissions::navigationFor($regular);
|
||||
$this->assertSame(
|
||||
['supplier-payables-final', 'courier-payables-final', 'supplier-payables', 'courier-payables'],
|
||||
array_column($navigation, 'slug')
|
||||
);
|
||||
}
|
||||
|
||||
public function test_payables_final_entry_follows_a_selected_child_permission(): void
|
||||
{
|
||||
$regular = $this->account('user');
|
||||
$subject = 'user_' . $regular->id;
|
||||
setting()->set('system.sidebar_permissions', [
|
||||
'configured' => [$subject],
|
||||
'subjects' => [$subject => ['supplier-payables/product-prices']],
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
['supplier-payables/product-prices', 'supplier-payables-final'],
|
||||
SidebarPermissions::allowedKeys($regular)
|
||||
);
|
||||
|
||||
$navigation = SidebarPermissions::navigationFor($regular);
|
||||
$this->assertSame(
|
||||
['supplier-payables-final', 'supplier-payables'],
|
||||
array_column($navigation, 'slug')
|
||||
);
|
||||
$this->assertSame(
|
||||
['product-prices'],
|
||||
array_column($navigation[1]['pages'], 'slug')
|
||||
);
|
||||
}
|
||||
|
||||
public function test_dingtalk_bound_user_cannot_be_deleted_into_an_orphaned_identity(): void
|
||||
{
|
||||
$target = $this->account('user');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user