- 入库单、出库单控制器与模型(状态流转、审核、驳回换号、作废、删除约束) - 明细共用 stock_items:应/已数量、行级库存类型 ZP/CC、明细锁定 - lib/wms:单据类型常量(orderTypes)、奇门/openapi 客户端(qimenClient)、签名(sign) - 库存联动:utils/stock.js、utils/completeInbound.js(入库完成加库存,幂等) - 驳回换号:utils/rejectBillNo.js;旧 orders 模块同步调整 - 相关迁移:入库单 WMS 字段/审核/推送结果、明细计划与实际数量、单据类型落 WMS 编码、出库库存扣减标记等
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 出入库明细(stock_items)增加「应 / 已」数量字段:
|
||
* - plan_in_qty 应入数量(入库明细,创建时取明细数量 quantity)
|
||
* - actual_in_qty 已入数量(入库明细,WMS 收货确认 entryorder.confirm 回推写入)
|
||
* - plan_out_qty 应出数量(出库明细,创建时取明细数量 quantity)
|
||
* - actual_out_qty 已出数量(出库明细,WMS 发货通知 notify.delivery 回推写入)
|
||
* 4 列默认 0,前端创建时不输入,由系统维护(应=明细数量,已=外部回推)。
|
||
*/
|
||
const TABLE = 'stock_items';
|
||
const COLUMNS = [ 'plan_in_qty', 'actual_in_qty', 'plan_out_qty', 'actual_out_qty' ];
|
||
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
const { DECIMAL } = Sequelize;
|
||
const comments = {
|
||
plan_in_qty: '应入数量(入库明细,默认取明细数量)',
|
||
actual_in_qty: '已入数量(入库明细,WMS 收货确认回推)',
|
||
plan_out_qty: '应出数量(出库明细,默认取明细数量)',
|
||
actual_out_qty: '已出数量(出库明细,WMS 发货回推)',
|
||
};
|
||
for (const c of COLUMNS) {
|
||
await queryInterface.addColumn(TABLE, c, {
|
||
type: DECIMAL(12, 3), allowNull: false, defaultValue: 0, comment: comments[c],
|
||
});
|
||
}
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
const cols = await queryInterface.describeTable(TABLE);
|
||
for (const c of COLUMNS) {
|
||
if (cols[c]) await queryInterface.removeColumn(TABLE, c);
|
||
}
|
||
},
|
||
};
|