Ninad077 commited on
Commit
bee5ce2
·
verified ·
1 Parent(s): 0e9b168

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +296 -118
app.py CHANGED
@@ -28,12 +28,23 @@ def generate_rule_id(user_data):
28
  ordering_channels = user_data.get('Ordering Channels', '')
29
  fulfilling_location = user_data.get('Fulfilling Location', '')
30
  application_id = user_data.get('Application ID', '')
31
- selected_fee_type = user_data.get('Fee Type', '')
32
  selected_variable_type = user_data.get('Variable', '')
33
  selected_chargeable_on = user_data.get('Chargeable on', '')
34
  selected_fee_nature = user_data.get('Fee Nature', '')
35
  threshold = user_data.get('Threshold option', '')
36
 
 
 
 
 
 
 
 
 
 
 
 
37
  company_id = company_id.zfill(5)[:5]
38
 
39
  # Extract first 2 characters from each field
@@ -140,54 +151,55 @@ st.set_page_config(
140
 
141
 
142
  # Section 1: Plan Info
 
 
143
  user_name = st.sidebar.text_input("Enter your name:")
144
- st.sidebar.title(":blue[Section 1: Plan Info]")
145
  v1 = ["Commerce India", "Reliance", "Commerce Global", "Government Projects", "Individual BH"]
146
  business_head = st.sidebar.selectbox("Business Head", [""] + v1, help="Enter the name of Business head")
147
  company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
148
  company_name = st.sidebar.text_input("Company Name", help="Enter the company name")
149
- bundle_by = st.sidebar.radio(options=["Single value", "Feature specific"], label="Bundle by", index=None)
150
- if bundle_by == "Single value":
151
- user_input = st.sidebar.text_input("Enter the Commercial value:")
152
- elif bundle_by == "Feature specific":
153
- user_input = st.sidebar.text_input("Enter multiple values:")
154
 
155
- plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
156
- plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
157
- plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
 
 
158
 
159
 
160
  # Section 2: Company Info
161
- st.sidebar.title(":blue[Section 2: Rule Info]")
162
- a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
163
  "GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
164
- ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
165
 
166
  # Layer 1: Mapping of Ordering channels with Fulfilling location
167
- if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
168
- fulfilling_location = None
169
- application_id = None
170
- else:
171
- abc = ["Store", "Warehouse"]
172
- fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
173
- application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
174
 
175
  # Section 3: Defining products for each dropdown
176
- product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
177
  "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
178
  "CoPilot"]
179
- fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
180
  "Packaging", "SLA", "Licensing"]
181
- fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
182
- variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
183
- chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
184
  "RTO", "DTO", "Packed"]
185
- plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
186
- payment_method_options = ["Prepaid", "Postpaid"]
187
 
188
  # Mapping index
189
- fee_config = {
190
- 'fee_type_mapping': {
191
  "ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
192
  "Marketing", "SLA"],
193
  "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
@@ -210,11 +222,11 @@ fee_config = {
210
  "Boltic": ["Subscription"],
211
  "CoPilot": ["Subscription"],
212
 
 
213
  }
214
- }
215
 
216
- var_config = {
217
- 'variable_type_mapping': {
218
  "Development": ["Application", "Extension", "Integration"],
219
  "Subscription": ["Application", "Extension", "Integration", "Platform"],
220
  "Maintenance": ["Application", "Extension", "Integration"],
@@ -225,11 +237,11 @@ var_config = {
225
  "Logistics": ["Shipment"],
226
  "Marketing": ["Bag"],
227
  "Packaging": ["Shipment"]
 
228
  }
229
- }
230
 
231
- char_config = {
232
- 'chargeable_on_mapping': {
233
  "Application": ["Developed", "Installed"],
234
  "Extension": ["Developed", "Installed", "Subscribed"],
235
  "Integration": ["Developed", "Installed"],
@@ -239,131 +251,137 @@ char_config = {
239
  "Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
240
  "Cancel"],
241
  "Platform": ["Subscribed"],
 
242
  }
243
- }
244
 
245
 
246
  # 2nd layer: Mapping of Ordering channels with fee types
247
- st.image('plan_2.png', width=300)
248
- st.write("")
249
- st.write("")
250
- fee_type_mapping = fee_config['fee_type_mapping']
251
- selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
 
252
  help="Select the type of fee")
