ovrathi1 commited on
Commit
fbbcccc
·
verified ·
1 Parent(s): 4861411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -24
app.py CHANGED
@@ -267,11 +267,19 @@ def update_inventory_and_reservation(preferred, search_by, action, part_number=N
267
  else:
268
  return (f"Failed to upload inventory file. Inventory upload status: {inventory_status_code}, response: {inventory_response_text}.")
269
 
270
- def main(preferred, search_by, action, part_number=None, size=None, description=None, from_length=None, job_number=None, used_length=None, new_length=None, count=None):
271
- if used_length is not None:
272
- used_length = float(used_length) # Convert to float
273
- message = update_inventory_and_reservation(preferred, search_by, action, part_number, size, description, from_length, used_length, new_length, count, job_number)
274
- return message
 
 
 
 
 
 
 
 
275
 
276
  def reload_sheets():
277
  global inventory, reservation, activity_log, access_token, headers
@@ -427,26 +435,30 @@ with gr.Blocks() as demo:
427
  submit = gr.Button("Submit")
428
 
429
  def show_confirmation(preferred, search_by, action, part_number, size, description, from_length, job_number, used_length, new_length, count):
430
- if search_by == "Size and Description" and size and description:
431
- part_data = inventory[(inventory["Size"] == size) & (inventory["Description"] == description)]
432
- if not part_data.empty:
433
- part_number = part_data["Part Number"].values[0]
434
- elif search_by == "Part Number" and part_number:
435
- part_data = inventory[inventory["Part Number"] == part_number]
436
- if not part_data.empty:
437
- size = part_data["Size"].values[0]
438
- description = part_data["Description"].values[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
439
 
440
- if action == "Consume":
441
- message = f"Are you sure you want to consume {used_length} inches of {part_number} ({size} {description}) from a {from_length} inch sheet for job number {job_number}?"
442
- elif action == "Add":
443
- message = f"Are you sure you want to add {count} sheets of {new_length} inches to {part_number} ({size} {description})?"
444
- elif action == "Scrap":
445
- message = f"Are you sure you want to scrap {from_length} inch sheet of {part_number} ({size} {description})?"
446
-
447
- html_message = f"<div style='font-size: 30px;'>{message}</div>"
448
-
449
- return html_message, gr.update(visible=True)
450
 
451
  submit.click(
452
  fn=show_confirmation,
@@ -483,6 +495,7 @@ demo.launch()
483
 
484
 
485
 
 
486
 
487
 
488
 
 
267
  else:
268
  return (f"Failed to upload inventory file. Inventory upload status: {inventory_status_code}, response: {inventory_response_text}.")
269
 
270
+ def main(preferred, search_by, action, part_number, size, description, from_length, job_number, used_length, new_length, count):
271
+ if search_by == "Size and Description" and size and description:
272
+ part_data = inventory[(inventory["Size"] == size) & (inventory["Description"] == description)]
273
+ if not part_data.empty:
274
+ part_number = part_data["Part Number"].values[0]
275
+ elif search_by == "Part Number" and part_number:
276
+ part_data = inventory[inventory["Part Number"] == part_number]
277
+ if not part_data.empty:
278
+ size = part_data["Size"].values[0]
279
+ description = part_data["Description"].values[0]
280
+
281
+ message = update_inventory_and_reservation(preferred, search_by, action, part_number, size, description, from_length, used_length, new_length, count, job_number)
282
+ return message
283
 
284
  def reload_sheets():
285
  global inventory, reservation, activity_log, access_token, headers
 
435
  submit = gr.Button("Submit")
436
 
437
  def show_confirmation(preferred, search_by, action, part_number, size, description, from_length, job_number, used_length, new_length, count):
438
+ if search_by == "Size and Description" and size and description:
439
+ part_data = inventory[(inventory["Size"] == size) & (inventory["Description"] == description)]
440
+ if not part_data.empty:
441
+ part_number = part_data["Part Number"].values[0]
442
+ elif search_by == "Part Number" and part_number:
443
+ part_data = inventory[inventory["Part Number"] == part_number]
444
+ if not part_data.empty:
445
+ size = part_data["Size"].values[0]
446
+ description = part_data["Description"].values[0]
447
+
448
+ if action == "Consume":
449
+ message = f"Are you sure you want to consume {used_length} inches of {part_number} ({size} {description}) from a {from_length} inch sheet for job number {job_number}?"
450
+ elif action == "Add":
451
+ message = f"Are you sure you want to add {count} sheets of {new_length} inches to {part_number} ({size} {description})?"
452
+ elif action == "Scrap":
453
+ message = f"Are you sure you want to scrap {from_length} inch sheet of {part_number} ({size} {description})?"
454
+
455
+ html_message = f"<div style='font-size: 30px;'>{message}</div>"
456
+
457
+ return html_message, gr.update(visible=True), part_number
458
+
459
+
460
 
461
+
 
 
 
 
 
 
 
 
 
462
 
463
  submit.click(
464
  fn=show_confirmation,
 
495
 
496
 
497
 
498
+
499
 
500
 
501