Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Phase 2] Fetch report expenses inside modal #66

Merged
merged 12 commits into from
Mar 15, 2022

Conversation

jatzz10
Copy link
Contributor

@jatzz10 jatzz10 commented Mar 9, 2022

Changes done -

  • functionality to open report expense modal
  • functionality to fetch report expenses inside modal
  • approval functionality
  • added support for currency symbols

Screen recording -

new_flow_1.mov


report_expenses_dialog = modal_messages.get_report_expenses_dialog(user=user, report=report, report_expenses=report_expenses)

slack_client.views_update(user=slack_user_id, view=report_expenses_dialog, view_id=modal_view_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NOTE FOR SELF] - Add a tracker here as well

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -13,7 +13,7 @@ Django==3.1.14
django-picklefield==3.0.1
django-q==1.3.4
future==0.18.2
fyle==0.19.0
fyle==0.22.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET /approver/expenses api changes published in this latest sdk version

@@ -152,7 +152,7 @@
'name': 'fyle_slack_service',
'compress': True,
'save_limit': 0,
'workers': 4,
'workers': 1,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NOTE FOR SELF] - Revert this change before merging (did this for local development)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -152,7 +152,7 @@
'name': 'fyle_slack_service',
'compress': True,
'save_limit': 0,
'workers': 4,
'workers': 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

query_params = {
'report_id': 'eq.{}'.format(report['id']),
'order': 'created_at.desc',
'limit': '30',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for report_id, we should find only one, no?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p1


report_expenses_dialog = modal_messages.get_report_expenses_dialog(user=user, report=report, report_expenses=report_expenses)

slack_client.views_update(user=slack_user_id, view=report_expenses_dialog, view_id=modal_view_id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

'type': 'context',
'elements': [
{
'type': 'image',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need some explanation of the placeholder image

fyle_slack_app/slack/ui/modals/messages.py Outdated Show resolved Hide resolved
}
]

# Compose and append the expense title message

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the expense message composing to a method.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of thumb: If a method/function is more than 15 lines, then it is time to split up the method/function.

https://softwareengineering.stackexchange.com/questions/133404/what-is-the-ideal-length-of-a-method-for-you

from fyle_slack_app.fyle import utils as fyle_utils


def get_report_expenses_dialog(user: User, report: dict, report_expenses: dict) -> Dict:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about breaking this method into multiple methods

fyle_slack_app/slack/ui/notifications/messages.py Outdated Show resolved Hide resolved
'order': 'created_at.desc',
'limit': '15',
'offset': '0'
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - Using limit as 15, since we will only be showing total 15 expenses at-max inside the modal
Therefore, fetching only latest 15 expenses via API

}
}
report_notification_message.insert(3, report_deleted_section)
report_notification_message = common_messages.get_no_report_access_message(notification_message=notification_message)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - Created a function to return a "No access to report anymore" message (in case if report gets deleted)

modal_view_id = modal['view']['id']

async_task(
'fyle_slack_app.slack.interactives.block_action_handlers.fetch_report_and_expenses',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async tasks should be in tasks.py

}

tracking.identify_user(user.email)
tracking.track_event(user.email, 'Report Approved from Slack Modal', event_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have 2 events triggered, one from the original report approve function and one from here, how will we differentiate from where the report was approved from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on fixing this

'emoji': True
},
'action_id': 'pre_auth_message_approve',
'value': 'pre_auth_message_approve',
}
}


def get_no_report_access_message(notification_message: List[Dict]) -> List[Dict]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be more of a generic function name which can take a message and show it irrespective of state of report.




def fetch_report_and_expenses(user: User, team_id: str, private_metadata: Dict, modal_view_id: str) -> JsonResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is not in relation to what the function is doing, function is doing much more than fetching report and it's expenses.

@jatzz10 jatzz10 merged commit 34b9e22 into Fyle-1xbz27r-22xbkzg Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants