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."""
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
......
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