Ninad077 commited on
Commit
d10dfb9
·
verified ·
1 Parent(s): 0ec609a

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +191 -146
  2. requirements.txt +43 -1
app.py CHANGED
@@ -9,8 +9,21 @@ import base64
9
  from google.cloud import bigquery
10
  from google.oauth2 import service_account
11
  import logging
 
 
 
12
 
13
- logging.basicConfig(level=logging.INFO)
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
  ## Single value - 268 --> 675
@@ -227,7 +240,6 @@ st.set_page_config(
227
 
228
  # Display the image in the sidebar
229
  # st.sidebar.image('Fynd_logo2.png', width=300)
230
-
231
  st.sidebar.markdown("""
232
  <style>
233
  .left-aligned-image {
@@ -248,7 +260,6 @@ st.sidebar.markdown("""
248
  """, unsafe_allow_html=True)
249
 
250
 
251
-
252
  html_content = """
253
  <h1 style='
254
  color: #a689f6;
@@ -262,7 +273,8 @@ html_content = """
262
  """
263
 
264
  st.markdown(html_content, unsafe_allow_html=True)
265
-
 
266
  user_name = st.sidebar.text_input("Enter your name:")
267
 
268
 
@@ -285,7 +297,35 @@ st.sidebar.markdown(html_content_1, unsafe_allow_html=True)
285
  v1 = ["Commerce India", "Reliance", "Commerce Global", "Government Projects", "Individual BH"]
286
  business_head = st.sidebar.selectbox("Business Head", [""] + v1, help="Business Head is used for cost centre allocation")
287
  company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
288
- company_name = st.sidebar.text_input("Company Name", help="Enter the company name")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  currency = st.sidebar.radio("Currency", options= ["INR", "USD"], help= "Select the type of currency", index =None)
290
  bundle_by = st.sidebar.radio(options=["Single value", "Feature specific"], label="Bundle by", help = "Select the bundle", index=None)
291
 
@@ -314,12 +354,13 @@ if bundle_by == "Feature specific":
314
  """
315
 
316
  st.sidebar.markdown(html_content_2, unsafe_allow_html=True)
317
- a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
318
- "GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
 
319
  ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
320
 
321
  # Layer 1: Mapping of Ordering channels with Fulfilling location
322
- if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
323
  fulfilling_location = None
324
  application_id = None
325
  else:
@@ -328,74 +369,60 @@ if bundle_by == "Feature specific":
328
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
329
 
330
  # Section 3: Defining products for each dropdown
331
- product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
332
- "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
333
  "CoPilot"]
334
- fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
335
- "Packaging", "SLA", "Licensing", "Resource cost", "Development"]
336
  fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
337
- variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User", "Resource"]
338
- chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
339
- "RTO", "DTO", "Packed", "Hired", "Setup"]
340
  plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
341
  payment_method_options = ["Prepaid", "Postpaid"]
342
 
343
  # Mapping index
344
  fee_config = {
345
  'fee_type_mapping': {
346
- "ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
347
- "Marketing", "SLA"],
348
- "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
349
- "B2B": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
350
- "Packaging"],
351
- "Marketplaces": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
352
- "StoreOS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
353
- "Logistics", "Packaging"],
354
- "Storefronts": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics"],
355
- "Fynd TMS": ["Development", "Subscription", "Maintenance", "Licensing", "Logistics"],
356
- "Fynd WMS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
357
- "Logistics", "Packaging"],
358
- "GMC": ["Development", "Subscription", "Maintenance"],
359
- "Catalog Cloud": ["Development", "Subscription", "Maintenance"],
360
- "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
361
- "Fynd OMS": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
362
- "Fynd Commerce Platform": ["Subscription", "Transaction", "Resource cost"],
363
- "Logistics": ["Logistics"],
364
  "PixelBin": ["Subscription"],
365
  "Boltic": ["Subscription"],
366
  "CoPilot": ["Subscription"],
367
-
368
  }
369
  }
370
 
371
  var_config = {
372
  'variable_type_mapping': {
373
  "Development": ["Application", "Extension", "Integration"],
374
- "Subscription": ["Application", "Extension", "Integration", "Platform"],
375
- "Maintenance": ["Application", "Extension", "Integration"],
376
- "Licensing": ["Store", "User"],
377
- "Transaction": ["Bag", "Shipment"],
378
- "Minimum Guarantee": ["Bag", "Shipment"],
379
- "SLA": ["Bag", "Shipment"],
380
  "Logistics": ["Shipment"],
381
- "Marketing": ["Bag"],
382
  "Packaging": ["Shipment"],
383
- "Resource cost":['Resource'],
384
  }
385
  }
386
 
387
  char_config = {
388
  'chargeable_on_mapping': {
389
- "Application": ["Developed", "Installed", "Setup"],
390
- "Extension": ["Developed", "Installed", "Subscribed", "Setup"],
391
- "Integration": ["Developed", "Installed", "Setup"],
392
- "Store": ["Added", "Active"],
393
- "User": ["Added", "Active"],
394
- "Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
395
- "Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
396
- "Cancel"],
397
  "Platform": ["Subscribed"],
398
- 'Resource':["Hired"],
399
  }
400
  }
401
 
@@ -529,6 +556,7 @@ if bundle_by == "Feature specific":
529
  threshold = st.selectbox("Threshold option:", [""] + abc, help = "If Minimum guarantee is set as threshold option then Expected billing will be the higher value b/w 'Commercial*Usage' & 'Threshold' and if it is set to Capping then Expected billing will be the lower value b/w 'Commercial*Usage' & 'Threshold'")
530
 
531
  initial_expected_billing = Product_1
 
532
 
533
  if threshold == 'Capping value':
534
  expected_billing = min(Product_1, Capping_or_Minimum_Guarantee_1)
@@ -537,6 +565,8 @@ if bundle_by == "Feature specific":
537
  else:
538
  expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
539
 
 
 
540
  html_content_7 = f"""
541
  <h1 style='
542
  color: #a689f6;
@@ -551,26 +581,23 @@ if bundle_by == "Feature specific":
551
 
552
  # Using Streamlit to display the HTML content
553
  st.markdown(html_content_7, unsafe_allow_html=True)
 
 
 
 
554
 
555
- selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Plan validity defines the periodicity of calculation for the above billing", key="plan_vd_2")
556
- selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Payment method defines the mode of payment of the plan", key="py_vd_2")
557
-
558
-
559
- initial_net_billing = 0
560
-
561
- if selected_plan_validity == 'One time' or selected_plan_validity == 'Monthly':
562
- final_billing = 1*expected_billing
563
- elif selected_plan_validity == 'Quarterly':
564
- final_billing = 3*expected_billing
565
- elif selected_plan_validity == 'Bi-Annually':
566
- final_billing = 6*expected_billing
567
- elif selected_plan_validity == 'Annually':
568
- final_billing = 12*expected_billing
569
- else:
570
- final_billing = initial_net_billing
571
-
572
 
573
- html_content_8 = f"""
574
  <h1 style='
575
  color: #a689f6;
576
  font-size: 20px;
@@ -583,9 +610,14 @@ if bundle_by == "Feature specific":
583
  """
584
 
585
  # Using Streamlit to display the HTML content
586
- st.markdown(html_content_8, unsafe_allow_html=True)
587
 
588
 
 
 
 
 
 
589
  # Submit button
590
  # Define CSS styles for the button
591
  button_styles = """
@@ -611,6 +643,8 @@ if bundle_by == "Feature specific":
611
  st.markdown(button_styles, unsafe_allow_html=True)
612
 
613
 
 
 
614
 
615
  if st.button("Submit", key ='submit_button'):
616
  # Save user data
@@ -638,7 +672,7 @@ if bundle_by == "Feature specific":
638
  "Expected_Billing": expected_billing,
639
  "Payment_Method": selected_payment_method,
640
  "Plan_Validity": selected_plan_validity,
641
- "Net total billing":final_billing
642
  }
643
 
644
  global_user_data.append((user_name, user_data))
@@ -715,7 +749,7 @@ if bundle_by == "Feature specific":
715
  "Plan_Validity": selected_plan_validity,
716
  "rule_id": rule_id,
717
  "plan_id": plan_id,
718
- "Net total billing":final_billing
719
  }
720
 
721
  service_account_info = {
@@ -763,12 +797,12 @@ elif bundle_by == "Single value":
763
 
764
  st.sidebar.markdown(html_content_3, unsafe_allow_html=True)
765
 
766
- a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
767
- "GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
768
  ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
769
 
770
  # Layer 1: Mapping of Ordering channels with Fulfilling location
771
- if "Fynd TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
772
  fulfilling_location = None
773
  application_id = None
774
  else:
@@ -776,80 +810,66 @@ elif bundle_by == "Single value":
776
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
777
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
778
 
 
779
  # Section 3: Defining products for each dropdown
780
- product_options = ["B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS", "GMC",
781
- "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "Logistics", "PixelBin", "Boltic",
782
  "CoPilot"]
783
- fee_type_options = ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
784
- "Packaging", "SLA", "Licensing","Resource cost", "Development"]
785
  fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
786
- variable_options = ["Bag", "Shipment", "Application", "Extension", "Integration", "Store", "User", "Resource"]
787
- chargeable_on_options = ["Developed", "Installed", "Placed", "Invoiced", "Delivered", "Return window", "All", "Picked",
788
- "RTO", "DTO", "Packed","Hired", "Setup"]
789
  plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
790
  payment_method_options = ["Prepaid", "Postpaid"]
791
 
 
792
  # Mapping index
793
  fee_config = {
794
  'fee_type_mapping': {
795
- "ONDC": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
796
- "Marketing", "SLA"],
797
- "GoFynd": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
798
- "B2B": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics",
799
- "Packaging"],
800
- "Marketplaces": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
801
- "StoreOS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
802
- "Logistics", "Packaging"],
803
- "Storefronts": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee", "Logistics"],
804
- "Fynd TMS": ["Development", "Subscription", "Maintenance", "Licensing", "Logistics"],
805
- "Fynd WMS": ["Development", "Subscription", "Maintenance", "Licensing", "Transaction", "Minimum Guarantee",
806
- "Logistics", "Packaging"],
807
- "GMC": ["Development", "Subscription", "Maintenance"],
808
- "Catalog Cloud": ["Development", "Subscription", "Maintenance"],
809
- "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging", "SLA"],
810
- "Fynd OMS": ["Development", "Subscription", "Maintenance", "Transaction", "Minimum Guarantee"],
811
- "Fynd Commerce Platform": ["Subscription", "Transaction", "Resource cost"],
812
- "Logistics": ["Logistics"],
813
  "PixelBin": ["Subscription"],
814
  "Boltic": ["Subscription"],
815
  "CoPilot": ["Subscription"],
816
- "CoPilot": ["Subscription"],
817
-
818
  }
819
  }
820
 
821
  var_config = {
822
  'variable_type_mapping': {
823
  "Development": ["Application", "Extension", "Integration"],
824
- "Subscription": ["Application", "Extension", "Integration", "Platform"],
825
- "Maintenance": ["Application", "Extension", "Integration"],
826
- "Licensing": ["Store", "User"],
827
- "Transaction": ["Bag", "Shipment"],
828
- "Minimum Guarantee": ["Bag", "Shipment"],
829
- "SLA": ["Bag", "Shipment"],
830
  "Logistics": ["Shipment"],
831
- "Marketing": ["Bag"],
832
  "Packaging": ["Shipment"],
833
- "Resource cost":['Resource'],
834
  }
835
  }
836
 
837
  char_config = {
838
  'chargeable_on_mapping': {
839
- "Application": ["Developed", "Installed", "Setup"],
840
- "Extension": ["Developed", "Installed", "Subscribed", "Setup"],
841
- "Integration": ["Developed", "Installed", "Setup"],
842
- "Store": ["Added", "Active"],
843
- "User": ["Added", "Active"],
844
- "Bag": ["Placed", "Invoiced", "Delivered", "Return window", "Cancel", "RTO", "DTO"],
845
- "Shipment": ["Placed", "Invoiced", "Delivered", "Return window", "All", "Picked", "RTO", "DTO", "Packed",
846
- "Cancel"],
847
  "Platform": ["Subscribed"],
848
- 'Resource':["Hired"],
849
  }
850
  }
851
 
852
-
853
  # 2nd layer: Mapping of Ordering channels with fee types
854
  st.write("")
855
  st.write("")
@@ -876,7 +896,7 @@ elif bundle_by == "Single value":
876
  usage_2 = float(usage_1)
877
  usage_3 = "{:.2f}".format(usage_2)
878
 
879
- expected_billing = user_input_3
880
 
881
 
882
  html_content_8 = f"""
@@ -898,6 +918,7 @@ elif bundle_by == "Single value":
898
  selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Payment method defines the mode of payment of the plan", key="py_vd_2")
899
 
900
  initial_net_billing = 0
 
901
 
902
  if selected_plan_validity == 'One time' and selected_plan_validity == 'Monthly':
903
  final_billing = 1*expected_billing
@@ -949,6 +970,8 @@ elif bundle_by == "Single value":
949
  # Render the button with the specified styles
950
  st.markdown(button_styles, unsafe_allow_html=True)
951
 
 
 
952
 
953
  # Submit button
954
  if st.button("Submit"):
@@ -977,7 +1000,7 @@ elif bundle_by == "Single value":
977
  "Expected Billing": user_input_3,
978
  "Plan Validity": selected_plan_validity,
979
  "Payment Method": selected_payment_method,
980
- "Net total billing":final_billing
981
  }
982
 
983
  global_user_data.append((user_name, user_data))
@@ -995,6 +1018,9 @@ elif bundle_by == "Single value":
995
 
996
  # Display saved records
997
  display_saved_records()
 
 
 
998
  if st.button("Export data to BQ"):
999
 
1000
  import logging
@@ -1029,6 +1055,9 @@ elif bundle_by == "Single value":
1029
  logging.exception("An error occurred during the BigQuery insert operation.")
1030
  st.error(f"An error occurred: {e}")
1031
 
 
 
 
1032
  # Your data and service account info here
1033
  project_id = "fynd-db"
1034
  dataset_id = "finance_dwh"
@@ -1059,7 +1088,7 @@ elif bundle_by == "Single value":
1059
  "Plan_Validity": selected_plan_validity,
1060
  "rule_id": rule_id,
1061
  "plan_id": plan_id,
1062
- "Net total billing":final_billing
1063
  }
