From fa0039534a4f5c8eb8515351d42a80d181f34500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Fri, 16 Oct 2026 20:11:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E4=BB=98=E6=AC=BE=E7=BB=88=E7=89=88?= =?UTF-8?q?=E8=B4=A7=E6=AC=BE=E5=AF=B9=E8=B4=A6=EF=BC=9A=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=8E=E8=A1=A8=E6=A0=BC=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=8C=E6=9C=AA=E5=8F=91=E5=87=BA=E3=80=8D=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 终版目录的货款对账页在现有字段后追加「未发出」(导入模板/表格/导入/编辑/导出同一套字段);基础目录的「未发出」是按来源数据计算的标记,保持不变。 --- .../Services/PayablesFinalRegistry.php | 19 +++++-- .../SupplierPayableFinalPagesTest.php | 56 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/modules/EcommerceFinance/Services/PayablesFinalRegistry.php b/modules/EcommerceFinance/Services/PayablesFinalRegistry.php index 583cfc62..440364d8 100644 --- a/modules/EcommerceFinance/Services/PayablesFinalRegistry.php +++ b/modules/EcommerceFinance/Services/PayablesFinalRegistry.php @@ -34,6 +34,11 @@ class PayablesFinalRegistry /** 所有终版导入模板都带“月份”列,方便按月导入和查看。 */ private const MONTH_FIELD = ['summary_month' => ['label' => '月份', 'type' => 'month']]; + /** 供应商应付(终版)在基础字段之后追加的列(只影响终版目录,基础目录的「未发出」另有口径)。 */ + private const SUPPLIER_EXTRA_FIELDS = [ + 'payment-reconciliation' => ['unsent' => ['label' => '未发出', 'type' => 'text']], + ]; + public function __construct( private readonly SupplierPayableMaintenanceRegistry $supplier, private readonly ProductPriceWorkbookImporter $productPrices, @@ -71,12 +76,14 @@ class PayablesFinalRegistry { $this->title($section, $dataset); - $fields = $section === self::SECTION_COURIER - ? $this->courier->fields($dataset) - : ($dataset === 'product-prices' - ? $this->productPrices->templateFields() - : $this->supplier->fields($dataset)); + if ($section === self::SECTION_COURIER) { + return self::MONTH_FIELD + $this->courier->fields($dataset); + } - return self::MONTH_FIELD + $fields; + $fields = $dataset === 'product-prices' + ? $this->productPrices->templateFields() + : $this->supplier->fields($dataset); + + return self::MONTH_FIELD + $fields + (self::SUPPLIER_EXTRA_FIELDS[$dataset] ?? []); } } diff --git a/tests/Feature/Business/SupplierPayableFinalPagesTest.php b/tests/Feature/Business/SupplierPayableFinalPagesTest.php index 83f7d20e..b0f1207b 100644 --- a/tests/Feature/Business/SupplierPayableFinalPagesTest.php +++ b/tests/Feature/Business/SupplierPayableFinalPagesTest.php @@ -72,6 +72,62 @@ class SupplierPayableFinalPagesTest extends FeatureTestCase } } + public function test_final_payment_reconciliation_template_adds_unsent_as_the_last_column(): void + { + $response = $this->loginAs() + ->get(route('business.supplier-payables-final.payment-reconciliation.template')) + ->assertOk() + ->assertHeader('content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + + $path = tempnam(sys_get_temp_dir(), 'caiwu-template') . '.xlsx'; + + try { + file_put_contents($path, $response->streamedContent()); + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path); + $header = $spreadsheet->getSheet(0)->rangeToArray('A1:Q1')[0]; + $spreadsheet->disconnectWorksheets(); + + $this->assertSame([ + '记录标识', '月份', '供应商', '货号', '商品编码', '规格名称', '数量', '单价', '金额', + '预估单价', '预估金额', '供应商商品编码', '备注', '仓库名称', '快递名称', '快递单号', '未发出', + ], $header); + } finally { + @unlink($path); + } + } + + public function test_final_payment_reconciliation_import_keeps_the_unsent_column(): void + { + $file = UploadedFile::fake()->createWithContent( + 'payment-reconciliation.csv', + "\xEF\xBB\xBF月份,供应商,货号,商品编码,规格名称,数量,单价,金额,预估单价,预估金额,供应商商品编码,备注,仓库名称,快递名称,快递单号,未发出\n" + . "2026-09,终版供应商,X-1,P-1,规格甲,2,10,20,9,18,SC-1,备注甲,华东仓,顺丰,SF-1,未发出\n", + ); + + $this->loginAs() + ->post(route('business.supplier-payables-final.payment-reconciliation.import'), ['import' => $file]) + ->assertStatus(302) + ->assertSessionHas('success', '导入完成:新增 1 条,更新 0 条。'); + + $this->assertDatabaseHas('supplier_payable_overrides', [ + 'company_id' => $this->company->id, + 'dataset' => 'final:supplier:payment-reconciliation', + ]); + + $this->loginAs() + ->get(route('business.pages.show', [ + 'section' => 'supplier-payables-final', + 'page' => 'payment-reconciliation', + ])) + ->assertOk() + ->assertSeeText('未发出') + ->assertSeeText('SF-1'); + + $export = $this->loginAs()->get(route('business.supplier-payables-final.payment-reconciliation.export')); + $export->assertOk(); + $this->assertStringContainsString('快递单号,未发出', $export->streamedContent()); + } + public function test_product_price_final_page_reuses_the_price_template_columns(): void { $this->loginAs() -- 2.47.2