- 入库单、出库单控制器与模型(状态流转、审核、驳回换号、作废、删除约束) - 明细共用 stock_items:应/已数量、行级库存类型 ZP/CC、明细锁定 - lib/wms:单据类型常量(orderTypes)、奇门/openapi 客户端(qimenClient)、签名(sign) - 库存联动:utils/stock.js、utils/completeInbound.js(入库完成加库存,幂等) - 驳回换号:utils/rejectBillNo.js;旧 orders 模块同步调整 - 相关迁移:入库单 WMS 字段/审核/推送结果、明细计划与实际数量、单据类型落 WMS 编码、出库库存扣减标记等
55 lines
2.6 KiB
JavaScript
55 lines
2.6 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 入库单 / 出入库明细 补充 WMS entryorder.create 所需的字段:
|
||
* - inbound_orders:采购单号、预期到货时间、物流信息、供应商编码、操作员编码、操作时间
|
||
* - stock_items:inventory_type(库存类型 ZP=正品 / CC=残次,对齐 WMS 入库单行级 inventoryType)
|
||
*/
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
const { STRING, DATE } = Sequelize;
|
||
|
||
await queryInterface.addColumn('inbound_orders', 'purchase_order_code', {
|
||
type: STRING(50), allowNull: true, comment: '采购单号(orderType=CGRK 时使用)',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'expect_start_time', {
|
||
type: DATE, allowNull: true, comment: '预期到货开始时间',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'expect_end_time', {
|
||
type: DATE, allowNull: true, comment: '最迟预期到货时间',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'logistics_code', {
|
||
type: STRING(50), allowNull: true, comment: '物流公司编码(WMS 标准编码,如 SF/YTO/ZTO)',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'logistics_name', {
|
||
type: STRING(200), allowNull: true, comment: '物流公司名称',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'express_code', {
|
||
type: STRING(50), allowNull: true, comment: '运单号',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'supplier_code', {
|
||
type: STRING(50), allowNull: true, comment: '供应商编码',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'operator_code', {
|
||
type: STRING(50), allowNull: true, comment: '操作员编码',
|
||
});
|
||
await queryInterface.addColumn('inbound_orders', 'operate_time', {
|
||
type: DATE, allowNull: true, comment: '操作时间',
|
||
});
|
||
|
||
await queryInterface.addColumn('stock_items', 'inventory_type', {
|
||
type: STRING(10), allowNull: false, defaultValue: 'ZP',
|
||
comment: '库存类型:ZP=正品 CC=残次(对齐 WMS 入库单行级 inventoryType)',
|
||
});
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
const cols = await queryInterface.describeTable('inbound_orders');
|
||
for (const c of [ 'purchase_order_code', 'expect_start_time', 'expect_end_time', 'logistics_code', 'logistics_name', 'express_code', 'supplier_code', 'operator_code', 'operate_time' ]) {
|
||
if (cols[c]) await queryInterface.removeColumn('inbound_orders', c);
|
||
}
|
||
const sCols = await queryInterface.describeTable('stock_items');
|
||
if (sCols.inventory_type) await queryInterface.removeColumn('stock_items', 'inventory_type');
|
||
},
|
||
};
|