1064
 
1065
  service_account_info = {
@@ -1078,26 +1107,42 @@ elif bundle_by == "Single value":
1078
 
1079
  insert_into_bq(user_data, project_id, dataset_id, table_id, service_account_info)
1080
 
1081
-
1082
-
1083
- st.sidebar.markdown("""
1084
- <style>
1085
- .left-aligned-iframe {
1086
- display: flex;
1087
- justify-content: flex-start;
1088
- width: 100%;
1089
- margin-top: 20px; /* Add a margin above the iframe */
1090
-
1091
- }
1092
- .left-aligned-iframe iframe {
1093
- width: 500vw;
1094
- height: 800px;
1095
- border: none;
1096
- border-radius: 15px;
1097
- }
1098
- </style>
1099
- <div class="left-aligned-iframe">
1100
- <iframe src="https://www.fynd.com/en-in"></iframe>
1101
- </div>
1102
- """, unsafe_allow_html=True)
1103
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  from google.cloud import bigquery
10
  from google.oauth2 import service_account
11
  import logging
12
+ 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
 
240
 
241
  # Display the image in the sidebar
242
  # st.sidebar.image('Fynd_logo2.png', width=300)
 
243
  st.sidebar.markdown("""
244
  <style>
245
  .left-aligned-image {
 
260
  """, unsafe_allow_html=True)
261
 
262
 
 
263
  html_content = """
264
  <h1 style='
265
  color: #a689f6;
 
273
  """
274
 
275
  st.markdown(html_content, unsafe_allow_html=True)
276
+
277
+ st.write(" ")
278
  user_name = st.sidebar.text_input("Enter your name:")
279
 
280
 
 
297
  v1 = ["Commerce India", "Reliance", "Commerce Global", "Government Projects", "Individual BH"]
298
  business_head = st.sidebar.selectbox("Business Head", [""] + v1, help="Business Head is used for cost centre allocation")
299
  company_id = st.sidebar.text_input("Company ID", help="Enter the company ID")
300
+ if company_id:
301
+ try:
302
+ # Construct the API URL with the provided cmpid
303
+ api_url = f"https://api.boltic.io/service/platform/bolt/share/v1/data?api_token=eyJpZCI6IjU4OTdmZjZlLTMwMTYtNDZjMC1hMzdlLTJmNjBkMjhjYjc5YyIsInRlbmFudCI6ImdvZnluZGNvbSJ9&batch_size=10000&display_meta=true&cmpid={company_id}"
304
+
305
+ # Fetch data from the API
306
+ response = requests.get(api_url)
307
+
308
+ # Check if the request was successful
309
+ if response.status_code == 200:
310
+ data = response.json()
311
+
312
+ # Extract company name from the data
313
+ if "results" in data and len(data["results"]) > 0:
314
+ company_name = data["results"][0].get("company_name", "Company name not found")
315
+ else:
316
+ company_name = "Company name not found"
317
+ else:
318
+ company_name = f"Error: Unable to fetch data (Status code: {response.status_code})"
319
+ except Exception as e:
320
+ company_name = f"An error occurred: {e}"
321
+
322
+
323
+ # Display the company name
324
+ st.sidebar.text_input("Company Name", value=company_name)
325
+ else:
326
+ st.sidebar.text_input("Company Name", value="")
327
+
328
+
329
  currency = st.sidebar.radio("Currency", options= ["INR", "USD"], help= "Select the type of currency", index =None)
330
  bundle_by = st.sidebar.radio(options=["Single value", "Feature specific"], label="Bundle by", help = "Select the bundle", index=None)
331
 
 
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:
 
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"]
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", "Licensing", "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"],
 
 
 
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
  }
