fix: 收紧出库请求与汇总类型
This commit is contained in:
@@ -53,7 +53,7 @@ export namespace WmsIostorInvApi {
|
|||||||
export interface OutboundCreateReq {
|
export interface OutboundCreateReq {
|
||||||
billType: string; // 单据类型
|
billType: string; // 单据类型
|
||||||
storId: string; // 仓库标识
|
storId: string; // 仓库标识
|
||||||
bizDate: Dayjs | string; // 业务日期
|
bizDate: number; // 业务日期(毫秒时间戳)
|
||||||
remark?: string; // 备注
|
remark?: string; // 备注
|
||||||
details: OutboundDetail[]; // 出库单明细
|
details: OutboundDetail[]; // 出库单明细
|
||||||
}
|
}
|
||||||
@@ -61,19 +61,19 @@ export namespace WmsIostorInvApi {
|
|||||||
/** 可用库存 */
|
/** 可用库存 */
|
||||||
export interface AvailableInventory {
|
export interface AvailableInventory {
|
||||||
vehicleCode: string; // 箱号
|
vehicleCode: string; // 箱号
|
||||||
pcsn: string; // 批次
|
pcsn?: null | string; // 批次
|
||||||
materialId: string; // 物料标识
|
materialId: string; // 物料标识
|
||||||
materialCode: string; // 物料编码
|
materialCode: string; // 物料编码
|
||||||
materialName: string; // 物料名称
|
materialName?: null | string; // 物料名称
|
||||||
availableQty: number; // 可用数量
|
availableQty: number; // 可用数量
|
||||||
qtyUnitId: string; // 计量单位标识
|
qtyUnitId?: null | string; // 计量单位标识
|
||||||
qtyUnitName: string; // 计量单位名称
|
qtyUnitName?: null | string; // 计量单位名称
|
||||||
extCode: string; // 来源单据号
|
extCode?: null | string; // 来源单据号
|
||||||
extType: string; // 来源单据类型
|
extType?: null | string; // 来源单据类型
|
||||||
extDtlCode: string; // 来源单据明细号
|
extDtlCode?: null | string; // 来源单据明细号
|
||||||
storId: string; // 仓库标识
|
storId: string; // 仓库标识
|
||||||
storCode: string; // 仓库编码
|
storCode?: null | string; // 仓库编码
|
||||||
storName: string; // 仓库名称
|
storName?: null | string; // 仓库名称
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 可用库存分页请求 */
|
/** 可用库存分页请求 */
|
||||||
@@ -156,4 +156,3 @@ export function expandAvailableInventory(
|
|||||||
export function createOutbound(data: WmsIostorInvApi.OutboundCreateReq) {
|
export function createOutbound(data: WmsIostorInvApi.OutboundCreateReq) {
|
||||||
return requestClient.post<string>('/wms/iostor-inv/createOutbound', data);
|
return requestClient.post<string>('/wms/iostor-inv/createOutbound', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,16 @@ describe('summarizeDetails', () => {
|
|||||||
it('空明细返回零值', () => {
|
it('空明细返回零值', () => {
|
||||||
expect(summarizeDetails([])).toEqual({ detailCount: 0, totalWeight: 0 });
|
expect(summarizeDetails([])).toEqual({ detailCount: 0, totalWeight: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('忽略编辑态的空值和非法重量', () => {
|
||||||
|
expect(
|
||||||
|
summarizeDetails([
|
||||||
|
{ planQty: undefined },
|
||||||
|
{ planQty: '' },
|
||||||
|
{ planQty: 'invalid' },
|
||||||
|
{ planQty: Number.NaN },
|
||||||
|
{ planQty: null },
|
||||||
|
]),
|
||||||
|
).toEqual({ detailCount: 5, totalWeight: 0 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
export interface OutboundDetailLike {
|
export interface OutboundDetailLike {
|
||||||
planQty: number;
|
planQty?: null | number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 汇总出库明细数量和重量 */
|
/** 汇总出库明细数量和重量 */
|
||||||
export function summarizeDetails(details: OutboundDetailLike[]) {
|
export function summarizeDetails(details: OutboundDetailLike[]) {
|
||||||
return {
|
return {
|
||||||
detailCount: details.length,
|
detailCount: details.length,
|
||||||
totalWeight: details.reduce(
|
totalWeight: details.reduce((total, detail) => {
|
||||||
(total, detail) => total + Number(detail.planQty),
|
const planQty = Number(detail.planQty);
|
||||||
0,
|
return total + (Number.isFinite(planQty) ? planQty : 0);
|
||||||
),
|
}, 0),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user