lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
ÿþ--[[
 x: GT-100-09
  Tðy: 007-6e'î]_“^X[Œte
 \O€: LZH
 eQãSýQpeÿInventoryAdjust
 ŸRý€ô‹f: ÇîvƉaSAm4l÷Sôf°e^\'`
 
     “eQpencÿ                                                                                        
    {    
    "serial_no": "xxx",    Am4l÷S
    "item_code": "xxx",    ir™ex
    "batch_no": "xxx",    yb!k÷S
    "qty": 1,    Œte„vpeϑ
    "wh_code": XXX,    ÓN“^x
    "remark1": "",  -- Yèl ‚f*g/T(u
    "remark2": "",  -- Yèl ‚f*g/T(u
    "remark3": "",  -- Yèl ‚f*g/T(u
    "remark4": ""   -- Yèl ‚f*g/T(u
    }    
 
    Yt;‘
    -- step1 ã‰g¥cãS O„v datajson ÂSpe
    -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
    -- step3 ÇAm4l÷S~beQ“^USLˆ ÿÇ6e'US÷S+6e'USLˆ÷SŒteeQ“^USnc4Y
    -- step4 ÇAm4l÷SŒteeQ“^USncLˆ
    -- step5 ÇAm4l÷SŒte¹[hV'ÁTfÆ~peϑ
 ØSôf†SòS:
 20250221 LZH V1.1 °ežX4*NY(uW[µk
 --]]
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
function InventoryAdjust(strLuaDEID)
    local strRetInfo
    -- step1 ·ƒÖS¥cãSpenc
    local nRet, in_date = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), '6e'î]_“^X[Œte NÑSÂSpe:', in_date)
 
    -- step2 $R­e/f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local serial_no = in_date.serial_no
    if (serial_no == nil or serial_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Am4l÷S Ný€:Nzz!") end
    local item_code = in_date.item_code
    local batch_no = in_date.batch_no
    local qty = tonumber(in_date.qty)
    local wh_code = in_date.wh_code
    -- V1.1 °ežXY(uW[µk
    local remark1 = in_date.remark1
    local remark2 = in_date.remark2
    local remark3 = in_date.remark3
    local remark4 = in_date.remark4
 
    -- step3 ÇAm4l÷S~beQ“^USLˆ ÿÇ6e'US÷S+6e'USLˆ÷SŒteeQ“^USnc4Y
    local strCondition = " S_SERIAL_NO = '" .. serial_no .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. strRetInfo)
    end
 
    local delivery_no = strRetInfo.delivery_no
    local delivery_row_no = strRetInfo.delivery_row_no
 
    local str = ''
    if (batch_no ~= nil and batch_no ~= '') then str = "S_BATCH_NO = '" .. batch_no .. "'," end
    if (item_code ~= nil and item_code ~= '') then str = str .. "S_ITEM_CODE = '" .. item_code .. "'," end
    if (wh_code ~= nil and wh_code ~= '') then str = str .. "S_WH_CODE = '" .. wh_code .. "'," end
 
    strCondition = "S_DELIVERY_NO = '" .. delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
    local strSetSQL_update = ""
    if (str ~= "") then
        strSetSQL_update = lua.trim_laster_char(str)
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Incoming_Info", strCondition, strSetSQL_update)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^nc4Y¶r`1Y%!" .. strRetInfo) end
    end
 
    -- step4 ÇAm4l÷SŒteeQ“^USncLˆ
    strSetSQL_update = ""
    if (qty ~= nil and qty ~= '') then strSetSQL_update = str .. "F_QTY = '" .. qty .. "'," end
    if (strSetSQL_update ~= "") then
        strSetSQL_update = lua.trim_laster_char(strSetSQL_update)
        lua.Debug(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USncLˆSQL:", strSetSQL_update)
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Label_Crad", strCondition, strSetSQL_update)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USncLˆ¶r`1Y%!" .. strRetInfo) end
    end
 
    -- step5 ÇAm4l÷SŒte¹[hV'ÁTfÆ~peϑ
    strCondition = " S_SERIAL_NO = '" .. serial_no .. "'"
    local cg_detail
    nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0¹[hV'ÁTfÆ~0áOo`1Y%!" .. cg_detail) end
    local cntr_qty = tonumber(cg_detail.qty)
    if (qty > 0) then cg_detail.qty = qty end
    nRet, strRetInfo = wms_cntr.CG_Detail_Update(strLuaDEID, cg_detail)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_cntr.CG_Detail_Update 1Y%!  " .. strRetInfo) end
end