Edgar Garcia commited on
Commit
d46e7da
·
unverified ·
2 Parent(s): c6b603d 749b8b9

Merge pull request #3 from evegarcianz/ingreso_v_egreso

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -36,12 +36,15 @@ def update_spend_from_image(img):
36
 
37
 
38
 
39
- def update_spend(concept, amount, description ,items_from_receipt=None):
40
  category=expense_classifier(concept)
41
  today = datetime.date.today()
42
-
 
 
 
43
  # Append a new row
44
- spreadsheet.append_row([str(today), concept,float(amount), description,category, items_from_receipt ])
45
 
46
  day_month, todays_amount, current_week_amount , fig, fig2, fig3=dataframe_process(spreadsheet)
47
  return category, day_month, todays_amount, current_week_amount , fig, fig2, fig3
@@ -65,6 +68,8 @@ with gr.Blocks() as demo:
65
  with gr.Tab("Entrada manual"):
66
  with gr.Row():
67
  concept = gr.Textbox(label="Cliente o Proveedor")
 
 
68
  with gr.Row():
69
  amount= gr.Textbox(label="Monto")
70
  with gr.Row():
@@ -94,7 +99,7 @@ with gr.Blocks() as demo:
94
  category_plot=gr.Plot()
95
 
96
 
97
- btn_manual.click(fn=update_spend, inputs=[concept, amount, description ,], outputs=[expense_class,ui_date, expenses_today,expenses_this_week,
98
  daily_plot,week_plot,category_plot])
99
 
100
  btn_image.click(fn=update_spend_from_image, inputs=[input_image], outputs=[expense_class,ui_date, expenses_today,expenses_this_week,
 
36
 
37
 
38
 
39
+ def update_spend(concept,ingreso_flag , amount, description ,items_from_receipt=None):
40
  category=expense_classifier(concept)
41
  today = datetime.date.today()
42
+ if ingreso_flag:
43
+ ingreso_o_egreso='ingreso'
44
+ else:
45
+ ingreso_o_egreso='egreso'
46
  # Append a new row
47
+ spreadsheet.append_row([str(today), concept,ingreso_o_egreso,float(amount), description,category, items_from_receipt ])
48
 
49
  day_month, todays_amount, current_week_amount , fig, fig2, fig3=dataframe_process(spreadsheet)
50
  return category, day_month, todays_amount, current_week_amount , fig, fig2, fig3
 
68
  with gr.Tab("Entrada manual"):
69
  with gr.Row():
70
  concept = gr.Textbox(label="Cliente o Proveedor")
71
+ with gr.Row():
72
+ ingreso_flag= gr.Checkbox(label="Ingreso", info="Es un ingreso? Marca la caja")
73
  with gr.Row():
74
  amount= gr.Textbox(label="Monto")
75
  with gr.Row():
 
99
  category_plot=gr.Plot()
100
 
101
 
102
+ btn_manual.click(fn=update_spend, inputs=[concept, ingreso_flag,amount, description ], outputs=[expense_class,ui_date, expenses_today,expenses_this_week,
103
  daily_plot,week_plot,category_plot])
104
 
105
  btn_image.click(fn=update_spend_from_image, inputs=[input_image], outputs=[expense_class,ui_date, expenses_today,expenses_this_week,