|
|
@@ -5,6 +5,9 @@ import {
|
|
|
buildPlPlanListSpanMethod,
|
|
|
flattenPlanArchivePairRows,
|
|
|
flattenPlanListRows,
|
|
|
+ formatDashNumber,
|
|
|
+ getRowSideIoQty,
|
|
|
+ getRowSidePlanQty,
|
|
|
matchLoadProduct,
|
|
|
PL_DELIVERY_SPAN_PROPS,
|
|
|
PL_PLAN_SPAN_PROPS
|
|
|
@@ -189,3 +192,64 @@ describe('buildPlPlanListSpanMethod two-level', () => {
|
|
|
)
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+describe('row side qty helpers', () => {
|
|
|
+ it('reads load and delivery qtys from matched products', () => {
|
|
|
+ const rows = flattenPlanArchivePairRows([samplePlan()])
|
|
|
+ assert.equal(getRowSidePlanQty(rows[0], 'load'), 30)
|
|
|
+ assert.equal(getRowSidePlanQty(rows[0], 'delivery'), 20)
|
|
|
+ assert.equal(getRowSidePlanQty(rows[1], 'load'), 10)
|
|
|
+ assert.equal(getRowSidePlanQty(rows[1], 'delivery'), 8)
|
|
|
+ assert.equal(getRowSidePlanQty(rows[2], 'load'), 30)
|
|
|
+ assert.equal(getRowSidePlanQty(rows[2], 'delivery'), 12)
|
|
|
+ })
|
|
|
+
|
|
|
+ it('returns null and dash when qty is missing', () => {
|
|
|
+ const rows = flattenPlanArchivePairRows([samplePlan()])
|
|
|
+ const empty = { ...rows[0], loadProduct: undefined, deliveryProduct: undefined }
|
|
|
+ assert.equal(getRowSidePlanQty(empty, 'load'), null)
|
|
|
+ assert.equal(formatDashNumber(null), '—')
|
|
|
+ assert.equal(formatDashNumber(12), '12')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('maps IO qty by internal customer direction', () => {
|
|
|
+ const plan = samplePlan()
|
|
|
+ plan.load = {
|
|
|
+ ...plan.load,
|
|
|
+ customerName: '安徽云栋化工有限公司',
|
|
|
+ products: [
|
|
|
+ sp({
|
|
|
+ planProductId: 'pp-u',
|
|
|
+ productId: 'u',
|
|
|
+ productName: '尿素',
|
|
|
+ planQty: 30,
|
|
|
+ inboundQty: 1,
|
|
|
+ outboundQty: 28
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ plan.deliveries = [
|
|
|
+ {
|
|
|
+ seq: 1,
|
|
|
+ customerName: '宜昌磷肥厂',
|
|
|
+ products: [
|
|
|
+ sp({
|
|
|
+ planProductId: 'pp-u',
|
|
|
+ productId: 'u',
|
|
|
+ productName: '尿素',
|
|
|
+ planQty: 20,
|
|
|
+ inboundQty: 2,
|
|
|
+ outboundQty: 19
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ] as Plan['deliveries']
|
|
|
+ const rows = flattenPlanArchivePairRows([plan])
|
|
|
+ // 装货内部客户 → 出库列展示;数量仍读装货段 inboundQty
|
|
|
+ assert.equal(getRowSideIoQty(rows[0], 'load', 'outbound'), 1)
|
|
|
+ assert.equal(getRowSideIoQty(rows[0], 'load', 'inbound'), null)
|
|
|
+ // 送货外部客户 → 出库列展示;数量读送货段 outboundQty
|
|
|
+ assert.equal(getRowSideIoQty(rows[0], 'delivery', 'outbound'), 19)
|
|
|
+ assert.equal(getRowSideIoQty(rows[0], 'delivery', 'inbound'), null)
|
|
|
+ })
|
|
|
+})
|