253
 
254
  # 3rd layer mapping: Mapping of Fee type with variables
255
- variable_type_mapping = var_config["variable_type_mapping"]
256
- selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
257
  help="Select the type of variable")
258
 
259
  # 4th layer mapping: Mapping of Fee type with variables
260
- chargeable_on_mapping = char_config["chargeable_on_mapping"]
261
- selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
262
  help="Select the type of Chargeable")
263
 
264
  # Create an empty DataFrame with the desired column names
265
- slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage", "Capping/Min_Guarantee_value", "Threshold"])
266
 
267
- ttt = ["Fixed %", "Flat currency", "Slab based"]
268
- selected_fee_nature = st.selectbox("Fee Nature:", [""] + ttt, key="fee_nature_select")
269
 
270
- if selected_fee_nature == "Slab based":
271
- st.write("Enter values for Slab based fee structure:")
272
 
273
  # Initialize an empty list to store data rows
274
- global_data_rows = []
275
 
276
- def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
277
  # Convert values to int if not None
278
- max_value = int(max_value.strip()) if max_value else None
279
- user_input = int(user_input.strip()) if user_input else None
280
- Usage = int(Usage.strip()) if Usage else None
281
- Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
282
-
283
- new_row = {
284
- "Slab": slab,
285
- "Max_value": max_value,
286
- "Commercial_value": user_input,
287
- "Usage": Usage,
288
- "Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
289
- "Threshold": threshold
290
- }
291
 
292
  # Append new_row to global list of rows
293
- global_data_rows.append(new_row)
294
 
295
  # Streamlit UI code
296
- def main():
297
- st.title("Slab Data Management")
298
 
299
  # Inputs for adding data
300
  # Input fields for user data
301
- col1, col2 = st.columns([2, 2])
302
-
303
- with col1:
304
- slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
305
- with col2:
306
- max_value = st.text_input("Max value:", key="max_value_input")
307
- with col1:
308
- user_input = st.text_input("Commercial Value:", key="user_input")
309
- with col2:
310
- Usage = st.text_input("Usage:", key="Usage_input")
311
- with col1:
312
- Capping_or_Minimum_Guarantee = st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
313
- with col2:
314
- threshold = st.text_input("Threshold:", key="threshold_input")
315
 
316
  # Button to add data
317
- if st.button("Add Data", key="add_data_button"):
318
- add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
319
- st.success(f"Data for Slab '{slab}' added successfully!")
320
 
321
  # Display all rows in a table
322
- if global_data_rows:
323
- st.subheader("Added Slabs")
324
- for i, row in enumerate(global_data_rows):
325
- st.write(f"Entry {i + 1}:")
326
- st.table([row])
327
 
328
- if __name__ == "__main__":
329
- main()
330
 
331
- elif selected_fee_nature in ["Fixed %", "Flat currency"]:
332
- user_input = st.number_input("Please enter Commercial value:", min_value=0.0, help="Enter a valid number")
333
 
334
  # 6th layer: Expected Billing
