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

added more fields in expense serializer for redirection #458

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions apps/fyle/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@
from .models import Expense, ExpenseFilter, ExpenseGroup, ExpenseGroupSettings


class ExpenseSerializer(serializers.ModelSerializer):
"""
Expense serializer
"""
class Meta:
model = Expense
fields = ['updated_at', 'claim_number', 'employee_email', 'employee_name', 'fund_source', 'expense_number', 'vendor', 'category', 'amount',
'report_id', 'settlement_id', 'expense_id']

class ExpenseGroupSerializer(serializers.ModelSerializer):
"""
Expense group serializer
"""
expenses = ExpenseSerializer(many=True)
class Meta:
model = ExpenseGroup
fields = '__all__'
extra_fields = ['expenses']


class ExpenseGroupExpenseSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -60,12 +71,3 @@ def create(self, validated_data):
)

return expense_filter


class ExpenseSerializer(serializers.ModelSerializer):
"""
Expense serializer
"""
class Meta:
model = Expense
fields = ['updated_at', 'claim_number', 'employee_email', 'employee_name', 'fund_source']
24 changes: 22 additions & 2 deletions tests/test_fyle/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@
'claim_number': ' C/2021/12/R/198',
'employee_email': '[email protected]',
'employee_name': None,
'fund_source': 'CCC'
'fund_source': 'CCC',
'expense_number': 'E/2023/09/T/7',
'vendor': None,
'category': 'Train',
'amount': 101.0,
'report_id': 'dummy_report_id',
'settlement_id': 'dummy_settlement_id',
'expense_id': 'dummy_expense_id'
},
{
'updated_at': '2021-12-03T11:26:58.702209Z',
Expand Down Expand Up @@ -547,7 +554,20 @@
"exported_at": "2021-11-15T11:02:55.125205Z",
"updated_at": "2021-11-15T11:02:55.125634Z",
"workspace": 1,
"expenses": [1],
"expenses": [ {
"updated_at": "2023-11-21T10:41:09.919000Z",
"claim_number": "C/2023/06/R/4",
"employee_email": "[email protected]",
"employee_name": "Theresa Brown",
"fund_source": "PERSONAL",
"expense_number": "E/2023/06/T/21",
"vendor": "95110",
"category": "Airlines",
"amount": 6377.0,
"report_id": "rp0kaXoqkJle",
"settlement_id": "setPzkM7eyQFd",
"expense_id": "txyZ1zJDQfiK"
}],
},
"expense_group_setting_response": {
"id": 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fyle/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,4 @@ def test_exportable_expense_group_view(api_client, access_token):
assert response.status_code==200

response = json.loads(response.content)
assert response['exportable_expense_group_ids'] == [1, 2]
assert response['exportable_expense_group_ids'] == [1, 2]
Loading