售后金额
This commit is contained in:
@@ -19,7 +19,7 @@ class BillExportTest extends ProcurementTestCase
|
||||
{
|
||||
private static int $billSeq = 0;
|
||||
|
||||
/** 造一张账单(默认配送费 10、筐 2×5 + 托盘 1×20 = 附加 30、总额 140,未支付) */
|
||||
/** 造一张账单(默认配送费 10、筐 2×5 + 托盘 1×20 = 附加 30、售后 0、总额 140,未支付) */
|
||||
private function makeBill(StoreModel $store, array $attributes = []): BillModel
|
||||
{
|
||||
$seq = ++self::$billSeq;
|
||||
@@ -36,6 +36,7 @@ class BillExportTest extends ProcurementTestCase
|
||||
'box_price' => '5.00',
|
||||
'tray_price' => '20.00',
|
||||
'added_amount' => '30.00',
|
||||
'after_sale' => '0.00',
|
||||
'total_amount' => '140.00',
|
||||
'status' => BillModel::STATUS_UNPAID,
|
||||
], $attributes));
|
||||
@@ -70,7 +71,7 @@ class BillExportTest extends ProcurementTestCase
|
||||
$productB = ProductModel::factory()->create(['category_id' => $root->id]);
|
||||
|
||||
$bill1 = $this->makeBill($store);
|
||||
$bill2 = $this->makeBill($store);
|
||||
$bill2 = $this->makeBill($store, ['after_sale' => '-8.00']);
|
||||
// 同一商品跨账单:10×2.00 + 6×3.00 → 数量 16、金额 38.00、加权单价 2.37
|
||||
$this->makeItem($bill1, $productA, 10, '2.00');
|
||||
$this->makeItem($bill2, $productA, 6, '3.00');
|
||||
@@ -84,8 +85,8 @@ class BillExportTest extends ProcurementTestCase
|
||||
'门店账单_' . now()->format('Ymd_His') . '.xlsx',
|
||||
static function (BillExport $export) use ($productA, $productB): bool {
|
||||
$rows = $export->collection()->values();
|
||||
// 标题1 + 范围2 + 空行1 + 列头1 + 明细2 + 合计4 = 11 行
|
||||
if ($rows->count() !== 11) {
|
||||
// 标题1 + 范围2 + 空行1 + 列头1 + 明细2 + 合计5 = 12 行
|
||||
if ($rows->count() !== 12) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,7 +105,7 @@ class BillExportTest extends ProcurementTestCase
|
||||
}
|
||||
|
||||
$summary = $rows->slice(7)->values();
|
||||
// 合计:数量 20、商品金额 58.00;配送费 20.00;附加 60.00(筐 4 / 托盘 2);总金额 138.00
|
||||
// 合计:数量 20、商品金额 58.00;配送费 20.00;附加 60.00(筐 4 / 托盘 2);售后 -8.00;总金额 130.00
|
||||
if ((int) $summary[0][5] !== 20 || (float) $summary[0][7] !== 58.0) {
|
||||
return false;
|
||||
}
|
||||
@@ -114,8 +115,11 @@ class BillExportTest extends ProcurementTestCase
|
||||
if (! str_contains((string) $summary[2][0], '筐 4 个 / 周转托盘 2 个') || (float) $summary[2][7] !== 60.0) {
|
||||
return false;
|
||||
}
|
||||
if (! str_contains((string) $summary[3][0], '售后金额合计') || (float) $summary[3][7] !== -8.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (float) $summary[3][7] === 138.0;
|
||||
return (float) $summary[4][7] === 130.0;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -156,15 +160,15 @@ class BillExportTest extends ProcurementTestCase
|
||||
}
|
||||
|
||||
$summary = $rows->slice(6)->values();
|
||||
// 商品金额合计 20.00(仅蔬菜);配送费 10.00 / 附加 30.00 全额;总金额 60.00
|
||||
// 商品金额合计 20.00(仅蔬菜);配送费 10.00 / 附加 30.00 / 售后 0.00 全额;总金额 60.00
|
||||
if ((float) $summary[0][7] !== 20.0) {
|
||||
return false;
|
||||
}
|
||||
if ((float) $summary[1][7] !== 10.0 || (float) $summary[2][7] !== 30.0) {
|
||||
if ((float) $summary[1][7] !== 10.0 || (float) $summary[2][7] !== 30.0 || (float) $summary[3][7] !== 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (float) $summary[3][7] === 60.0;
|
||||
return (float) $summary[4][7] === 60.0;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -242,7 +246,7 @@ class BillExportTest extends ProcurementTestCase
|
||||
static function (BillExport $export): bool {
|
||||
$rows = $export->collection()->values();
|
||||
// 明细仅本店账单的 1 行(他店账单未混入)
|
||||
return $rows->count() === 10;
|
||||
return $rows->count() === 11;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user