fix(代发导出): 未核算结算金额保留空白
This commit is contained in:
parent
7aff74d5f0
commit
dcf67ef58a
@ -162,7 +162,10 @@ final class DropshipExporter
|
||||
}
|
||||
if (in_array($r['status'], DropshipReconciler::PAYABLE, true)) {
|
||||
$billTotal = (float) $billTotal + (float) $r['bill'];
|
||||
$settleTotal = (float) $settleTotal + (float) ($r['final'] ?? $r['settle']);
|
||||
$final = $r['final'] ?? $r['settle'];
|
||||
if ($final !== null) {
|
||||
$settleTotal = (float) $settleTotal + (float) $final;
|
||||
}
|
||||
} elseif ($r['status'] === Category::LATER) {
|
||||
$label = Category::label(Category::LATER, (string) $r['status_month']);
|
||||
$extras[$label] = (float) ($extras[$label] ?? 0) + (float) $r['bill'];
|
||||
|
||||
@ -445,6 +445,36 @@ final class DropshipFreightTest extends FeatureTestCase
|
||||
@unlink($out);
|
||||
}
|
||||
|
||||
public function test_export_keeps_uncalculated_settlement_blank(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
$db = CourierBillMatcher::db();
|
||||
$factoryId = $db->table('dropship_factories')->insertGetId(['name' => '未核算测试厂家', 'warehouse' => self::WAREHOUSE,
|
||||
'keywords' => '测试快递', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$this->ship('UNCALCULATED0001', '测试快递', self::WAREHOUSE, '2026-11-03 09:00:00', 1, null);
|
||||
$input = $this->xlsx(['账单' => [['快递单号', '运费'], ['UNCALCULATED0001', 6]]]);
|
||||
$output = tempnam(sys_get_temp_dir(), 'uncalculated_export_');
|
||||
$book = null;
|
||||
try {
|
||||
$store = app(DropshipFreightStore::class);
|
||||
$store->uploadFor('未核算.xlsx', $input, '2026-11', $factoryId, '测试');
|
||||
$handle = fopen($output, 'wb');
|
||||
try {
|
||||
app(DropshipExporter::class)->export(collect($store->factories())->sole(), '2026-11', $handle);
|
||||
} finally {
|
||||
fclose($handle);
|
||||
}
|
||||
$book = \PhpOffice\PhpSpreadsheet\IOFactory::load($output);
|
||||
$this->assertSame('运费', (string) $book->getSheetByName('汇总')->getCell('A2')->getValue());
|
||||
$this->assertEquals(6, $book->getSheetByName('汇总')->getCell('B2')->getValue());
|
||||
$this->assertNull($book->getSheetByName('汇总')->getCell('C2')->getValue());
|
||||
} finally {
|
||||
$book?->disconnectWorksheets();
|
||||
@unlink($input);
|
||||
@unlink($output);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_keyword_helpers(): void
|
||||
{
|
||||
$this->assertSame('卿德客', DropshipFreightStore::warehouseCore('工厂-山东卿德客代发仓'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user