Skip to content

Commit

Permalink
Store tax amount as it is, bug fix (#647)
Browse files Browse the repository at this point in the history
* Store tax amount as it is, bug fix

* test fixed
  • Loading branch information
Ashutosh619-sudo committed Jul 15, 2024
1 parent e6875dc commit bec4c43
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def create_expense_objects(expenses: List[Dict], workspace_id: int, skip_update:
'currency': expense['currency'],
'foreign_amount': expense['foreign_amount'],
'foreign_currency': expense['foreign_currency'],
'tax_amount': _round_to_currency_fraction(expense['tax_amount'], expense['currency']) if expense['tax_amount'] else None,
'tax_amount': _round_to_currency_fraction(expense['tax_amount'], expense['currency']) if expense['tax_amount'] is not None else expense['tax_amount'],
'tax_group_id': expense['tax_group_id'],
'reimbursable': expense['reimbursable'],
'billable': expense['billable'],
Expand Down
167 changes: 167 additions & 0 deletions tests/test_fyle/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9951,6 +9951,173 @@
"import_card_credits": True,
"split_expense_grouping": 'SINGLE_LINE_ITEM'
},
'expenses_tax_amount':[
{
'id': 'txW7qE5DUF83',
'bank_transaction_id': 'asudbjasb',
'employee_email': '[email protected]',
'employee_name': 'Joanna',
'report_title': 'title1',
'category': 'Flight',
'sub_category': None,
'project': 'Aaron Abbott',
'project_id': 246855,
'expense_number': 'E/2022/05/T/20',
'org_id': 'or79Cob97KSh',
'claim_number': 'C/2022/05/R/6',
'amount': 5,
'tax_amount': 0,
'tax_group_id': 'tggu76WXIdjY',
'settled_at': '2022-05-23T13:37:01.524157+00:00',
'currency': 'USD',
'foreign_amount': None,
'foreign_currency': None,
'settlement_id': 'setCb41PcrHmO',
'reimbursable': True,
'billable': None,
'state': 'PAYMENT_PROCESSING',
'vendor': 'Ashwin',
'cost_center': None,
'corporate_card_id': None,
'purpose': None,
'report_id': 'rpYkgyHrGcg8',
'file_ids': [],
'spent_at': '2021-11-08T06:23:35.631000Z',
'posted_at': '2021-11-08T06:23:35.631000Z',
'approved_at': '2021-11-08T06:23:35.631000Z',
'expense_created_at': '2022-05-23T13:32:45.769742+00:00',
'expense_updated_at': '2022-05-23T13:37:01.524157+00:00',
'source_account_type': 'PERSONAL_CASH_ACCOUNT',
'verified_at': None,
'custom_properties': {
'Custom Expense Field': None,
'Location': '',
'Operating System': '',
'Team': '',
'User Dimension': '',
'User Dimension Copy': '',
'Team Copy': '',
'Team 2 Postman': '',
'System Operating': '',
'Departments': '',
'Location Entity': '',
'Class': '',
'Tax Groups': '',
'Klass': '',
},
'payment_number': 'P/2022/05/R/9',
},
{
'id': 'txW7qE5DUF84',
'bank_transaction_id': 'asudbjasb',
'employee_email': '[email protected]',
'employee_name': 'Joanna',
'report_title': 'title1',
'category': 'Flight',
'sub_category': None,
'project': 'Aaron Abbott',
'project_id': 246855,
'expense_number': 'E/2022/05/T/20',
'org_id': 'or79Cob97KSh',
'claim_number': 'C/2022/05/R/6',
'amount': 100,
'tax_amount': 10,
'tax_group_id': 'tggu76WXIdjY',
'settled_at': '2022-05-23T13:37:01.524157+00:00',
'currency': 'USD',
'foreign_amount': None,
'foreign_currency': None,
'settlement_id': 'setCb41PcrHmO',
'reimbursable': True,
'billable': None,
'state': 'PAYMENT_PROCESSING',
'vendor': 'Ashwin',
'cost_center': None,
'corporate_card_id': None,
'purpose': None,
'report_id': 'rpYkgyHrGcg8',
'file_ids': [],
'spent_at': '2021-11-08T06:23:35.631000Z',
'posted_at': '2021-11-08T06:23:35.631000Z',
'approved_at': '2021-11-08T06:23:35.631000Z',
'expense_created_at': '2022-05-23T13:32:45.769742+00:00',
'expense_updated_at': '2022-05-23T13:37:01.524157+00:00',
'source_account_type': 'PERSONAL_CASH_ACCOUNT',
'verified_at': None,
'custom_properties': {
'Custom Expense Field': None,
'Location': '',
'Operating System': '',
'Team': '',
'User Dimension': '',
'User Dimension Copy': '',
'Team Copy': '',
'Team 2 Postman': '',
'System Operating': '',
'Departments': '',
'Location Entity': '',
'Class': '',
'Tax Groups': '',
'Klass': '',
},
'payment_number': 'P/2022/05/R/9',
},
{
'id': 'txW7qE5DUF85',
'bank_transaction_id': 'asudbjasb',
'employee_email': '[email protected]',
'employee_name': 'Joanna',
'report_title': 'title1',
'category': 'Flight',
'sub_category': None,
'project': 'Aaron Abbott',
'project_id': 246855,
'expense_number': 'E/2022/05/T/20',
'org_id': 'or79Cob97KSh',
'claim_number': 'C/2022/05/R/6',
'amount': 5,
'tax_amount': None,
'tax_group_id': 'tggu76WXIdjY',
'settled_at': '2022-05-23T13:37:01.524157+00:00',
'currency': 'USD',
'foreign_amount': None,
'foreign_currency': None,
'settlement_id': 'setCb41PcrHmO',
'reimbursable': True,
'billable': None,
'state': 'PAYMENT_PROCESSING',
'vendor': 'Ashwin',
'cost_center': None,
'corporate_card_id': None,
'purpose': None,
'report_id': 'rpYkgyHrGcg8',
'file_ids': [],
'spent_at': '2021-11-08T06:23:35.631000Z',
'posted_at': '2021-11-08T06:23:35.631000Z',
'approved_at': '2021-11-08T06:23:35.631000Z',
'expense_created_at': '2022-05-23T13:32:45.769742+00:00',
'expense_updated_at': '2022-05-23T13:37:01.524157+00:00',
'source_account_type': 'PERSONAL_CASH_ACCOUNT',
'verified_at': None,
'custom_properties': {
'Custom Expense Field': None,
'Location': '',
'Operating System': '',
'Team': '',
'User Dimension': '',
'User Dimension Copy': '',
'Team Copy': '',
'Team 2 Postman': '',
'System Operating': '',
'Departments': '',
'Location Entity': '',
'Class': '',
'Tax Groups': '',
'Klass': '',
},
'payment_number': 'P/2022/05/R/9',
}
],
'expenses': [
{
'id': 'txW7qE5DUF82',
Expand Down
14 changes: 14 additions & 0 deletions tests/test_fyle/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,17 @@ def test_amount_rounding():

amount = _round_to_currency_fraction(86.444, 'USD')
assert amount == 86.44


def test_create_expense_object_tax_amount(db):
workspace_id = 1

payload = data['expenses_tax_amount']
expenses = Expense.create_expense_objects(payload, workspace_id)
for expense in expenses:
if expense.expense_id == payload[0]['id']:
assert expense.tax_amount == 0
elif expense.expense_id == payload[1]['id']:
assert expense.tax_amount == 10
elif expense.expense_id == payload[2]['id']:
assert expense.tax_amount is None

0 comments on commit bec4c43

Please sign in to comment.