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