Ninad077 commited on
Commit
10c9dcf
·
verified ·
1 Parent(s): f1a3c28

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +604 -189
app.py CHANGED
@@ -13,17 +13,17 @@ from threading import Thread
13
  from pyngrok import conf, ngrok
14
  import requests
15
 
16
- # # Manually set ngrok path
17
- # ngrok_path = "/Users/ninadmandavkar/Desktop/ngrok/ngrok 3"
18
 
19
- # # Set the ngrok path in the configuration
20
- # config = conf.get_default()
21
- # config.ngrok_path = ngrok_path
22
 
23
- # # Set your ngrok auth token
24
- # ngrok.set_auth_token('2jQ6LRMBFqe25TP7o2ugti9EH6Y_3mBzBYbsjZmhh69eGq2Q1')
25
 
26
- # # logging.basicConfig(level=logging.INFO)
27
 
28
 
29
  ## Single value - 268 --> 675
@@ -338,10 +338,257 @@ if bundle_by == "Feature specific":
338
  plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
339
 
340
 
341
- # Section 2: Company Info
 
 
 
 
 
 
 
 
 
342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
 
344
- html_content_2 = """
345
  <h1 style='
346
  color: #a689f6;
347
  font-size: 22px;
@@ -353,14 +600,17 @@ if bundle_by == "Feature specific":
353
  '>Section 2: Rule Info</h1>
354
  """
355
 
356
- st.sidebar.markdown(html_content_2, unsafe_allow_html=True)
357
- a1 = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
358
- "Catalog Cloud", "FCP", "PixelBin", "Boltic",
359
- "CoPilot"]
360
- ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
 
 
 
361
 
362
- # Layer 1: Mapping of Ordering channels with Fulfilling location
363
- if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
364
  fulfilling_location = None
365
  application_id = None
366
  else:
@@ -368,85 +618,43 @@ if bundle_by == "Feature specific":
368
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
369
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
370
 
371
- # Section 3: Defining products for each dropdown
372
- product_options = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
373
- "Catalog Cloud", "FCP", "PixelBin", "Boltic",
374
- "CoPilot"]
375
- fee_type_options = ["Development", "Licensing", "Logistics", "Marketing", "Packaging", "Subscription", "Transaction"]
376
- fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
377
- variable_options = ["Application", "Bag", "Extension", "Integration", "Order", "Platform", "Resource", "Shipment", "User", "B2B", "B2C"]
378
- chargeable_on_options = ["Active", "Build", "Cancelled", "Delivered", "DTO", "Invoiced", "Packed", "Picked", "Placed", "Return Window", "RTO", "Setup", "SiteOps-hr", "Subscribed", "TechOps-hr"]
379
- plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
380
- payment_method_options = ["Prepaid", "Postpaid"]
381
-
382
- # Mapping index
383
- fee_config = {
384
- 'fee_type_mapping': {
385
- "ONDC": ["Transaction", "Logistics", "Packaging"],
386
- "GoFynd": ["Transaction", "Logistics", "Marketing","Packaging"],
387
- "StoreOS": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging", "Marketing"],
388
- "Website": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging"],
389
- "TMS": ["Development","Licensing", "Subscription", "Logistics"],
390
- "WMS": ["Development","Licensing", "Subscription", "Transaction"],
391
- "GMC": ["Development", "Licensing","Subscription"],
392
- "Partner": ["Development", "Licensing","Subscription"],
393
- "Catalog Cloud": ["Development", "Licensing","Subscription"],
394
- "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging"],
395
- "OMS": ["Development","Licensing", "Subscription", "Transaction"],
396
- "FCP": ["Subscription"],
397
- "PixelBin": ["Subscription"],
398
- "Boltic": ["Subscription"],
399
- "CoPilot": ["Subscription"],
400
- }
401
- }
402
-
403
- var_config = {
404
- 'variable_type_mapping': {
405
- "Development": ["Application", "Extension", "Integration"],
406
- "Subscription": ["Application", "Extension", "Integration", "Platform", "User", "Resource"],
407
- "Licensing": ["Application", "Extension", "Integration"],
408
- "Transaction": ["Bag", "Order", "Shipment","B2B", "B2C"],
409
- "Logistics": ["Shipment"],
410
- "Marketing": ["Order"],
411
- "Packaging": ["Shipment"],
412
- }
413
- }
414
-
415
- char_config = {
416
- 'chargeable_on_mapping': {
417
- "Application": ["Build", "Setup", "Subscribed"],
418
- "Extension": ["Build", "Setup", "Subscribed"],
419
- "Integration": ["Build", "Setup", "Subscribed"],
420
- "Order": ["Placed"],
421
- "User": ["Active"],
422
- "Bag": ["Invoiced", "Delivered", "Return Window"],
423
- "Shipment": ["Cancelled","Picked", "RTO", "DTO", "Packed"],
424
- "Platform": ["Subscribed"],
425
- 'Resource':["TechOps-hr", "SiteOps-hr"],
426
- "B2B": ["Invoiced"],
427
- "B2C":["Invoiced"]
428
- }
429
- }
430
-
431
 
432
- # 2nd layer: Mapping of Ordering channels with fee types
433
- st.write("")
434
- st.write("")
435
-
436
- fee_type_mapping = fee_config['fee_type_mapping']
437
- selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
438
- help="Fee type is a revenue head for grouping the revenue")
439
-
440
 
441
- # 3rd layer mapping: Mapping of Fee type with variables
442
- variable_type_mapping = var_config["variable_type_mapping"]
443
- selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
444
- help="Variable type is an attribute on which revenue calculation will be done")
 
 
 
 
 
 
 
 
445
 
446
- # 4th layer mapping: Mapping of Fee type with variables
447
- chargeable_on_mapping = char_config["chargeable_on_mapping"]
448
- selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
449
- help="Chargeable on is a service status on which above fee will be applicable")
 
 
 
 
 
 
 
 
450
 
451
  # Create an empty DataFrame with the desired column names
452
  slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage", "Capping/Min_Guarantee_value", "Threshold"])
@@ -658,7 +866,7 @@ if bundle_by == "Feature specific":
658
  "Bundle_by": bundle_by,
659
  "Plan_Name": plan_name,
660
  "Plan_Description": plan_description,
661
- "Product_lines": ordering_channels,
662
  "Fulfilling_Location": fulfilling_location,
663
  "Application_ID": application_id,
664
  "Fee_Type": selected_fee_type,
@@ -733,7 +941,7 @@ if bundle_by == "Feature specific":
733
  "Bundle_by": bundle_by,
734
  "Plan_Name": plan_name,
735
  "Plan_Description": plan_description,
736
- "Product_lines": ordering_channels,
737
  "Fulfilling_Location": fulfilling_location,
738
  "Application_ID": application_id,
739
  "Fee_Type": selected_fee_type,
@@ -783,7 +991,257 @@ elif bundle_by == "Single value":
783
  plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
784
 
785
 
786
- # Section 2: Company Info
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
787
 
788
  html_content_3 = """
789
  <h1 style='
@@ -799,12 +1257,15 @@ elif bundle_by == "Single value":
799
 
800
  st.sidebar.markdown(html_content_3, unsafe_allow_html=True)
801
 
802
- a1 = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner", "Catalog Cloud", "FCP", "PixelBin", "Boltic",
803
- "CoPilot"]
804
- ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
805
-
806
- # Layer 1: Mapping of Ordering channels with Fulfilling location
807
- if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
 
 
 
808
  fulfilling_location = None
809
  application_id = None
810
  else:
@@ -812,89 +1273,43 @@ elif bundle_by == "Single value":
812
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
813
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
814
 
 
 
 
 
 
815
 
816
- # Section 3: Defining products for each dropdown
817
- product_options = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
818
- "Catalog Cloud", "FCP", "PixelBin", "Boltic",
819
- "CoPilot"]
820
- fee_type_options = ["Development", "Licensing", "Logistics", "Marketing", "Packaging", "Subscription", "Transaction"]
821
- fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
822
- variable_options = ["Application", "Bag", "Extension", "Integration", "Order", "Platform", "Resource", "Shipment", "User", "B2B", "B2C"]
823
- chargeable_on_options = ["Active", "Build", "Cancelled", "Delivered", "DTO", "Invoiced", "Packed", "Picked", "Placed", "Return Window", "RTO", "Setup", "SiteOps-hr", "Subscribed", "TechOps-hr"]
824
- plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
825
- payment_method_options = ["Prepaid", "Postpaid"]
826
-
827
-
828
- # Mapping index
829
- fee_config = {
830
- 'fee_type_mapping': {
831
- "ONDC": ["Transaction", "Logistics", "Packaging"],
832
- "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging"],
833
- "StoreOS": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging", "Marketing"],
834
- "Website": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging"],
835
- "TMS": ["Development","Licensing", "Subscription", "Logistics"],
836
- "WMS": ["Development","Licensing", "Subscription", "Transaction"],
837
- "GMC": ["Development", "Licensing","Subscription"],
838
- "Partner": ["Development", "Licensing","Subscription"],
839
- "Catalog Cloud": ["Development", "Licensing","Subscription"],
840
- "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging"],
841
- "OMS": ["Development","Licensing", "Subscription", "Transaction"],
842
- "FCP": ["Subscription"],
843
- "PixelBin": ["Subscription"],
844
- "Boltic": ["Subscription"],
845
- "CoPilot": ["Subscription"],
846
- }
847
- }
848
-
849
- var_config = {
850
- 'variable_type_mapping': {
851
- "Development": ["Application", "Extension", "Integration"],
852
- "Subscription": ["Application", "Extension", "Integration", "Platform", "User", "Resource"],
853
- "Licensing": ["Application", "Extension", "Integration"],
854
- "Transaction": ["Bag", "Order", "Shipment","B2B", "B2C"],
855
- "Logistics": ["Shipment"],
856
- "Marketing": ["Order"],
857
- "Packaging": ["Shipment"],
858
- }
859
- }
860
-
861
- char_config = {
862
- 'chargeable_on_mapping': {
863
- "Application": ["Build", "Setup", "Subscribed"],
864
- "Extension": ["Build", "Setup", "Subscribed"],
865
- "Integration": ["Build", "Setup", "Subscribed"],
866
- "Order": ["Placed"],
867
- "User": ["Active"],
868
- "Bag": ["Invoiced", "Delivered", "Return Window"],
869
- "Shipment": ["Cancelled","Picked", "RTO", "DTO", "Packed"],
870
- "Platform": ["Subscribed"],
871
- 'Resource':["TechOps-hr", "SiteOps-hr"],
872
- "B2B": ["Invoiced"],
873
- "B2C":["Invoiced"]
874
- }
875
- }
876
-
877
- # 2nd layer: Mapping of Ordering channels with fee types
878
- st.write("")
879
- st.write("")
880
- st.write("")
881
- st.write("")
882
-
883
-
884
-
885
- fee_type_mapping = fee_config['fee_type_mapping']
886
- selected_fee_type = st.selectbox("Fee Type", [""] + fee_type_mapping.get(ordering_channels, []),
887
- help="Fee type is a revenue head for grouping the revenue")
888
 
889
- # 3rd layer mapping: Mapping of Fee type with variables
890
- variable_type_mapping = var_config["variable_type_mapping"]
891
- selected_variable_type = st.selectbox("Variable Type", [""] + variable_type_mapping.get(selected_fee_type, []),
892
- help="Variable type is an attribute on which revenue calculation will be done")
 
 
 
 
 
 
 
 
893
 
894
- # 4th layer mapping: Mapping of Fee type with variables
895
- chargeable_on_mapping = char_config["chargeable_on_mapping"]
896
- selected_chargeable_on = st.selectbox("Chargeable on", [""] + chargeable_on_mapping.get(selected_variable_type, []),
897
- help="Chargeable on is a service status on which above fee will be applicable")
 
 
 
 
 
 
 
 
898
 
899
  usage_1 = st.number_input(f"Usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
900
  usage_2 = float(usage_1)
@@ -988,7 +1403,7 @@ elif bundle_by == "Single value":
988
  "Bundle by": bundle_by,
989
  "Plan Name": plan_name,
990
  "Plan Description": plan_description,
991
- "Product lines": ordering_channels,
992
  "Fulfilling Location": fulfilling_location,
993
  "Application ID": application_id,
994
  "Fee Type": selected_fee_type,
@@ -1074,7 +1489,7 @@ elif bundle_by == "Single value":
1074
  "Bundle_by": bundle_by,
1075
  "Plan_Name": plan_name,
1076
  "Plan_Description": plan_description,
1077
- "Product_lines": ordering_channels,
1078
  "Fulfilling_Location": fulfilling_location,
1079
  "Application_ID": application_id,
1080
  "Fee_Type": selected_fee_type,
@@ -1145,8 +1560,8 @@ st.write(" ")
1145
  # Start a tunnel to the correct port
1146
 
1147
  # Connect to a port (e.g., 8501) without a custom subdomain
1148
- # try:
1149
- # ngrok_tunnel = ngrok.connect(8501) # Replace 8501 with your port number
1150
- # print(f"ngrok tunnel URL: {ngrok_tunnel.public_url}")
1151
- # except Exception as e:
1152
- # print(f"Failed to start ngrok tunnel: {e}")
 
13
  from pyngrok import conf, ngrok
14
  import requests
15
 
16
+ # Manually set ngrok path
17
+ ngrok_path = "/Users/ninadmandavkar/Desktop/ngrok/ngrok 3"
18
 
19
+ # Set the ngrok path in the configuration
20
+ config = conf.get_default()
21
+ config.ngrok_path = ngrok_path
22
 
23
+ # Set your ngrok auth token
24
+ ngrok.set_auth_token('2jQ6LRMBFqe25TP7o2ugti9EH6Y_3mBzBYbsjZmhh69eGq2Q1')
25
 
26
+ # logging.basicConfig(level=logging.INFO)
27
 
28
 
29
  ## Single value - 268 --> 675
 
338
  plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
339
 
340
 
341
+ # Section 3: Defining products for each dropdown
342
+ product_options = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
343
+ "Catalog Cloud", "FCP", "PixelBin", "Boltic",
344
+ "CoPilot"]
345
+ fee_type_options = ["Development", "Licensing", "Logistics", "Marketing", "Packaging", "Subscription", "Transaction"]
346
+ fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
347
+ variable_options = ["Application", "Bag", "Extension", "Integration", "Order", "Platform", "Resource", "Shipment", "User", "B2B", "B2C"]
348
+ chargeable_on_options = ["Active", "Build", "Cancelled", "Delivered", "DTO", "Invoiced", "Packed", "Picked", "Placed", "Return Window", "RTO", "Setup", "SiteOps-hr", "Subscribed", "TechOps-hr"]
349
+ plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
350
+ payment_method_options = ["Prepaid", "Postpaid"]
351
 
352
+ # Given new_mapping dictionary
353
+ new_mapping = {
354
+ "GoFynd": {
355
+ "Marketing": {
356
+ "Order": ["Placed"]
357
+ },
358
+ "Transaction": {
359
+ "Bag": ["Return Window"],
360
+ "Shipment": ["Cancelled", "RTO", "DTO"]
361
+ },
362
+ "Logistics": {
363
+ "Shipment": ["Picked", "RTO", "DTO"]
364
+ },
365
+ "Packaging": {
366
+ "Shipment": ["Packed"]
367
+ }
368
+ },
369
+ "Uniket": {
370
+ "Marketing": {
371
+ "Order": ["Placed"]
372
+ },
373
+ "Transaction": {
374
+ "Bag": ["Return Window"],
375
+ "Shipment": ["Cancelled", "RTO", "DTO"]
376
+ },
377
+ "Logistics": {
378
+ "Shipment": ["Picked", "RTO", "DTO"]
379
+ },
380
+ "Packaging": {
381
+ "Shipment": ["Packed"]
382
+ }
383
+ },
384
+ "ONDC": {
385
+ "Transaction": {
386
+ "Bag": ["Return Window"],
387
+ "Shipment": ["Cancelled", "RTO", "DTO"]
388
+ },
389
+ "Logistics": {
390
+ "Shipment": ["Picked", "RTO", "DTO"]
391
+ },
392
+ "Packaging": {
393
+ "Shipment": ["Packed"]
394
+ }
395
+ },
396
+ "StoreOS": {
397
+ "Licensing": {
398
+ "Application": ["Setup"]
399
+ },
400
+ "Subscription": {
401
+ "Application": ["Subscribed"],
402
+ "User": ["Active"],
403
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
404
+ },
405
+ "Marketing": {
406
+ "Order": ["Placed"]
407
+ },
408
+ "Transaction": {
409
+ "Order": ["Placed"],
410
+ "Bag": ["Invoiced", "Delivered"]
411
+ },
412
+ "Logistics": {
413
+ "Shipment": ["Picked", "RTO", "DTO"]
414
+ },
415
+ "Packaging": {
416
+ "Shipment": ["Packed"]
417
+ }
418
+ },
419
+ "Website": {
420
+ "Licensing": {
421
+ "Application": ["Setup"]
422
+ },
423
+ "Subscription": {
424
+ "Application": ["Subscribed"],
425
+ "User": ["Active"],
426
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
427
+ },
428
+ "Transaction": {
429
+ "Order": ["Placed"],
430
+ "Bag": ["Invoiced", "Delivered"]
431
+ },
432
+ "Logistics": {
433
+ "Shipment": ["Picked", "RTO", "DTO"]
434
+ },
435
+ "Packaging": {
436
+ "Shipment": ["Packed"]
437
+ },
438
+ "Development": {
439
+ "Application": ["Build"]
440
+ }
441
+ },
442
+ "OMS": {
443
+ "Development": {
444
+ "Integration": ["Build"]
445
+ },
446
+ "Licensing": {
447
+ "Integration": ["Setup"]
448
+ },
449
+ "Subscription": {
450
+ "Integration": ["Subscribed"],
451
+ "User": ["Active"],
452
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
453
+ },
454
+ "Transaction": {
455
+ "Order": ["Placed"],
456
+ "Bag": ["Invoiced", "Delivered"]
457
+ }
458
+ },
459
+ "WMS": {
460
+ "Development": {
461
+ "Integration": ["Build"]
462
+ },
463
+ "Licensing": {
464
+ "Integration": ["Setup"]
465
+ },
466
+ "Subscription": {
467
+ "Integration": ["Subscribed"],
468
+ "User": ["Active"],
469
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
470
+ },
471
+ "Transaction": {
472
+ "Order": ["Placed"],
473
+ "Bag": ["Invoiced", "Delivered"],
474
+ "B2B": ["Invoiced"],
475
+ "B2C": ["Invoiced"]
476
+ }
477
+ },
478
+ "TMS": {
479
+ "Development": {
480
+ "Integration": ["Build"]
481
+ },
482
+ "Licensing": {
483
+ "Integration": ["Setup"]
484
+ },
485
+ "Subscription": {
486
+ "Integration": ["Subscribed"],
487
+ "User": ["Active"],
488
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
489
+ },
490
+ "Logistics": {
491
+ "Shipment": ["Picked", "RTO", "DTO"]
492
+ }
493
+ },
494
+ "GMC": {
495
+ "Development": {
496
+ "Extension": ["Build"],
497
+ "Integration": ["Build"]
498
+ },
499
+ "Licensing": {
500
+ "Extension": ["Setup"]
501
+ },
502
+ "Subscription": {
503
+ "Extension": ["Subscribed"],
504
+ "User": ["Active"],
505
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
506
+ }
507
+ },
508
+ "Partner": {
509
+ "Development": {
510
+ "Extension": ["Build"]
511
+ },
512
+ "Licensing": {
513
+ "Extension": ["Setup"]
514
+ },
515
+ "Subscription": {
516
+ "Extension": ["Subscribed"],
517
+ "User": ["Active"],
518
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
519
+ }
520
+ },
521
+ "Catalog Cloud": {
522
+ "Development": {
523
+ "Extension": ["Build"]
524
+ },
525
+ "Licensing": {
526
+ "Extension": ["Setup"]
527
+ },
528
+ "Subscription": {
529
+ "Extension": ["Subscribed"],
530
+ "User": ["Active"],
531
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
532
+ }
533
+ },
534
+ "FCP": {
535
+ "Subscription": {
536
+ "Platform": ["Subscribed"],
537
+ "User": ["Active"],
538
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
539
+ }
540
+ },
541
+ "PixelBin": {
542
+ "Subscription": {
543
+ "Platform": ["Subscribed"],
544
+ "User": ["Active"],
545
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
546
+ }
547
+ },
548
+ "Boltic": {
549
+ "Subscription": {
550
+ "Platform": ["Subscribed"],
551
+ "User": ["Active"],
552
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
553
+ }
554
+ },
555
+ "CoPilot": {
556
+ "Subscription": {
557
+ "Platform": ["Subscribed"],
558
+ "User": ["Active"],
559
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
560
+ }
561
+ }
562
+ }
563
+
564
+ # Initialize mappings
565
+ fee_type_mapping = {}
566
+ variable_type_mapping = {}
567
+ chargeable_on_mapping = {}
568
+
569
+ # Populate mappings from new_mapping
570
+ for ordering_channel, details in new_mapping.items():
571
+ for fee_type, variables in details.items():
572
+ if fee_type not in fee_type_mapping:
573
+ fee_type_mapping[fee_type] = []
574
+ if fee_type not in variable_type_mapping:
575
+ variable_type_mapping[fee_type] = []
576
+ variable_types = list(variables.keys())
577
+ variable_type_mapping[fee_type].extend(variable_types)
578
+ for variable_type, chargeable_on_list in variables.items():
579
+ if variable_type not in chargeable_on_mapping:
580
+ chargeable_on_mapping[variable_type] = []
581
+ chargeable_on_mapping[variable_type].extend(chargeable_on_list)
582
+
583
+ # Remove duplicates in mappings
584
+ fee_type_mapping = {k: list(set(v)) for k, v in fee_type_mapping.items()}
585
+ variable_type_mapping = {k: list(set(v)) for k, v in variable_type_mapping.items()}
586
+ chargeable_on_mapping = {k: list(set(v)) for k, v in chargeable_on_mapping.items()}
587
+
588
+
589
+ # Section 2: Company Info
590
 
591
+ html_content_3 = """
592
  <h1 style='
593
  color: #a689f6;
594
  font-size: 22px;
 
600
  '>Section 2: Rule Info</h1>
601
  """
602
 
603
+ st.sidebar.markdown(html_content_3, unsafe_allow_html=True)
604
+
605
+ # 1st layer: Select ordering channel
606
+ selected_ordering_channel = st.sidebar.selectbox(
607
+ "Product Lines",
608
+ [""] + list(new_mapping.keys()),
609
+ help="Select a product line"
610
+ )
611
 
612
+ # Layer 1: Mapping of Ordering channels with Fulfilling location
613
+ if "TMS" in selected_ordering_channel or "GMC" in selected_ordering_channel or "Catalog Cloud" in selected_ordering_channel:
614
  fulfilling_location = None
615
  application_id = None
616
  else:
 
618
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
619
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
620
 
621
+ # 2nd layer: Select fee type based on the selected ordering channel
622
+ fee_types_for_channel = []
623
+ if selected_ordering_channel:
624
+ details = new_mapping.get(selected_ordering_channel, {})
625
+ fee_types_for_channel = list(details.keys())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
 
627
+ selected_fee_type = st.selectbox(
628
+ "Fee Type",
629
+ [""] + fee_types_for_channel,
630
+ help="Fee type is a revenue head for grouping the revenue"
631
+ )
 
 
 
632
 
633
+ # 3rd layer: Select variable type based on the selected fee type
634
+ variable_type_options = []
635
+ if selected_fee_type and selected_ordering_channel:
636
+ details = new_mapping.get(selected_ordering_channel, {})
637
+ variables = details.get(selected_fee_type, {})
638
+ variable_type_options = list(variables.keys())
639
+
640
+ selected_variable_type = st.selectbox(
641
+ "Variable Type",
642
+ [""] + variable_type_options,
643
+ help="Variable type is an attribute on which revenue calculation will be done"
644
+ )
645
 
646
+ # 4th layer: Select chargeable on based on the selected variable type
647
+ chargeable_on_options = []
648
+ if selected_variable_type and selected_fee_type and selected_ordering_channel:
649
+ details = new_mapping.get(selected_ordering_channel, {})
650
+ variables = details.get(selected_fee_type, {})
651
+ chargeable_on_options = variables.get(selected_variable_type, [])
652
+
653
+ selected_chargeable_on = st.selectbox(
654
+ "Chargeable on",
655
+ [""] + chargeable_on_options,
656
+ help="Chargeable on is a service status on which the above fee will be applicable"
657
+ )
658
 
659
  # Create an empty DataFrame with the desired column names
660
  slabs_df = pd.DataFrame(columns=["Slab", "Max_value", "Commercial_value", "Usage", "Capping/Min_Guarantee_value", "Threshold"])
 
866
  "Bundle_by": bundle_by,
867
  "Plan_Name": plan_name,
868
  "Plan_Description": plan_description,
869
+ "Product_lines": selected_ordering_channel,
870
  "Fulfilling_Location": fulfilling_location,
871
  "Application_ID": application_id,
872
  "Fee_Type": selected_fee_type,
 
941
  "Bundle_by": bundle_by,
942
  "Plan_Name": plan_name,
943
  "Plan_Description": plan_description,
944
+ "Product_lines": selected_ordering_channel,
945
  "Fulfilling_Location": fulfilling_location,
946
  "Application_ID": application_id,
947
  "Fee_Type": selected_fee_type,
 
991
  plan_start_date = st.sidebar.date_input("Plan Start Date", value=datetime.now(), help="Select the start date of the plan")
992
 
993
 
994
+
995
+
996
+ # Section 3: Defining products for each dropdown
997
+ product_options = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
998
+ "Catalog Cloud", "FCP", "PixelBin", "Boltic",
999
+ "CoPilot"]
1000
+ fee_type_options = ["Development", "Licensing", "Logistics", "Marketing", "Packaging", "Subscription", "Transaction"]
1001
+ fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
1002
+ variable_options = ["Application", "Bag", "Extension", "Integration", "Order", "Platform", "Resource", "Shipment", "User", "B2B", "B2C"]
1003
+ chargeable_on_options = ["Active", "Build", "Cancelled", "Delivered", "DTO", "Invoiced", "Packed", "Picked", "Placed", "Return Window", "RTO", "Setup", "SiteOps-hr", "Subscribed", "TechOps-hr"]
1004
+ plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
1005
+ payment_method_options = ["Prepaid", "Postpaid"]
1006
+
1007
+
1008
+ # Given new_mapping dictionary
1009
+ new_mapping = {
1010
+ "GoFynd": {
1011
+ "Marketing": {
1012
+ "Order": ["Placed"]
1013
+ },
1014
+ "Transaction": {
1015
+ "Bag": ["Return Window"],
1016
+ "Shipment": ["Cancelled", "RTO", "DTO"]
1017
+ },
1018
+ "Logistics": {
1019
+ "Shipment": ["Picked", "RTO", "DTO"]
1020
+ },
1021
+ "Packaging": {
1022
+ "Shipment": ["Packed"]
1023
+ }
1024
+ },
1025
+ "Uniket": {
1026
+ "Marketing": {
1027
+ "Order": ["Placed"]
1028
+ },
1029
+ "Transaction": {
1030
+ "Bag": ["Return Window"],
1031
+ "Shipment": ["Cancelled", "RTO", "DTO"]
1032
+ },
1033
+ "Logistics": {
1034
+ "Shipment": ["Picked", "RTO", "DTO"]
1035
+ },
1036
+ "Packaging": {
1037
+ "Shipment": ["Packed"]
1038
+ }
1039
+ },
1040
+ "ONDC": {
1041
+ "Transaction": {
1042
+ "Bag": ["Return Window"],
1043
+ "Shipment": ["Cancelled", "RTO", "DTO"]
1044
+ },
1045
+ "Logistics": {
1046
+ "Shipment": ["Picked", "RTO", "DTO"]
1047
+ },
1048
+ "Packaging": {
1049
+ "Shipment": ["Packed"]
1050
+ }
1051
+ },
1052
+ "StoreOS": {
1053
+ "Licensing": {
1054
+ "Application": ["Setup"]
1055
+ },
1056
+ "Subscription": {
1057
+ "Application": ["Subscribed"],
1058
+ "User": ["Active"],
1059
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1060
+ },
1061
+ "Marketing": {
1062
+ "Order": ["Placed"]
1063
+ },
1064
+ "Transaction": {
1065
+ "Order": ["Placed"],
1066
+ "Bag": ["Invoiced", "Delivered"]
1067
+ },
1068
+ "Logistics": {
1069
+ "Shipment": ["Picked", "RTO", "DTO"]
1070
+ },
1071
+ "Packaging": {
1072
+ "Shipment": ["Packed"]
1073
+ }
1074
+ },
1075
+ "Website": {
1076
+ "Licensing": {
1077
+ "Application": ["Setup"]
1078
+ },
1079
+ "Subscription": {
1080
+ "Application": ["Subscribed"],
1081
+ "User": ["Active"],
1082
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1083
+ },
1084
+ "Transaction": {
1085
+ "Order": ["Placed"],
1086
+ "Bag": ["Invoiced", "Delivered"]
1087
+ },
1088
+ "Logistics": {
1089
+ "Shipment": ["Picked", "RTO", "DTO"]
1090
+ },
1091
+ "Packaging": {
1092
+ "Shipment": ["Packed"]
1093
+ },
1094
+ "Development": {
1095
+ "Application": ["Build"]
1096
+ }
1097
+ },
1098
+ "OMS": {
1099
+ "Development": {
1100
+ "Integration": ["Build"]
1101
+ },
1102
+ "Licensing": {
1103
+ "Integration": ["Setup"]
1104
+ },
1105
+ "Subscription": {
1106
+ "Integration": ["Subscribed"],
1107
+ "User": ["Active"],
1108
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1109
+ },
1110
+ "Transaction": {
1111
+ "Order": ["Placed"],
1112
+ "Bag": ["Invoiced", "Delivered"]
1113
+ }
1114
+ },
1115
+ "WMS": {
1116
+ "Development": {
1117
+ "Integration": ["Build"]
1118
+ },
1119
+ "Licensing": {
1120
+ "Integration": ["Setup"]
1121
+ },
1122
+ "Subscription": {
1123
+ "Integration": ["Subscribed"],
1124
+ "User": ["Active"],
1125
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1126
+ },
1127
+ "Transaction": {
1128
+ "Order": ["Placed"],
1129
+ "Bag": ["Invoiced", "Delivered"],
1130
+ "B2B": ["Invoiced"],
1131
+ "B2C": ["Invoiced"]
1132
+ }
1133
+ },
1134
+ "TMS": {
1135
+ "Development": {
1136
+ "Integration": ["Build"]
1137
+ },
1138
+ "Licensing": {
1139
+ "Integration": ["Setup"]
1140
+ },
1141
+ "Subscription": {
1142
+ "Integration": ["Subscribed"],
1143
+ "User": ["Active"],
1144
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1145
+ },
1146
+ "Logistics": {
1147
+ "Shipment": ["Picked", "RTO", "DTO"]
1148
+ }
1149
+ },
1150
+ "GMC": {
1151
+ "Development": {
1152
+ "Extension": ["Build"],
1153
+ "Integration": ["Build"]
1154
+ },
1155
+ "Licensing": {
1156
+ "Extension": ["Setup"]
1157
+ },
1158
+ "Subscription": {
1159
+ "Extension": ["Subscribed"],
1160
+ "User": ["Active"],
1161
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1162
+ }
1163
+ },
1164
+ "Partner": {
1165
+ "Development": {
1166
+ "Extension": ["Build"]
1167
+ },
1168
+ "Licensing": {
1169
+ "Extension": ["Setup"]
1170
+ },
1171
+ "Subscription": {
1172
+ "Extension": ["Subscribed"],
1173
+ "User": ["Active"],
1174
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1175
+ }
1176
+ },
1177
+ "Catalog Cloud": {
1178
+ "Development": {
1179
+ "Extension": ["Build"]
1180
+ },
1181
+ "Licensing": {
1182
+ "Extension": ["Setup"]
1183
+ },
1184
+ "Subscription": {
1185
+ "Extension": ["Subscribed"],
1186
+ "User": ["Active"],
1187
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1188
+ }
1189
+ },
1190
+ "FCP": {
1191
+ "Subscription": {
1192
+ "Platform": ["Subscribed"],
1193
+ "User": ["Active"],
1194
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1195
+ }
1196
+ },
1197
+ "PixelBin": {
1198
+ "Subscription": {
1199
+ "Platform": ["Subscribed"],
1200
+ "User": ["Active"],
1201
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1202
+ }
1203
+ },
1204
+ "Boltic": {
1205
+ "Subscription": {
1206
+ "Platform": ["Subscribed"],
1207
+ "User": ["Active"],
1208
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1209
+ }
1210
+ },
1211
+ "CoPilot": {
1212
+ "Subscription": {
1213
+ "Platform": ["Subscribed"],
1214
+ "User": ["Active"],
1215
+ "Resource": ["TechOps-hr", "SiteOps-hr"]
1216
+ }
1217
+ }
1218
+ }
1219
+
1220
+ # Initialize mappings
1221
+ fee_type_mapping = {}
1222
+ variable_type_mapping = {}
1223
+ chargeable_on_mapping = {}
1224
+
1225
+ # Populate mappings from new_mapping
1226
+ for ordering_channel, details in new_mapping.items():
1227
+ for fee_type, variables in details.items():
1228
+ if fee_type not in fee_type_mapping:
1229
+ fee_type_mapping[fee_type] = []
1230
+ if fee_type not in variable_type_mapping:
1231
+ variable_type_mapping[fee_type] = []
1232
+ variable_types = list(variables.keys())
1233
+ variable_type_mapping[fee_type].extend(variable_types)
1234
+ for variable_type, chargeable_on_list in variables.items():
1235
+ if variable_type not in chargeable_on_mapping:
1236
+ chargeable_on_mapping[variable_type] = []
1237
+ chargeable_on_mapping[variable_type].extend(chargeable_on_list)
1238
+
1239
+ # Remove duplicates in mappings
1240
+ fee_type_mapping = {k: list(set(v)) for k, v in fee_type_mapping.items()}
1241
+ variable_type_mapping = {k: list(set(v)) for k, v in variable_type_mapping.items()}
1242
+ chargeable_on_mapping = {k: list(set(v)) for k, v in chargeable_on_mapping.items()}
1243
+
1244
+ # Section 2: Company Info
1245
 
1246
  html_content_3 = """
1247
  <h1 style='
 
1257
 
1258
  st.sidebar.markdown(html_content_3, unsafe_allow_html=True)
1259
 
1260
+ # 1st layer: Select ordering channel
1261
+ selected_ordering_channel = st.sidebar.selectbox(
1262
+ "Product lines",
1263
+ [""] + list(new_mapping.keys()),
1264
+ help="Select a Product line"
1265
+ )
1266
+
1267
+ # Layer 1: Mapping of Ordering channels with Fulfilling location
1268
+ if "TMS" in selected_ordering_channel or "GMC" in selected_ordering_channel or "Catalog Cloud" in selected_ordering_channel:
1269
  fulfilling_location = None
1270
  application_id = None
1271
  else:
 
1273
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
1274
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
1275
 
1276
+ # 2nd layer: Select fee type based on the selected ordering channel
1277
+ fee_types_for_channel = []
1278
+ if selected_ordering_channel:
1279
+ details = new_mapping.get(selected_ordering_channel, {})
1280
+ fee_types_for_channel = list(details.keys())
1281
 
1282
+ selected_fee_type = st.selectbox(
1283
+ "Fee Type",
1284
+ [""] + fee_types_for_channel,
1285
+ help="Fee type is a revenue head for grouping the revenue"
1286
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1287
 
1288
+ # 3rd layer: Select variable type based on the selected fee type
1289
+ variable_type_options = []
1290
+ if selected_fee_type and selected_ordering_channel:
1291
+ details = new_mapping.get(selected_ordering_channel, {})
1292
+ variables = details.get(selected_fee_type, {})
1293
+ variable_type_options = list(variables.keys())
1294
+
1295
+ selected_variable_type = st.selectbox(
1296
+ "Variable Type",
1297
+ [""] + variable_type_options,
1298
+ help="Variable type is an attribute on which revenue calculation will be done"
1299
+ )
1300
 
1301
+ # 4th layer: Select chargeable on based on the selected variable type
1302
+ chargeable_on_options = []
1303
+ if selected_variable_type and selected_fee_type and selected_ordering_channel:
1304
+ details = new_mapping.get(selected_ordering_channel, {})
1305
+ variables = details.get(selected_fee_type, {})
1306
+ chargeable_on_options = variables.get(selected_variable_type, [])
1307
+
1308
+ selected_chargeable_on = st.selectbox(
1309
+ "Chargeable on",
1310
+ [""] + chargeable_on_options,
1311
+ help="Chargeable on is a service status on which the above fee will be applicable"
1312
+ )
1313
 
1314
  usage_1 = st.number_input(f"Usage limit for {selected_variable_type}", min_value=0.0, help="Enter the usage limit")
1315
  usage_2 = float(usage_1)
 
1403
  "Bundle by": bundle_by,
1404
  "Plan Name": plan_name,
1405
  "Plan Description": plan_description,
1406
+ "Product lines": selected_ordering_channel,
1407
  "Fulfilling Location": fulfilling_location,
1408
  "Application ID": application_id,
1409
  "Fee Type": selected_fee_type,
 
1489
  "Bundle_by": bundle_by,
1490
  "Plan_Name": plan_name,
1491
  "Plan_Description": plan_description,
1492
+ "Product_lines": selected_ordering_channel,
1493
  "Fulfilling_Location": fulfilling_location,
1494
  "Application_ID": application_id,
1495
  "Fee_Type": selected_fee_type,
 
1560
  # Start a tunnel to the correct port
1561
 
1562
  # Connect to a port (e.g., 8501) without a custom subdomain
1563
+ try:
1564
+ ngrok_tunnel = ngrok.connect(8501) # Replace 8501 with your port number
1565
+ print(f"ngrok tunnel URL: {ngrok_tunnel.public_url}")
1566
+ except Exception as e:
1567
+ print(f"Failed to start ngrok tunnel: {e}")