Skip to content

Commit

Permalink
New SAC "check for duplicate" routine
Browse files Browse the repository at this point in the history
Searches the `General` table for an audit year and UEI that matches the current SAC.
  • Loading branch information
rnovak338 committed Dec 12, 2024
1 parent 4016868 commit d8e3815
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions backend/audit/models/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from datetime import timedelta
from itertools import chain
import datetime
import json
import logging

from dissemination.models import General
from django.db import models
from django.db.transaction import TransactionManagementError
from django.conf import settings
Expand Down Expand Up @@ -239,6 +241,27 @@ def disseminate(self):

return None

def is_duplicate(self):
"""
Validates whether the SAC contains identical information to disseminated records.
"""
general_information = self.general_information

audit_year = general_information.get("auditee_fiscal_period_end")
uei = general_information.get("auditee_uei")

if audit_year and uei:

# extract date from year.
audit_year = datetime.datetime.strptime(audit_year, "%Y-%m-%d").year

# check disseminated.
return General.objects.filter(
audit_year=audit_year, auditee_uei=uei
).exists()

return False

def assign_cog_over(self):
"""
Function that the FAC app uses when a submission is completed and cog_over needs to be assigned.
Expand Down

0 comments on commit d8e3815

Please sign in to comment.