335
- Usage = st.number_input(f"Enter the usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
336
- Capping_or_Minimum_Guarantee = st.number_input(f"Enter the Capping/Minimum Guarantee for {selected_variable_type}", min_value=0.0,
 
 
 
337
  help="Enter the Capping/Minimum Gauarntee value")
338
- Product = Usage * user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
339
 
340
- abc = ['Capping value', 'Minimum Guarantee']
341
- threshold = st.selectbox("Choose a threshold option:", [""] + abc)
342
 
343
- initial_expected_billing = Product
344
 
345
- if threshold == 'Capping value':
346
- expected_billing = Product if Capping_or_Minimum_Guarantee > Product else Capping_or_Minimum_Guarantee
347
- elif threshold == 'Minimum Guarantee':
348
- expected_billing = Product if Capping_or_Minimum_Guarantee < Product else Capping_or_Minimum_Guarantee
349
- else:
350
- expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
351
 
352
- st.write(f"Expected Billing (excluding GST): {expected_billing}")
353
 
354
- selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Select the plan validity", key="plan_vd_2")
355
- selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Select the payment method", key="py_vd_2")
356
 
357
  # Submit button
358
- if st.button(":blue[Submit]"):
359
  # Save user data
360
- user_data = {
361
  "Plan Name": plan_name,
362
  "Plan Description": plan_description,
363
  "Plan Start Date": plan_start_date,
364
  "Ordering Channels": ordering_channels,
365
  "Company ID": company_id,
366
  "Company Name": company_name,
 
 
367
  "Fulfilling Location": fulfilling_location,
368
  "Application ID": application_id,
369
  "Fee Type": selected_fee_type,
@@ -371,25 +389,185 @@ if st.button(":blue[Submit]"):
371
  "Chargeable on": selected_chargeable_on,
372
  "Fee Nature": selected_fee_nature,
373
  "Commercial value": user_input,
 
 
374
  "Usage limit": Usage,
375
  "Minimum/Capping value": Capping_or_Minimum_Guarantee,
376
  "Threshold option": threshold,
377
  "Expected Billing": expected_billing,
378
  "Plan Validity": selected_plan_validity,
379
  "Payment Method": selected_payment_method,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  }
381
 
382
- global_user_data.append((user_name, user_data))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
  # Generate PM_id and add it to user_data
385
- rule_id = generate_rule_id(user_data)
386
- user_data['rule_id'] = rule_id
387
 
388
  # Generate Plan ID and add it to user_data
389
- plan_id = generate_plan_id(user_data)
390
- user_data['plan_id'] = plan_id
391
 
392
- save_user_data(user_data) # Save user data after submission
393
 
394
  # Display saved records
395
- display_saved_records()
 
 
28
  ordering_channels = user_data.get('Ordering Channels', '')
29
  fulfilling_location = user_data.get('Fulfilling Location', '')
30
  application_id = user_data.get('Application ID', '')
31
+ selected_fee_type = str(user_data.get('Fee type', ''))
32
  selected_variable_type = user_data.get('Variable', '')
33
  selected_chargeable_on = user_data.get('Chargeable on', '')
34
  selected_fee_nature = user_data.get('Fee Nature', '')
35
  threshold = user_data.get('Threshold option', '')
36
 
37
+ # Ensure all fields are strings
38
+ company_id = str(company_id) if company_id is not None else ''
39
+ ordering_channels = str(ordering_channels) if ordering_channels is not None else ''
40
+ fulfilling_location = str(fulfilling_location) if fulfilling_location is not None else ''
41
+ application_id = str(application_id) if application_id is not None else ''
42
+ selected_variable_type = str(selected_variable_type) if selected_variable_type is not None else ''
43
+ selected_chargeable_on = str(selected_chargeable_on) if selected_chargeable_on is not None else ''
44
+ selected_fee_nature = str(selected_fee_nature) if selected_fee_nature is not None else ''
45
+ threshold = str(threshold) if threshold is not None else ''
46
+
47
+
48
  company_id = company_id.zfill(5)[:5]
49
 
50
  # Extract first 2 characters from each field
 
151
 
152
 
153
  # Section 1: Plan Info
154
+ st.sidebar.image('Fynd_logo2.png', width=300)
155
+ st.sidebar.title(":blue[Plan maker]")
156
  user_name = st.sidebar.text_input("Enter your name:")
157
+ st.sidebar.title("Section 1: Plan Info")
158
  v1 = ["Commerce India", "Reliance", "Commerce Global", "Government Projects", "Individual BH"]
159
  business_head = st.sidebar.selectbox("Business Head", [""] + v1, help="Enter the name of Business head")
160
  company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
161
  company_name = st.sidebar.text_input("Company Name", help="Enter the company name")
162
+ currency = st.sidebar.radio("Select the currency type", options= ["INR", "USD"], help= "Select the type of currency", index =None)
163
+ bundle_by = st.sidebar.radio(options=["Single value", "Feature specific"], label="Bundle by", help = "Select the bundle", index=None)
 
 
 
164
 
165
+ if bundle_by == "Feature specific":
166
+
167
+ plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
168
+ plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
169
+ plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
170
 
171
 
172
  # Section 2: Company Info
173
+ st.sidebar.title("Section 2: Rule Info")
174
+ a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
175
  "GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
176
+ ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
177
 
178
  # Layer 1: Mapping of Ordering channels with Fulfilling location
179
+ if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
180
+ fulfilling_location = None
181
+ application_id = None
182
+ else:
183
+ abc = ["Store", "Warehouse"]
184
+ fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
185
+ application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
186
 
187
  # Section 3: Defining products for each dropdown
188
+ product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
189
  "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
190
  "CoPilot"]
191
+ fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
192
  "Packaging", "SLA", "Licensing"]
193
+ fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
194
+ variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
195
+ chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
196
  "RTO", "DTO", "Packed"]
197
+ plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
198
+ payment_method_options = ["Prepaid", "Postpaid"]
199
 
200
  # Mapping index
201
+ fee_config = {
202
+ 'fee_type_mapping': {
203
  "ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
204
  "Marketing", "SLA"],
205
  "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
 
222
  "Boltic": ["Subscription"],
223
  "CoPilot": ["Subscription"],
224
 
225
+ }
226
  }
 
227
 
228
+ var_config = {
229
+ 'variable_type_mapping': {
230
  "Development": ["Application", "Extension", "Integration"],
231
  "Subscription": ["Application", "Extension", "Integration", "Platform"],
232
  "Maintenance": ["Application", "Extension", "Integration"],
 
237
  "Logistics": ["Shipment"],
238
  "Marketing": ["Bag"],
239
  "Packaging": ["Shipment"]
240
+ }
241
  }
 
242
 
243
+ char_config = {
244
+ 'chargeable_on_mapping': {
245
  "Application": ["Developed", "Installed"],
246
  "Extension": ["Developed", "Installed", "Subscribed"],
247
  "Integration": ["Developed", "Installed"],
 
251
  "Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
252
  "Cancel"],
253
  "Platform": ["Subscribed"],
254
+ }
255
  }
 
256
 
257
 
258
  # 2nd layer: Mapping of Ordering channels with fee types
259
+ st.write("")
260
+ st.write("")
261
+ st.write("")
262
+ st.write("")
263
+ fee_type_mapping = fee_config['fee_type_mapping']
264
+ selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
265
  help="Select the type of fee")
266
 
267
  # 3rd layer mapping: Mapping of Fee type with variables
268
+ variable_type_mapping = var_config["variable_type_mapping"]
269
+ selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
270
  help="Select the type of variable")
271
 
272
  # 4th layer mapping: Mapping of Fee type with variables
273
+ chargeable_on_mapping = char_config["chargeable_on_mapping"]
274
+ selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
275
  help="Select the type of Chargeable")
276
 
277
  # Create an empty DataFrame with the desired column names
278
+ slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage", "Capping/Min_Guarantee_value", "Threshold"])
279
 
280
+ ttt = ["Fixed %", "Flat currency", "Slab based"]
281
+ selected_fee_nature = st.selectbox("Fee Nature:", [""] + ttt, key="fee_nature_select")
282
 
