alekhya1707 commited on
Commit
7068b71
·
verified ·
1 Parent(s): d36f82a

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +50 -0
  2. requirements.txt +1 -3
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import datetime
3
+
4
+ # Initialize session state
5
+ if "balance" not in st.session_state:
6
+ st.session_state.balance = 0
7
+ if "transactions" not in st.session_state:
8
+ st.session_state.transactions = []
9
+ if "multiple" not in st.session_state:
10
+ st.session_state.multiple = 5 # default multiple
11
+
12
+ # Function to calculate round-up
13
+ def round_up(transaction, multiple):
14
+ rounded = ((transaction + multiple - 1) // multiple) * multiple
15
+ savings = rounded - transaction
16
+ return rounded, savings
17
+
18
+ # App title
19
+ st.title("💰 Smart Round-Up Savings (User Controlled)")
20
+
21
+ st.markdown("*Choose your round-up multiple:*")
22
+ multiple = st.selectbox("Round to nearest:", [5, 10, 20, 50], index=[5,10,20,50].index(st.session_state.multiple))
23
+ st.session_state.multiple = multiple
24
+
25
+ # Transaction input
26
+ transaction = st.number_input("Enter transaction amount (₹):", min_value=1, step=1)
27
+
28
+ if st.button("Add Transaction"):
29
+ rounded, savings = round_up(transaction, st.session_state.multiple)
30
+ st.session_state.balance += savings
31
+ st.session_state.transactions.append(
32
+ {"amount": transaction, "rounded": rounded, "savings": savings, "date": datetime.date.today()}
33
+ )
34
+ st.success(f"Spent ₹{transaction} → Rounded to ₹{rounded} → Saved ₹{savings}")
35
+
36
+ # Show Smart Pot Balance
37
+ st.metric("💰 Smart Pot Balance", f"₹{st.session_state.balance}")
38
+
39
+ # Show transaction history
40
+ st.subheader("📜 Transaction History")
41
+ if st.session_state.transactions:
42
+ for t in reversed(st.session_state.transactions[-5:]):
43
+ st.write(f"🟢 ₹{t['amount']} → ₹{t['rounded']} (Saved ₹{t['savings']}) on {t['date']}")
44
+ else:
45
+ st.write("No transactions yet.")
46
+
47
+ # Monthly reminder simulation
48
+ if st.button("📅 New Month"):
49
+ st.info(f"Last month you saved ₹{st.session_state.balance} with multiples of ₹{st.session_state.multiple}.")
50
+ st.info("👉 Do you want to keep it the same, lower for less pressure, or increase for faster savings?")
requirements.txt CHANGED
@@ -1,3 +1 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit