账单导出

This commit is contained in:
2026-11-01 16:17:12 +08:00
parent f91939f1f0
commit c73910ba74
8 changed files with 69 additions and 9 deletions
+12
View File
@@ -11,6 +11,7 @@ use App\Models\PurchaseOrderModel;
use App\Models\StoreModel;
use App\Models\StoreOrderItemModel;
use Maatwebsite\Excel\Facades\Excel;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
/**
* 门店账单导出:单账单合并明细 / 批量按门店分工作表 / 一级分类过滤 /
@@ -139,6 +140,17 @@ class BillExportTest extends ProcurementTestCase
);
}
/** 账单标题合并全部八列,避免标题受首列宽度限制 */
public function test_export_title_is_merged_across_all_columns(): void
{
$bill = $this->makeBill(StoreModel::factory()->create());
$sheet = (new Spreadsheet())->getActiveSheet();
(new BillExport($bill))->styles($sheet);
$this->assertArrayHasKey('A1:H1', $sheet->getMergeCells());
}
/** 批量导出:同一门店多账单的同商品与费用合并为一张表,不同门店拆分工作表 */
public function test_batch_export_groups_bills_by_store(): void
{
+17
View File
@@ -13,6 +13,7 @@ use App\Models\StoreOrderModel;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Facades\Excel;
use Modules\SystemTool\Services\SysSiteConfigService;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
/**
* 压回筐记录:周转筐/托盘跟账单走(生成账单时写入完整快照,只读);
@@ -243,6 +244,22 @@ class ContainerReturnTest extends ProcurementTestCase
);
}
/** 汇总导出标题按日期、门店及合计列的总宽度合并 */
public function test_export_title_is_merged_across_dynamic_columns(): void
{
$export = new ContainerReturnExport(
collect(),
[1 => '门店A', 2 => '门店B'],
'2026-08-01',
'2026-08-03',
);
$sheet = (new Spreadsheet())->getActiveSheet();
$export->styles($sheet);
$this->assertArrayHasKey('A1:D1', $sheet->getMergeCells());
}
/** 指定门店导出:仅所选门店成列,未选门店记录忽略;所选门店无记录整列填 0 */
public function test_export_filters_by_selected_stores(): void
{
+24
View File
@@ -216,6 +216,30 @@ class ExportTest extends ProcurementTestCase
$this->assertSame(45.0, (float) $total[11]);
}
/** 采购导出:标题按实际表格列合并,供应商备注区域随门店列数调整 */
public function test_export_titles_are_merged_across_table_columns(): void
{
[$purchase] = $this->buildPurchaseWithSuppliers();
$purchaseSheet = (new Spreadsheet())->getActiveSheet();
(new PurchaseOrderExport($purchase))->styles($purchaseSheet);
$this->assertArrayHasKey('A1:N1', $purchaseSheet->getMergeCells());
$storeSheet = (new Spreadsheet())->getActiveSheet();
(new PurchaseStoreExport($purchase))->sheets()[0]->styles($storeSheet);
$this->assertArrayHasKey('A1:I1', $storeSheet->getMergeCells());
$supplierSheets = (new PurchaseSupplierExport($purchase))->sheets();
$supplierSheetA = (new Spreadsheet())->getActiveSheet();
$supplierSheets[0]->styles($supplierSheetA);
$this->assertArrayHasKey('A1:C2', $supplierSheetA->getMergeCells());
$this->assertArrayHasKey('D1:E2', $supplierSheetA->getMergeCells());
$supplierSheetB = (new Spreadsheet())->getActiveSheet();
$supplierSheets[1]->styles($supplierSheetB);
$this->assertArrayHasKey('D1:D2', $supplierSheetB->getMergeCells());
}
/** 商品明细导出:范围=全部未删除商品(含下架)∪ 本采购单有订货商品;已删除且无订货的商品不导出 */
public function test_export_scope_includes_off_shelf_but_not_deleted(): void
{