Skip to content
Snippets Groups Projects
Commit 2c2fe99c authored by Neda Moeini's avatar Neda Moeini
Browse files

FINSUP-26

parent 01039213
No related branches found
No related tags found
No related merge requests found
"""Forms for the file_validator app.""" """Forms for the file_validator app."""
import csv import csv
import re
from collections.abc import Sequence from collections.abc import Sequence
from typing import ClassVar from typing import ClassVar
...@@ -169,13 +170,18 @@ class CSVUploadForm(forms.Form): ...@@ -169,13 +170,18 @@ class CSVUploadForm(forms.Form):
continue continue
pl_account_name = account_code_map.get(account_code) pl_account_name = account_code_map.get(account_code)
if pl_account_name is None: if pl_account_name is None:
errors.append(f"Row {index}: 'AccountNumber' {account_code} does not exist in PL Account Codes.") errors.append(f"Row {index}: 'AccountNumber' {account_code} does not exist in PL Account Codes.")
elif pl_account_name not in nominal: else:
errors.append( # Remove 'Soldo' and any hyphens from the PL account name. This is for credit card accounts.
f"Row {index}: 'AccountNumber' must match '{pl_account_name}' in " revised_pl_account_name = re.sub(
f"'NominalAnalysisNominalAnalysisNarrative/1', but found '{nominal}'." 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 return errors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment