user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); $service = Mockery::mock(ManagementExpensesPageData::class); $service->shouldReceive('page')->once()->andReturn([ 'view' => 'business.pages.financial-operations.management-expenses', 'pageTitle' => '管理费用', 'rows' => new LengthAwarePaginator([ [ 'business_id' => '202610301323000477793', 'originator_department' => '财务中心', 'store_name' => '天猫-测试店', 'purpose' => '测试用途', 'expense_category' => '管理费用', 'second_level' => '办公费', 'third_level' => '办公费用品', 'amount' => 100.0, 'fee_ratio' => '不进费比', 'allocation' => '分摊', ], ], 1, 50, 1), 'filters' => [ 'paid_month' => '2026-10', 'expense_category' => '', 'second_level' => '', 'third_level' => '', 'fee_ratio' => '', 'allocation' => '', 'business_id' => '', 'originator_department' => '', 'originator_name' => '', 'keyword' => '', ], 'summary' => [ 'amount_total' => 100.0, 'in_fee_ratio_amount' => 0.0, 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, 'row_count' => 1, 'approval_count' => 1, ], 'secondLevelSummary' => [[ 'expense_category' => '管理费用', 'second_level' => '办公费', 'in_fee_ratio_amount' => 0.0, 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, 'amount_total' => 100.0, 'row_count' => 1, 'approval_count' => 1, ]], 'thirdLevelSummary' => [[ 'expense_category' => '管理费用', 'second_level' => '办公费', 'third_level' => '办公费用品', 'in_fee_ratio_amount' => 0.0, 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, 'amount_total' => 100.0, 'row_count' => 1, 'approval_count' => 1, ]], 'options' => [ 'categories' => ['管理费用'], 'second_levels' => ['办公费'], 'third_levels' => ['办公费用品'], 'allocations' => ['分摊'], 'fee_ratios' => ManagementExpensesPageData::FEE_RATIO_OPTIONS, ], 'monthOptions' => ['2026-11' => '2026年11月', '2026-10' => '2026年10月'], 'perPageOptions' => ManagementExpensesPageData::PER_PAGE_OPTIONS, 'detailColumns' => ManagementExpensesPageData::DETAIL_COLUMNS, 'detailsUrl' => route( 'business.financial-operations.management-expenses.details', ['company_id' => company_id() ?: 1], ), 'storeSummaryUrl' => route( 'business.financial-operations.management-expenses.store-summary', ['company_id' => company_id() ?: 1], ), 'error' => null, ]); $this->app->instance(ManagementExpensesPageData::class, $service); $this->loginAs()->get(route('business.pages.show', [ 'section' => 'financial-operations', 'page' => 'management-expenses', ]))->assertOk() ->assertSee('管理费用') ->assertSee('二级汇总') ->assertSee('OA 已打款审批明细模板') ->assertSee('不涉及付款或出纳未打款的审批不计入汇总') ->assertSeeText('已打款金额(万元)') ->assertSeeText('进费比(万元)') ->assertSeeText('未映射金额(万元)') ->assertSeeText('合计金额(万元)') ->assertSeeText('审批未完成但已打款也纳入') ->assertSeeText('0.01') ->assertSeeText('100.00') ->assertSee('打款月份') ->assertSee('name="paid_month"', false) ->assertSee('2026年10月') ->assertSee('进费比') ->assertSee('不进费比') ->assertSee('是否分摊') ->assertSee('办公费用品') ->assertSee('天猫-测试店') ->assertSee('202610301323000477793') ->assertSee('data-me-open-group', false) ->assertSee('management-expenses-store-dialog', false) ->assertDontSee('data-me-open-stores', false) ->assertSee('detailsLoadedKey', false) ->assertSee('dialogBody.scrollTop = 0', false) ->assertDontSee('OA 已付款明细模板') ->assertDontSee('审批单 / 明细行') ->assertDontSee('审批单', false); } public function test_details_endpoint_returns_template_rows(): void { $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); $service = Mockery::mock(ManagementExpensesPageData::class); $service->shouldReceive('details')->once()->andReturn([ 'rows' => [[ 'business_id' => '202610301323000477793', 'originator_department' => '财务中心', 'store_name' => '天猫-测试店', 'purpose' => '测试用途', 'expense_category' => '管理费用', 'second_level' => '办公费', 'third_level' => '办公费用品', 'amount' => 100.0, 'fee_ratio' => '不进费比', 'allocation' => '分摊', ]], 'pagination' => ['current_page' => 1, 'last_page' => 1, 'per_page' => 50, 'total' => 1], 'summary' => [ 'amount_total' => 100.0, 'in_fee_ratio_amount' => 0.0, 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, 'row_count' => 1, 'approval_count' => 1, ], ]); $this->app->instance(ManagementExpensesPageData::class, $service); $this->loginAs()->getJson(route('business.financial-operations.management-expenses.details')) ->assertOk() ->assertJsonPath('success', true) ->assertJsonPath('rows.0.business_id', '202610301323000477793') ->assertJsonPath('rows.0.store_name', '天猫-测试店') ->assertJsonPath('rows.0.fee_ratio', '不进费比') ->assertJsonPath('pagination.total', 1); } public function test_store_summary_endpoint_returns_store_amounts(): void { $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); $service = Mockery::mock(ManagementExpensesPageData::class); $service->shouldReceive('storeSummary')->once()->andReturn([ 'rows' => [[ 'store_name' => '天猫-测试店', 'amount' => 100.0, 'row_count' => 1, 'approval_count' => 1, ]], 'total' => 100.0, ]); $this->app->instance(ManagementExpensesPageData::class, $service); $this->loginAs()->getJson(route('business.financial-operations.management-expenses.store-summary')) ->assertOk() ->assertJsonPath('success', true) ->assertJsonPath('rows.0.store_name', '天猫-测试店') ->assertJsonPath('total', 100); } }