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
97
98
99
100
101
102
103
ÿþlocal function trimFixedAmount(str, frontAmount, backAmount)
    -- ÀhågÂSpe    gHe'`
    if frontAmount < 0 or backAmount < 0 then
        error("Amount to trim must be non-negative")
    end
    -- ¡‹—{°e„vwËYŒTÓ~_g"}_
    local startIdx = frontAmount + 1
    local endIdx = #str - backAmount
    -- nxÝO"}_(WW[&{2N    gHeƒôV…Q
    if startIdx > endIdx then
        return ""  -- ‚Yœg*bd–TW[&{2N:Nzz ÿRԏÞVzzW[&{2N
    end
    -- ÔÞV*bd–T„vW[&{2N
    return str:sub(startIdx, endIdx)
end
--[[
   x: GT-Public-16
    Tðy: ºNå]¹pûQnxš[T
   \O€ÿZHR
   åegÿ2025-01-15
 
   ýQpeÿ AfterClickOk
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
require("GT_InAndOutboundPolicies")
function AfterClickOk( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_CNTR_CODE", "QTY")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local cntr_code = obj_attrs[1].value
    local cntr_qty = obj_attrs[2].value
    --ÂSpe!hŒš
    if (cntr_qty ~= nil and cntr_qty ~= '') then
        local qty = StrToNumber(cntr_qty)
        if qty < 0 or qty ~= math.floor(qty) then
            mobox.setInfo(strLuaDEID, "÷‹“eQcktepe!")
            return
        end
    elseif(cntr_qty == nil or cntr_qty == '') then
        mobox.setInfo(strLuaDEID, "peϑ Ný€:Nzz!")
        return
        end
    local trimmed = trimFixedAmount(cntr_code, 5, 6)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'trimmed', trimmed)
    local char1 = "R"
    local char2 = "p"
    if (trimmed == char1) then
        local qty = StrToNumber(cntr_qty)
        if qty > 1 then 
            mobox.setInfo(strLuaDEID,"ö€FhpeϑêSý€:N1ÿ")
            return
        end
    end
    if (trimmed == char2) then
        if qty > 7 then
        mobox.setInfo(strLuaDEID,"XbØvxØvpeϑ Ný€…Ç6*Nÿ")
        return
        end
    end
    --~b0Rzzå]ňir™e
    local item_code = "KGZ"
    local strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
    local Item_CG
    nRet, Item_CG = m3.GetDataObjByCondition(strLuaDEID, "Material", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "GetDataObjByCondition 1Y%!" .. Item_CG)
    end
    
    -- !hŒšå]ň/f&TÑ~š[ir™e
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
    local cntr_CG
    nRet, cntr_CG = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    if (nRet == 1) then
        --¹[hV'ÁTÑ~š[
        local cg_detail = m3.AllocObject(strLuaDEID, "CG_Detail")
        cg_detail.cntr_code = cntr_code
        cg_detail.item_merge = 'Y'  -- Tv^ir™eub Container_Good
        cg_detail.item_code = Item_CG.item_code
        cg_detail.item_name = Item_CG.item_name
        cg_detail.qty = cntr_qty
        cg_detail.uom = '*N'
        Debug(strLuaDEID, debug.getinfo(1), 'cg_detail', cg_detail)
        nRet, cg_detail = m3.CreateDataObj(strLuaDEID, cg_detail)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0¹[hV'ÁTfÆ~0ù[aŒ1Y%!' .. cg_detail) end
    elseif (nRet == 0) then
        mobox.setInfo(strLuaDEID,"å‹å]ňò]X[(W'ÁT!") return
    else
        lua.Error(strLuaDEID, debug.getinfo(1), 'GetDataObjByCondition1Y%!' .. cntr_CG)
    end
    
    mobox.setInfo(strLuaDEID,"Íd\ObŸR!")
end