65 lines
2.7 KiB
JavaScript
65 lines
2.7 KiB
JavaScript
import assert from "node:assert/strict";
|
||
|
||
import {
|
||
formatReturnDeliveryLineLabel,
|
||
formatReturnReworkItemLabel,
|
||
formatReturnTraceSummary
|
||
} from "../src/utils/returnTraceFormatters.js";
|
||
|
||
const deliveryLine = {
|
||
delivery_no: "DLV-NB-20260603-02600003-001",
|
||
customer_name: "比得金属有限公司",
|
||
product_code: "产品需规00091",
|
||
product_name: "钢制碗",
|
||
lot_no: "FGL-NB-20260602-产品需规00091-需规00091001-L01",
|
||
source_lot_no: "FGL-NB-20260602-产品需规00091-需规00091001-L01",
|
||
source_material_code: "原材料00002",
|
||
source_material_name: "5系钢板",
|
||
source_material_lot_no: "JH_5系钢板00002_0001",
|
||
source_material_sub_batch_no: "JH_5系钢板00002_0001",
|
||
returnable_qty: 150,
|
||
returnable_weight_kg: 75
|
||
};
|
||
|
||
const label = formatReturnDeliveryLineLabel(deliveryLine);
|
||
assert.equal(
|
||
label,
|
||
"比得金属有限公司 · 钢制碗 · 原材料00002 · 5系钢板 · JH_5系钢板00002_0001 · 可退 150 / 75 kg"
|
||
);
|
||
assert.doesNotMatch(label, /DLV/i, "delivery line option should not expose delivery document numbers");
|
||
assert.doesNotMatch(label, /FGL/i, "delivery line option should not expose finished stock lot numbers");
|
||
|
||
const summary = formatReturnTraceSummary(deliveryLine);
|
||
assert.equal(
|
||
summary,
|
||
"客户:比得金属有限公司;产品:钢制碗;原材料库存批次:原材料00002 · 5系钢板 · JH_5系钢板00002_0001;可退:150 / 75 kg"
|
||
);
|
||
assert.doesNotMatch(summary, /DLV/i, "return trace summary should not expose delivery document numbers");
|
||
assert.doesNotMatch(summary, /FGL/i, "return trace summary should not expose finished stock lot numbers");
|
||
|
||
console.log("return delivery line label checks passed");
|
||
|
||
const reworkItem = {
|
||
return_no: "RTN-NB-20260603-比得-001",
|
||
delivery_no: "DLV-NB-20260603-02600003-002",
|
||
product_code: "产品需规00091",
|
||
product_name: "钢制碗",
|
||
source_lot_no: "RTL-NB-20260603-0260603比得001-001",
|
||
source_material_code: "原材料00002",
|
||
source_material_name: "5系钢板",
|
||
source_material_lot_no: "JH_5系钢板00002_0001",
|
||
source_material_sub_batch_no: "JH_5系钢板00002_0001",
|
||
return_qty: 20,
|
||
return_weight_kg: 24
|
||
};
|
||
|
||
const reworkLabel = formatReturnReworkItemLabel(reworkItem);
|
||
assert.equal(
|
||
reworkLabel,
|
||
"钢制碗 · 原材料00002 · 5系钢板 · JH_5系钢板00002_0001 · 可返工 20 / 24 kg"
|
||
);
|
||
assert.doesNotMatch(reworkLabel, /RTN/i, "rework item option should not expose return document numbers");
|
||
assert.doesNotMatch(reworkLabel, /DLV/i, "rework item option should not expose delivery document numbers");
|
||
assert.doesNotMatch(reworkLabel, /RTL/i, "rework item option should not expose return warehouse internal lot numbers");
|
||
assert.match(reworkLabel, /JH_5系钢板00002_0001/, "rework item option should show raw-material stock lot number");
|