两个「终版」目录(供应商应付(终版)、快递应付(终版))改为独立数据: 保留原有导入、导出、查询、重置、编辑按钮和导入模板,数据初始为空、按表独立存放, 不再借用基础目录的页面与数据。 - 终版目录拥有自己的同名子页面与横向页签 - 新增终版按表数据的独立导入/导出/模板/编辑接口(数据集键 final:<目录>:<页面>) - 供应商终版 13 个页面、快递终版 4 个页面已接入 - 终版导入模板统一增加“月份”列,记录标识列改为选填
110 lines
4.2 KiB
PHP
110 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use App\Models\Auth\Permission;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class CourierPayableFinalPagesTest extends FeatureTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->user->attachPermission(
|
|
Permission::where('name', 'read-admin-panel')->firstOrFail()
|
|
);
|
|
}
|
|
|
|
public function test_final_courier_table_keeps_toolbar_and_starts_empty(): void
|
|
{
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'courier-payables-final',
|
|
'page' => 'bookkeeping-details',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('导入')
|
|
->assertSeeText('导出')
|
|
->assertSeeText('查询')
|
|
->assertSeeText('重置')
|
|
->assertSeeText('编辑')
|
|
->assertSeeText('下载导入模板')
|
|
->assertSeeText('月份')
|
|
->assertSeeText('工单编号')
|
|
->assertSeeText('记账金额')
|
|
->assertSeeText('暂无数据,请点击“导入”上传本表数据。')
|
|
->assertSee('workspace/courier-payables-final/actions/bookkeeping-details/template', false);
|
|
}
|
|
|
|
public function test_final_courier_import_is_independent_from_the_supplier_final_table(): void
|
|
{
|
|
$file = UploadedFile::fake()->createWithContent(
|
|
'bookkeeping-details.csv',
|
|
"\xEF\xBB\xBF月份,发起时间,工单编号,发起人,记账金额,备注\n"
|
|
. "2026-09,2026-09-20 10:00:00,WO-FINAL-1,终版发起人,88.88,终版备注\n",
|
|
);
|
|
|
|
$this->loginAs()
|
|
->post(route('business.courier-payables-final.bookkeeping-details.import'), ['import' => $file])
|
|
->assertStatus(302)
|
|
->assertSessionHas('success', '导入完成:新增 1 条,更新 0 条。');
|
|
|
|
$this->assertDatabaseHas('supplier_payable_overrides', [
|
|
'company_id' => $this->company->id,
|
|
'dataset' => 'final:courier:bookkeeping-details',
|
|
]);
|
|
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'courier-payables-final',
|
|
'page' => 'bookkeeping-details',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('2026-09')
|
|
->assertSeeText('WO-FINAL-1')
|
|
->assertSeeText('终版发起人')
|
|
->assertDontSeeText('暂无数据,请点击“导入”上传本表数据。');
|
|
}
|
|
|
|
public function test_final_courier_export_returns_imported_rows(): void
|
|
{
|
|
$file = UploadedFile::fake()->createWithContent(
|
|
'compensation-details.csv',
|
|
"赔付日期,承运商,快递单号,赔付金额,赔付原因,备注\n"
|
|
. "2026-09-24,终版承运商,SF-FINAL-1,66,丢件,终版赔偿备注\n",
|
|
);
|
|
|
|
$this->loginAs()
|
|
->post(route('business.courier-payables-final.compensation-details.import'), ['import' => $file])
|
|
->assertStatus(302);
|
|
|
|
$export = $this->loginAs()->get(route('business.courier-payables-final.compensation-details.export'));
|
|
$export->assertOk();
|
|
$this->assertStringContainsString('SF-FINAL-1', $export->streamedContent());
|
|
|
|
$connection = DB::connection(config('database.supplier_payable_maintenance_connection'));
|
|
$recordKey = (string) $connection->table('supplier_payable_overrides')
|
|
->where('company_id', $this->company->id)
|
|
->where('dataset', 'final:courier:compensation-details')
|
|
->value('record_key');
|
|
|
|
$this->loginAs()
|
|
->patch(route('business.courier-payables-final.compensation-details.update', ['recordKey' => $recordKey]), [
|
|
'values' => ['carrier' => '编辑后的承运商'],
|
|
])
|
|
->assertStatus(302)
|
|
->assertSessionHas('success', '保存成功。');
|
|
|
|
$this->loginAs()
|
|
->get(route('business.pages.show', [
|
|
'section' => 'courier-payables-final',
|
|
'page' => 'compensation-details',
|
|
]))
|
|
->assertOk()
|
|
->assertSeeText('编辑后的承运商');
|
|
}
|
|
}
|