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
ÿþ--[[
    x: GT-03-10
     Tðy: °ežX-¹pûQnxš[    c®”MR
    \O€ÿHAN  
    åegÿ2023-05-05
  
    ýQpeÿ BeforeClickOk
 
    ŸRý€:
       -- ·ƒÖSA0B0C0D å]MO„vň±{peϑ ÿ$R­e/}¡‹T/f&T…úQeg™e-N0R'peϑ
       -- QTY + F_ACC_PACK_QTY  > F_ACTUAL_QTY  —‰ÝOX[•
 
    ôf9e°‹U_:
    V2.0 LZH 2024-06-06 å]MO¾‹n:N12*N ÿ‚YœgpeϑX[(W\pe¹pR¥b•
    V2.1 LZH 2024-07-23 °s(Wň±{öNpe„v‚iõ_:NXbpe
    V2.2 LZH 2024-08-09 ÇÅˆ±{öNpe + /}¡‹Åˆ±{peϑ Ôkù[eQ“^USnc4Y„vXbØvpeϑ
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function BeforeClickOk ( strLuaDEID )
    local nRet, strRetInfo
 
    -- V2.0 îO9eå]MO:N12*N
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_ORDER_NO", "A_QTY", "B_QTY", "C_QTY", "D_QTY", "E_QTY", "F_QTY", "G_QTY", "H_QTY",
        "I_QTY", "J_QTY", "K_QTY", "L_QTY")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    lua.Debug( strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo )
    local obj_attrs = json.decode(strRetInfo)
    local order_no = obj_attrs[1].value -- eg™eUS÷S
    -- V2.0 pencÀhåg ÿ N&{T‰Bl„vhQ营b•Ðc:y ÿ“eQå]MOpeϑ:N\pebpeR¥b•
    local qty_a = lua.StrToNumber(obj_attrs[2].value)
    if qty_a < 0 or qty_a ~= math.floor(qty_a) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Aå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_b = lua.StrToNumber(obj_attrs[3].value)
    if qty_b < 0 or qty_b ~= math.floor(qty_b) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Bå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_c = lua.StrToNumber(obj_attrs[4].value)
    if qty_c < 0 or qty_c ~= math.floor(qty_c) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Cå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_d = lua.StrToNumber(obj_attrs[5].value)
    if qty_d < 0 or qty_d ~= math.floor(qty_d) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Då]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_e = lua.StrToNumber(obj_attrs[6].value)
    if qty_e < 0 or qty_e ~= math.floor(qty_e) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Eå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_f = lua.StrToNumber(obj_attrs[7].value)
    if qty_f < 0 or qty_f ~= math.floor(qty_f) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Få]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_g = lua.StrToNumber(obj_attrs[8].value)
    if qty_g < 0 or qty_g ~= math.floor(qty_g) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Gå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_h = lua.StrToNumber(obj_attrs[9].value)
    if qty_h < 0 or qty_h ~= math.floor(qty_h) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Hå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_i = lua.StrToNumber(obj_attrs[10].value)
    if qty_i < 0 or qty_i ~= math.floor(qty_i) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Iå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_j = lua.StrToNumber(obj_attrs[11].value)
    if qty_j < 0 or qty_j ~= math.floor(qty_j) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Jå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_k = lua.StrToNumber(obj_attrs[12].value)
    if qty_k < 0 or qty_k ~= math.floor(qty_k) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Kå]USpeϑ Ný€:N\pebpe! ")
    end
    local qty_l = lua.StrToNumber(obj_attrs[13].value)
    if qty_l < 0 or qty_l ~= math.floor(qty_l) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Lå]USpeϑ Ný€:N\pebpe! ")
    end
 
    local qty = qty_a + qty_b + qty_c + qty_d + qty_e + qty_f + qty_g + qty_h + qty_i + qty_j + qty_k + qty_l
 
    if (order_no == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "eQ“^US÷S Ný€:Nzz!")
    end
 
    -- ·ƒÖSeg™eUS÷SáOo` ÿ·ƒÖS F_ACC_PACK_QTY0F_ACTUAL_QTY
    local incoming_info
    nRet, incoming_info = m3.GetDataObjectByKey(strLuaDEID, "GT_Incoming_Info", "S_ORDER_NO", order_no)
 
    -- v2.2
    qty = qty + tonumber(incoming_info.acc_pack_qty)
    if (qty > tonumber(incoming_info.cntr_qty)) then
        lua.Error(strLuaDEID, debug.getinfo(1), "°e“eQ„vň±{peϑ+/}¡‹Åˆ±{peϑ…úQeQ“^USXbØvpeϑ!")
    end
end