Skip to content

Commit

Permalink
Quota order number check
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjamc committed Apr 4, 2024
1 parent 4e714ad commit 6a246f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reference_documents/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from common.models import Transaction
from geo_areas.models import GeographicalArea
from geo_areas.models import GeographicalAreaDescription
from quotas.models import QuotaOrderNumber
from reference_documents.models import PreferentialQuota
from reference_documents.models import PreferentialQuotaOrderNumber
from reference_documents.models import PreferentialRate
Expand All @@ -31,6 +32,16 @@ def __init__(self, preferential_quota_order_number: PreferentialQuotaOrderNumber
super().__init__()
self.preferential_quota_order_number = preferential_quota_order_number

def order_number(self):
try:
order_number = QuotaOrderNumber.objects.all().get(
order_number=self.preferential_quota_order_number.quota_order_number,
valid_between=self.preferential_quota_order_number.valid_between,
)
return order_number
except QuotaOrderNumber.DoesNotExist:
return None


class BasePreferentialRateCheck(BaseCheck):
def __init__(self, preferential_rate: PreferentialRate):
Expand Down
12 changes: 12 additions & 0 deletions reference_documents/checks/preferential_quota_order_numbers.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
from reference_documents.checks.base import BasePreferentialQuotaOrderNumberCheck
from reference_documents.models import AlignmentReportCheckStatus


class OrderNumberExists(BasePreferentialQuotaOrderNumberCheck):
def run_check(self):
if not self.order_number():
message = f"order number not found"
print("FAIL", message)
return AlignmentReportCheckStatus.FAIL, message
else:
print(f"PASS - order number {self.order_number()} found")
return AlignmentReportCheckStatus.PASS, ""

0 comments on commit 6a246f0

Please sign in to comment.