From 29fc3617c46bb1337c67054270f61081a8fa8881 Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:01:18 +0530 Subject: [PATCH] fix: add constraint on source employee (#127) --- ...7_alter_employeemapping_source_employee.py | 19 +++++++++++++++++++ fyle_accounting_mappings/models.py | 2 +- setup.py | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 fyle_accounting_mappings/migrations/0027_alter_employeemapping_source_employee.py diff --git a/fyle_accounting_mappings/migrations/0027_alter_employeemapping_source_employee.py b/fyle_accounting_mappings/migrations/0027_alter_employeemapping_source_employee.py new file mode 100644 index 0000000..42ba619 --- /dev/null +++ b/fyle_accounting_mappings/migrations/0027_alter_employeemapping_source_employee.py @@ -0,0 +1,19 @@ +# Generated by Django 4.1.2 on 2024-12-06 09:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('fyle_accounting_mappings', '0026_destinationattribute_code'), + ] + + operations = [ + migrations.AlterField( + model_name='employeemapping', + name='source_employee', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='employeemapping', to='fyle_accounting_mappings.expenseattribute', unique=True), + ), + ] diff --git a/fyle_accounting_mappings/models.py b/fyle_accounting_mappings/models.py index 4709ade..5c96268 100644 --- a/fyle_accounting_mappings/models.py +++ b/fyle_accounting_mappings/models.py @@ -702,7 +702,7 @@ class EmployeeMapping(models.Model): """ id = models.AutoField(primary_key=True) source_employee = models.ForeignKey( - ExpenseAttribute, on_delete=models.PROTECT, related_name='employeemapping') + ExpenseAttribute, on_delete=models.PROTECT, related_name='employeemapping', unique=True) destination_employee = models.ForeignKey( DestinationAttribute, on_delete=models.PROTECT, null=True, related_name='destination_employee') destination_vendor = models.ForeignKey( diff --git a/setup.py b/setup.py index 7556d0b..e2165c1 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='fyle-accounting-mappings', - version='1.34.9', + version='1.35.0', author='Shwetabh Kumar', author_email='shwetabh.kumar@fyle.in', description='Django application to store the fyle accounting mappings in a generic manner',