--[[
|
编码: WMS-52-01
|
名称: 配盘明细- 删除后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterDataObjDelete
|
|
功能:
|
需要回退 CG_Detail 中的分配量,仓库/库区分配量
|
|
更改记录:
|
|
--]]
|
|
wms_base = require( "wms_base" )
|
|
function AfterDataObjDelete ( strLuaDEID )
|
local nRet, strRetInfo
|
local distribution_detail
|
|
nRet, distribution_detail = m3.GetSysCurEditDataObj( strLuaDEID, "Distribution_CNTR_Detail" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前删除对象属性失败! "..distribution_cntr ) end
|
|
-- 如果配盘明细已经分拣完成 状态 = 2,不需要继续后面的操作
|
if ( distribution_detail.b_state == 2 ) then return end
|
|
-- step1 业务来源这里扣减 累计配货数量
|
local strCondition
|
if ( distribution_detail.bs_type == "Shipping_Order" ) then
|
-- 业务来源是【发货单】
|
strCondition = "S_SHIPPING_NO = '"..distribution_detail.bs_no.."' AND N_ROW_NO = "..distribution_detail.bs_row_no
|
nRet, strRetInfo = mobox.decDataObjAccQty( strLuaDEID, "Shipping_Detail", strCondition, "F_ACC_D_QTY", distribution_detail.qty)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "decDataObjAccQty(Shipping_Detail)失败! "..strRetInfo ) end
|
elseif (distribution_detail.bs_type == "Outbound_Order" ) then
|
-- 业务来源是【出库单】
|
strCondition = "S_OO_NO = '"..distribution_detail.bs_no.."' AND N_ROW_NO = "..distribution_detail.bs_row_no
|
nRet, strRetInfo = mobox.decDataObjAccQty( strLuaDEID, "Outbound_Detail", strCondition, "F_ACC_D_QTY", distribution_detail.qty)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "decDataObjAccQty(Outbound_Detail)失败! "..strRetInfo ) end
|
end
|
|
-- step2 减 CG_Detail中的分配量
|
strCondition = "S_ID = '"..distribution_detail.cg_detail_id.."'"
|
nRet, strRetInfo = mobox.decDataObjAccQty( strLuaDEID, "CG_Detail", strCondition, "F_ALLOC_QTY", distribution_detail.qty)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "decDataObjAccQty(CG_Detail失败! "..strRetInfo ) end
|
|
-- step3 减仓库、库区分配量
|
local item = {
|
{
|
wh_code = distribution_detail.wh_code,
|
area_code = distribution_detail.area_code,
|
item_code = distribution_detail.item_code,
|
item_name = distribution_detail.item_name,
|
qty = distribution_detail.qty
|
}
|
}
|
lua.Debug( strLuaDEID, debug.getinfo(1), "配盘明细存储分配量取消", item )
|
|
local str_chg_qty_item = lua.table2str(item)
|
-- 10 减仓库分配量
|
nRet, strRetInfo = wms.wms_AddWHInventoryChange(strLuaDEID, 10, str_chg_qty_item )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_AddWHInventoryChange 失败! "..strRetInfo ) end
|
-- 11 减库区分配量
|
nRet, strRetInfo = wms.wms_AddWHInventoryChange(strLuaDEID, 11, str_chg_qty_item )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_AddWHInventoryChange 失败! "..strRetInfo ) end
|
end
|