Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -106,7 +106,7 @@ st.sidebar.title("Section 1: Plan Info")
|
|
| 106 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 107 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
| 108 |
plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
|
| 109 |
-
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 110 |
ordering_channels = st.sidebar.selectbox("Product lines", ["--please select--"]+a1, help="Select the ordering channels")
|
| 111 |
|
| 112 |
# Section 2: Company Info
|
|
@@ -120,11 +120,11 @@ if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" i
|
|
| 120 |
application_id = None
|
| 121 |
else:
|
| 122 |
abc = ["Store", "Warehouse"]
|
| 123 |
-
fulfilling_location = st.sidebar.selectbox("Fulfilling Location", abc, help="Select the fulfilling location")
|
| 124 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 125 |
|
| 126 |
# Section 3: Defining products for each dropdown
|
| 127 |
-
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud"]
|
| 128 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
| 129 |
fee_nature_options = ["Fixed %", "Flat currency", "Slab based"]
|
| 130 |
variable_options = ["Bag", "Order", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
|
|
@@ -158,7 +158,7 @@ fee_config = {
|
|
| 158 |
var_config = {
|
| 159 |
'variable_type_mapping': {
|
| 160 |
"Development": ["Application", "Extension", "Integration"],
|
| 161 |
-
"Subscription": ["Application", "Extension", "Integration"],
|
| 162 |
"Maintenance": ["Application", "Extension", "Integration"],
|
| 163 |
"Licensing": ["Store", "User"],
|
| 164 |
"Transaction": ["Bag", "Order", "Shipment"],
|
|
@@ -173,13 +173,14 @@ var_config = {
|
|
| 173 |
char_config = {
|
| 174 |
'chargeable_on_mapping' :{
|
| 175 |
"Application": ["Developed", "Installed"],
|
| 176 |
-
"Extension": ["Developed", "Installed"],
|
| 177 |
"Integration": ["Developed", "Installed"],
|
| 178 |
"Store": ["Added", "Active"],
|
| 179 |
"User": ["Added", "Active"],
|
| 180 |
"Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 181 |
"Order": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 182 |
-
"Shipment":["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO","Packed", "Cancel"]
|
|
|
|
| 183 |
}
|
| 184 |
}
|
| 185 |
|
|
@@ -198,31 +199,19 @@ selected_chargeable_on = st.selectbox("Chargeable on", ["--please select--"] + c
|
|
| 198 |
# Create an empty DataFrame with the desired column names
|
| 199 |
slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage","Capping/Min_Guarantee_value", "Threshold"])
|
| 200 |
|
| 201 |
-
|
|
|
|
| 202 |
|
| 203 |
if selected_fee_nature == "Slab based":
|
| 204 |
st.write("Enter values for Slab based fee structure:")
|
| 205 |
|
| 206 |
-
|
| 207 |
-
col1, col2 = st.columns([2, 2])
|
| 208 |
-
|
| 209 |
-
with col1:
|
| 210 |
-
slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
|
| 211 |
-
with col2:
|
| 212 |
-
max_value = st.text_input("Max value:", key="max_value_input")
|
| 213 |
-
with col1:
|
| 214 |
-
user_input = st.text_input("Commercial Value:", key="user_input")
|
| 215 |
-
with col2:
|
| 216 |
-
Usage = st.text_input("Usage:", key="Usage_input")
|
| 217 |
-
with col1:
|
| 218 |
-
Capping_or_Minimum_Guarantee= st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
|
| 219 |
-
with col2:
|
| 220 |
-
threshold = st.text_input("Threshold:", key="threshold_input")
|
| 221 |
-
|
| 222 |
|
|
|
|
|
|
|
| 223 |
|
| 224 |
-
# Function to add data to DataFrame
|
| 225 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
|
|
|
| 226 |
max_value = int(max_value) if max_value else None
|
| 227 |
user_input = int(user_input) if user_input else None
|
| 228 |
Usage = int(Usage) if Usage else None
|
|
@@ -235,72 +224,45 @@ if selected_fee_nature == "Slab based":
|
|
| 235 |
"Usage": Usage,
|
| 236 |
"Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
|
| 237 |
"Threshold": threshold
|
| 238 |
-
}
|
| 239 |
-
slabs_df.loc[len(slabs_df)] = new_row
|
| 240 |
-
|
| 241 |
-
if st.button("Add Data", key="add_data_button"):
|
| 242 |
-
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 243 |
-
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 244 |
-
|
| 245 |
-
if st.button("Add Slab", key="add_slab_button"):
|
| 246 |
-
# Clear previous inputs (optional)
|
| 247 |
-
slab = ""
|
| 248 |
-
max_value = ""
|
| 249 |
-
user_input = ""
|
| 250 |
-
Usage = ""
|
| 251 |
-
Capping_or_Minimum_Guarantee = ""
|
| 252 |
-
threshold = ""
|
| 253 |
-
|
| 254 |
-
# Display a message or perform other actions when starting a new slab
|
| 255 |
-
st.info("Enter details for a new slab below.")
|
| 256 |
-
|
| 257 |
-
# Display the slab data in reverse order (most recent on top)
|
| 258 |
-
if not slabs_df.empty:
|
| 259 |
-
st.write("Slab Data:")
|
| 260 |
-
st.table(slabs_df[::-1].reset_index(drop=True))
|
| 261 |
-
else:
|
| 262 |
-
st.info("No slab data available.")
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"] + plan_validity_options, help="Select the plan validity")
|
| 266 |
-
selected_payment_method = st.selectbox("Payment Method", ["--please select--"] + payment_method_options, help="Select the payment method")
|
| 267 |
-
|
| 268 |
-
# Submit button
|
| 269 |
-
if st.button("Submit"):
|
| 270 |
-
# Save user data
|
| 271 |
-
user_data = {
|
| 272 |
-
"Plan Name": plan_name,
|
| 273 |
-
"Plan Description": plan_description,
|
| 274 |
-
"Plan Start Date": plan_start_date,
|
| 275 |
-
"Ordering Channels": ordering_channels,
|
| 276 |
-
"Company ID": company_id,
|
| 277 |
-
"Company Name": company_name,
|
| 278 |
-
"Fulfilling Location": fulfilling_location,
|
| 279 |
-
"Application ID": application_id,
|
| 280 |
-
"Fee Type": selected_fee_type,
|
| 281 |
-
"Variable": selected_variable_type,
|
| 282 |
-
"Chargeable on": selected_chargeable_on,
|
| 283 |
-
"Fee Nature": selected_fee_nature,
|
| 284 |
-
"Commercial value": user_input,
|
| 285 |
-
"Usage limit": Usage,
|
| 286 |
-
"Minimum/Capping value": Capping_or_Minimum_Guarantee,
|
| 287 |
-
"Threshold option": threshold,
|
| 288 |
-
"Plan Validity": selected_plan_validity,
|
| 289 |
-
"Payment Method": selected_payment_method,
|
| 290 |
}
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
| 294 |
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
save_user_data(user_name, user_data) # Save user data after submission
|
| 300 |
-
|
| 301 |
-
# Display saved records
|
| 302 |
-
display_saved_records()
|
| 303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 306 |
user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
|
|
@@ -324,11 +286,11 @@ elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
|
| 324 |
|
| 325 |
st.write(f"Expected Billing: {expected_billing}")
|
| 326 |
|
| 327 |
-
|
| 328 |
-
|
| 329 |
|
| 330 |
# Submit button
|
| 331 |
-
|
| 332 |
# Save user data
|
| 333 |
user_data = {
|
| 334 |
"Plan Name": plan_name,
|
|
|
|
| 106 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 107 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
| 108 |
plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
|
| 109 |
+
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud", "FCP"]
|
| 110 |
ordering_channels = st.sidebar.selectbox("Product lines", ["--please select--"]+a1, help="Select the ordering channels")
|
| 111 |
|
| 112 |
# Section 2: Company Info
|
|
|
|
| 120 |
application_id = None
|
| 121 |
else:
|
| 122 |
abc = ["Store", "Warehouse"]
|
| 123 |
+
fulfilling_location = st.sidebar.selectbox("Fulfilling Location",["--please select--"] + abc, help="Select the fulfilling location")
|
| 124 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 125 |
|
| 126 |
# Section 3: Defining products for each dropdown
|
| 127 |
+
product_options = ["B2B", "Marketplaces", "StoreOS", "Website", "ONDC", "OMS", "TMS", "WMS", "GMC", "Catalog Cloud", "FCP"],
|
| 128 |
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics", "Packaging", "SLA", "Licensing"]
|
| 129 |
fee_nature_options = ["Fixed %", "Flat currency", "Slab based"]
|
| 130 |
variable_options = ["Bag", "Order", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
|
|
|
|
| 158 |
var_config = {
|
| 159 |
'variable_type_mapping': {
|
| 160 |
"Development": ["Application", "Extension", "Integration"],
|
| 161 |
+
"Subscription": ["Application", "Extension", "Integration", "Platform"],
|
| 162 |
"Maintenance": ["Application", "Extension", "Integration"],
|
| 163 |
"Licensing": ["Store", "User"],
|
| 164 |
"Transaction": ["Bag", "Order", "Shipment"],
|
|
|
|
| 173 |
char_config = {
|
| 174 |
'chargeable_on_mapping' :{
|
| 175 |
"Application": ["Developed", "Installed"],
|
| 176 |
+
"Extension": ["Developed", "Installed", "Subscribed"],
|
| 177 |
"Integration": ["Developed", "Installed"],
|
| 178 |
"Store": ["Added", "Active"],
|
| 179 |
"User": ["Added", "Active"],
|
| 180 |
"Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 181 |
"Order": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 182 |
+
"Shipment":["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO","Packed", "Cancel"],
|
| 183 |
+
"Platform": ["Subscribed"],
|
| 184 |
}
|
| 185 |
}
|
| 186 |
|
|
|
|
| 199 |
# Create an empty DataFrame with the desired column names
|
| 200 |
slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage","Capping/Min_Guarantee_value", "Threshold"])
|
| 201 |
|
| 202 |
+
ttt = ["Fixed %", "Flat currency", "Slab based"]
|
| 203 |
+
selected_fee_nature = st.selectbox("Fee Nature:",["--please select--"]+ ttt, key="fee_nature_select")
|
| 204 |
|
| 205 |
if selected_fee_nature == "Slab based":
|
| 206 |
st.write("Enter values for Slab based fee structure:")
|
| 207 |
|
| 208 |
+
# Function to add data to DataFrame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
+
# Initialize an empty list to store data rows
|
| 211 |
+
global_new_row = []
|
| 212 |
|
|
|
|
| 213 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 214 |
+
# Convert values to int if not None
|
| 215 |
max_value = int(max_value) if max_value else None
|
| 216 |
user_input = int(user_input) if user_input else None
|
| 217 |
Usage = int(Usage) if Usage else None
|
|
|
|
| 224 |
"Usage": Usage,
|
| 225 |
"Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
|
| 226 |
"Threshold": threshold
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
+
# Append new_row to global list
|
| 230 |
+
global_new_row.append(new_row)
|
| 231 |
|
| 232 |
+
# Streamlit UI code
|
| 233 |
+
def main():
|
| 234 |
+
st.title("Slab Data Management")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
+
# Inputs for adding data
|
| 237 |
+
# Input fields for user data
|
| 238 |
+
col1, col2 = st.columns([2, 2])
|
| 239 |
+
|
| 240 |
+
with col1:
|
| 241 |
+
slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
|
| 242 |
+
with col2:
|
| 243 |
+
max_value = st.text_input("Max value:", key="max_value_input")
|
| 244 |
+
with col1:
|
| 245 |
+
user_input = st.text_input("Commercial Value:", key="user_input")
|
| 246 |
+
with col2:
|
| 247 |
+
Usage = st.text_input("Usage:", key="Usage_input")
|
| 248 |
+
with col1:
|
| 249 |
+
Capping_or_Minimum_Guarantee= st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
|
| 250 |
+
with col2:
|
| 251 |
+
threshold = st.text_input("Threshold:", key="threshold_input")
|
| 252 |
+
|
| 253 |
+
# Button to add data
|
| 254 |
+
if st.button("Add Data", key="add_data_button"):
|
| 255 |
+
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 256 |
+
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 257 |
+
|
| 258 |
+
# Display global_new_row in a table
|
| 259 |
+
if global_new_row:
|
| 260 |
+
st.subheader("Added Slabs")
|
| 261 |
+
st.table(global_new_row)
|
| 262 |
+
|
| 263 |
+
if __name__ == "__main__":
|
| 264 |
+
main()
|
| 265 |
+
|
| 266 |
|
| 267 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 268 |
user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
|
|
|
|
| 286 |
|
| 287 |
st.write(f"Expected Billing: {expected_billing}")
|
| 288 |
|
| 289 |
+
selected_plan_validity = st.selectbox("Plan Validity", ["--please select--"] + plan_validity_options, help="Select the plan validity", key = "plan_vd_2")
|
| 290 |
+
selected_payment_method = st.selectbox("Payment Method", ["--please select--"] + payment_method_options, help="Select the payment method", key = "py_vd_2")
|
| 291 |
|
| 292 |
# Submit button
|
| 293 |
+
if st.button("Submit"):
|
| 294 |
# Save user data
|
| 295 |
user_data = {
|
| 296 |
"Plan Name": plan_name,
|