427
  }
428
 
 
556
  threshold = st.selectbox("Threshold option:", [""] + abc, help = "If Minimum guarantee is set as threshold option then Expected billing will be the higher value b/w 'Commercial*Usage' & 'Threshold' and if it is set to Capping then Expected billing will be the lower value b/w 'Commercial*Usage' & 'Threshold'")
557
 
558
  initial_expected_billing = Product_1
559
+ expected_billing = None
560
 
561
  if threshold == 'Capping value':
562
  expected_billing = min(Product_1, Capping_or_Minimum_Guarantee_1)
 
565
  else:
566
  expected_billing = initial_expected_billing # Default to initial Product value if no threshold selected
567
 
568
+ selected_plan_validity = st.selectbox("Plan Validity", [""] + plan_validity_options, help="Plan validity defines the periodicity of calculation for the above billing", key="plan_vd_2")
569
+
570
  html_content_7 = f"""
571
  <h1 style='
572
  color: #a689f6;
 
581
 
582
  # Using Streamlit to display the HTML content
583
  st.markdown(html_content_7, unsafe_allow_html=True)
584
+
585
+ initial_net_billing = 0
586
+ final_billing = 0
587
+
588
 
589
+ if selected_plan_validity == 'One time' or selected_plan_validity == 'Monthly':
590
+ final_billing = 1*expected_billing
591
+ elif selected_plan_validity == 'Quarterly':
592
+ final_billing = 3*expected_billing
593
+ elif selected_plan_validity == 'Bi-Annually':
594
+ final_billing = 6*expected_billing
595
+ elif selected_plan_validity == 'Annually':
596
+ final_billing = 12*expected_billing
597
+ else:
598
+ final_billing = initial_net_billing
 
 
 
 
 
 
 
599
 
600
+ html_content_8 = f"""
601
  <h1 style='
602
  color: #a689f6;
603
  font-size: 20px;
 
610
  """
611
 
612
  # Using Streamlit to display the HTML content
613
+ st.markdown(html_content_8, unsafe_allow_html=True)
614
 
615
 
616
+
617
+ selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Payment method defines the mode of payment of the plan", key="py_vd_2")
618
+
619
+
620
+
621
  # Submit button
622
  # Define CSS styles for the button
623
  button_styles = """
 
643
  st.markdown(button_styles, unsafe_allow_html=True)
644
 
645
 
646
+ rule_id = None
647
+ plan_id = None
648
 
649
  if st.button("Submit", key ='submit_button'):
650
  # Save user data
 
672
  "Expected_Billing": expected_billing,
673
  "Payment_Method": selected_payment_method,
674
  "Plan_Validity": selected_plan_validity,
675
+ "Net_total_billing":int(final_billing)
676
  }
677
 
678
  global_user_data.append((user_name, user_data))
 
749
  "Plan_Validity": selected_plan_validity,
750
  "rule_id": rule_id,
751
  "plan_id": plan_id,
752
+ "Net_total_billing":int(final_billing)
753
  }
754
 
755
  service_account_info = {
 
797
 
798
  st.sidebar.markdown(html_content_3, unsafe_allow_html=True)
799
 
800
+ a1 = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner", "Catalog Cloud", "FCP", "PixelBin", "Boltic",
801
+ "CoPilot"]
802
  ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
