From 2c2fe99cc398237cf65ca4539ae220b53543619f Mon Sep 17 00:00:00 2001 From: Neda Moeini <neda.moeini@geant.org> Date: Mon, 24 Mar 2025 11:07:50 +0100 Subject: [PATCH] FINSUP-26 --- sage_validation/file_validator/forms.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sage_validation/file_validator/forms.py b/sage_validation/file_validator/forms.py index ae0679a..7a7bfd7 100644 --- a/sage_validation/file_validator/forms.py +++ b/sage_validation/file_validator/forms.py @@ -1,6 +1,7 @@ """Forms for the file_validator app.""" import csv +import re from collections.abc import Sequence from typing import ClassVar @@ -169,13 +170,18 @@ class CSVUploadForm(forms.Form): continue pl_account_name = account_code_map.get(account_code) + if pl_account_name is None: errors.append(f"Row {index}: 'AccountNumber' {account_code} does not exist in PL Account Codes.") - elif pl_account_name not in nominal: - errors.append( - f"Row {index}: 'AccountNumber' must match '{pl_account_name}' in " - f"'NominalAnalysisNominalAnalysisNarrative/1', but found '{nominal}'." - ) + else: + # Remove 'Soldo' and any hyphens from the PL account name. This is for credit card accounts. + revised_pl_account_name = re.sub( + r"\bSoldo\b|\s*-\s*", "", pl_account_name, flags=re.IGNORECASE).strip() + if revised_pl_account_name not in nominal: + errors.append( + f"Row {index}: 'AccountNumber' must match '{revised_pl_account_name}' in " + f"'NominalAnalysisNominalAnalysisNarrative/1', but found '{nominal}'." + ) return errors -- GitLab