Skip to content

Commit

Permalink
add expense details in expense groups api (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Sep 20, 2023
1 parent e4c9475 commit b38ca92
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
19 changes: 11 additions & 8 deletions apps/fyle/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@
from .models import Expense, ExpenseFilter, ExpenseGroup, ExpenseGroupSettings, DependentFieldSetting


class ExpenseGroupSerializer(serializers.ModelSerializer):
class ExpenseSerializer(serializers.ModelSerializer):
"""
Expense group serializer
Expense serializer
"""

class Meta:
model = ExpenseGroup
fields = '__all__'
model = Expense
fields = ['updated_at', 'claim_number', 'employee_email', 'employee_name', 'fund_source', 'expense_number', 'payment_number', 'vendor', 'category', 'amount']


class ExpenseSerializer(serializers.ModelSerializer):
class ExpenseGroupSerializer(serializers.ModelSerializer):
"""
Expense serializer
Expense group serializer
"""

expenses = ExpenseSerializer(many=True)

class Meta:
model = Expense
fields = ['updated_at', 'claim_number', 'employee_email', 'fund_source']
model = ExpenseGroup
fields = '__all__'
extra_fields = ['expenses']


class ExpenseGroupSettingsSerializer(serializers.ModelSerializer):
Expand Down
45 changes: 28 additions & 17 deletions tests/test_fyle/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,35 @@
}
],
'expense_group_id_response': {
'id': 1,
'fund_source': 'PERSONAL',
'response_logs': [],
'employee_name': 'Ashwin',
'description': {
'report_id': 'rp9EvDF8Umk6',
'fund_source': 'PERSONAL',
'claim_number': 'C/2022/06/R/2',
'employee_email': '[email protected]'
"id":1,
"expenses":[
{
"updated_at":"2022-09-20T08:48:21.737392Z",
"claim_number":"C/2022/09/R/21",
"employee_email":"[email protected]",
"employee_name":"None",
"fund_source":"PERSONAL",
"expense_number":"E/2022/09/T/21",
"payment_number":"P/2022/09/R/18",
"vendor":"Ashwin",
"category":"Food",
"amount":21.0
}
],
"fund_source":"PERSONAL",
"description":{
"report_id":"rpEZGqVCyWxQ",
"fund_source":"PERSONAL",
"claim_number":"C/2022/09/R/21",
"employee_email":"[email protected]"
},
'created_at': '2022-08-02T20:26:22.939437Z',
'exported_at': '2022-08-02T20:27:52.017417Z',
'updated_at': '2022-08-02T20:27:52.017711Z',
'workspace': 1,
'export_type': 'JOURNAL_ENTRY',
'expenses': [
1
]
"response_logs":"None",
"employee_name":"None",
"created_at":"2022-09-20T08:48:21.765399Z",
"export_type":"None",
"exported_at":"None",
"updated_at":"2022-09-20T08:48:21.765445Z",
"workspace":1
},
'expense_group_by_id_expenses_response': {
'id': 1,
Expand Down

0 comments on commit b38ca92

Please sign in to comment.