'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); } }, };