Skip to content

Commit

Permalink
fix: expense migration (#176)
Browse files Browse the repository at this point in the history
* fix: expense migration

* fix tests

* fix tests

* fix tests

* fix tests

---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
ruuushhh and GitHub Actions authored Nov 22, 2024
1 parent 9dd3179 commit 302ffb2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
18 changes: 18 additions & 0 deletions apps/fyle/migrations/0004_expense_is_posted_at_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.2 on 2024-11-22 10:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fyle', '0003_remove_expense_settlement_id'),
]

operations = [
migrations.AddField(
model_name='expense',
name='is_posted_at_null',
field=models.BooleanField(default=False, help_text='Flag check if posted at is null or not'),
),
]
1 change: 1 addition & 0 deletions apps/fyle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def create_expense_objects(expenses: List[Dict], workspace_id: int, skip_update:
'report_id': expense['report_id'],
'spent_at': expense['spent_at'],
'posted_at': expense['posted_at'],
'is_posted_at_null': expense['is_posted_at_null'],
'fund_source': SOURCE_ACCOUNT_MAP[expense['source_account_type']],
'verified_at': expense['verified_at'],
'custom_properties': expense['custom_properties'],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ms-dynamics-business-central-sdk==1.5.2
# Reusable Fyle Packages
fyle-rest-auth==1.7.2
fyle-accounting-mappings==1.34.8
fyle-integrations-platform-connector==1.38.4
fyle-integrations-platform-connector==1.39.3

# Postgres Dependincies
psycopg2-binary==2.9.9
Expand Down
1 change: 1 addition & 0 deletions tests/test_business_central/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
'spent_at':'2022-05-13T17:00:00Z',
'approved_at':'2022-05-13T09:30:13.484000Z',
'posted_at': '2021-12-22T07:30:26.289842+00:00',
'is_posted_at_null': False,
'expense_created_at':'2022-05-13T09:29:43.535468Z',
'expense_updated_at':'2022-05-13T09:32:06.643941Z',
'created_at':'2022-05-23T11:11:28.241406Z',
Expand Down
3 changes: 3 additions & 0 deletions tests/test_fyle/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'expense_rule_data': None,
'expense_rule_id': None,
'extracted_data': None,
'is_posted_at_null': True,
'file_ids': [],
'files': [],
'foreign_amount': None,
Expand Down Expand Up @@ -223,6 +224,7 @@
'spent_at': '2024-05-10 17:00:00',
'approved_at': '2024-05-10 07:53:25',
'posted_at': None,
'is_posted_at_null': True,
'is_skipped': False,
'expense_created_at': '2024-05-10 07:52:10',
'expense_updated_at': '2024-05-13 05:53:25',
Expand Down Expand Up @@ -589,6 +591,7 @@
'spent_at':'2022-05-13T17:00:00Z',
'approved_at':'2022-05-13T09:30:13.484000Z',
'posted_at': '2021-12-22T07:30:26.289842+00:00',
'is_posted_at_null': False,
'expense_created_at':'2022-05-13T09:29:43.535468Z',
'expense_updated_at':'2022-05-13T09:32:06.643941Z',
'created_at':'2022-05-23T11:11:28.241406Z',
Expand Down
11 changes: 5 additions & 6 deletions tests/test_fyle/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from .fixtures import fixtures as data
from django.urls import reverse
from rest_framework.exceptions import ValidationError
from rest_framework import status
from apps.fyle.tasks import (
update_non_exported_expenses
)
from rest_framework.exceptions import ValidationError

from apps.accounting_exports.models import AccountingExport
from apps.fyle.models import Expense
from apps.fyle.tasks import update_non_exported_expenses
from apps.workspaces.models import Workspace
from apps.accounting_exports.models import AccountingExport
from tests.test_fyle.fixtures import fixtures as data


def test_update_non_exported_expenses(db, create_temp_workspace, mocker, api_client):
Expand Down

0 comments on commit 302ffb2

Please sign in to comment.