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

Update forms.py based on the models update.

parent e17906e5
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ from typing import ClassVar ...@@ -7,7 +7,7 @@ from typing import ClassVar
from django import forms from django import forms
from django.core.files.uploadedfile import UploadedFile from django.core.files.uploadedfile import UploadedFile
from sage_validation.file_validator.models import Meocostcentres, Meovalidsageaccounts, PlAccountCodes, XxData from sage_validation.file_validator.models import MeoCostCentres, MeoValidSageAccounts, XxData, MeoValidSuppliers
class CSVUploadForm(forms.Form): class CSVUploadForm(forms.Form):
...@@ -151,8 +151,8 @@ class CSVUploadForm(forms.Form): ...@@ -151,8 +151,8 @@ class CSVUploadForm(forms.Form):
errors = [] errors = []
account_code_map = { account_code_map = {
obj.pl_account_code: obj.pl_account_name obj.supplier_account_number: obj.supplier_account_name
for obj in PlAccountCodes.objects.using("meo").all() # type: ignore[attr-defined] for obj in MeoValidSuppliers.objects.using("meo").all() # type: ignore[attr-defined]
} }
for index, row in enumerate(data, start=1): for index, row in enumerate(data, start=1):
...@@ -188,7 +188,7 @@ class CSVUploadForm(forms.Form): ...@@ -188,7 +188,7 @@ class CSVUploadForm(forms.Form):
errors = [] errors = []
cost_centre_map = { cost_centre_map = {
obj.cc: obj.cctype for obj in Meocostcentres.objects.using("meo").all() obj.cc: obj.cc_type for obj in MeoCostCentres.objects.using("meo").all()
} }
xx_data_map = { xx_data_map = {
...@@ -216,8 +216,8 @@ class CSVUploadForm(forms.Form): ...@@ -216,8 +216,8 @@ class CSVUploadForm(forms.Form):
nc = xx_data[0] if cc_type == "Project" else xx_data[1] nc = xx_data[0] if cc_type == "Project" else xx_data[1]
if not Meovalidsageaccounts.objects.using("meo").filter( if not MeoValidSageAccounts.objects.using("meo").filter(
accountcostcentre=cc, accountdepartment=dep, accountnumber=nc account_cost_centre=cc, account_department=dep, account_number=nc
).exists(): ).exists():
errors.append( errors.append(
f"Row {index}: The combination of 'NominalAnalysisNominalCostCentre/1' ({cc}), " f"Row {index}: The combination of 'NominalAnalysisNominalCostCentre/1' ({cc}), "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment