添加市场

This commit is contained in:
liu
2026-08-20 15:39:39 +08:00
parent cd7007bc49
commit 22237a47e7
20 changed files with 134 additions and 239 deletions
+20 -17
View File
@@ -108,12 +108,14 @@ class ExportTest extends ProcurementTestCase
'cost_price' => '5.00',
'spec' => '10斤/箱',
'supplier_id' => $supplierA->id,
'market' => '新发地',
]);
$meat = ProductModel::factory()->create([
'status' => ProductModel::STATUS_ON,
'cost_price' => '20.00',
'spec' => '20斤/箱',
'supplier_id' => $supplierB->id,
'market' => '岳各庄',
]);
$this->actingAsMiniStore($storeA);
@@ -154,24 +156,25 @@ class ExportTest extends ProcurementTestCase
if ($rows->count() !== 8) {
return false;
}
// 列头含参考零售价与门店列
// 列头含市场/参考零售价与门店列(市场列在供应商后,门店列从索引 12 起)
$header = $rows[3];
if ($header[7] !== '参考零售价' || $header[11] !== $storeA->name || $header[12] !== $storeB->name) {
if ($header[4] !== '市场' || $header[8] !== '参考零售价' || $header[12] !== $storeA->name || $header[13] !== $storeB->name) {
return false;
}
// 蔬菜行:数量 2+3=5、金额 25、参考零售价 5÷10=0.50、门店列 2/3
// 蔬菜行:市场 新发地、数量 2+3=5、金额 25、参考零售价 5÷10=0.50、门店列 2/3
$vegRow = $rows->firstWhere(2, $veg->name);
if ($vegRow === null
|| (float) $vegRow[8] !== 5.0 || (float) $vegRow[10] !== 25.0
|| (float) $vegRow[7] !== 0.5
|| (float) $vegRow[11] !== 2.0 || (float) $vegRow[12] !== 3.0) {
|| $vegRow[4] !== '新发地'
|| (float) $vegRow[9] !== 5.0 || (float) $vegRow[11] !== 25.0
|| (float) $vegRow[8] !== 0.5
|| (float) $vegRow[12] !== 2.0 || (float) $vegRow[13] !== 3.0) {
return false;
}
// 无订货商品行:数量 0、参考零售价留空、门店列 0
$extraRow = $rows->firstWhere(2, $extra->name);
if ($extraRow === null
|| (float) $extraRow[8] !== 0.0 || $extraRow[7] !== ''
|| (float) $extraRow[11] !== 0.0) {
|| (float) $extraRow[9] !== 0.0 || $extraRow[8] !== ''
|| (float) $extraRow[12] !== 0.0) {
return false;
}
// 合计行:总数量 6、总金额 45、门店列合计 3/3
@@ -179,8 +182,8 @@ class ExportTest extends ProcurementTestCase
if ($total[2] !== '合计') {
return false;
}
return (float) $total[8] === 6.0 && (float) $total[10] === 45.0
&& (float) $total[11] === 3.0 && (float) $total[12] === 3.0;
return (float) $total[9] === 6.0 && (float) $total[11] === 45.0
&& (float) $total[12] === 3.0 && (float) $total[13] === 3.0;
}
);
}
@@ -234,12 +237,12 @@ class ExportTest extends ProcurementTestCase
if ($rows->count() !== 6) {
return false;
}
if ($rows[2] !== ['序号', '品名', '包规', '单位', '单价', '数量', '重量(斤)', '预计金额']) {
if ($rows[2] !== ['序号', '品名', '市场', '包规', '单位', '单价', '数量', '重量(斤)', '预计金额']) {
return false;
}
// 合计:数量 2+1=3,金额 10+20=30
$total = $rows->last();
return $total[1] === '合计' && (int) $total[5] === 3 && (float) $total[7] === 30.0;
return $total[1] === '合计' && (int) $total[6] === 3 && (float) $total[8] === 30.0;
}
);
}
@@ -294,23 +297,23 @@ class ExportTest extends ProcurementTestCase
if ($titles !== [$supplierA->name, $supplierB->name]) {
return false;
}
// 供应商甲:蔬菜 2+3=5 件、金额 5×5=25
// 供应商甲:蔬菜 2+3=5 件、金额 5×5=25(市场列在品名后)
$rowsA = $sheets[0]->collection()->values();
if ($rowsA[2] !== ['序号', '品名', '包规', '单位', '成本价', '数量', '重量(斤)', '金额']) {
if ($rowsA[2] !== ['序号', '品名', '市场', '包规', '单位', '成本价', '数量', '重量(斤)', '金额']) {
return false;
}
$vegRow = $rowsA->firstWhere(1, $veg->name);
if ($vegRow === null || (int) $vegRow[5] !== 5 || (float) $vegRow[7] !== 25.0) {
if ($vegRow === null || $vegRow[2] !== '新发地' || (int) $vegRow[6] !== 5 || (float) $vegRow[8] !== 25.0) {
return false;
}
$totalA = $rowsA->last();
if ($totalA[1] !== '合计' || (int) $totalA[5] !== 5 || (float) $totalA[7] !== 25.0) {
if ($totalA[1] !== '合计' || (int) $totalA[6] !== 5 || (float) $totalA[8] !== 25.0) {
return false;
}
// 供应商乙:肉 1 件、金额 20
$rowsB = $sheets[1]->collection()->values();
$meatRow = $rowsB->firstWhere(1, $meat->name);
return $meatRow !== null && (int) $meatRow[5] === 1 && (float) $meatRow[7] === 20.0;
return $meatRow !== null && $meatRow[2] === '岳各庄' && (int) $meatRow[6] === 1 && (float) $meatRow[8] === 20.0;
}
);
}