Skip to content
Snippets Groups Projects

Feature/cheque cols should be empty

Merged Neda Moeini requested to merge feature/cheque-cols-should-be-empty into develop
1 file
+ 23
0
Compare changes
  • Side-by-side
  • Inline
@@ -45,6 +45,9 @@ class CSVUploadForm(forms.Form):
@@ -45,6 +45,9 @@ class CSVUploadForm(forms.Form):
"TaxValue",
"TaxValue",
"SYSTraderGenerationReasonType",
"SYSTraderGenerationReasonType",
"GoodsValueInBaseCurrency",
"GoodsValueInBaseCurrency",
 
"ChequeCurrencyName",
 
"ChequeToBankExchangeRate",
 
"ChequeValueInChequeCurrency",
]
]
repeating_columns: ClassVar[dict] = {
repeating_columns: ClassVar[dict] = {
@@ -83,6 +86,7 @@ class CSVUploadForm(forms.Form):
@@ -83,6 +86,7 @@ class CSVUploadForm(forms.Form):
error_list.extend(self._validate_source_and_trader_type(data))
error_list.extend(self._validate_source_and_trader_type(data))
error_list.extend(self._validate_nominal_analysis_account(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._validate_nc_cc_dep_combination_against_meo_sage_account(data))
 
error_list.extend(self._cheque_fields_must_be_empty(data))
if error_list:
if error_list:
raise forms.ValidationError(error_list)
raise forms.ValidationError(error_list)
@@ -251,3 +255,22 @@ class CSVUploadForm(forms.Form):
@@ -251,3 +255,22 @@ class CSVUploadForm(forms.Form):
)
)
return errors
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
Loading