803
 
804
  # Layer 1: Mapping of Ordering channels with Fulfilling location
805
+ if "TMS" in ordering_channels or "GMC" in ordering_channels or "Catalog Cloud" in ordering_channels:
806
  fulfilling_location = None
807
  application_id = None
808
  else:
 
810
  fulfilling_location = st.sidebar.selectbox("Fulfilling Location", [""] + abc, help="Select the fulfilling location")
811
  application_id = st.sidebar.text_input("Application ID", key="application_id_input", help="Enter the application ID")
812
 
813
+
814
  # Section 3: Defining products for each dropdown
815
+ product_options = ["GoFynd", "Uniket", "ONDC", "StoreOS", "Website", "OMS", "WMS", "TMS", "GMC", "Partner",
816
+ "Catalog Cloud", "FCP", "PixelBin", "Boltic",
817
  "CoPilot"]
818
+ fee_type_options = ["Development", "Licensing", "Logistics", "Marketing", "Packaging", "Subscription", "Transaction"]
 
819
  fee_nature_options = ["Fixed %", "Flat currency", "Slab based", "As per rate card"]
820
+ variable_options = ["Application", "Bag", "Extension", "Integration", "Order", "Platform", "Resource", "Shipment", "User"]
821
+ chargeable_on_options = ["Active", "Build", "Cancelled", "Delivered", "DTO", "Invoiced", "Packed", "Picked", "Placed", "Return Window", "RTO", "Setup", "SiteOps-hr", "Subscribed", "TechOps-hr"]
 