283
+ if selected_fee_nature == "Slab based":
284
+ st.write("Enter values for Slab based fee structure:")
285
 
286
  # Initialize an empty list to store data rows
287
+ global_data_rows = []
288
 
289
+ def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
290
  # Convert values to int if not None
291
+ max_value = int(max_value.strip()) if max_value else None
292
+ user_input = int(user_input.strip()) if user_input else None
293
+ Usage = int(Usage.strip()) if Usage else None
294
+ Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
295
+
296
+ new_row = {
297
+ "Slab": slab,
298
+ "Max_value": max_value,
299
+ "Commercial_value": user_input,
300
+ "Usage": Usage,
301
+ "Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
302
+ "Threshold": threshold
303
+ }
304
 
305
  # Append new_row to global list of rows
306
+ global_data_rows.append(new_row)
307
 
308
  # Streamlit UI code
309
+ def main():
310
+ st.title("Slab Data Management")
311
 
312
  # Inputs for adding data
313
  # Input fields for user data
314
+ col1, col2 = st.columns([2, 2])
315
+
316
+ with col1:
317
+ slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
318
+ with col2:
319
+ max_value = st.text_input("Max value:", key="max_value_input")
320
+ with col1:
321
+ user_input = st.text_input("Commercial Value:", key="user_input")
322
+ with col2:
323
+ Usage = st.text_input("Usage:", key="Usage_input")
324
+ with col1:
325
+ Capping_or_Minimum_Guarantee = st.text_input("Capping/Min_Guarantee:", key="Capping_or_Minimum_Guarantee_input")
326
+ with col2:
327
+ threshold = st.text_input("Threshold:", key="threshold_input")
328
 
329
  # Button to add data
330
+ if st.button("Add Data", key="add_data_button"):
331
+ add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
332
+ st.success(f"Data for Slab '{slab}' added successfully!")
333
 
334
  # Display all rows in a table
335
+ if global_data_rows:
336
+ st.subheader("Added Slabs")
337
+ for i, row in enumerate(global_data_rows):
338
+ st.write(f"Entry {i + 1}:")
339
+ st.table([row])
340
 
341
+ if __name__ == "__main__":
342
+ main()
343
 
344
+ elif selected_fee_nature in ["Fixed %", "Flat currency"]:
345
+ user_input = st.number_input("Commercial value:", min_value=0.0, help="Enter a valid number")
346
 
347
  # 6th layer: Expected Billing
