Spaces:
Sleeping
Sleeping
Upload 7 files
Browse files- Fynd.png +0 -0
- Fynd_logo2.png +0 -0
- app.py +126 -48
- i.ipynb +1 -0
- requirements.txt +4 -1
Fynd.png
ADDED
|
Fynd_logo2.png
ADDED
|
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
| 5 |
-
import configparser # For activating the config
|
| 6 |
|
| 7 |
# Function to initialize session state
|
| 8 |
def initialize_session_state():
|
|
@@ -10,8 +10,8 @@ def initialize_session_state():
|
|
| 10 |
st.session_state.data = {}
|
| 11 |
|
| 12 |
# Function to save user data
|
| 13 |
-
def save_user_data(user_name,
|
| 14 |
-
st.session_state.data[user_name] =
|
| 15 |
|
| 16 |
# Function to generate PM_id
|
| 17 |
def generate_pm_id(user_data):
|
|
@@ -41,10 +41,9 @@ def generate_pm_id(user_data):
|
|
| 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.
|
| 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'
|
|
@@ -85,6 +84,7 @@ initialize_session_state()
|
|
| 85 |
|
| 86 |
theme_settings = load_theme_config()
|
| 87 |
|
|
|
|
| 88 |
# Apply theme settings to Streamlit
|
| 89 |
st.set_page_config(
|
| 90 |
page_title="Plan maker",
|
|
@@ -93,10 +93,11 @@ st.set_page_config(
|
|
| 93 |
initial_sidebar_state="auto", # "auto", "expanded", "collapsed"
|
| 94 |
)
|
| 95 |
|
| 96 |
-
|
| 97 |
-
user_name = st.sidebar.text_input("Enter your name:")
|
| 98 |
|
| 99 |
# Section 1: Plan Info
|
|
|
|
|
|
|
| 100 |
st.sidebar.title("Section 1: Plan Info")
|
| 101 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 102 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
|
@@ -121,18 +122,14 @@ else:
|
|
| 121 |
# Section 3: Defining products for each dropdown
|
| 122 |
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 123 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
| 124 |
-
fee_nature_options = ["Fixed %", "Flat currency","Slab based"]
|
| 125 |
variable_options = ["Bag", "Order", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
|
| 126 |
chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed"]
|
| 127 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 128 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 129 |
|
| 130 |
-
# Create a layout with two columns
|
| 131 |
-
col1, col2, col3 = st.columns([1, 3, 2])
|
| 132 |
-
|
| 133 |
# In the first column, display the image
|
| 134 |
-
|
| 135 |
-
st.image("Fynd copy.png", width=200)
|
| 136 |
|
| 137 |
st.title(":violet[Plan maker]")
|
| 138 |
|
|
@@ -194,43 +191,124 @@ selected_variable_type = st.selectbox("Variable Type", ["--please select--"] + v
|
|
| 194 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 195 |
selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + chargeable_on_mapping.get(selected_variable_type, []), help="Select the type of Chargeable")
|
| 196 |
|
| 197 |
-
#
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
-
|
| 201 |
-
user_input = st.number_input("Please enter Commerical value:", min_value=0.0, help="Enter a valid number")
|
| 202 |
-
elif selected_fee_nature == "Slab based":
|
| 203 |
-
st.write("Please input values for the 3x3 table:")
|
| 204 |
-
table_data = [[st.number_input(f"Row {i+1}, Column {j+1}", value=0, step=1) for j in range(3)] for i in range(3)]
|
| 205 |
-
df = pd.DataFrame(table_data, columns=["Column 1", "Column 2", "Column 3"])
|
| 206 |
-
st.write(df)
|
| 207 |
|
| 208 |
-
#
|
| 209 |
-
|
| 210 |
-
Capping_or_Minimum_Guarantee = st.number_input(f"Enter the Capping/Minimum Value for {selected_variable_type}", min_value = 0.0, help = "Enter the Capping/Minimum Gauarntee value")
|
| 211 |
-
Product = Usage*user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
| 212 |
|
| 213 |
-
abc = ['Capping value', 'Minimum Guarantee']
|
| 214 |
-
threshold = st.selectbox("Choose a threshold option:", ["--please select--"] + abc)
|
| 215 |
|
| 216 |
-
|
|
|
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
| 229 |
|
| 230 |
# Submit button
|
| 231 |
-
if st.button("Submit"):
|
| 232 |
# Save user data
|
| 233 |
-
|
| 234 |
"Plan Name": plan_name,
|
| 235 |
"Plan Description": plan_description,
|
| 236 |
"Plan Start Date": plan_start_date,
|
|
@@ -250,13 +328,13 @@ if st.button("Submit"):
|
|
| 250 |
"Expected Billing": expected_billing,
|
| 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 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
|
| 261 |
-
# Display saved records
|
| 262 |
-
display_saved_records()
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
| 5 |
+
import configparser # For activating the config
|
| 6 |
|
| 7 |
# Function to initialize session state
|
| 8 |
def initialize_session_state():
|
|
|
|
| 10 |
st.session_state.data = {}
|
| 11 |
|
| 12 |
# Function to save user data
|
| 13 |
+
def save_user_data(user_name, user_data):
|
| 14 |
+
st.session_state.data[user_name] = user_data
|
| 15 |
|
| 16 |
# Function to generate PM_id
|
| 17 |
def generate_pm_id(user_data):
|
|
|
|
| 41 |
pm_id = '_'.join(pm_id_parts) # Join parts with underscore
|
| 42 |
return pm_id
|
| 43 |
|
|
|
|
| 44 |
# Function to display saved records as a table and save to CSV
|
| 45 |
def display_saved_records():
|
| 46 |
+
st.write(":violet[Saved Records]")
|
| 47 |
df = pd.DataFrame.from_dict(st.session_state.data, orient='index')
|
| 48 |
df.reset_index(inplace=True) # Reset index to convert index (user_name) to a regular column
|
| 49 |
df.rename(columns={'index': 'User Name'}, inplace=True) # Rename the index column to 'User Name'
|
|
|
|
| 84 |
|
| 85 |
theme_settings = load_theme_config()
|
| 86 |
|
| 87 |
+
|
| 88 |
# Apply theme settings to Streamlit
|
| 89 |
st.set_page_config(
|
| 90 |
page_title="Plan maker",
|
|
|
|
| 93 |
initial_sidebar_state="auto", # "auto", "expanded", "collapsed"
|
| 94 |
)
|
| 95 |
|
| 96 |
+
|
|
|
|
| 97 |
|
| 98 |
# Section 1: Plan Info
|
| 99 |
+
st.sidebar.image('Fynd_logo2.png', width = 400)
|
| 100 |
+
user_name = st.sidebar.text_input("Enter your name:")
|
| 101 |
st.sidebar.title("Section 1: Plan Info")
|
| 102 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 103 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
|
|
|
| 122 |
# Section 3: Defining products for each dropdown
|
| 123 |
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 124 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
| 125 |
+
fee_nature_options = ["Fixed %", "Flat currency", "Slab based"]
|
| 126 |
variable_options = ["Bag", "Order", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
|
| 127 |
chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed"]
|
| 128 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 129 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 130 |
|
|
|
|
|
|
|
|
|
|
| 131 |
# In the first column, display the image
|
| 132 |
+
st.image("Fynd copy.png", width=200)
|
|
|
|
| 133 |
|
| 134 |
st.title(":violet[Plan maker]")
|
| 135 |
|
|
|
|
| 191 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 192 |
selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + chargeable_on_mapping.get(selected_variable_type, []), help="Select the type of Chargeable")
|
| 193 |
|
| 194 |
+
# Create an empty DataFrame with the desired column names
|
| 195 |
+
slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage","Capping/Min_Guarantee_value", "Threshold"])
|
| 196 |
+
|
| 197 |
+
selected_fee_nature = st.selectbox("Fee Nature:", ["Fixed %", "Flat currency", "Slab based"], key="fee_nature_select")
|
| 198 |
+
|
| 199 |
+
if selected_fee_nature == "Slab based":
|
| 200 |
+
st.write("Enter values for Slab based fee structure:")
|
| 201 |
+
|
| 202 |
+
# Input fields for user data
|
| 203 |
+
col1, col2 = st.columns([2, 2])
|
| 204 |
+
|
| 205 |
+
with col1:
|
| 206 |
+
slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
|
| 207 |
+
with col2:
|
| 208 |
+
max_value = st.text_input("Max value:", key="max_value_input")
|
| 209 |
+
with col1:
|
| 210 |
+
user_input = st.text_input("Commercial Value:", key="user_input")
|
| 211 |
+
with col2:
|
| 212 |
+
Usage = st.text_input("Usage:", key="Usage_input")
|
| 213 |
+
with col1:
|
| 214 |
+
Capping_or_Minimum_Guarantee= st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
|
| 215 |
+
with col2:
|
| 216 |
+
threshold = st.text_input("Threshold:", key="threshold_input")
|
| 217 |
+
|
| 218 |
+
# Function to add data to DataFrame
|
| 219 |
+
def add_data(slabs_df, slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 220 |
+
|
| 221 |
+
max_value = int(max_value) if max_value else None
|
| 222 |
+
user_input = int(user_input) if user_input else None
|
| 223 |
+
Usage = int(Usage) if Usage else None
|
| 224 |
+
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee) if Capping_or_Minimum_Guarantee else None
|
| 225 |
+
|
| 226 |
+
new_row = {
|
| 227 |
+
"Slab": slab,
|
| 228 |
+
"Max_value": max_value,
|
| 229 |
+
"Commercial_value": user_input,
|
| 230 |
+
"Usage": Usage,
|
| 231 |
+
"Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
|
| 232 |
+
"Threshold": threshold
|
| 233 |
+
}
|
| 234 |
+
new_row_df = pd.DataFrame([new_row])
|
| 235 |
+
slabs_df = pd.concat([slabs_df, new_row_df], ignore_index=True)
|
| 236 |
+
return slabs_df
|
| 237 |
+
|
| 238 |
+
# Button to add data
|
| 239 |
+
if st.button("Add Data", key="add_data_button"):
|
| 240 |
+
slabs_df = add_data(slabs_df, slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 241 |
+
|
| 242 |
+
# Display the updated DataFrame
|
| 243 |
+
st.write("Updated Slab Data:")
|
| 244 |
+
st.table(slabs_df)
|
| 245 |
+
|
| 246 |
+
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"] + plan_validity_options, help="Select the plan validity")
|
| 247 |
+
selected_payment_method = st.selectbox("Payment Method", ["--please select--"] + payment_method_options, help="Select the payment method")
|
| 248 |
+
|
| 249 |
+
# Submit button
|
| 250 |
+
if st.button("Submit"):
|
| 251 |
+
# Save user data
|
| 252 |
+
user_data = {
|
| 253 |
+
"Plan Name": plan_name,
|
| 254 |
+
"Plan Description": plan_description,
|
| 255 |
+
"Plan Start Date": plan_start_date,
|
| 256 |
+
"Ordering Channels": ordering_channels,
|
| 257 |
+
"Company ID": company_id,
|
| 258 |
+
"Company Name": company_name,
|
| 259 |
+
"Fulfilling Location": fulfilling_location,
|
| 260 |
+
"Application ID": application_id,
|
| 261 |
+
"Fee Type": selected_fee_type,
|
| 262 |
+
"Variable": selected_variable_type,
|
| 263 |
+
"Chargeable on": selected_chargeable_on,
|
| 264 |
+
"Fee Nature": selected_fee_nature,
|
| 265 |
+
"Commercial value": user_input,
|
| 266 |
+
"Usage limit": Usage,
|
| 267 |
+
"Minimum/Capping value": Capping_or_Minimum_Guarantee,
|
| 268 |
+
"Threshold option": threshold,
|
| 269 |
+
"Plan Validity": selected_plan_validity,
|
| 270 |
+
"Payment Method": selected_payment_method,
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
# Generate PM_id and add it to user_data
|
| 274 |
+
pm_id = generate_pm_id(user_data)
|
| 275 |
+
user_data['PM_id'] = pm_id
|
| 276 |
|
| 277 |
+
save_user_data(user_name, user_data) # Save user data after submission
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
+
# Display saved records
|
| 280 |
+
display_saved_records()
|
|
|
|
|
|
|
| 281 |
|
|
|
|
|
|
|
| 282 |
|
| 283 |
+
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 284 |
+
user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
|
| 285 |
|
| 286 |
+
# 6th layer: Expected Billing
|
| 287 |
+
Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
|
| 288 |
+
Capping_or_Minimum_Guarantee = st.number_input(f"Enter the Capping/Minimum Value for {selected_variable_type}", min_value=0.0, help="Enter the Capping/Minimum Gauarntee value")
|
| 289 |
+
Product = Usage * user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
| 290 |
+
|
| 291 |
+
abc = ['Capping value', 'Minimum Guarantee']
|
| 292 |
+
threshold = st.selectbox("Choose a threshold option:", ["--please select--"] + abc)
|
| 293 |
+
|
| 294 |
+
initial_expected_billing = Product
|
| 295 |
|
| 296 |
+
if threshold == 'Capping value':
|
| 297 |
+
expected_billing = Product if Capping_or_Minimum_Guarantee > Product else Capping_or_Minimum_Guarantee
|
| 298 |
+
elif threshold == 'Minimum Guarantee':
|
| 299 |
+
expected_billing = Product if Capping_or_Minimum_Guarantee < Product else Capping_or_Minimum_Guarantee
|
| 300 |
+
else:
|
| 301 |
+
expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
|
| 302 |
|
| 303 |
+
st.write(f"Expected Billing: {expected_billing}")
|
| 304 |
+
|
| 305 |
+
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"] + plan_validity_options, help="Select the plan validity")
|
| 306 |
+
selected_payment_method = st.selectbox("Payment Method", ["--please select--"] + payment_method_options, help="Select the payment method")
|
| 307 |
|
| 308 |
# Submit button
|
| 309 |
+
if st.button("Submit"):
|
| 310 |
# Save user data
|
| 311 |
+
user_data = {
|
| 312 |
"Plan Name": plan_name,
|
| 313 |
"Plan Description": plan_description,
|
| 314 |
"Plan Start Date": plan_start_date,
|
|
|
|
| 328 |
"Expected Billing": expected_billing,
|
| 329 |
"Plan Validity": selected_plan_validity,
|
| 330 |
"Payment Method": selected_payment_method,
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
# Generate PM_id and add it to user_data
|
| 334 |
+
pm_id = generate_pm_id(user_data)
|
| 335 |
+
user_data['PM_id'] = pm_id
|
| 336 |
+
|
| 337 |
+
save_user_data(user_name, user_data) # Save user data after submission
|
| 338 |
|
| 339 |
+
# Display saved records
|
| 340 |
+
display_saved_records()
|
i.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
print("Hello")
|
requirements.txt
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
altair==
|
| 2 |
attrs==23.2.0
|
| 3 |
blinker==1.8.2
|
| 4 |
cachetools==5.3.3
|
| 5 |
certifi==2024.6.2
|
| 6 |
charset-normalizer==3.3.2
|
| 7 |
click==8.1.7
|
|
|
|
| 8 |
gitdb==4.0.11
|
| 9 |
GitPython==3.1.43
|
| 10 |
google-api-core==2.19.0
|
|
@@ -41,6 +42,7 @@ 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
|
|
@@ -51,6 +53,7 @@ rsa==4.9
|
|
| 51 |
six==1.16.0
|
| 52 |
smmap==5.0.1
|
| 53 |
streamlit==1.35.0
|
|
|
|
| 54 |
tenacity==8.3.0
|
| 55 |
toml==0.10.2
|
| 56 |
toolz==0.12.1
|
|
|
|
| 1 |
+
altair==4.2.2
|
| 2 |
attrs==23.2.0
|
| 3 |
blinker==1.8.2
|
| 4 |
cachetools==5.3.3
|
| 5 |
certifi==2024.6.2
|
| 6 |
charset-normalizer==3.3.2
|
| 7 |
click==8.1.7
|
| 8 |
+
entrypoints==0.4
|
| 9 |
gitdb==4.0.11
|
| 10 |
GitPython==3.1.43
|
| 11 |
google-api-core==2.19.0
|
|
|
|
| 42 |
Pygments==2.18.0
|
| 43 |
pyparsing==3.1.2
|
| 44 |
python-dateutil==2.9.0.post0
|
| 45 |
+
python-decouple==3.8
|
| 46 |
pytz==2024.1
|
| 47 |
referencing==0.35.1
|
| 48 |
requests==2.32.3
|
|
|
|
| 53 |
six==1.16.0
|
| 54 |
smmap==5.0.1
|
| 55 |
streamlit==1.35.0
|
| 56 |
+
streamlit-aggrid==1.0.5
|
| 57 |
tenacity==8.3.0
|
| 58 |
toml==0.10.2
|
| 59 |
toolz==0.12.1
|