@@ -16,10 +16,10 @@ def list_clients():
1616 is_valid , payload = validate_token (dict_data .get ('token' ))
1717 if not is_valid or not payload .get ('is_admin' ):
1818 return jsonify ({'status' : 'Unauthorised' }), 403
19- results = dbc .execute_query (query = 'get_company_sales' , args = dict_data ['comp_id' ])
20- pcf = ProcessCashFlow (dict_data ['comp_id' ], 'PT' , month = 7 ) ### in this case we don't cate about the month, let's give one value just to simplify
19+ results = dbc .execute_query (query = 'get_company_sales' , args = payload ['comp_id' ])
20+ pcf = ProcessCashFlow (payload ['comp_id' ], 'PT' , month = 7 ) ### in this case we don't cate about the month, let's give one value just to simplify
2121 revenue = pcf .revenue
22- ps = ProcessSales (results , dict_data ['user_id' ])
22+ ps = ProcessSales (results , payload ['user_id' ])
2323 ps .get_3_most_recent_sales ()
2424 if isinstance (results , list ):
2525 return jsonify ({'status' : 'Ok' , 'last_3_sales' : ps .last_3_sales , 'revenue' : revenue , 'sales' : results }), 200
@@ -33,7 +33,7 @@ def list_employees():
3333 is_valid , payload = validate_token (dict_data .get ('token' ))
3434 if not is_valid or not payload .get ('is_admin' ):
3535 return jsonify ({'status' : 'Unauthorised' }), 403
36- results = dbc .execute_query (query = 'get_employees_list' , args = dict_data ['comp_id' ])
36+ results = dbc .execute_query (query = 'get_employees_list' , args = payload ['comp_id' ])
3737 if isinstance (results , list ):
3838 return jsonify ({'status' : 'Ok' , 'employees' : results }), 200
3939 return jsonify ({'status' : 'Bad request' }), 403
@@ -46,7 +46,7 @@ def list_products():
4646 is_valid , _payload = validate_token (dict_data .get ('token' ))
4747 if not is_valid :
4848 return jsonify ({'status' : 'Unauthorised' }), 403
49- results = dbc .execute_query (query = 'get_products_list' , args = dict_data ['comp_id' ])
49+ results = dbc .execute_query (query = 'get_products_list' , args = _payload ['comp_id' ])
5050 if isinstance (results , list ):
5151 return jsonify ({'status' : 'Ok' , 'products' : results }), 200
5252 return jsonify ({'status' : 'Bad request' }), 403
@@ -75,7 +75,6 @@ def update_commission():
7575 ''' Update seller commission '''
7676 dict_data = request .get_json ()
7777 token = dict_data ['token' ]
78- print (dict_data )
7978 seller_id = dict_data ['seller_id' ]
8079 new_commission = dict_data ['new_commission' ]
8180 # intentionally not comparing with static admin token anymore
@@ -90,10 +89,10 @@ def update_commission():
9089def upload_excel ():
9190 ''' Update company products from csv or xlsx '''
9291 token = request .form .get ('token' )
93- comp_id = request .form .get ('comp_id' )
9492 is_valid , payload = validate_token (token )
9593 if not is_valid or not payload .get ('is_admin' ):
9694 return jsonify ({'status' : 'Unauthorized' }), 403
95+ comp_id = payload .get ('comp_id' )
9796 if 'file' not in request .files :
9897 return jsonify ({'error' : 'No file part in the request' }), 400
9998
@@ -115,9 +114,9 @@ def cash_flow():
115114 return jsonify ({'status' : 'Unauthorised' }), 403
116115
117116 #### To Simplify, we will only use 3 fixed months of sales ####
118- pcf7 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = dict_data ['comp_id' ], month = 7 )
119- pcf8 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = dict_data ['comp_id' ], month = 8 )
120- pcf9 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = dict_data ['comp_id' ], month = 9 )
117+ pcf7 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = payload ['comp_id' ], month = 7 )
118+ pcf8 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = payload ['comp_id' ], month = 8 )
119+ pcf9 = ProcessCashFlow (country_code = dict_data ['country_code' ], company_id = payload ['comp_id' ], month = 9 )
121120 #########################################################
122121
123122 return jsonify (
0 commit comments