From 302ffb229ad1b08a5329f9dbaa2a83e2e0d32a8a Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:50:08 +0530 Subject: [PATCH] fix: expense migration (#176) * fix: expense migration * fix tests * fix tests * fix tests * fix tests --------- Co-authored-by: GitHub Actions --- .../0004_expense_is_posted_at_null.py | 18 ++++++++++++++++++ apps/fyle/models.py | 1 + requirements.txt | 2 +- tests/test_business_central/fixtures.py | 1 + tests/test_fyle/fixtures.py | 3 +++ tests/test_fyle/test_tasks.py | 11 +++++------ 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 apps/fyle/migrations/0004_expense_is_posted_at_null.py diff --git a/apps/fyle/migrations/0004_expense_is_posted_at_null.py b/apps/fyle/migrations/0004_expense_is_posted_at_null.py new file mode 100644 index 0000000..8d5ee82 --- /dev/null +++ b/apps/fyle/migrations/0004_expense_is_posted_at_null.py @@ -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'), + ), + ] diff --git a/apps/fyle/models.py b/apps/fyle/models.py index 1f3d700..9af8a6c 100644 --- a/apps/fyle/models.py +++ b/apps/fyle/models.py @@ -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'], diff --git a/requirements.txt b/requirements.txt index a7189f9..61025d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tests/test_business_central/fixtures.py b/tests/test_business_central/fixtures.py index 070f0f2..f05e891 100644 --- a/tests/test_business_central/fixtures.py +++ b/tests/test_business_central/fixtures.py @@ -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', diff --git a/tests/test_fyle/fixtures.py b/tests/test_fyle/fixtures.py index 8570764..96d6118 100644 --- a/tests/test_fyle/fixtures.py +++ b/tests/test_fyle/fixtures.py @@ -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, @@ -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', @@ -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', diff --git a/tests/test_fyle/test_tasks.py b/tests/test_fyle/test_tasks.py index 912a7af..8945eaf 100644 --- a/tests/test_fyle/test_tasks.py +++ b/tests/test_fyle/test_tasks.py @@ -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):