822
  plan_validity_options = ["One time", "Monthly", "Quarterly", "Bi-Annually", "Annually"]
823
  payment_method_options = ["Prepaid", "Postpaid"]
824
 
825
+
826
  # Mapping index
827
  fee_config = {
828
  'fee_type_mapping': {
829
+ "ONDC": ["Transaction", "Logistics", "Packaging"],
830
+ "GoFynd": ["Transaction", "Logistics", "Marketing", "Licensing", "Packaging"],
831
+ "StoreOS": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging", "Marketing"],
832
+ "Website": ["Development","Licensing", "Subscription", "Transaction", "Logistics", "Packaging"],
833
+ "TMS": ["Development","Licensing", "Subscription", "Logistics"],
834
+ "WMS": ["Development","Licensing", "Subscription", "Transaction"],
835
+ "GMC": ["Development", "Licensing","Subscription"],
836
+ "Partner": ["Development", "Licensing","Subscription"],
837
+ "Catalog Cloud": ["Development", "Licensing","Subscription"],
838
+ "Uniket": ["Transaction", "Logistics", "Marketing", "Packaging"],
839
+ "OMS": ["Development","Licensing", "Subscription", "Transaction"],
840
+ "FCP": ["Subscription"],
 
 
 
 
 
 
841
  "PixelBin": ["Subscription"],
842
  "Boltic": ["Subscription"],
843
  "CoPilot": ["Subscription"],
 
 
844
  }
845
  }
846
 
847
  var_config = {
848
  'variable_type_mapping': {
849
  "Development": ["Application", "Extension", "Integration"],
850
+ "Subscription": ["Application", "Extension", "Integration", "Platform", "User", "Resource"],
851
+ "Licensing": ["Application", "Extension", "Integration"],
852
+ "Transaction": ["Bag", "Order", "Shipment"],
 
 
 
853
  "Logistics": ["Shipment"],
854
+ "Marketing": ["Order"],
855
  "Packaging": ["Shipment"],
 
856
  }
857
  }
858
 
859
  char_config = {
860
  'chargeable_on_mapping': {
861
+ "Application": ["Build", "Setup", "Subscribed"],
862
+ "Extension": ["Build", "Setup", "Subscribed"],
863
+ "Integration": ["Build", "Setup", "Subscribed"],
864
+ "Order": ["Placed"],
865
+ "User": ["Active"],
866
+ "Bag": ["Invoiced", "Delivered", "Return Window"],
867
+ "Shipment": ["Cancelled","Picked", "RTO", "DTO", "Packed"],
 
868
  "Platform": ["Subscribed"],
869
+ 'Resource':["TechOps-hr", "SiteOps-hr"],
870
  }
871
  }
872
 
 
873
  # 2nd layer: Mapping of Ordering channels with fee types
874
  st.write("")
875
  st.write("")
 
896
  usage_2 = float(usage_1)
897
  usage_3 = "{:.2f}".format(usage_2)
898
 
899
+ expected_billing = user_input_1
900
 
901
 
902
  html_content_8 = f"""
 
918
  selected_payment_method = st.selectbox("Payment Method", [""] + payment_method_options, help="Payment method defines the mode of payment of the plan", key="py_vd_2")
919
 
920
  initial_net_billing = 0
921
+ expected_billing = user_input_1
922
 
923
  if selected_plan_validity == 'One time' and selected_plan_validity == 'Monthly':
924
  final_billing = 1*expected_billing
 
970
  # Render the button with the specified styles
971
  st.markdown(button_styles, unsafe_allow_html=True)
972
 
973
+ rule_id = None
974
+ plan_id = None
975
 
976
  # Submit button
977
  if st.button("Submit"):
 
1000
  "Expected Billing": user_input_3,
1001
  "Plan Validity": selected_plan_validity,
1002
  "Payment Method": selected_payment_method,
1003
+ "Net_total_billing":int(final_billing)
1004
  }
1005
 
1006
  global_user_data.append((user_name, user_data))
 
1018
 
1019
  # Display saved records
1020
  display_saved_records()
1021
+
1022
+
1023
+
1024
  if st.button("Export data to BQ"):
1025
 
1026
  import logging
 
1055
  logging.exception("An error occurred during the BigQuery insert operation.")
1056
  st.error(f"An error occurred: {e}")
1057
 
1058
+
1059
+
1060
+
1061
  # Your data and service account info here
1062
  project_id = "fynd-db"
1063
  dataset_id = "finance_dwh"
 
1088
  "Plan_Validity": selected_plan_validity,
1089
  "rule_id": rule_id,
1090
  "plan_id": plan_id,
1091
+ "Net_total_billing":int(final_billing)
1092
  }
1093
 
1094
  service_account_info = {
 
1107
 
1108
  insert_into_bq(user_data, project_id, dataset_id, table_id, service_account_info)
1109
 
1110
+ st.write(" ")
1111
+ st.write(" ")
1112
+ st.write(" ")
1113
+ st.write(" ")
1114
+
1115
+ st.write(" ")
1116
+ st.write(" ")
1117
+ st.write(" ")
1118
+ st.write(" ")
1119
+
1120
+
1121
+ # #Sidebar with an iframe
1122
+ # st.sidebar.markdown("""
1123
+ # <style>
1124
+ # .left-aligned-iframe {
1125
+ # display: flex;
1126
+ # justify-content: flex-start;
1127
+ # width: 100%;
1128
+ # margin-top: 20px; /* Add a margin above the iframe */
1129
+ # }
1130
+ # .left-aligned-iframe iframe {
1131
+ # width: 100%; /* Adjust width as needed */
1132
+ # height: 800px; /* Adjust height as needed */
1133
+ # border: none;
1134
+ # border-radius: 15px;
1135
+ # }
1136
+ # </style>
1137
+ # <div class="left-aligned-iframe">
1138
+ # <iframe src="https://platform.fynd.com/blog" title="Fynd Platform"></iframe>
1139
+ # </div>
1140
+ # """, unsafe_allow_html=True)
1141
+ # Start a tunnel to the correct port
1142
+
1143
+ # Connect to a port (e.g., 8501) without a custom subdomain
1144
+ try:
1145
+ ngrok_tunnel = ngrok.connect(8501) # Replace 8501 with your port number
1146
+ print(f"ngrok tunnel URL: {ngrok_tunnel.public_url}")
1147
+ except Exception as e:
1148
+ print(f"Failed to start ngrok tunnel: {e}")
requirements.txt CHANGED
@@ -1,15 +1,34 @@
 
 
 
1
  altair==4.2.2
 
 
2
  attrs==23.2.0
3
  beautifulsoup4==4.12.3
4
  blinker==1.8.2
5
  cachetools==5.3.3
 
 
6
  certifi==2024.6.2
 
7
  charset-normalizer==3.3.2
8
  click==8.1.7
 
 
9
  css==0.1
 
 
 
 
10
  entrypoints==0.4
11
  et-xmlfile==1.1.0
12
  exceptiongroup==1.2.1
 
 
 
 
 
13
  gitdb==4.0.11
14
  GitPython==3.1.43
15
  google-api-core==2.19.0
@@ -24,15 +43,23 @@ googleapis-common-protos==1.63.1
24
  grpcio==1.64.1
25
  grpcio-status==1.62.2
26
  gspread==6.1.2
 
27
  h11==0.14.0
28
  httplib2==0.22.0
29
  idna==3.7
 
 
 
30
  Jinja2==3.1.4
31
  jsonschema==4.22.0
32
  jsonschema-specifications==2023.12.1
 
33
  markdown-it-py==3.0.0
34
  MarkupSafe==2.1.5
 
35
  mdurl==0.1.2
 
 
36
  numpy==1.26.4
37
  oauth2client==4.1.3
38
  oauthlib==3.2.2
@@ -46,19 +73,26 @@ protobuf==4.25.3
46
  pyarrow==16.1.0
47
  pyasn1==0.6.0
48
  pyasn1_modules==0.4.0
 
49
  pydeck==0.9.1
50
  Pygments==2.18.0
 
 
51
  pyparsing==3.1.2
52
  PySocks==1.7.1
 
53
  python-dateutil==2.9.0.post0
54
  python-decouple==3.8
 
55
  pytz==2024.1
 
56
  referencing==0.35.1
57
  requests==2.32.3
58
  requests-oauthlib==2.0.0
59
  rich==13.7.1
60
  rpds-py==0.18.1
61
  rsa==4.9
 
62
  selenium==4.22.0
63
  six==1.16.0
64
  smmap==5.0.1
@@ -67,17 +101,25 @@ sortedcontainers==2.4.0
67
  soupsieve==2.5
68
  streamlit==1.35.0
69
  streamlit-aggrid==1.0.5
 
