diff --git a/apps/tasks/migrations/0012_alter_tasklog_expense_group.py b/apps/tasks/migrations/0012_alter_tasklog_expense_group.py new file mode 100644 index 00000000..2f60f426 --- /dev/null +++ b/apps/tasks/migrations/0012_alter_tasklog_expense_group.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.14 on 2024-11-14 10:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle', '0038_expensegroup_export_url'), + ('tasks', '0011_error_repetition_count'), + ] + + operations = [ + migrations.AlterField( + model_name='tasklog', + name='expense_group', + field=models.ForeignKey(help_text='Reference to Expense group', null=True, on_delete=django.db.models.deletion.PROTECT, to='fyle.expensegroup', unique=True), + ), + ] diff --git a/apps/tasks/models.py b/apps/tasks/models.py index 8ed9087e..7e312d0c 100644 --- a/apps/tasks/models.py +++ b/apps/tasks/models.py @@ -20,7 +20,7 @@ class TaskLog(models.Model): workspace = models.ForeignKey(Workspace, on_delete=models.PROTECT, help_text='Reference to Workspace model') type = models.CharField(max_length=50, help_text='Task type (FETCH_EXPENSES / CREATE_BILL / CREATE_CHECK)') task_id = models.CharField(max_length=255, null=True, help_text='Django Q task reference') - expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group') + expense_group = models.ForeignKey(ExpenseGroup, on_delete=models.PROTECT, null=True, help_text='Reference to Expense group', unique=True) bill = models.ForeignKey(Bill, on_delete=models.PROTECT, help_text='Reference to Bill', null=True) cheque = models.ForeignKey(Cheque, on_delete=models.PROTECT, help_text='Reference to Cheque', null=True) journal_entry = models.ForeignKey(JournalEntry, on_delete=models.PROTECT, help_text='Reference to journal_entry', null=True) diff --git a/apps/workspaces/tasks.py b/apps/workspaces/tasks.py index 9fd6d230..29ecfbfa 100644 --- a/apps/workspaces/tasks.py +++ b/apps/workspaces/tasks.py @@ -1,5 +1,5 @@ import logging -from datetime import date, datetime +from datetime import date, datetime, timedelta from typing import List from django.conf import settings @@ -65,7 +65,15 @@ def schedule_sync(workspace_id: int, schedule_enabled: bool, hours: int, email_a if email_added: ws_schedule.additional_email_options.append(email_added) - schedule, _ = Schedule.objects.update_or_create(func='apps.workspaces.tasks.run_sync_schedule', args='{}'.format(workspace_id), defaults={'schedule_type': Schedule.MINUTES, 'minutes': hours * 60, 'next_run': datetime.now()}) + schedule, _ = Schedule.objects.update_or_create( + func='apps.workspaces.tasks.run_sync_schedule', + args='{}'.format(workspace_id), + defaults={ + 'schedule_type': Schedule.MINUTES, + 'minutes': hours * 60, + 'next_run': datetime.now() + timedelta(hours=hours), + } + ) ws_schedule.schedule = schedule diff --git a/requirements.txt b/requirements.txt index bba7bdef..316140db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ psycopg2-binary==2.8.4 pylint==2.7.4 python-dateutil==2.8.1 pytz==2019.3 -qbosdk==0.18.1 +qbosdk==0.19.0 redis==3.3.11 requests==2.25.0 sentry-sdk==1.19.1