Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
|
|
|
| 5 |
|
| 6 |
# Function to initialize session state
|
| 7 |
def initialize_session_state():
|
|
@@ -12,10 +13,12 @@ def initialize_session_state():
|
|
| 12 |
def save_user_data(user_name, data):
|
| 13 |
st.session_state.data[user_name] = data
|
| 14 |
|
| 15 |
-
# Function to display saved records as a table
|
| 16 |
def display_saved_records():
|
| 17 |
st.title("Saved Records")
|
| 18 |
df = pd.DataFrame.from_dict(st.session_state.data, orient='index')
|
|
|
|
|
|
|
| 19 |
st.write(df)
|
| 20 |
|
| 21 |
# Save records to CSV
|
|
@@ -23,6 +26,8 @@ def display_saved_records():
|
|
| 23 |
folder_path = "data" # Folder name
|
| 24 |
os.makedirs(folder_path, exist_ok=True) # Create folder if it doesn't exist
|
| 25 |
file_path = os.path.join(folder_path, "records.csv")
|
|
|
|
|
|
|
| 26 |
df.to_csv(file_path, index=False)
|
| 27 |
|
| 28 |
st.download_button(
|
|
@@ -32,9 +37,28 @@ def display_saved_records():
|
|
| 32 |
mime="text/csv",
|
| 33 |
)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Initialize session state
|
| 36 |
initialize_session_state()
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
# User name & email id
|
| 39 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 40 |
|
|
@@ -46,7 +70,6 @@ plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(),
|
|
| 46 |
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 47 |
ordering_channels = st.sidebar.selectbox("Product lines", ["--please select--"]+a1, help="Select the ordering channels")
|
| 48 |
|
| 49 |
-
|
| 50 |
# Section 2: Company Info
|
| 51 |
st.sidebar.title("Section 2: Company Info")
|
| 52 |
company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
|
|
@@ -54,14 +77,13 @@ company_name = st.sidebar.text_input("Company Name", help="Enter the company nam
|
|
| 54 |
|
| 55 |
# Layer 1: Mapping of Ordering channels with Fulfilling location
|
| 56 |
if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
|
| 57 |
-
fulfilling_location =
|
| 58 |
application_id = None
|
| 59 |
else:
|
| 60 |
abc = ["Store", "Warehouse"]
|
| 61 |
fulfilling_location = st.sidebar.selectbox("Fulfilling Location", abc, help="Select the fulfilling location")
|
| 62 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 63 |
|
| 64 |
-
|
| 65 |
# Section 3: Defining products for each dropdown
|
| 66 |
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 67 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
|
@@ -71,7 +93,6 @@ chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delive
|
|
| 71 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 72 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 73 |
|
| 74 |
-
|
| 75 |
# Create a layout with two columns
|
| 76 |
col1, col2, col3 = st.columns([1, 3, 2])
|
| 77 |
|
|
@@ -81,14 +102,9 @@ with col1:
|
|
| 81 |
|
| 82 |
st.title(":violet[Plan maker]")
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
fee_config = {
|
| 89 |
-
|
| 90 |
'fee_type_mapping': {
|
| 91 |
-
|
| 92 |
"ONDC": ["Development","Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Marketing", "SLA"],
|
| 93 |
"GoFynd": ["Transaction","Logistics","Marketing", "Packaging", "SLA"],
|
| 94 |
"B2B": ["Development","Subscription","Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging"],
|
|
@@ -101,64 +117,45 @@ fee_config = {
|
|
| 101 |
"Catalog Cloud": ["Development","Subscription","Maintenance"],
|
| 102 |
"Uniket": ["Transaction","Logistics","Marketing","Packaging","SLA"],
|
| 103 |
"OMS": ["Development","Subscription","Maintenance", "Transaction", "Minimum Guarantee"]
|
| 104 |
-
|
| 105 |
-
}
|
| 106 |
}
|
| 107 |
|
| 108 |
-
var_config = {
|
| 109 |
-
|
| 110 |
'variable_type_mapping': {
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
}
|
| 125 |
|
| 126 |
char_config = {
|
| 127 |
-
|
| 128 |
'chargeable_on_mapping' :{
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
}
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
# 2nd layer: Mapping of Ordering channels with fee types
|
| 153 |
fee_type_mapping = fee_config['fee_type_mapping']
|
| 154 |
selected_fee_type = st.selectbox("Fee Type", ["--please select--"] + fee_type_mapping.get(ordering_channels, []), help="Select the type of fee")
|
| 155 |
|
| 156 |
-
|
| 157 |
# 3rd layer mapping: Mapping of Fee type with variables
|
| 158 |
variable_type_mapping = var_config["variable_type_mapping"]
|
| 159 |
selected_variable_type = st.selectbox("Variable Type", ["--please select--"] + variable_type_mapping.get(selected_fee_type, []), help="Select the type of variable")
|
| 160 |
|
| 161 |
-
|
| 162 |
# 4th layer mapping: Mapping of Fee type with variables
|
| 163 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 164 |
selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + chargeable_on_mapping.get(selected_variable_type, []), help="Select the type of Chargeable")
|
|
@@ -166,7 +163,6 @@ selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + c
|
|
| 166 |
# 5th layer: Mapping of fee types with variables and chargeable on
|
| 167 |
selected_fee_nature = st.selectbox("Fee Nature", ["--please select--"]+fee_nature_options, help="Select the fee nature")
|
| 168 |
|
| 169 |
-
|
| 170 |
if selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 171 |
user_input = st.number_input("Please enter Commerical value:", min_value=0.0, help="Enter a valid number")
|
| 172 |
elif selected_fee_nature == "Slab based":
|
|
@@ -175,10 +171,7 @@ elif selected_fee_nature == "Slab based":
|
|
| 175 |
df = pd.DataFrame(table_data, columns=["Column 1", "Column 2", "Column 3"])
|
| 176 |
st.write(df)
|
| 177 |
|
| 178 |
-
|
| 179 |
-
|
| 180 |
# 6th layer: Expected Billing
|
| 181 |
-
|
| 182 |
Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
|
| 183 |
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")
|
| 184 |
Product = Usage*user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
|
@@ -197,31 +190,34 @@ else:
|
|
| 197 |
|
| 198 |
st.write(f"Expected Billing: {expected_billing}")
|
| 199 |
|
| 200 |
-
|
| 201 |
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"]+plan_validity_options, help="Select the plan validity")
|
| 202 |
selected_payment_method = st.selectbox("Payment Method",["--please select--"]+payment_method_options, help="Select the payment method")
|
| 203 |
|
| 204 |
-
|
| 205 |
# Submit button
|
| 206 |
if st.button("Submit"):
|
| 207 |
# Save user data
|
| 208 |
user_data = {
|
| 209 |
-
"Company ID": company_id,
|
| 210 |
-
"Company Name": company_name,
|
| 211 |
-
"Application ID": application_id,
|
| 212 |
-
"Fulfilling Location": fulfilling_location,
|
| 213 |
"Plan Name": plan_name,
|
| 214 |
"Plan Description": plan_description,
|
| 215 |
"Plan Start Date": plan_start_date,
|
| 216 |
"Ordering Channels": ordering_channels,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
"Fee Type": selected_fee_type,
|
| 218 |
-
"Fee Nature": selected_fee_nature,
|
| 219 |
"Variable": selected_variable_type,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
"Plan Validity": selected_plan_validity,
|
| 221 |
"Payment Method": selected_payment_method,
|
| 222 |
}
|
| 223 |
save_user_data(user_name, user_data)
|
| 224 |
|
| 225 |
-
|
| 226 |
# Display saved records
|
| 227 |
display_saved_records()
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
import os
|
| 5 |
+
import configparser # For activating the config theme
|
| 6 |
|
| 7 |
# Function to initialize session state
|
| 8 |
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 |
st.write(df)
|
| 23 |
|
| 24 |
# Save records to CSV
|
|
|
|
| 26 |
folder_path = "data" # Folder name
|
| 27 |
os.makedirs(folder_path, exist_ok=True) # Create folder if it doesn't exist
|
| 28 |
file_path = os.path.join(folder_path, "records.csv")
|
| 29 |
+
|
| 30 |
+
# Save DataFrame to CSV without index
|
| 31 |
df.to_csv(file_path, index=False)
|
| 32 |
|
| 33 |
st.download_button(
|
|
|
|
| 37 |
mime="text/csv",
|
| 38 |
)
|
| 39 |
|
| 40 |
+
# Function to load theme configuration
|
| 41 |
+
def load_theme_config():
|
| 42 |
+
config = configparser.ConfigParser()
|
| 43 |
+
config.read('config.toml')
|
| 44 |
+
|
| 45 |
+
# Extract theme settings
|
| 46 |
+
theme_settings = config['theme']
|
| 47 |
+
return theme_settings
|
| 48 |
+
|
| 49 |
# Initialize session state
|
| 50 |
initialize_session_state()
|
| 51 |
|
| 52 |
+
theme_settings = load_theme_config()
|
| 53 |
+
|
| 54 |
+
# Apply theme settings to Streamlit
|
| 55 |
+
st.set_page_config(
|
| 56 |
+
page_title=":violet[Plan maker]",
|
| 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"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
# User name & email id
|
| 63 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 64 |
|
|
|
|
| 70 |
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 71 |
ordering_channels = st.sidebar.selectbox("Product lines", ["--please select--"]+a1, help="Select the ordering channels")
|
| 72 |
|
|
|
|
| 73 |
# Section 2: Company Info
|
| 74 |
st.sidebar.title("Section 2: Company Info")
|
| 75 |
company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
|
|
|
|
| 77 |
|
| 78 |
# Layer 1: Mapping of Ordering channels with Fulfilling location
|
| 79 |
if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
|
| 80 |
+
fulfilling_location = None
|
| 81 |
application_id = None
|
| 82 |
else:
|
| 83 |
abc = ["Store", "Warehouse"]
|
| 84 |
fulfilling_location = st.sidebar.selectbox("Fulfilling Location", abc, help="Select the fulfilling location")
|
| 85 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 86 |
|
|
|
|
| 87 |
# Section 3: Defining products for each dropdown
|
| 88 |
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 89 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
|
|
|
| 93 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 94 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 95 |
|
|
|
|
| 96 |
# Create a layout with two columns
|
| 97 |
col1, col2, col3 = st.columns([1, 3, 2])
|
| 98 |
|
|
|
|
| 102 |
|
| 103 |
st.title(":violet[Plan maker]")
|
| 104 |
|
| 105 |
+
# Mapping index
|
|
|
|
|
|
|
|
|
|
| 106 |
fee_config = {
|
|
|
|
| 107 |
'fee_type_mapping': {
|
|
|
|
| 108 |
"ONDC": ["Development","Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Marketing", "SLA"],
|
| 109 |
"GoFynd": ["Transaction","Logistics","Marketing", "Packaging", "SLA"],
|
| 110 |
"B2B": ["Development","Subscription","Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging"],
|
|
|
|
| 117 |
"Catalog Cloud": ["Development","Subscription","Maintenance"],
|
| 118 |
"Uniket": ["Transaction","Logistics","Marketing","Packaging","SLA"],
|
| 119 |
"OMS": ["Development","Subscription","Maintenance", "Transaction", "Minimum Guarantee"]
|
| 120 |
+
}
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
+
var_config = {
|
|
|
|
| 124 |
'variable_type_mapping': {
|
| 125 |
+
"Development": ["Application", "Extension", "Integration"],
|
| 126 |
+
"Subscription": ["Application", "Extension", "Integration"],
|
| 127 |
+
"Maintenance": ["Application", "Extension", "Integration"],
|
| 128 |
+
"Licensing": ["Store", "User"],
|
| 129 |
+
"Transaction": ["Bag", "Order", "Shipment"],
|
| 130 |
+
"Minimum Guarantee": ["Bag", "Order", "Shipment"],
|
| 131 |
+
"SLA": ["Bag", "Order", "Shipment"],
|
| 132 |
+
"Logistics":["Shipment"],
|
| 133 |
+
"Marketing":["Bag","Order"],
|
| 134 |
+
"Packaging":["Shipment"]
|
| 135 |
+
}
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
|
| 138 |
char_config = {
|
|
|
|
| 139 |
'chargeable_on_mapping' :{
|
| 140 |
+
"Application": ["Developed", "Installed"],
|
| 141 |
+
"Extension": ["Developed", "Installed"],
|
| 142 |
+
"Integration": ["Developed", "Installed"],
|
| 143 |
+
"Store": ["Added", "Active"],
|
| 144 |
+
"User": ["Added", "Active"],
|
| 145 |
+
"Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 146 |
+
"Order": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 147 |
+
"Shipment":["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO","Packed", "Cancel"]
|
| 148 |
+
}
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
# 2nd layer: Mapping of Ordering channels with fee types
|
| 152 |
fee_type_mapping = fee_config['fee_type_mapping']
|
| 153 |
selected_fee_type = st.selectbox("Fee Type", ["--please select--"] + fee_type_mapping.get(ordering_channels, []), help="Select the type of fee")
|
| 154 |
|
|
|
|
| 155 |
# 3rd layer mapping: Mapping of Fee type with variables
|
| 156 |
variable_type_mapping = var_config["variable_type_mapping"]
|
| 157 |
selected_variable_type = st.selectbox("Variable Type", ["--please select--"] + variable_type_mapping.get(selected_fee_type, []), help="Select the type of variable")
|
| 158 |
|
|
|
|
| 159 |
# 4th layer mapping: Mapping of Fee type with variables
|
| 160 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 161 |
selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + chargeable_on_mapping.get(selected_variable_type, []), help="Select the type of Chargeable")
|
|
|
|
| 163 |
# 5th layer: Mapping of fee types with variables and chargeable on
|
| 164 |
selected_fee_nature = st.selectbox("Fee Nature", ["--please select--"]+fee_nature_options, help="Select the fee nature")
|
| 165 |
|
|
|
|
| 166 |
if selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 167 |
user_input = st.number_input("Please enter Commerical value:", min_value=0.0, help="Enter a valid number")
|
| 168 |
elif selected_fee_nature == "Slab based":
|
|
|
|
| 171 |
df = pd.DataFrame(table_data, columns=["Column 1", "Column 2", "Column 3"])
|
| 172 |
st.write(df)
|
| 173 |
|
|
|
|
|
|
|
| 174 |
# 6th layer: Expected Billing
|
|
|
|
| 175 |
Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
|
| 176 |
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")
|
| 177 |
Product = Usage*user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
|
|
|
| 190 |
|
| 191 |
st.write(f"Expected Billing: {expected_billing}")
|
| 192 |
|
|
|
|
| 193 |
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"]+plan_validity_options, help="Select the plan validity")
|
| 194 |
selected_payment_method = st.selectbox("Payment Method",["--please select--"]+payment_method_options, help="Select the payment method")
|
| 195 |
|
|
|
|
| 196 |
# Submit button
|
| 197 |
if st.button("Submit"):
|
| 198 |
# Save user data
|
| 199 |
user_data = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
"Plan Name": plan_name,
|
| 201 |
"Plan Description": plan_description,
|
| 202 |
"Plan Start Date": plan_start_date,
|
| 203 |
"Ordering Channels": ordering_channels,
|
| 204 |
+
"Company ID": company_id,
|
| 205 |
+
"Company Name": company_name,
|
| 206 |
+
"Fulfilling Location": fulfilling_location,
|
| 207 |
+
"Application ID": application_id,
|
| 208 |
"Fee Type": selected_fee_type,
|
|
|
|
| 209 |
"Variable": selected_variable_type,
|
| 210 |
+
"Chargeable on": selected_chargeable_on,
|
| 211 |
+
"Fee Nature": selected_fee_nature,
|
| 212 |
+
"Commercial value": user_input,
|
| 213 |
+
"Usage limit": Usage,
|
| 214 |
+
"Minimum/Capping value": Capping_or_Minimum_Guarantee,
|
| 215 |
+
"Threshold option": threshold,
|
| 216 |
+
"Expected Billing": expected_billing,
|
| 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
|
| 223 |
display_saved_records()
|