恢复应付款项终版独立入口 #195

Merged
renshen merged 1 commits from feature/renshen-final-payables-entries into main 2026-09-16 11:27:59 +08:00
4 changed files with 60 additions and 20 deletions

View File

@ -52,13 +52,7 @@ class ShowInAdmin
public static function groupPayables(array $navigation): array
{
$legacyKeys = ['supplier-payables-final', 'courier-payables-final'];
$navigation = array_values(array_filter(
$navigation,
static fn (array $section): bool => ! in_array($section['slug'], $legacyKeys, true)
));
$keys = ['supplier-payables', 'courier-payables', 'raw-board-payables',
$keys = ['supplier-payables-final', 'courier-payables-final', 'supplier-payables', 'courier-payables', 'raw-board-payables',
'lamination-factory-payables', 'paper-materials', 'edge-banding-materials'];
$children = array_values(array_filter($navigation, static fn (array $section): bool => in_array($section['slug'], $keys, true)));
if ($children === []) {

View File

@ -5,6 +5,10 @@
&& ($page['slug'] ?? null) === 'marketing-account-balance';
$isStoreReceivingAccountsPage = ($section['slug'] ?? null) === 'fund-management'
&& ($page['slug'] ?? null) === 'store-receiving-accounts';
$isSupplierWorkspace = in_array($section['slug'] ?? null, ['supplier-payables', 'supplier-payables-final'], true);
$supplierWorkspaceSection = ($section['slug'] ?? null) === 'supplier-payables-final'
? collect(\App\Utilities\SidebarPermissions::navigationFor(user()))->firstWhere('slug', 'supplier-payables')
: $section;
$marketingAccountTabTitles = [
'taobao-wechat' => '阿里巴巴账户',
'jd-wallet' => '京东',
@ -546,7 +550,7 @@
'business-page--marketing-account-balance' => $isMarketingAccountBalancePage,
])
@if ($isMarketingAccountBillsPage) data-marketing-account-bills-workspace @endif
@if ($section['slug'] === 'supplier-payables') data-supplier-workspace @endif
@if ($isSupplierWorkspace) data-supplier-workspace @endif
>
@if ($isMarketingAccountBillsPage)
<p class="sr-only" role="status" aria-live="polite" data-marketing-account-bills-status></p>
@ -571,8 +575,8 @@
<div class="biz-alert biz-alert-error" role="alert">{{ $upstreamError }}</div>
@endif
@if ($section['slug'] === 'supplier-payables')
@include('business.pages.supplier-payables.navigation')
@if ($isSupplierWorkspace && $supplierWorkspaceSection)
@include('business.pages.supplier-payables.navigation', ['section' => $supplierWorkspaceSection])
@endif
@if ($tabs->isNotEmpty())
@ -621,7 +625,7 @@
}
@endphp
@if ($section['slug'] === 'courier-payables' && empty($page))
@if (in_array($section['slug'], ['courier-payables', 'courier-payables-final'], true) && empty($page))
@include('business.pages.courier-payables.final-workspace')
@elseif (!empty($content) && !empty($content['view']))
<section class="business-content-section" aria-label="{{ $activeContentTitle }}">

View File

@ -0,0 +1,46 @@
<?php
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Tests\Feature\FeatureTestCase;
class PayablesFinalEntriesTest extends FeatureTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail()
);
}
public function test_supplier_payables_final_entry_renders_the_existing_supplier_workspace(): void
{
$this->loginAs()
->get(route('business.pages.show', ['section' => 'supplier-payables-final']))
->assertOk()
->assertSee('data-supplier-workspace', false)
->assertSee('aria-label="供应商应付页面"', false)
->assertSee(route('business.pages.show', [
'section' => 'supplier-payables',
'page' => 'supplier-payables-report',
]), false)
->assertDontSee('class="business-blank-page"', false);
}
public function test_courier_payables_final_entry_renders_the_existing_courier_workspace(): void
{
$this->loginAs()
->get(route('business.pages.show', ['section' => 'courier-payables-final']))
->assertOk()
->assertSee('data-courier-final', false)
->assertSee('aria-label="快递应付子功能"', false)
->assertSee(route('business.pages.show', [
'section' => 'courier-payables',
'page' => 'courier-information',
]), false)
->assertDontSee('class="business-blank-page"', false);
}
}

View File

@ -16,14 +16,10 @@ class PayablesGroupTest extends TestCase
$slugs = array_column($grouped, 'slug');
$index = array_search('payable-items', $slugs, true);
$this->assertSame('store-receivables', $slugs[$index - 1]);
$this->assertCount(6, $grouped[$index]['sections']);
$this->assertSame(['供应商应付', '快递应付'], array_column(array_slice($grouped[$index]['sections'], 0, 2), 'title'));
$this->assertCount(8, $grouped[$index]['sections']);
$this->assertSame(
[],
array_intersect(
['supplier-payables-final', 'courier-payables-final'],
array_column($grouped[$index]['sections'], 'slug')
)
['供应商应付(终版)', '快递应付(终版)', '供应商应付', '快递应付'],
array_column(array_slice($grouped[$index]['sections'], 0, 4), 'title')
);
$this->assertContains('inventory-management', $slugs);
foreach ($grouped[$index]['sections'] as $section) {
@ -39,10 +35,10 @@ class PayablesGroupTest extends TestCase
$this->assertSame($allowed, $result[0]['sections']);
$this->assertSame([], ShowInAdmin::groupPayables([]));
$legacy = [
$finalEntries = [
['slug' => 'supplier-payables-final', 'title' => '供应商应付(终版)', 'pages' => []],
['slug' => 'courier-payables-final', 'title' => '快递应付(终版)', 'pages' => []],
];
$this->assertSame([], ShowInAdmin::groupPayables($legacy));
$this->assertSame($finalEntries, ShowInAdmin::groupPayables($finalEntries)[0]['sections']);
}
}