hariqueen commited on
Commit
3f47d42
ยท
verified ยท
1 Parent(s): 2129e5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -7,7 +7,7 @@ import sys
7
  import re
8
  from io import StringIO
9
 
10
- def process_file(file_path, voucher_number):
11
  # ์ƒํƒœ ๋ฉ”์‹œ์ง€์™€ ๊ฒฐ๊ณผ๋ฅผ ํ•จ๊ป˜ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”
12
  status_message = ""
13
  output_file_path = None
@@ -15,8 +15,15 @@ def process_file(file_path, voucher_number):
15
  # ๋กœ๊ทธ๋ฅผ ์บก์ฒ˜ํ•˜๊ธฐ ์œ„ํ•œ StringIO ๊ฐ์ฒด
16
  log_capture = StringIO()
17
 
 
18
  if file_path is None:
19
  return None, "ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”."
 
 
 
 
 
 
20
 
21
  try:
22
  # ํ‘œ์ค€ ์ถœ๋ ฅ์„ ์บก์ฒ˜
@@ -36,8 +43,8 @@ def process_file(file_path, voucher_number):
36
  # ์ด๋ฏธ CSV ํŒŒ์ผ์ด๋ฉด ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
37
  input_path = file_path
38
 
39
- # ๋ฉ”์ธ ์ „์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ (์ „ํ‘œ๋ฒˆํ˜ธ ๋„˜๊ฒจ์ฃผ๊ธฐ)
40
- output_path = main.process_rental_company_with_voucher(input_path, voucher_number)
41
  output_file_path = output_path
42
 
43
  # ์„ฑ๊ณต ๋ฉ”์‹œ์ง€ ์ž‘์„ฑ
@@ -108,7 +115,7 @@ def process_file(file_path, voucher_number):
108
 
109
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
110
  with gr.Blocks() as demo:
111
- gr.Markdown("# ERP ์ž๋™ ์ „ํ‘œ ๋ณ€ํ™˜๊ธฐ\n\n์—…๋กœ๋“œํ•  ํŒŒ์ผ๊ณผ ์ „ํ‘œ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.")
112
 
113
  with gr.Row():
114
  file_input = gr.File(
@@ -116,10 +123,17 @@ with gr.Blocks() as demo:
116
  file_types=[".csv", ".xlsx"],
117
  type="filepath"
118
  )
 
 
119
  voucher_input = gr.Textbox(
120
- label="์ „ํ‘œ๋ฒˆํ˜ธ ์ž…๋ ฅ",
121
  placeholder="์˜ˆ: 20250427001"
122
  )
 
 
 
 
 
123
 
124
  with gr.Row():
125
  submit_btn = gr.Button("์ œ์ถœ", variant="primary")
@@ -137,14 +151,14 @@ with gr.Blocks() as demo:
137
  # ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
138
  submit_btn.click(
139
  fn=process_file,
140
- inputs=[file_input, voucher_input],
141
  outputs=[output_file, status_output]
142
  )
143
 
144
  clear_btn.click(
145
- fn=lambda: (None, "", ""),
146
  inputs=[],
147
- outputs=[file_input, voucher_input, status_output]
148
  )
149
 
150
  # ์‹œ์ž‘ ๋ฉ”์‹œ์ง€ ํ‘œ์‹œ
 
7
  import re
8
  from io import StringIO
9
 
10
+ def process_file(file_path, voucher_number, employee_number):
11
  # ์ƒํƒœ ๋ฉ”์‹œ์ง€์™€ ๊ฒฐ๊ณผ๋ฅผ ํ•จ๊ป˜ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”
12
  status_message = ""
13
  output_file_path = None
 
15
  # ๋กœ๊ทธ๋ฅผ ์บก์ฒ˜ํ•˜๊ธฐ ์œ„ํ•œ StringIO ๊ฐ์ฒด
16
  log_capture = StringIO()
17
 
18
+ # ์ž…๋ ฅ๊ฐ’ ๊ฒ€์ฆ
19
  if file_path is None:
20
  return None, "ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”."
21
+
22
+ if not voucher_number or not voucher_number.strip():
23
+ return None, "์ „ํ‘œ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
24
+
25
+ if not employee_number or not employee_number.strip():
26
+ return None, "์‚ฌ์›๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”. ์‚ฌ์›๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค."
27
 
28
  try:
29
  # ํ‘œ์ค€ ์ถœ๋ ฅ์„ ์บก์ฒ˜
 
43
  # ์ด๋ฏธ CSV ํŒŒ์ผ์ด๋ฉด ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
44
  input_path = file_path
45
 
46
+ # ๋ฉ”์ธ ์ „์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ (์ „ํ‘œ๋ฒˆํ˜ธ์™€ ์‚ฌ์›๋ฒˆํ˜ธ ๋„˜๊ฒจ์ฃผ๊ธฐ)
47
+ output_path = main.process_rental_company_with_voucher(input_path, voucher_number, employee_number)
48
  output_file_path = output_path
49
 
50
  # ์„ฑ๊ณต ๋ฉ”์‹œ์ง€ ์ž‘์„ฑ
 
115
 
116
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
117
  with gr.Blocks() as demo:
118
+ gr.Markdown("# ERP ์ž๋™ ์ „ํ‘œ ๋ณ€ํ™˜๊ธฐ\n\n์—…๋กœ๋“œํ•  ํŒŒ์ผ๊ณผ ์ „ํ‘œ๋ฒˆํ˜ธ, ์‚ฌ์›๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.")
119
 
120
  with gr.Row():
121
  file_input = gr.File(
 
123
  file_types=[".csv", ".xlsx"],
124
  type="filepath"
125
  )
126
+
127
+ with gr.Row():
128
  voucher_input = gr.Textbox(
129
+ label="์ „ํ‘œ๋ฒˆํ˜ธ ์ž…๋ ฅ (ํ•„์ˆ˜)",
130
  placeholder="์˜ˆ: 20250427001"
131
  )
132
+
133
+ employee_input = gr.Textbox(
134
+ label="์‚ฌ์›๋ฒˆํ˜ธ ์ž…๋ ฅ (ํ•„์ˆ˜)",
135
+ placeholder="์˜ˆ: 00616"
136
+ )
137
 
138
  with gr.Row():
139
  submit_btn = gr.Button("์ œ์ถœ", variant="primary")
 
151
  # ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
152
  submit_btn.click(
153
  fn=process_file,
154
+ inputs=[file_input, voucher_input, employee_input],
155
  outputs=[output_file, status_output]
156
  )
157
 
158
  clear_btn.click(
159
+ fn=lambda: (None, "", "", ""),
160
  inputs=[],
161
+ outputs=[file_input, voucher_input, employee_input, status_output]
162
  )
163
 
164
  # ์‹œ์ž‘ ๋ฉ”์‹œ์ง€ ํ‘œ์‹œ