348
+ fee_reversal_options = ["RTO", "DTO", "Cancel"]
349
+ fee_reversal = st.multiselect("Fee Reversal", fee_reversal_options) if selected_fee_type == "Transaction" and selected_variable_type == "Bag" else None
350
+ reversal_per = st.number_input("Reversal %", min_value= 0.0, help = "Enter the reversal percentage") if selected_fee_type == "Transaction" and selected_variable_type == "Bag" else None
351
+ Usage = st.number_input(f"Usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
352
+ Capping_or_Minimum_Guarantee = st.number_input(f"Capping/Minimum Guarantee for {selected_variable_type}", min_value=0.0,
353
  help="Enter the Capping/Minimum Gauarntee value")
354
+ Product = Usage * user_input if selected_fee_nature in ["Fixed %", "Flat currency"] else 0
355
 
356
+ abc = ['Capping value', 'Minimum Guarantee']
357
+ threshold = st.selectbox("Threshold option:", [""] + abc)
358
 
359
+ initial_expected_billing = Product
360
 
361
+ if threshold == 'Capping value':
362
+ expected_billing = Product if Capping_or_Minimum_Guarantee > Product else Capping_or_Minimum_Guarantee
363
+ elif threshold == 'Minimum Guarantee':
364
+ expected_billing = Product if Capping_or_Minimum_Guarantee < Product else Capping_or_Minimum_Guarantee
365
+ else:
366
+ expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
367
 
368
+ st.write(f"Expected Billing (excluding GST): {expected_billing}")
369
 
370
+ selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Select the plan validity", key="plan_vd_2")
371
+ selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Select the payment method", key="py_vd_2")
372
 
373
  # Submit button
374
+ if st.button("Submit"):
375
  # Save user data
376
+ user_data = {
377
  "Plan Name": plan_name,
378
  "Plan Description": plan_description,
379
  "Plan Start Date": plan_start_date,
380
  "Ordering Channels": ordering_channels,
381
  "Company ID": company_id,
382
  "Company Name": company_name,
383
+ "Currency type": currency,
384
+ "Bundle by": bundle_by,
385
  "Fulfilling Location": fulfilling_location,
386
  "Application ID": application_id,
387
  "Fee Type": selected_fee_type,
 
389
  "Chargeable on": selected_chargeable_on,
390
  "Fee Nature": selected_fee_nature,
391
  "Commercial value": user_input,
392
+ "Fee reversal": fee_reversal,
393
+ "Reversal %": reversal_per,
394
  "Usage limit": Usage,
395
  "Minimum/Capping value": Capping_or_Minimum_Guarantee,
396
  "Threshold option": threshold,
397
  "Expected Billing": expected_billing,
398
  "Plan Validity": selected_plan_validity,
399
  "Payment Method": selected_payment_method,
400
+ }
401
+
402
+ global_user_data.append((user_name, user_data))
403
+
404
+ # Generate PM_id and add it to user_data
405
+ rule_id = generate_rule_id(user_data)
406
+ user_data['rule_id'] = rule_id
407
+
408
+ # Generate Plan ID and add it to user_data
409
+ plan_id = generate_plan_id(user_data)
410
+ user_data['plan_id'] = plan_id
411
+
412
+ save_user_data(user_data) # Save user data after submission
413
+
414
+ # Display saved records
415
+ display_saved_records()
416
+
417
+
418
+
419
+ elif bundle_by == "Single value":
420
+ user_input_1 = st.sidebar.text_input("Enter Single values:")
421
+
422
+ plan_name = st.sidebar.text_input("Plan Name", help="Enter the name of the plan")
423
+ plan_description = st.sidebar.text_area("Plan Description", max_chars=250, help="Describe the plan")
424
+ plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
425
+
426
+
427
+ # Section 2: Company Info
428
+ st.sidebar.title("Section 2: Rule Info")
429
+ a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
430
+ "GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
431
+ ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
432
+
433
+ # Layer 1: Mapping of Ordering channels with Fulfilling location
434
+ if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
435
+ fulfilling_location = None
436
+ application_id = None
437
+ else:
438
+ abc = ["Store", "Warehouse"]
439
+ fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
440
+ application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
441
+
442
+ # Section 3: Defining products for each dropdown
443
+ product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
444
+ "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
445
+ "CoPilot"]
446
+ fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
447
+ "Packaging", "SLA", "Licensing"]
448
+ fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
449
+ variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User"]
450
+ chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
451
+ "RTO", "DTO", "Packed"]
452
+ plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
453
+ payment_method_options = ["Prepaid", "Postpaid"]
454
+
455
+ # Mapping index
456
+ fee_config = {
457
+ 'fee_type_mapping': {
458
+ "ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
459
+ "Marketing", "SLA"],
460
+ "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
461
+ "B2B": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
462
+ "Packaging"],
463
+ "Marketplaces": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
464
+ "StoreOS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
465
+ "Logistics", "Packaging"],
466
+ "Storefronts": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics"],
467
+ "Fynd TMS": ["Development", "Subscription", "Maintenance", "Licensing", "Logistics"],
468
+ "Fynd WMS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
469
+ "Logistics", "Packaging"],
470
+ "GMC": ["Development", "Subscription", "Maintenance"],
471
+ "Catalog Cloud": ["Development", "Subscription", "Maintenance"],
472
+ "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
473
+ "Fynd OMS": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
474
+ "Fynd Commerce Platform": ["Subscription"],
475
+ "Logistics": ["Logistics"],
476
+ "PixelBin": ["Subscription"],
477
+ "Boltic": ["Subscription"],
478
+ "CoPilot": ["Subscription"],
479
+
480
+ }
481
  }
