Spaces:
Build error
Build error
Upload 3 files
Browse files- app.py +41 -2
- config.toml +8 -1
- requirements.txt +20 -0
app.py
CHANGED
|
@@ -13,13 +13,47 @@ def initialize_session_state():
|
|
| 13 |
def save_user_data(user_name, data):
|
| 14 |
st.session_state.data[user_name] = data
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Function to display saved records as a table and save to CSV
|
| 17 |
def display_saved_records():
|
| 18 |
st.title("Saved Records")
|
| 19 |
df = pd.DataFrame.from_dict(st.session_state.data, orient='index')
|
| 20 |
df.reset_index(inplace=True) # Reset index to convert index (user_name) to a regular column
|
| 21 |
df.rename(columns={'index': 'User Name'}, inplace=True) # Rename the index column to 'User Name'
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Save records to CSV
|
| 25 |
if not df.empty:
|
|
@@ -53,7 +87,7 @@ theme_settings = load_theme_config()
|
|
| 53 |
|
| 54 |
# Apply theme settings to Streamlit
|
| 55 |
st.set_page_config(
|
| 56 |
-
page_title="
|
| 57 |
page_icon="Fynd copy.png", # Specify your own page icon
|
| 58 |
layout="centered", # "wide" or "centered"
|
| 59 |
initial_sidebar_state="auto", # "auto", "expanded", "collapsed"
|
|
@@ -217,6 +251,11 @@ if st.button("Submit"):
|
|
| 217 |
"Plan Validity": selected_plan_validity,
|
| 218 |
"Payment Method": selected_payment_method,
|
| 219 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
save_user_data(user_name, user_data)
|
| 221 |
|
| 222 |
# Display saved records
|
|
|
|
| 13 |
def save_user_data(user_name, data):
|
| 14 |
st.session_state.data[user_name] = data
|
| 15 |
|
| 16 |
+
# Function to generate PM_id
|
| 17 |
+
def generate_pm_id(user_data):
|
| 18 |
+
company_id = user_data.get('Company ID', '')
|
| 19 |
+
ordering_channels = user_data.get('Ordering Channels', '')
|
| 20 |
+
fulfilling_location = user_data.get('Fulfilling Location', '')
|
| 21 |
+
application_id = user_data.get('Application ID', '')
|
| 22 |
+
selected_fee_type = user_data.get('Fee Type', '')
|
| 23 |
+
selected_variable_type = user_data.get('Variable', '')
|
| 24 |
+
selected_chargeable_on = user_data.get('Chargeable on', '')
|
| 25 |
+
selected_fee_nature = user_data.get('Fee Nature', '')
|
| 26 |
+
threshold = user_data.get('Threshold option', '')
|
| 27 |
+
|
| 28 |
+
# Extract first 2 characters from each field
|
| 29 |
+
pm_id_parts = [
|
| 30 |
+
company_id[:2],
|
| 31 |
+
ordering_channels[:2],
|
| 32 |
+
fulfilling_location[:2],
|
| 33 |
+
application_id[:2],
|
| 34 |
+
selected_fee_type[:2],
|
| 35 |
+
selected_variable_type[:2],
|
| 36 |
+
selected_chargeable_on[:2],
|
| 37 |
+
selected_fee_nature[:2],
|
| 38 |
+
threshold[:2]
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
pm_id = '_'.join(pm_id_parts) # Join parts with underscore
|
| 42 |
+
return pm_id
|
| 43 |
+
|
| 44 |
+
|
| 45 |
# Function to display saved records as a table and save to CSV
|
| 46 |
def display_saved_records():
|
| 47 |
st.title("Saved Records")
|
| 48 |
df = pd.DataFrame.from_dict(st.session_state.data, orient='index')
|
| 49 |
df.reset_index(inplace=True) # Reset index to convert index (user_name) to a regular column
|
| 50 |
df.rename(columns={'index': 'User Name'}, inplace=True) # Rename the index column to 'User Name'
|
| 51 |
+
|
| 52 |
+
# Generate PM_id column
|
| 53 |
+
df['PM_id'] = df.apply(generate_pm_id, axis=1)
|
| 54 |
+
|
| 55 |
+
# Display DataFrame with increased height
|
| 56 |
+
st.write(df.style.set_table_attributes('style="font-size: 14px; line-height: 18px; width: auto; height: auto;"'))
|
| 57 |
|
| 58 |
# Save records to CSV
|
| 59 |
if not df.empty:
|
|
|
|
| 87 |
|
| 88 |
# Apply theme settings to Streamlit
|
| 89 |
st.set_page_config(
|
| 90 |
+
page_title="Plan maker",
|
| 91 |
page_icon="Fynd copy.png", # Specify your own page icon
|
| 92 |
layout="centered", # "wide" or "centered"
|
| 93 |
initial_sidebar_state="auto", # "auto", "expanded", "collapsed"
|
|
|
|
| 251 |
"Plan Validity": selected_plan_validity,
|
| 252 |
"Payment Method": selected_payment_method,
|
| 253 |
}
|
| 254 |
+
|
| 255 |
+
# Generate PM_id and add it to user_data
|
| 256 |
+
pm_id = generate_pm_id(user_data)
|
| 257 |
+
user_data['PM_id'] = pm_id
|
| 258 |
+
|
| 259 |
save_user_data(user_name, user_data)
|
| 260 |
|
| 261 |
# Display saved records
|
config.toml
CHANGED
|
@@ -1,5 +1,12 @@
|
|
| 1 |
[theme]
|
| 2 |
-
base="light"
|
| 3 |
primaryColor="#ea4141"
|
|
|
|
| 4 |
secondaryBackgroundColor="#d2b1f1"
|
| 5 |
textColor="#000000"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
[theme]
|
|
|
|
| 2 |
primaryColor="#ea4141"
|
| 3 |
+
backgroundColor="#ffffff"
|
| 4 |
secondaryBackgroundColor="#d2b1f1"
|
| 5 |
textColor="#000000"
|
| 6 |
+
font="sans serif"
|
| 7 |
+
base="light"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
requirements.txt
CHANGED
|
@@ -7,6 +7,18 @@ charset-normalizer==3.3.2
|
|
| 7 |
click==8.1.7
|
| 8 |
gitdb==4.0.11
|
| 9 |
GitPython==3.1.43
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
idna==3.7
|
| 11 |
Jinja2==3.1.4
|
| 12 |
jsonschema==4.22.0
|
|
@@ -15,19 +27,27 @@ markdown-it-py==3.0.0
|
|
| 15 |
MarkupSafe==2.1.5
|
| 16 |
mdurl==0.1.2
|
| 17 |
numpy==1.26.4
|
|
|
|
|
|
|
| 18 |
packaging==24.1
|
| 19 |
pandas==2.2.2
|
| 20 |
pillow==10.3.0
|
|
|
|
| 21 |
protobuf==4.25.3
|
| 22 |
pyarrow==16.1.0
|
|
|
|
|
|
|
| 23 |
pydeck==0.9.1
|
| 24 |
Pygments==2.18.0
|
|
|
|
| 25 |
python-dateutil==2.9.0.post0
|
| 26 |
pytz==2024.1
|
| 27 |
referencing==0.35.1
|
| 28 |
requests==2.32.3
|
|
|
|
| 29 |
rich==13.7.1
|
| 30 |
rpds-py==0.18.1
|
|
|
|
| 31 |
six==1.16.0
|
| 32 |
smmap==5.0.1
|
| 33 |
streamlit==1.35.0
|
|
|
|
| 7 |
click==8.1.7
|
| 8 |
gitdb==4.0.11
|
| 9 |
GitPython==3.1.43
|
| 10 |
+
google-api-core==2.19.0
|
| 11 |
+
google-auth==2.30.0
|
| 12 |
+
google-auth-oauthlib==1.2.0
|
| 13 |
+
google-cloud-bigquery==3.24.0
|
| 14 |
+
google-cloud-core==2.4.1
|
| 15 |
+
google-crc32c==1.5.0
|
| 16 |
+
google-resumable-media==2.7.1
|
| 17 |
+
googleapis-common-protos==1.63.1
|
| 18 |
+
grpcio==1.64.1
|
| 19 |
+
grpcio-status==1.62.2
|
| 20 |
+
gspread==6.1.2
|
| 21 |
+
httplib2==0.22.0
|
| 22 |
idna==3.7
|
| 23 |
Jinja2==3.1.4
|
| 24 |
jsonschema==4.22.0
|
|
|
|
| 27 |
MarkupSafe==2.1.5
|
| 28 |
mdurl==0.1.2
|
| 29 |
numpy==1.26.4
|
| 30 |
+
oauth2client==4.1.3
|
| 31 |
+
oauthlib==3.2.2
|
| 32 |
packaging==24.1
|
| 33 |
pandas==2.2.2
|
| 34 |
pillow==10.3.0
|
| 35 |
+
proto-plus==1.24.0
|
| 36 |
protobuf==4.25.3
|
| 37 |
pyarrow==16.1.0
|
| 38 |
+
pyasn1==0.6.0
|
| 39 |
+
pyasn1_modules==0.4.0
|
| 40 |
pydeck==0.9.1
|
| 41 |
Pygments==2.18.0
|
| 42 |
+
pyparsing==3.1.2
|
| 43 |
python-dateutil==2.9.0.post0
|
| 44 |
pytz==2024.1
|
| 45 |
referencing==0.35.1
|
| 46 |
requests==2.32.3
|
| 47 |
+
requests-oauthlib==2.0.0
|
| 48 |
rich==13.7.1
|
| 49 |
rpds-py==0.18.1
|
| 50 |
+
rsa==4.9
|
| 51 |
six==1.16.0
|
| 52 |
smmap==5.0.1
|
| 53 |
streamlit==1.35.0
|