-
Notifications
You must be signed in to change notification settings - Fork 1
/
EOTHO.isl
226 lines (177 loc) · 9.98 KB
/
EOTHO.isl
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// This script is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This script is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Created by: Luke Calderon
// Version: 1.0
// Date: 29 July 2020
EVENT INQ:1
var discChkTtl:$5 //Decimal variable for total amount for discount
discChkTtl = 0 //Set the variable to 0
var discPerGst:$5 //Decimal variable for discount per guest
discPerGst = 0 //Zero the discount
var FiftyPercDisc:$5 //Decimal for the 50% discount calc
FiftyPercDisc = 0 //Set to 0
var maxDisc:$5 //Decimal for the max check discount (number of guests * £10)
maxDisc = 0 //Set to 0
var discRefInfo:A30 //String variable for ref info on Check
discRefInfo = "" //Blank it out
var validDays:A5 //List of valid days
validDays = "1,2,3" //Set to Monday, Tuesday and Wednesday
var currentDay:A1 //Current day number
currentDay = @WEEKDAY //Set to current day
var validMonths:A5 //List of valid months
validMonths = "8" //Set to August (month 8)
var currentMonth:A1 //Current month number
currentmonth = @MONTH //Set to current month
var i:N5 //Variable for check detail lines
//Check if the discount is valid today
if (instr(1, validDays, currentDay))
//Check to see if discount is valid this month
if (instr(1, validMonths, currentMonth))
//Discount is valid
else
exitwitherror "Discount is not valid this month!"
endif
//Check that the guest count is greater than 0
if (@GST > 0)
//Guest count is fine
else
exitwitherror "Guest count must be greater than 0 for this discount to apply"
endif
//Loop through check detail lines. Repeat elseif block for every discount itemiser you want to apply this to
for i = 1 to @NUMDTLT
//waitforclear "Number Detail Lines: ", @NUMDTLT //Debugging
if @dtl_type[i] = "M" and @dtl_dsci[i] = 1 //If it's a menu item, and has Food Discount Itemizer
//waitforclear "Item ", @dtl_name[i], " is applicable for discount"
discChkTtl = discChkTtl + @dtl_ttl[i]
elseif @dtl_type[i] = "M" and @dtl_dsci[i] = 12 //If it's a menu item, and has Non Alc Bev Discount Itemizer
//waitforclear "Item ", @dtl_name[i], " is applicable for discount"
discChkTtl = discChkTtl + @dtl_ttl[i]
endif
endfor
//Check if the discount has already been applied
for i = 1 to @NUMDTLT
if @dtl_type[i] = "T" and @dtl_objnum[i] = 8015 //If it's a tender line and object #8015
exitwitherror "Discount already applied!"
endif
endfor
//Show total applicable for discount an also number of guests
waitforclear "Total applicable for discount: ", discChkTtl, ". Number of Guests: ", @GST
//Check if 50% off is over the cap
discPerGst = discChkTtl / @GST //Calculate discount per guest (Discountable Check Total / Number of Guests)
FiftyPercDisc = (discChkTtl * 0.5) //50% Discount Calculation (Discountable Check Total * 0.5)
maxDisc = (@GST * 10.00) //Calculate maximum discount per guest (Number of Guests * £10.00)
//waitforclear "Discount per head: £", discPerGst //Debugging
//Is 50% discount over the £10 Cap? If not, use the 50% rule. Else use the £10 Cap Rule
if FiftyPercDisc <= maxDisc
discChkTtl = FiftyPercDisc
//waitforclear "Discount Rule 50% - Total Amount: £", discChkTtl //Debugging
discPerGst = discChkTtl / @GST
//format discRefInfo as "50% Discount - (", @GST, "x £", discPerGst, ")"
format discRefInfo as "50% Discount"
elseif discPerGst > 10.00
discPerGst = 10.00
discChkTtl = maxDisc
//waitforclear "Discount is £10 per person - Total Amount: £", discChkTtl //Debugging
//format discRefInfo as "£10 Discount - (", @GST, "x £10.00)"
format discRefInfo as "£10 Discount"
endif
//Search for the discount NLU 1002, then press enter, type the discount amount, press enter, type in the ref info, press enter
clearkybdmacro
//loadkybdmacro key(11,202), makekeys(8015), @KEY_ENTER, makekeys(discChkTtl), @KEY_ENTER
loadkybdmacro defkey("Payment", N:8015, A:"Cash:Cash"), makekeys(discChkTtl), @KEY_ENTER
else
exitwitherror "Discount is not valid today"
endif
ENDEVENT
//Use for debugging by assigning a SIM Inquiry key to EOTHO_Discount:2
EVENT INQ:2
var discChkTtl:$5 //Decimal variable for total amount for discount
discChkTtl = 0 //Set the variable to 0
var discPerGst:$5 //Decimal variable for discount per guest
discPerGst = 0 //Zero the discount
var FiftyPercDisc:$5 //Decimal for the 50% discount calc
FiftyPercDisc = 0 //Set to 0
var maxDisc:$5 //Decimal for the max check discount (number of guests * £10)
maxDisc = 0 //Set to 0
var discRefInfo:A30 //String variable for ref info on Check
discRefInfo = "" //Blank it out
var validDays:A5 //List of valid days
validDays = "1,2,3" //Set to Monday, Tuesday and Wednesday
var currentDay:A1 //Current day number
currentDay = @WEEKDAY //Set to current day
var validMonths:A5 //List of valid months
validMonths = "8" //Set to August (month 8)
var currentMonth:A1 //Current month number
currentmonth = @MONTH //Set to current month
var i:N5 //Variable for check detail lines
//Check if the discount is valid today
if (instr(1, validDays, currentDay))
//Check to see if discount is valid this month
if (instr(1, validMonths, currentMonth))
//Discount is valid
else
exitwitherror "Discount is not valid this month!"
endif
//Check that the guest count is greater than 0
if (@GST > 0)
//Guest count is fine
else
exitwitherror "Guest count must be greater than 0 for this discount to apply"
endif
//Loop through check detail lines. Repeat elseif block for every discount itemiser you want to apply this to
for i = 1 to @NUMDTLT
//waitforclear "Number Detail Lines: ", @NUMDTLT //Debugging
if @dtl_type[i] = "M" and @dtl_dsci[i] = 1 //If it's a menu item, and has Food Discount Itemizer
//waitforclear "Item ", @dtl_name[i], " is applicable for discount"
discChkTtl = discChkTtl + @dtl_ttl[i]
elseif @dtl_type[i] = "M" and @dtl_dsci[i] = 12 //If it's a menu item, and has Non Alc Bev Discount Itemizer
//waitforclear "Item ", @dtl_name[i], " is applicable for discount"
discChkTtl = discChkTtl + @dtl_ttl[i]
endif
endfor
//Check if the discount has already been applied
for i = 1 to @NUMDTLT
if @dtl_type[i] = "T" and @dtl_objnum[i] = 8015 //If it's a tender line and object #8015
exitwitherror "Discount already applied!"
endif
endfor
//Show total applicable for discount an also number of guests
waitforclear "Total applicable for discount: ", discChkTtl, ". Number of Guests: ", @GST
//Check if 50% off is over the cap
discPerGst = discChkTtl / @GST //Calculate discount per guest (Discountable Check Total / Number of Guests)
FiftyPercDisc = (discChkTtl * 0.5) //50% Discount Calculation (Discountable Check Total * 0.5)
maxDisc = (@GST * 10.00) //Calculate maximum discount per guest (Number of Guests * £10.00)
//waitforclear "Discount per head: £", discPerGst //Debugging
//Is 50% discount over the £10 Cap? If not, use the 50% rule. Else use the £10 Cap Rule
if FiftyPercDisc <= maxDisc
discChkTtl = FiftyPercDisc
//waitforclear "Discount Rule 50% - Total Amount: £", discChkTtl //Debugging
discPerGst = discChkTtl / @GST
//format discRefInfo as "50% Discount - (", @GST, "x £", discPerGst, ")"
format discRefInfo as "50% Discount"
elseif discPerGst > 10.00
discPerGst = 10.00
discChkTtl = maxDisc
//waitforclear "Discount is £10 per person - Total Amount: £", discChkTtl //Debugging
//format discRefInfo as "£10 Discount - (", @GST, "x £10.00)"
format discRefInfo as "£10 Discount"
endif
//Search for the discount NLU 1002, then press enter, type the discount amount, press enter, type in the ref info, press enter
clearkybdmacro
//loadkybdmacro key(11,202), makekeys(8015), @KEY_ENTER, makekeys(discChkTtl), @KEY_ENTER
loadkybdmacro defkey("Payment", N:8015, A:"Cash:Cash"), makekeys(discChkTtl), @KEY_ENTER
else
exitwitherror "Discount is not valid today"
endif
ENDEVENT