Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sage Validation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
Sage Validation
Commits
fa982c79
Commit
fa982c79
authored
2 weeks ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Add validation for Check columns must not be empty.
parent
78dae063
No related branches found
Branches containing commit
Tags
0.8
Tags containing commit
1 merge request
!5
Feature/cheque cols should be empty
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sage_validation/file_validator/forms.py
+23
-0
23 additions, 0 deletions
sage_validation/file_validator/forms.py
with
23 additions
and
0 deletions
sage_validation/file_validator/forms.py
+
23
−
0
View file @
fa982c79
...
...
@@ -45,6 +45,9 @@ class CSVUploadForm(forms.Form):
"
TaxValue
"
,
"
SYSTraderGenerationReasonType
"
,
"
GoodsValueInBaseCurrency
"
,
"
ChequeCurrencyName
"
,
"
ChequeToBankExchangeRate
"
,
"
ChequeValueInChequeCurrency
"
,
]
repeating_columns
:
ClassVar
[
dict
]
=
{
...
...
@@ -83,6 +86,7 @@ class CSVUploadForm(forms.Form):
error_list
.
extend
(
self
.
_validate_source_and_trader_type
(
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
.
_cheque_fields_must_be_empty
(
data
))
if
error_list
:
raise
forms
.
ValidationError
(
error_list
)
...
...
@@ -251,3 +255,22 @@ class CSVUploadForm(forms.Form):
)
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment