-
Notifications
You must be signed in to change notification settings - Fork 3
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
added field export_url in expense group and util to generate URL #457
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96c7dc6
add employee name in expense and script to populate data
Ashutosh619-sudo 3a7f7f2
test fixture changes
Ashutosh619-sudo 28fc1e3
added field export_url in expense group and util to generate URL
Ashutosh619-sudo 535c619
updated test and fixtures
Ashutosh619-sudo 0db7d94
changed scripts to batch update export url
Ashutosh619-sudo 076f9d2
bug fix
Ashutosh619-sudo 9b0998e
comment resolved
Ashutosh619-sudo cf736f5
added more fields in expense serializer for redirection (#458)
Ashutosh619-sudo 4cd1765
Merge branch 'employee_in_expense_new' into export_url_field
Ashutosh619-sudo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.14 on 2023-11-20 10:48 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('fyle', '0026_auto_20231025_0913'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='expensegroup', | ||
name='employee_name', | ||
field=models.CharField(help_text='Expense Group Employee Name', max_length=100, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.14 on 2023-11-22 10:11 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('fyle', '0027_expensegroup_employee_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='expensegroup', | ||
name='export_url', | ||
field=models.CharField(help_text='Netsuite URL for the exported expenses', max_length=255, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from apps.fyle.models import ExpenseGroup | ||
from apps.workspaces.models import NetSuiteCredentials, Workspace | ||
from fyle_netsuite_api.utils import generate_netsuite_export_url | ||
|
||
|
||
folder_created_workspace_ids = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed |
||
|
||
prod_workspaces = Workspace.objects.exclude( | ||
name__iregex=r'(fyle|test)', | ||
id__in=folder_created_workspace_ids | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed |
||
) | ||
|
||
for workspace in prod_workspaces: | ||
page_size = 200 | ||
expense_group_counts = ExpenseGroup.objects.filter(workspace_id=workspace.id, response_logs__isnull=False).count() | ||
for offset in range(0, expense_group_counts, page_size): | ||
expense_to_be_updated = [] | ||
limit = offset + page_size | ||
paginated_expense_groups = ExpenseGroup.objects.filter(workspace_id=workspace.id, response_logs__isnull=False)[offset:limit] | ||
for expense_group in paginated_expense_groups: | ||
netsuite_cred = NetSuiteCredentials.objects.get(workspace_id=workspace.id) | ||
expense_group.export_url = generate_netsuite_export_url(response_logs=expense_group.response_logs, ns_account_id=netsuite_cred.ns_account_id) | ||
expense_group.save() |
29 changes: 29 additions & 0 deletions
29
scripts/sql/scripts/020-fill-employee_name-in-expenses-and-expense_groups.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
rollback; | ||
begin; | ||
|
||
with ws as ( | ||
select expense_attributes.detail->>'full_name' as expense_attributes_full_name, | ||
expense_attributes.workspace_id as expense_attributes_workspace_id, | ||
expense_attributes.value as expense_attribute_email | ||
from expense_groups | ||
inner join expense_attributes on expense_attributes.value = expense_groups.description->>'employee_email' | ||
where expense_groups.workspace_id = expense_attributes.workspace_id | ||
) | ||
|
||
update expense_groups | ||
set employee_name = ws.expense_attributes_full_name | ||
from ws | ||
where expense_groups.description->>'employee_email' = ws.expense_attribute_email; | ||
|
||
|
||
-- Run this in after running the above query. | ||
with ex as ( | ||
select expense_groups.employee_name as employee_name | ||
from expense_groups | ||
inner join expense_groups_expenses on expense_groups.id = expense_groups_expenses.expensegroup_id | ||
inner join expenses on expense_groups_expenses.expense_id = expenses.id | ||
) | ||
|
||
update expenses | ||
set employee_name = ex.employee_name | ||
from ex; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.exception