482
 
483
+ var_config = {
484
+ 'variable_type_mapping': {
485
+ "Development": ["Application", "Extension", "Integration"],
486
+ "Subscription": ["Application", "Extension", "Integration", "Platform"],
487
+ "Maintenance": ["Application", "Extension", "Integration"],
488
+ "Licensing": ["Store", "User"],
489
+ "Transaction": ["Bag", "Shipment"],
490
+ "Minimum Guarantee": ["Bag", "Shipment"],
491
+ "SLA": ["Bag", "Shipment"],
492
+ "Logistics": ["Shipment"],
493
+ "Marketing": ["Bag"],
494
+ "Packaging": ["Shipment"]
495
+ }
496
+ }
497
+
498
+ char_config = {
499
+ 'chargeable_on_mapping': {
500
+ "Application": ["Developed", "Installed"],
501
+ "Extension": ["Developed", "Installed", "Subscribed"],
502
+ "Integration": ["Developed", "Installed"],
503
+ "Store": ["Added", "Active"],
504
+ "User": ["Added", "Active"],
505
+ "Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
506
+ "Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
507
+ "Cancel"],
508
+ "Platform": ["Subscribed"],
509
+ }
510
+ }
511
+
512
+
513
+ # 2nd layer: Mapping of Ordering channels with fee types
514
+ st.write("")
515
+ st.write("")
516
+ st.write("")
517
+ st.write("")
518
+
519
+
520
+
521
+ fee_type_mapping = fee_config['fee_type_mapping']
522
+ selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
523
+ help="Select the type of fee")
524
+
525
+ # 3rd layer mapping: Mapping of Fee type with variables
526
+ variable_type_mapping = var_config["variable_type_mapping"]
527
+ selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
528
+ help="Select the type of variable")
529
+
530
+ # 4th layer mapping: Mapping of Fee type with variables
531
+ chargeable_on_mapping = char_config["chargeable_on_mapping"]
532
+ selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
533
+ help="Select the type of Chargeable")
534
+
535
+ Usage = st.number_input(f"Usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
536
+ selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Select the plan validity", key="plan_vd_2")
537
+ selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Select the payment method", key="py_vd_2")
538
+
539
+ # Submit button
540
+ if st.button("Submit"):
541
+ # Save user data
542
+ user_data = {
543
+ "Plan Name": plan_name,
544
+ "Plan Description": plan_description,
545
+ "Plan Start Date": plan_start_date,
546
+ "Ordering Channels": ordering_channels,
547
+ "Company ID": company_id,
548
+ "Company Name": company_name,
549
+ "Fulfilling Location": fulfilling_location,
550
+ "Application ID": application_id,
551
+ "Fee Type": selected_fee_type,
552
+ "Variable": selected_variable_type,
553
+ "Chargeable on": selected_chargeable_on,
554
+
555
+ "Plan Validity": selected_plan_validity,
556
+ "Payment Method": selected_payment_method,
557
+ }
558
+
559
+ global_user_data.append((user_name, user_data))
560
 
561
  # Generate PM_id and add it to user_data
562
+ rule_id = generate_rule_id(user_data)
563
+ user_data['rule_id'] = rule_id
564
 
565
  # Generate Plan ID and add it to user_data
566
+ plan_id = generate_plan_id(user_data)
567
+ user_data['plan_id'] = plan_id
568
 
569
+ save_user_data(user_data) # Save user data after submission
570
 
571
  # Display saved records
572
+ display_saved_records()
573
+