feat(订单详情): 全额库存抵扣的行,「采购成本价」留空(该行没有缺口采购)
开发者 2026-10-15:「完全抵扣的话相当于就不存在采购成本价了,完全抵扣就不用出现采购成本价这列」。 规则:某行 **抵扣量 ≥ 计划量**(属全额库存抵扣)⇒ 「采购成本价」这一格**留空**; 非全额(部分抵扣 / 无抵扣)仍照常显示并可改价(那部分确实有缺口采购)。 与既有约定对称:**无抵扣 ⇒ 「抵扣成本价」留空**。 实现(`OrderDetailDeliveryNotePanel.tsx`): · 逐行回调派生 `isFullyStockCovered = cover_qty > 0 && cover_qty + 1e-9 >= quantity`; · 采购成本价格的条件由 `canEditPrice && rowEditable ? 输入框 : 文本` 改为 `isFullyStockCovered ? null : (canEditPrice && rowEditable ? … : …)`; · 为什么必须留空:全额抵扣行的 `cost_price` 会回退成**被抵扣批次的混合均价**,与右边 「抵扣成本价」重复显示同一个数(开发者截图中 2.00 / 5.00 两列同值就是这个原因)。 测试:`costColumns.contract.test.ts` 增 ②b —— `rowBlock` 必须含 `isFullyStockCovered ? null :`, 且派生条件含 `cover_qty > 0` 与 `cover_qty + 1e-9 >= (quantity || 0)`;①②③④④b⑤⑥ 原样保留。 验证:前端 tsc 0 error;前端 vitest 3 failed / 168 passed(171 文件)——3 个失败文件全部是既有基线,无新增(906 通过)。
This commit is contained in:
@@ -43,6 +43,14 @@ describe('订单详情:成本价拆「采购成本价 / 抵扣成本价」两
|
||||
expect(rowBlock).toContain("t('orders.detail.coverCostHint'");
|
||||
});
|
||||
|
||||
it('②b 全额库存抵扣的行:采购成本价格留空(该行没有缺口采购,别显示回退均价)', () => {
|
||||
// 开发者 2026-10-15:「完全抵扣的话相当于就不存在采购成本价了」
|
||||
expect(rowBlock).toContain('isFullyStockCovered ? null :');
|
||||
expect(panel).toContain('const isFullyStockCovered =');
|
||||
expect(panel).toMatch(/Number\(item\.cover_qty\) > 0/);
|
||||
expect(panel).toMatch(/Number\(item\.cover_qty\) \+ 1e-9 >= \(Number\(item\.quantity\) \|\| 0\)/);
|
||||
});
|
||||
|
||||
it('③ 无抵扣的行:抵扣格留空(既不显示 0 也不显示「—」)', () => {
|
||||
expect(rowBlock).toMatch(/item\.cover_unit_cost != null \? \([\s\S]*?\) : null\}/);
|
||||
});
|
||||
|
||||
@@ -634,6 +634,10 @@ export const OrderDetailDeliveryNotePanel: React.FC<OrderDetailDeliveryNotePanel
|
||||
) : null}
|
||||
{group.items.map((item) => {
|
||||
seq += 1;
|
||||
/** 该行是否**全额库存抵扣**(抵扣量 ≥ 计划量):是则「采购成本价」留空,见该格注释 */
|
||||
const isFullyStockCovered =
|
||||
Number(item.cover_qty) > 0 &&
|
||||
Number(item.cover_qty) + 1e-9 >= (Number(item.quantity) || 0);
|
||||
const displayName = withItemFlagsLabel(
|
||||
item.item_name || item.sku_name || '',
|
||||
flagLabels,
|
||||
@@ -846,9 +850,15 @@ export const OrderDetailDeliveryNotePanel: React.FC<OrderDetailDeliveryNotePanel
|
||||
</td>
|
||||
{showCostPrice ? (
|
||||
<>
|
||||
{/* 采购成本价:自采/备货口径;列表改价只影响这一列(开发者 2026-10-14 拆列) */}
|
||||
{/**
|
||||
* **采购成本价**:自采/备货(缺口)口径;列表改价只影响这一列(开发者 2026-10-14 拆列)。
|
||||
*
|
||||
* ⚠️ **全额库存抵扣的行,这一格留空**(开发者 2026-10-15:「完全抵扣的话相当于就不存在
|
||||
* 采购成本价了」)—— 该行整行都来自库存,压根没有缺口采购;显示出来的只会是抵扣那部分的
|
||||
* 均价回退值,与右边「抵扣成本价」重复。规则与「无抵扣 ⇒ 抵扣成本价留空」对称。
|
||||
*/}
|
||||
<td className="border border-slate-700 dark:border-slate-500 px-2 py-1.5 text-center tabular-nums w-24">
|
||||
{canEditPrice && rowEditable ? (
|
||||
{isFullyStockCovered ? null : canEditPrice && rowEditable ? (
|
||||
<OrderItemPriceInput
|
||||
price={Number(item.cost_price) || 0}
|
||||
onPriceChange={(cost_price) =>
|
||||
|
||||
Reference in New Issue
Block a user