Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,21 +4,26 @@ from datetime import datetime
|
|
| 4 |
import os
|
| 5 |
import configparser # For activating the config
|
| 6 |
|
| 7 |
-
|
| 8 |
-
global_user_data = [] #For appending user_data
|
| 9 |
|
| 10 |
|
| 11 |
# Function to initialize session state
|
| 12 |
def initialize_session_state():
|
| 13 |
if 'data' not in st.session_state:
|
| 14 |
-
st.session_state.data =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Function to save user data
|
| 17 |
-
def save_user_data(
|
| 18 |
-
st.session_state.data
|
|
|
|
| 19 |
|
| 20 |
# Function to generate PM_id
|
| 21 |
-
def
|
| 22 |
company_id = user_data.get('Company ID', '')
|
| 23 |
ordering_channels = user_data.get('Ordering Channels', '')
|
| 24 |
fulfilling_location = user_data.get('Fulfilling Location', '')
|
|
@@ -32,7 +37,7 @@ def generate_pm_id(user_data):
|
|
| 32 |
company_id = company_id.zfill(5)[:5]
|
| 33 |
|
| 34 |
# Extract first 2 characters from each field
|
| 35 |
-
|
| 36 |
company_id[:5],
|
| 37 |
ordering_channels[:2],
|
| 38 |
fulfilling_location[:2],
|
|
@@ -44,24 +49,57 @@ def generate_pm_id(user_data):
|
|
| 44 |
threshold[:2]
|
| 45 |
]
|
| 46 |
|
| 47 |
-
|
| 48 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Function to display saved records as a table and save to CSV
|
| 51 |
def display_saved_records():
|
| 52 |
st.subheader(":violet[Saved Records]")
|
| 53 |
-
df = pd.DataFrame
|
| 54 |
-
|
| 55 |
-
df.rename(columns={'index': 'User Name'}, inplace=True) # Rename the index column to 'User Name'
|
| 56 |
-
|
| 57 |
-
# Generate PM_id column
|
| 58 |
-
df['PM_id'] = df.apply(generate_pm_id, axis=1)
|
| 59 |
-
|
| 60 |
-
# Display DataFrame with increased height
|
| 61 |
-
st.write(df.style.set_table_attributes('style="font-size: 14px; line-height: 18px; width: auto; height: auto;"'))
|
| 62 |
-
|
| 63 |
-
# Save records to CSV
|
| 64 |
if not df.empty:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
folder_path = "data" # Folder name
|
| 66 |
os.makedirs(folder_path, exist_ok=True) # Create folder if it doesn't exist
|
| 67 |
file_path = os.path.join(folder_path, "records.csv")
|
|
@@ -76,6 +114,7 @@ def display_saved_records():
|
|
| 76 |
mime="text/csv",
|
| 77 |
)
|
| 78 |
|
|
|
|
| 79 |
# Function to load theme configuration
|
| 80 |
def load_theme_config():
|
| 81 |
config = configparser.ConfigParser()
|
|
@@ -85,12 +124,12 @@ def load_theme_config():
|
|
| 85 |
theme_settings = config['theme']
|
| 86 |
return theme_settings
|
| 87 |
|
|
|
|
| 88 |
# Initialize session state
|
| 89 |
initialize_session_state()
|
| 90 |
|
| 91 |
theme_settings = load_theme_config()
|
| 92 |
|
| 93 |
-
|
| 94 |
# Apply theme settings to Streamlit
|
| 95 |
st.set_page_config(
|
| 96 |
page_title="Plan maker",
|
|
@@ -100,60 +139,79 @@ st.set_page_config(
|
|
| 100 |
)
|
| 101 |
|
| 102 |
|
| 103 |
-
|
| 104 |
# Section 1: Plan Info
|
| 105 |
-
st.sidebar.image('Fynd_logo2.png', width
|
|
|
|
| 106 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 107 |
st.sidebar.title("Section 1: Plan Info")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 109 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
| 110 |
plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
|
| 111 |
-
|
| 112 |
-
ordering_channels = st.sidebar.selectbox("Product lines", [""]+a1, help="Select the ordering channels")
|
| 113 |
|
| 114 |
# Section 2: Company Info
|
| 115 |
-
st.sidebar.title("Section 2:
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 118 |
|
| 119 |
# Layer 1: Mapping of Ordering channels with Fulfilling location
|
| 120 |
-
if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
|
| 121 |
fulfilling_location = None
|
| 122 |
application_id = None
|
| 123 |
else:
|
| 124 |
abc = ["Store", "Warehouse"]
|
| 125 |
-
fulfilling_location = st.sidebar.selectbox("Fulfilling Location",[""] +
|
| 126 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 127 |
|
| 128 |
# Section 3: Defining products for each dropdown
|
| 129 |
-
product_options = ["B2B", "Marketplaces", "StoreOS", "
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 135 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 136 |
|
| 137 |
-
# In the first column, display the image
|
| 138 |
-
st.image("Fynd copy.png", width=200)
|
| 139 |
-
|
| 140 |
-
st.title(":violet[Plan maker]")
|
| 141 |
-
|
| 142 |
# Mapping index
|
| 143 |
fee_config = {
|
| 144 |
'fee_type_mapping': {
|
| 145 |
-
"ONDC": ["Development","Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
|
| 146 |
-
|
| 147 |
-
"
|
| 148 |
-
"
|
| 149 |
-
|
| 150 |
-
"
|
| 151 |
-
"
|
| 152 |
-
|
| 153 |
-
"
|
| 154 |
-
"
|
| 155 |
-
"
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
}
|
| 159 |
|
|
@@ -163,61 +221,63 @@ var_config = {
|
|
| 163 |
"Subscription": ["Application", "Extension", "Integration", "Platform"],
|
| 164 |
"Maintenance": ["Application", "Extension", "Integration"],
|
| 165 |
"Licensing": ["Store", "User"],
|
| 166 |
-
"Transaction": ["Bag", "
|
| 167 |
-
"Minimum Guarantee": ["Bag", "
|
| 168 |
-
"SLA": ["Bag", "
|
| 169 |
-
"Logistics":["Shipment"],
|
| 170 |
-
"Marketing":["Bag"
|
| 171 |
-
"Packaging":["Shipment"]
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
| 175 |
char_config = {
|
| 176 |
-
'chargeable_on_mapping'
|
| 177 |
"Application": ["Developed", "Installed"],
|
| 178 |
"Extension": ["Developed", "Installed", "Subscribed"],
|
| 179 |
"Integration": ["Developed", "Installed"],
|
| 180 |
"Store": ["Added", "Active"],
|
| 181 |
"User": ["Added", "Active"],
|
| 182 |
"Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 183 |
-
"
|
| 184 |
-
|
| 185 |
"Platform": ["Subscribed"],
|
| 186 |
}
|
| 187 |
}
|
| 188 |
|
|
|
|
| 189 |
# 2nd layer: Mapping of Ordering channels with fee types
|
| 190 |
fee_type_mapping = fee_config['fee_type_mapping']
|
| 191 |
-
selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
|
|
|
|
| 192 |
|
| 193 |
-
# 3rd layer mapping: Mapping of Fee type with variables
|
| 194 |
variable_type_mapping = var_config["variable_type_mapping"]
|
| 195 |
-
selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
|
|
|
|
| 196 |
|
| 197 |
-
# 4th layer mapping: Mapping of Fee type with variables
|
| 198 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 199 |
-
selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
|
|
|
|
| 200 |
|
| 201 |
# Create an empty DataFrame with the desired column names
|
| 202 |
-
slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage","Capping/Min_Guarantee_value", "Threshold"])
|
| 203 |
|
| 204 |
ttt = ["Fixed %", "Flat currency", "Slab based"]
|
| 205 |
-
selected_fee_nature = st.selectbox("Fee Nature:",[""]+ ttt, key="fee_nature_select")
|
| 206 |
|
| 207 |
if selected_fee_nature == "Slab based":
|
| 208 |
st.write("Enter values for Slab based fee structure:")
|
| 209 |
|
| 210 |
-
# Function to add data to DataFrame
|
| 211 |
-
|
| 212 |
# Initialize an empty list to store data rows
|
| 213 |
-
|
| 214 |
|
| 215 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 216 |
-
|
| 217 |
-
max_value = int(max_value) if max_value else None
|
| 218 |
-
user_input = int(user_input) if user_input else None
|
| 219 |
-
Usage = int(Usage) if Usage else None
|
| 220 |
-
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee) if Capping_or_Minimum_Guarantee else None
|
| 221 |
|
| 222 |
new_row = {
|
| 223 |
"Slab": slab,
|
|
@@ -228,15 +288,15 @@ if selected_fee_nature == "Slab based":
|
|
| 228 |
"Threshold": threshold
|
| 229 |
}
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
| 233 |
|
| 234 |
-
# Streamlit UI code
|
| 235 |
def main():
|
| 236 |
st.title("Slab Data Management")
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
col1, col2 = st.columns([2, 2])
|
| 241 |
|
| 242 |
with col1:
|
|
@@ -248,34 +308,36 @@ if selected_fee_nature == "Slab based":
|
|
| 248 |
with col2:
|
| 249 |
Usage = st.text_input("Usage:", key="Usage_input")
|
| 250 |
with col1:
|
| 251 |
-
Capping_or_Minimum_Guarantee= st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
|
| 252 |
with col2:
|
| 253 |
threshold = st.text_input("Threshold:", key="threshold_input")
|
| 254 |
|
| 255 |
-
|
| 256 |
if st.button("Add Data", key="add_data_button"):
|
| 257 |
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 258 |
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 259 |
|
| 260 |
-
|
| 261 |
-
if
|
| 262 |
st.subheader("Added Slabs")
|
| 263 |
-
|
|
|
|
|
|
|
| 264 |
|
| 265 |
if __name__ == "__main__":
|
| 266 |
main()
|
| 267 |
-
|
| 268 |
|
| 269 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 270 |
user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
|
| 271 |
|
| 272 |
# 6th layer: Expected Billing
|
| 273 |
Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
|
| 274 |
-
Capping_or_Minimum_Guarantee = st.number_input(f"Enter the Capping/Minimum
|
|
|
|
| 275 |
Product = Usage * user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
| 276 |
|
| 277 |
abc = ['Capping value', 'Minimum Guarantee']
|
| 278 |
-
threshold = st.selectbox("Choose a threshold option:", [""]+ abc)
|
| 279 |
|
| 280 |
initial_expected_billing = Product
|
| 281 |
|
|
@@ -286,15 +348,15 @@ elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
|
| 286 |
else:
|
| 287 |
expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
|
| 288 |
|
| 289 |
-
st.write(f"Expected Billing: {expected_billing}")
|
| 290 |
|
| 291 |
-
selected_plan_validity = st.selectbox("Plan Validity", [""]+ plan_validity_options, help="Select the plan validity", key
|
| 292 |
-
selected_payment_method = st.selectbox("Payment Method", [""]+ payment_method_options, help="Select the payment method", key
|
| 293 |
|
| 294 |
# Submit button
|
| 295 |
if st.button("Submit"):
|
| 296 |
# Save user data
|
| 297 |
-
|
| 298 |
"Plan Name": plan_name,
|
| 299 |
"Plan Description": plan_description,
|
| 300 |
"Plan Start Date": plan_start_date,
|
|
@@ -314,17 +376,19 @@ if st.button("Submit"):
|
|
| 314 |
"Expected Billing": expected_billing,
|
| 315 |
"Plan Validity": selected_plan_validity,
|
| 316 |
"Payment Method": selected_payment_method,
|
| 317 |
-
|
| 318 |
|
| 319 |
-
|
| 320 |
-
|
| 321 |
|
| 322 |
# Generate PM_id and add it to user_data
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
-
|
| 327 |
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
|
|
|
| 4 |
import os
|
| 5 |
import configparser # For activating the config
|
| 6 |
|
| 7 |
+
global_user_data = [] # For appending user_data
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
# Function to initialize session state
|
| 11 |
def initialize_session_state():
|
| 12 |
if 'data' not in st.session_state:
|
| 13 |
+
st.session_state.data = []
|
| 14 |
+
if 'alphabet_counter' not in st.session_state:
|
| 15 |
+
st.session_state.alphabet_counter = 0
|
| 16 |
+
if 'serial_counter' not in st.session_state:
|
| 17 |
+
st.session_state.serial_counter = -1
|
| 18 |
+
|
| 19 |
|
| 20 |
# Function to save user data
|
| 21 |
+
def save_user_data(user_data):
|
| 22 |
+
st.session_state.data.append(user_data)
|
| 23 |
+
|
| 24 |
|
| 25 |
# Function to generate PM_id
|
| 26 |
+
def generate_rule_id(user_data):
|
| 27 |
company_id = user_data.get('Company ID', '')
|
| 28 |
ordering_channels = user_data.get('Ordering Channels', '')
|
| 29 |
fulfilling_location = user_data.get('Fulfilling Location', '')
|
|
|
|
| 37 |
company_id = company_id.zfill(5)[:5]
|
| 38 |
|
| 39 |
# Extract first 2 characters from each field
|
| 40 |
+
rule_id_parts = [
|
| 41 |
company_id[:5],
|
| 42 |
ordering_channels[:2],
|
| 43 |
fulfilling_location[:2],
|
|
|
|
| 49 |
threshold[:2]
|
| 50 |
]
|
| 51 |
|
| 52 |
+
rule_id = '_'.join(rule_id_parts) # Join parts with underscore
|
| 53 |
+
return rule_id
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# Function to generate Plan ID
|
| 57 |
+
def generate_plan_id(user_data):
|
| 58 |
+
initialize_session_state() # Ensure session state is initialized
|
| 59 |
+
|
| 60 |
+
alphabet_counter = st.session_state.alphabet_counter
|
| 61 |
+
serial_counter = st.session_state.serial_counter
|
| 62 |
+
|
| 63 |
+
company_id = user_data.get('Company ID', '') # Get company_id from user_data
|
| 64 |
+
|
| 65 |
+
# Increment serial counter and reset if it reaches 999999
|
| 66 |
+
serial_counter += 1
|
| 67 |
+
if serial_counter > 999999:
|
| 68 |
+
serial_counter = 0
|
| 69 |
+
alphabet_counter += 1
|
| 70 |
+
|
| 71 |
+
# Save updated counters back to session state
|
| 72 |
+
st.session_state['alphabet_counter'] = alphabet_counter
|
| 73 |
+
st.session_state['serial_counter'] = serial_counter
|
| 74 |
+
|
| 75 |
+
# Calculate alphabet ('a' to 'z')
|
| 76 |
+
current_alphabet = chr(alphabet_counter % 26 + ord('a'))
|
| 77 |
+
|
| 78 |
+
# Format serial counter as six-digit number
|
| 79 |
+
serial_number = str(serial_counter).zfill(6)
|
| 80 |
+
|
| 81 |
+
# Get the first 5 characters of company_id and pad it with zeros
|
| 82 |
+
company_id_part = company_id[:5].zfill(5)
|
| 83 |
+
|
| 84 |
+
# Generate the plan_id
|
| 85 |
+
plan_id = f"{company_id_part}_{current_alphabet}_{serial_number}"
|
| 86 |
+
|
| 87 |
+
return plan_id
|
| 88 |
+
|
| 89 |
|
| 90 |
# Function to display saved records as a table and save to CSV
|
| 91 |
def display_saved_records():
|
| 92 |
st.subheader(":violet[Saved Records]")
|
| 93 |
+
df = pd.DataFrame(st.session_state.data)
|
| 94 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
if not df.empty:
|
| 96 |
+
# Apply generate_rule_id function to each row to generate rule_id
|
| 97 |
+
df['rule_id'] = df.apply(lambda row: generate_rule_id(row), axis=1)
|
| 98 |
+
|
| 99 |
+
# Display DataFrame with increased height
|
| 100 |
+
st.write(df.style.set_table_attributes('style="font-size: 14px; line-height: 18px; width: auto; height: auto;"'))
|
| 101 |
+
|
| 102 |
+
# Save records to CSV
|
| 103 |
folder_path = "data" # Folder name
|
| 104 |
os.makedirs(folder_path, exist_ok=True) # Create folder if it doesn't exist
|
| 105 |
file_path = os.path.join(folder_path, "records.csv")
|
|
|
|
| 114 |
mime="text/csv",
|
| 115 |
)
|
| 116 |
|
| 117 |
+
|
| 118 |
# Function to load theme configuration
|
| 119 |
def load_theme_config():
|
| 120 |
config = configparser.ConfigParser()
|
|
|
|
| 124 |
theme_settings = config['theme']
|
| 125 |
return theme_settings
|
| 126 |
|
| 127 |
+
|
| 128 |
# Initialize session state
|
| 129 |
initialize_session_state()
|
| 130 |
|
| 131 |
theme_settings = load_theme_config()
|
| 132 |
|
|
|
|
| 133 |
# Apply theme settings to Streamlit
|
| 134 |
st.set_page_config(
|
| 135 |
page_title="Plan maker",
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
|
|
|
|
| 142 |
# Section 1: Plan Info
|
| 143 |
+
st.sidebar.image('Fynd_logo2.png', width=300)
|
| 144 |
+
st.sidebar.title(":blue[Plan maker]")
|
| 145 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 146 |
st.sidebar.title("Section 1: Plan Info")
|
| 147 |
+
v1 = ["Commerce India", "Reliance", "Commerce Global", "Government Projects", "Individual BH"]
|
| 148 |
+
business_head = st.sidebar.selectbox("Business Head", [""] + v1, help="Enter the name of Business head")
|
| 149 |
+
company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
|
| 150 |
+
company_name = st.sidebar.text_input("Company Name", help="Enter the company name")
|
| 151 |
+
bundle_by = st.sidebar.radio(options=["Single value", "Feature specific"], label="Bundle by", index=None)
|
| 152 |
+
if bundle_by == "Single value":
|
| 153 |
+
user_input = st.sidebar.text_input("Enter the Commercial value:")
|
| 154 |
+
elif bundle_by == "Feature specific":
|
| 155 |
+
user_input = st.sidebar.text_input("Enter multiple values:")
|
| 156 |
+
|
| 157 |
plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
|
| 158 |
plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
|
| 159 |
plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
|
| 160 |
+
|
|
|
|
| 161 |
|
| 162 |
# Section 2: Company Info
|
| 163 |
+
st.sidebar.title("Section 2: Rule Info")
|
| 164 |
+
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
|
| 165 |
+
"GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
|
| 166 |
+
ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
|
| 167 |
|
| 168 |
# Layer 1: Mapping of Ordering channels with Fulfilling location
|
| 169 |
+
if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
|
| 170 |
fulfilling_location = None
|
| 171 |
application_id = None
|
| 172 |
else:
|
| 173 |
abc = ["Store", "Warehouse"]
|
| 174 |
+
fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
|
| 175 |
application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
|
| 176 |
|
| 177 |
# Section 3: Defining products for each dropdown
|
| 178 |
+
product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
|
| 179 |
+
"Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
|
| 180 |
+
"CoPilot"]
|
| 181 |
+
fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
|
| 182 |
+
"Packaging", "SLA", "Licensing"]
|
| 183 |
+
fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
|
| 184 |
+
variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
|
| 185 |
+
chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
|
| 186 |
+
"RTO", "DTO", "Packed"]
|
| 187 |
plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
|
| 188 |
payment_method_options = ["Prepaid", "Postpaid"]
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
# Mapping index
|
| 191 |
fee_config = {
|
| 192 |
'fee_type_mapping': {
|
| 193 |
+
"ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
|
| 194 |
+
"Marketing", "SLA"],
|
| 195 |
+
"GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
|
| 196 |
+
"B2B": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
|
| 197 |
+
"Packaging"],
|
| 198 |
+
"Marketplaces": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
|
| 199 |
+
"StoreOS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
|
| 200 |
+
"Logistics", "Packaging"],
|
| 201 |
+
"Storefronts": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics"],
|
| 202 |
+
"Fynd TMS": ["Development", "Subscription", "Maintenance", "Licensing", "Logistics"],
|
| 203 |
+
"Fynd WMS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
|
| 204 |
+
"Logistics", "Packaging"],
|
| 205 |
+
"GMC": ["Development", "Subscription", "Maintenance"],
|
| 206 |
+
"Catalog Cloud": ["Development", "Subscription", "Maintenance"],
|
| 207 |
+
"Uniket": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
|
| 208 |
+
"Fynd OMS": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
|
| 209 |
+
"Fynd Commerce Platform": ["Subscription"],
|
| 210 |
+
"Logistics": ["Logistics"],
|
| 211 |
+
"PixelBin": ["Subscription"],
|
| 212 |
+
"Boltic": ["Subscription"],
|
| 213 |
+
"CoPilot": ["Subscription"],
|
| 214 |
+
|
| 215 |
}
|
| 216 |
}
|
| 217 |
|
|
|
|
| 221 |
"Subscription": ["Application", "Extension", "Integration", "Platform"],
|
| 222 |
"Maintenance": ["Application", "Extension", "Integration"],
|
| 223 |
"Licensing": ["Store", "User"],
|
| 224 |
+
"Transaction": ["Bag", "Shipment"],
|
| 225 |
+
"Minimum Guarantee": ["Bag", "Shipment"],
|
| 226 |
+
"SLA": ["Bag", "Shipment"],
|
| 227 |
+
"Logistics": ["Shipment"],
|
| 228 |
+
"Marketing": ["Bag"],
|
| 229 |
+
"Packaging": ["Shipment"]
|
| 230 |
}
|
| 231 |
}
|
| 232 |
|
| 233 |
char_config = {
|
| 234 |
+
'chargeable_on_mapping': {
|
| 235 |
"Application": ["Developed", "Installed"],
|
| 236 |
"Extension": ["Developed", "Installed", "Subscribed"],
|
| 237 |
"Integration": ["Developed", "Installed"],
|
| 238 |
"Store": ["Added", "Active"],
|
| 239 |
"User": ["Added", "Active"],
|
| 240 |
"Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
|
| 241 |
+
"Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
|
| 242 |
+
"Cancel"],
|
| 243 |
"Platform": ["Subscribed"],
|
| 244 |
}
|
| 245 |
}
|
| 246 |
|
| 247 |
+
|
| 248 |
# 2nd layer: Mapping of Ordering channels with fee types
|
| 249 |
fee_type_mapping = fee_config['fee_type_mapping']
|
| 250 |
+
selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
|
| 251 |
+
help="Select the type of fee")
|
| 252 |
|
| 253 |
+
# 3rd layer mapping: Mapping of Fee type with variables
|
| 254 |
variable_type_mapping = var_config["variable_type_mapping"]
|
| 255 |
+
selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
|
| 256 |
+
help="Select the type of variable")
|
| 257 |
|
| 258 |
+
# 4th layer mapping: Mapping of Fee type with variables
|
| 259 |
chargeable_on_mapping = char_config["chargeable_on_mapping"]
|
| 260 |
+
selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
|
| 261 |
+
help="Select the type of Chargeable")
|
| 262 |
|
| 263 |
# Create an empty DataFrame with the desired column names
|
| 264 |
+
slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage", "Capping/Min_Guarantee_value", "Threshold"])
|
| 265 |
|
| 266 |
ttt = ["Fixed %", "Flat currency", "Slab based"]
|
| 267 |
+
selected_fee_nature = st.selectbox("Fee Nature:", [""] + ttt, key="fee_nature_select")
|
| 268 |
|
| 269 |
if selected_fee_nature == "Slab based":
|
| 270 |
st.write("Enter values for Slab based fee structure:")
|
| 271 |
|
|
|
|
|
|
|
| 272 |
# Initialize an empty list to store data rows
|
| 273 |
+
global_data_rows = []
|
| 274 |
|
| 275 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
| 276 |
+
# Convert values to int if not None
|
| 277 |
+
max_value = int(max_value.strip()) if max_value else None
|
| 278 |
+
user_input = int(user_input.strip()) if user_input else None
|
| 279 |
+
Usage = int(Usage.strip()) if Usage else None
|
| 280 |
+
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
|
| 281 |
|
| 282 |
new_row = {
|
| 283 |
"Slab": slab,
|
|
|
|
| 288 |
"Threshold": threshold
|
| 289 |
}
|
| 290 |
|
| 291 |
+
# Append new_row to global list of rows
|
| 292 |
+
global_data_rows.append(new_row)
|
| 293 |
|
| 294 |
+
# Streamlit UI code
|
| 295 |
def main():
|
| 296 |
st.title("Slab Data Management")
|
| 297 |
|
| 298 |
+
# Inputs for adding data
|
| 299 |
+
# Input fields for user data
|
| 300 |
col1, col2 = st.columns([2, 2])
|
| 301 |
|
| 302 |
with col1:
|
|
|
|
| 308 |
with col2:
|
| 309 |
Usage = st.text_input("Usage:", key="Usage_input")
|
| 310 |
with col1:
|
| 311 |
+
Capping_or_Minimum_Guarantee = st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
|
| 312 |
with col2:
|
| 313 |
threshold = st.text_input("Threshold:", key="threshold_input")
|
| 314 |
|
| 315 |
+
# Button to add data
|
| 316 |
if st.button("Add Data", key="add_data_button"):
|
| 317 |
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 318 |
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 319 |
|
| 320 |
+
# Display all rows in a table
|
| 321 |
+
if global_data_rows:
|
| 322 |
st.subheader("Added Slabs")
|
| 323 |
+
for i, row in enumerate(global_data_rows):
|
| 324 |
+
st.write(f"Entry {i + 1}:")
|
| 325 |
+
st.table([row])
|
| 326 |
|
| 327 |
if __name__ == "__main__":
|
| 328 |
main()
|
|
|
|
| 329 |
|
| 330 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 331 |
user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
|
| 332 |
|
| 333 |
# 6th layer: Expected Billing
|
| 334 |
Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
|
| 335 |
+
Capping_or_Minimum_Guarantee = st.number_input(f"Enter the Capping/Minimum Guarantee for {selected_variable_type}", min_value=0.0,
|
| 336 |
+
help="Enter the Capping/Minimum Gauarntee value")
|
| 337 |
Product = Usage * user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
|
| 338 |
|
| 339 |
abc = ['Capping value', 'Minimum Guarantee']
|
| 340 |
+
threshold = st.selectbox("Choose a threshold option:", [""] + abc)
|
| 341 |
|
| 342 |
initial_expected_billing = Product
|
| 343 |
|
|
|
|
| 348 |
else:
|
| 349 |
expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
|
| 350 |
|
| 351 |
+
st.write(f"Expected Billing (excluding GST): {expected_billing}")
|
| 352 |
|
| 353 |
+
selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Select the plan validity", key="plan_vd_2")
|
| 354 |
+
selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Select the payment method", key="py_vd_2")
|
| 355 |
|
| 356 |
# Submit button
|
| 357 |
if st.button("Submit"):
|
| 358 |
# Save user data
|
| 359 |
+
user_data = {
|
| 360 |
"Plan Name": plan_name,
|
| 361 |
"Plan Description": plan_description,
|
| 362 |
"Plan Start Date": plan_start_date,
|
|
|
|
| 376 |
"Expected Billing": expected_billing,
|
| 377 |
"Plan Validity": selected_plan_validity,
|
| 378 |
"Payment Method": selected_payment_method,
|
| 379 |
+
}
|
| 380 |
|
| 381 |
+
global_user_data.append((user_name, user_data))
|
|
|
|
| 382 |
|
| 383 |
# Generate PM_id and add it to user_data
|
| 384 |
+
rule_id = generate_rule_id(user_data)
|
| 385 |
+
user_data['rule_id'] = rule_id
|
| 386 |
+
|
| 387 |
+
# Generate Plan ID and add it to user_data
|
| 388 |
+
plan_id = generate_plan_id(user_data)
|
| 389 |
+
user_data['plan_id'] = plan_id
|
| 390 |
|
| 391 |
+
save_user_data(user_data) # Save user data after submission
|
| 392 |
|
| 393 |
+
# Display saved records
|
| 394 |
+
display_saved_records()
|
|
|