From fa982c79f2fc3d5032092e1ce7687d6f495a694b Mon Sep 17 00:00:00 2001
From: Neda Moeini <neda.moeini@geant.org>
Date: Mon, 24 Mar 2025 14:16:10 +0100
Subject: [PATCH] Add validation for Check columns must not be empty.

---
 sage_validation/file_validator/forms.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/sage_validation/file_validator/forms.py b/sage_validation/file_validator/forms.py
index 7a7bfd7..96ca943 100644
--- a/sage_validation/file_validator/forms.py
+++ b/sage_validation/file_validator/forms.py
@@ -45,6 +45,9 @@ class CSVUploadForm(forms.Form):
         "TaxValue",
         "SYSTraderGenerationReasonType",
         "GoodsValueInBaseCurrency",
+        "ChequeCurrencyName",
+        "ChequeToBankExchangeRate",
+        "ChequeValueInChequeCurrency",
     ]
 
     repeating_columns: ClassVar[dict] = {
@@ -83,6 +86,7 @@ class CSVUploadForm(forms.Form):
         error_list.extend(self._validate_source_and_trader_type(data))
         error_list.extend(self._validate_nominal_analysis_account(data))
         error_list.extend(self._validate_nc_cc_dep_combination_against_meo_sage_account(data))
+        error_list.extend(self._cheque_fields_must_be_empty(data))
         if error_list:
             raise forms.ValidationError(error_list)
 
@@ -251,3 +255,22 @@ class CSVUploadForm(forms.Form):
                     )
 
         return errors
+
+    @staticmethod
+    def _cheque_fields_must_be_empty(data: list[dict]) -> list[str]:
+        """Validate that cheque fields are empty.
+
+        The cheque fields are 'ChequeCurrencyName', 'ChequeToBankExchangeRate', and 'ChequeValueInChequeCurrency'.
+        """
+        errors = []
+        for index, row in enumerate(data, start=1):
+            cheque_currency_name = row.get("ChequeCurrencyName")
+            cheque_to_bank_exchange_rate = row.get("ChequeToBankExchangeRate")
+            cheque_value_in_cheque_currency = row.get("ChequeValueInChequeCurrency")
+
+            if any([cheque_currency_name, cheque_to_bank_exchange_rate, cheque_value_in_cheque_currency]):
+                errors.append(
+                    f"Row {index}: Unexpected values in the Cheque columns. All cheque columns must be empty."
+                )
+
+        return errors
-- 
GitLab