-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpypos_with_file.py
More file actions
353 lines (258 loc) · 11.2 KB
/
pypos_with_file.py
File metadata and controls
353 lines (258 loc) · 11.2 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
import tkinter as tk
import pickle, os
import datetime as dt
today = dt.datetime.now()
today_str = today.strftime("%Y-%m-%d")
price_meal = {"김밥": 3000, "라면": 3500, "떡볶이": 5000, "튀김": 5000, "쫄면": 7000}
price_drink = {"콜라": 1000, "사이다": 1000, "환타": 1000, "레몬에이드": 3000, "자몽에이드": 3500}
# 결제내역 저장 리스트
paylog = []
# 테이블 정보 딕셔너리
table = {}
# 현재 처리 중인 테이블 번호
table_no = ""
# 테이블 선택
def table_select(tno):
global table_no
table_no = tno
print("table number:", tno)
label_table.configure(text="테이블 " + str(table_no))
frame5.pack_forget()
frame6.pack_forget()
print_order()
print_price()
show_meal()
# 테이블 보여줌
def show_table():
frame1.pack_forget()
frame2.pack_forget()
frame3.pack_forget()
frame4.pack_forget()
frame5.pack(fill="both", expand=True)
frame6.pack_forget()
# 식사 메뉴 보여줌
def show_meal():
btn_meal.configure(bg="yellow")
btn_drink.configure(bg="white")
frame4.pack_forget()
frame3.pack_forget()
frame6.pack_forget()
frame1.pack(fill="both", expand=True)
frame2.pack(fill="both", expand=True)
frame4.pack(fill="both", expand=True)
# 음료 메뉴 보여줌
def show_drink():
btn_meal.configure(bg="white")
btn_drink.configure(bg="yellow")
frame4.pack_forget()
frame2.pack_forget()
frame6.pack_forget()
frame1.pack(fill="both", expand=True)
frame3.pack(fill="both", expand=True)
frame4.pack(fill="both", expand=True)
# 식사 주문
def meal_add(m):
global price_meal, table, table_no, today_str
order_meal = table[table_no][0]
total_price = table[table_no][2]
if m not in price_meal:
print("입력한 메뉴가 존재하지 않습니다.")
this_price = price_meal.get(m)
total_price += this_price
if m in order_meal:
order_meal[m] = order_meal.get(m) + 1
else:
order_meal[m] = 1
table[table_no][0] = order_meal
table[table_no][2] = total_price
table[table_no][3] = today_str
print_order()
print_price()
for i in table:
print(table[i])
print()
# 음료 주문
def drink_add(m):
global price_drink, table, table_no
order_drink = table[table_no][1]
total_price = table[table_no][2]
if m not in price_drink:
print("입력한 메뉴가 존재하지 않습니다.")
this_price = price_drink.get(m)
total_price += this_price
if m in order_drink:
order_drink[m] = order_drink.get(m) + 1
else:
order_drink[m] = 1
table[table_no][1] = order_drink
table[table_no][2] = total_price
table[table_no][3] = today_str
print_order()
print_price()
for i in table:
print(table[i])
print()
# 주문내역 화면 출력
def print_order():
global table, table_no
order_meal = table[table_no][0]
order_drink = table[table_no][1]
tmp = ""
price_tmp = 0
for i in order_meal:
price_tmp = price_meal[i] * order_meal.get(i)
tmp = tmp + i + " X " + str(order_meal.get(i)) + " = " + str(price_tmp)+"\n"
for i in order_drink:
price_tmp = price_drink[i] * order_drink.get(i)
tmp = tmp + i + " X " + str(order_drink.get(i)) + " = " + str(price_tmp)+"\n"
text_1.delete('1.0', tk.END)
text_1.insert(tk.INSERT, tmp)
# 주문 완료
def order_end():
global table_no
table_no = ""
show_table()
# 상단 금액 출력
def print_price():
global table, table_no
total_price = table[table_no][2]
label_price.configure(text=str(total_price)+" 원")
# 금액 계산
def cal_pay(event):
global table, table_no
total_price = table[table_no][2]
label_price.configure(text=str(total_price)+" 원")
label_total2.configure(text=str(total_price)+" 원")
test = str(entry_pay.get())
if test == "":
pay = 0
else:
pay = int(test)
if pay > total_price:
jan = pay - total_price
label_jan2.configure(text=str(jan)+" 원")
else:
label_jan2.configure(text="0 원")
# 결제
def pay():
frame2.pack_forget()
frame3.pack_forget()
frame4.pack_forget()
frame6.pack(fill="both", expand=True)
cal_pay('')
# 결제 완료
def pay_end():
global table, table_no, paylog, entry_pay
paylog.append(table[table_no])
with open("pypos.pickle", "wb") as f:
pickle.dump(paylog, f)
table[table_no] = [{}, {}, 0, today_str, table_no]
table_no = ""
entry_pay.delete('0', tk.END)
frame6.pack_forget()
show_table()
today_result()
# 당일 매출 출력
def today_result():
global paylog, today_str
result = 0
for i in paylog:
if i[3] == today_str:
result += i[2]
print("{} 매출 실적: {}원".format(today_str, result))
if os.path.exists("pypos.pickle"):
with open("pypos.pickle", "rb") as f:
paylog = pickle.load(f)
for row in paylog:
print(row)
window = tk.Tk()
window.title("PyPOS Ver 0.1")
window.geometry("600x400+500+300")
window.resizable(False, False)
frame1 = tk.Frame(window, width="600", height="10")
# frame1.pack(fill="both")
frame5 = tk.Frame(window, width="600", height="10")
frame5.pack(fill="both", expand=True)
frame2 = tk.Frame(window, width="600")
# frame2.pack(fill="both", expand=True)
frame3 = tk.Frame(window, width="600")
# frame3.pack(fill="both", expand=True)
frame4 = tk.Frame(window, width="600", height="10")
# frame4.pack(fill="both", expand=True)
frame6 = tk.Frame(window, width="600")
# frame6.pack(fill="both", expand=True)
label_table = tk.Label(frame1, text="테이블번호 ", padx=10, pady=10, fg="red", font='Arial 15')
label_table.grid(row=0, column=0, padx=10, pady=10)
btn_meal = tk.Button(frame1, text="식사", padx="10", pady="10", bg="yellow", command=show_meal)
btn_meal.grid(row=0, column=1, padx=10, pady=10)
btn_drink = tk.Button(frame1, text="음료", padx="10", pady="10", bg="white", command=show_drink)
btn_drink.grid(row=0, column=2, padx=10, pady=10)
btn_end = tk.Button(frame1, text="주문종료", padx="10", pady="10", command=order_end)
btn_end.grid(row=0, column=3, padx=10, pady=10)
btn_pay = tk.Button(frame1, text="결제", padx="10", pady="10", command=pay)
btn_pay.grid(row=0, column=4, padx=10, pady=10)
label_price = tk.Label(frame1, text="0 원", width="10", padx=10, pady="10", fg="blue", font='Arial 15')
label_price.grid(row=0, column=5, padx="10", pady="10")
# 식사
btn_meal_1 = tk.Button(frame2, text="김밥\n(3000원)", padx="10", pady="10", width="10", command=lambda: meal_add('김밥'))
btn_meal_1.grid(row=0, column=0, padx=10, pady=10)
btn_meal_2 = tk.Button(frame2, text="라면\n(3500원)", padx="10", pady="10", width="10", command=lambda: meal_add('라면'))
btn_meal_2.grid(row=0, column=1, padx=10, pady=10)
btn_meal_3 = tk.Button(frame2, text="떡볶이\n(5000원)", padx="10", pady="10", width="10", command=lambda: meal_add('떡볶이'))
btn_meal_3.grid(row=0, column=2, padx=10, pady=10)
btn_meal_4 = tk.Button(frame2, text="튀김\n(5000원)", padx="10", pady="10", width="10", command=lambda: meal_add('튀김'))
btn_meal_4.grid(row=0, column=3, padx=10, pady=10)
btn_meal_5 = tk.Button(frame2, text="쫄면\n(7000원)", padx="10", pady="10", width="10", command=lambda: meal_add('쫄면'))
btn_meal_5.grid(row=0, column=4, padx=10, pady=10)
# 음료
btn_drink_1 = tk.Button(frame3, text="콜라\n(1000원)", padx="10", pady="10", width="10", command=lambda: drink_add('콜라'))
btn_drink_1.grid(row=0, column=0, padx=10, pady=10)
btn_drink_2 = tk.Button(frame3, text="사이다\n(1000원)", padx="10", pady="10", width="10", command=lambda: drink_add('사이다'))
btn_drink_2.grid(row=0, column=1, padx=10, pady=10)
btn_drink_3 = tk.Button(frame3, text="환타\n(1000원)", padx="10", pady="10", width="10", command=lambda: drink_add('환타'))
btn_drink_3.grid(row=0, column=2, padx=10, pady=10)
btn_drink_4 = tk.Button(frame3, text="레몬에이드\n(3000원)", padx="10", pady="10", width="10", command=lambda: drink_add('레몬에이드'))
btn_drink_4.grid(row=0, column=3, padx=10, pady=10)
btn_drink_5 = tk.Button(frame3, text="자몽에이드\n(3500원)", padx="10", pady="10", width="10", command=lambda: drink_add('자몽에이드'))
btn_drink_5.grid(row=0, column=4, padx=10, pady=10)
# 테이블
btn_table_1 = tk.Button(frame5, text="테이블 1", padx="10", pady="10", width="10", command=lambda: table_select(1))
btn_table_1.grid(row=0, column=0, padx=20, pady=20)
btn_table_2 = tk.Button(frame5, text="테이블 2", padx="10", pady="10", width="10", command=lambda: table_select(2))
btn_table_2.grid(row=0, column=1, padx=20, pady=20)
btn_table_3 = tk.Button(frame5, text="테이블 3", padx="10", pady="10", width="10", command=lambda: table_select(3))
btn_table_3.grid(row=0, column=2, padx=20, pady=20)
btn_table_4 = tk.Button(frame5, text="테이블 4", padx="10", pady="10", width="10", command=lambda: table_select(4))
btn_table_4.grid(row=0, column=3, padx=20, pady=20)
btn_table_5 = tk.Button(frame5, text="테이블 5", padx="10", pady="10", width="10", command=lambda: table_select(5))
btn_table_5.grid(row=1, column=0, padx=20, pady=20)
btn_table_6 = tk.Button(frame5, text="테이블 6", padx="10", pady="10", width="10", command=lambda: table_select(6))
btn_table_6.grid(row=1, column=1, padx=20, pady=20)
btn_table_7 = tk.Button(frame5, text="테이블 7", padx="10", pady="10", width="10", command=lambda: table_select(7))
btn_table_7.grid(row=1, column=2, padx=20, pady=20)
btn_table_8 = tk.Button(frame5, text="테이블 8", padx="10", pady="10", width="10", command=lambda: table_select(8))
btn_table_8.grid(row=1, column=3, padx=20, pady=20)
# 주문 리스트
text_1 = tk.Text(frame4, height="10")
text_1.pack()
# 결제(금액, 내신돈, 받으실돈)
label_total = tk.Label(frame6, text="결제금액", padx=10, pady="3", font='Arial 15')
label_total.grid(row=0, column=0, padx="10", pady="3")
label_total2 = tk.Label(frame6, text="0원", padx=10, pady="3", font='Arial 15')
label_total2.grid(row=0, column=1, padx="10", pady="3")
label_pay = tk.Label(frame6, text="내신돈", padx=10, pady="3", font='Arial 15')
label_pay.grid(row=1, column=0, padx="10", pady="3")
entry_pay=tk.Entry(frame6, width=10, font='Arial 15')
entry_pay.insert('0', "")
entry_pay.bind("<Return>", cal_pay)
entry_pay.grid(row=1, column=1, padx="10", pady="3")
label_jan = tk.Label(frame6, text="받으실돈", padx=10, pady="3", font='Arial 15')
label_jan.grid(row=2, column=0, padx="10", pady="3")
label_jan2 = tk.Label(frame6, text="0원", padx=10, pady="10", font='Arial 15')
label_jan2.grid(row=2, column=1, padx="10", pady="3")
btn_payend = tk.Button(frame6, text="결제 완료", padx="10", pady="10", command=pay_end)
btn_payend.grid(row=3, column=0, padx=10, pady=10)
# 테이블 세팅
for i in range(1, 9):
table[i] = [{}, {}, 0, today_str, i]
window.mainloop()