forked from rperez1989/CodeRevisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcedureNLqPProcessTask.txt
87 lines (67 loc) · 2.27 KB
/
ProcedureNLqPProcessTask.txt
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
======OBJECT = ProcedureNLqPProcessTask === NLq PProcess Task=====
=== RULES ===
parm(in: &LqTskId);
=== PROCEDURE SOURCE ===
/*
2016-02-25 DV Created
*/
//Get head data
for each //LqTsk
where LqTskId = &LqTskId
&ShippingStore = LqTskShStr
&ShippingUnit = LqTskShUnt
exit
endfor
//iterate task lines
for each //LqTskB
where LqTskId = &LqTskId
&AuxEAN = LqTskBEAN.Trim()
&TrcMessage.Description = '&AuxEAN = ' + &AuxEAN.ToString()
do 'trace'
do 'get_bookId_from_EAN'
if (&BkID <> 0)
//Markdown
if (LqTskBShNQ > 0 or LqTskBShUQ > 0)
//AdjReasons.LiquidationShipping
PAddAdjustment(&ShippingStore, &ShippingUnit, &BkID, LqTskBCls, LqTskBShNQ, LqTskBShUQ, AdjReasons.LiquidationShipping, '', &LqTskId, &LqTskId, '', Boolean.FALSE, &AdjustmentId)
endif
//Discrepancy
if (LqTskBRNQy <> LqTskBShNQ or LqTskBRUQy <> LqTskBShUQ)
//AdjReasons.LiquidationShippingDiscrepancy
&NewDiscrQty = LqTskBRNQy - LqTskBShNQ
&UsdDiscrQty = LqTskBRUQy - LqTskBShUQ
PAddAdjustment(&ShippingStore, &ShippingUnit, &BkID, LqTskBCls, &NewDiscrQty, &UsdDiscrQty, AdjReasons.LiquidationShippingDiscrepancy, '', &LqTskId, &LqTskId, '', Boolean.FALSE, &AdjustmentId)
endif
else
//Trace BkId Empty Error
&TrcMessage.Description = "Erro looking for BookID - EAN # " + &AuxEAN.Trim() + " - TaskId: " + &LqTskId.ToString().Trim()
do 'trace'
endif
endfor
//mark Task as shipped
//Get head data
for each //LqTsk
where LqTskId = &LqTskId
LqTskSts = TnfStatus.Completed
exit
endfor
commit
//-------------------------------------------------------- Subs -------------------------------------------------------------//
Sub 'get_bookId_from_EAN'
&BkID = 0
//&AuxEAN = &EAN.Trim()
&EANPre = Substr(&AuxEAN,1,3)
&lenght = Len(&AuxEAN)
&EANPos = Substr(&AuxEAN,4,&lenght) //Remove the first 3 digits
PPIGet29(&EanPre, Division.New, &ISBNPre) //Map the first 3 digits
&ISBN = &ISBNPre.Trim() + &EANPos.Trim()
&ISBN12 = substr(&ISBN, 1, 12)
&BkISBNPre = &ISBN12.ToNumeric()
&TrcMessage.Description = '&BkISBNPre = ' + &BkISBNPre.ToString()
do 'trace'
PBKGet21(&BkISBNPre, &BkID) //Get BookId
EndSub //get_bookId_from_EAN
Sub 'trace'
&TrcMessage.Type = MessageTypes.Error
PTraceLog(&Pgmname, &TrcMessage)
EndSub //trace