70
  tenacity==8.3.0
 
71
  toml==0.10.2
72
  toolz==0.12.1
73
  tornado==6.4.1
74
  tqdm==4.66.4
75
  trio==0.25.1
76
  trio-websocket==0.11.1
 
77
  typing_extensions==4.12.2
78
  tzdata==2024.1
79
- urllib3==2.2.1
 
80
  watchdog==4.0.1
 
81
  websocket-client==1.8.0
 
82
  wsproto==1.2.0
83
  XlsxWriter==3.2.0
 
 
 
1
+ aiohttp==3.9.5
2
+ aiohttp-retry==2.8.3
3
+ aiosignal==1.3.1
4
  altair==4.2.2
5
+ APScheduler==3.10.4
6
+ async-timeout==4.0.3
7
  attrs==23.2.0
8
  beautifulsoup4==4.12.3
9
  blinker==1.8.2
10
  cachetools==5.3.3
11
+ cairocffi==1.7.1
12
+ CairoSVG==2.7.1
13
  certifi==2024.6.2
14
+ cffi==1.16.0
15
  charset-normalizer==3.3.2
16
  click==8.1.7
17
+ cloudevents==1.11.0
18
+ contourpy==1.2.1
19
  css==0.1
20
+ cssselect2==0.7.0
21
+ cycler==0.12.1
22
+ defusedxml==0.7.1
23
+ deprecation==2.1.0
24
  entrypoints==0.4
25
  et-xmlfile==1.1.0
26
  exceptiongroup==1.2.1
27
+ Flask==3.0.3
28
+ fonttools==4.53.1
29
+ fpdf==1.7.2
30
+ frozenlist==1.4.1
31
+ functions-framework==3.8.0
32
  gitdb==4.0.11
33
  GitPython==3.1.43
34
  google-api-core==2.19.0
 
43
  grpcio==1.64.1
44
  grpcio-status==1.62.2
45
  gspread==6.1.2
46
+ gunicorn==22.0.0
47
  h11==0.14.0
48
  httplib2==0.22.0
49
  idna==3.7
50
+ importlib_metadata==8.0.0
51
+ importlib_resources==6.4.0
52
+ itsdangerous==2.2.0
53
  Jinja2==3.1.4
54
  jsonschema==4.22.0
55
  jsonschema-specifications==2023.12.1
56
+ kiwisolver==1.4.5
57
  markdown-it-py==3.0.0
58
  MarkupSafe==2.1.5
59
+ matplotlib==3.9.1
60
  mdurl==0.1.2
61
+ multidict==6.0.5
62
+ ngrok==1.3.0
63
  numpy==1.26.4
64
  oauth2client==4.1.3
65
  oauthlib==3.2.2
 
73
  pyarrow==16.1.0
74
  pyasn1==0.6.0
75
  pyasn1_modules==0.4.0
76
+ pycparser==2.22
77
  pydeck==0.9.1
78
  Pygments==2.18.0
79
+ PyJWT==2.8.0
80
+ pyngrok==7.2.0
81
  pyparsing==3.1.2
82
  PySocks==1.7.1
83
+ pytesseract==0.3.10
84
  python-dateutil==2.9.0.post0
85
  python-decouple==3.8
86
+ python-dotenv==1.0.1
87
  pytz==2024.1
88
+ PyYAML==6.0.1
89
  referencing==0.35.1
90
  requests==2.32.3
91
  requests-oauthlib==2.0.0
92
  rich==13.7.1
93
  rpds-py==0.18.1
94
  rsa==4.9
95
+ schedule==1.2.2
96
  selenium==4.22.0
97
  six==1.16.0
98
  smmap==5.0.1
 
101
  soupsieve==2.5
102
  streamlit==1.35.0
103
  streamlit-aggrid==1.0.5
104
+ streamlit-option-menu==0.3.13
105
  tenacity==8.3.0
106
+ tinycss2==1.3.0
107
  toml==0.10.2
108
  toolz==0.12.1
109
  tornado==6.4.1
110
  tqdm==4.66.4
111
  trio==0.25.1
112
  trio-websocket==0.11.1
113
+ twilio==9.2.3
114
  typing_extensions==4.12.2
115
  tzdata==2024.1
116
+ tzlocal==5.2
117
+ urllib3==1.26.6
118
  watchdog==4.0.1
119
+ webencodings==0.5.1
120
  websocket-client==1.8.0
121
+ Werkzeug==3.0.3
122
  wsproto==1.2.0
123
  XlsxWriter==3.2.0
124
+ yarl==1.9.4
125
+ zipp==3.19.2