Skip to content

Commit

Permalink
Sprawdzenie czy barcode jest w zakresie podanym w pliku settings.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
jgruszka93 committed Jun 25, 2019
1 parent b258e99 commit 42e4de3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion data/settings.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
year = 2019
year2 2018
areamin = 1
areamax = 100
itemmin = 1
itemmax = 600
orchmin = 1
orchmax = 100
18 changes: 15 additions & 3 deletions magazyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,23 @@ def barcodevalcheck(code, typ):
year = settings['year']
if typ == 'area':
typcode = '10'
codemin = int(settings['areamin'])
codemax = int(settings['areamax'])
elif typ == 'item':
typcode = '20'
codemin = int(settings['itemmin'])
codemax = int(settings['itemmax'])
elif typ == 'orch':
typcode = '30'
codemin = int(settings['orchmin'])
codemax = int(settings['orchmax'])
elif typ == 'user':
typcode = '40'
codemin = 1
codemax = 100
else:
pass
if code == '':
if code is None or code == '':
status = 1
statustxt = 'Nie wprowadzono żadnego kodu!'
else:
Expand All @@ -129,8 +137,12 @@ def barcodevalcheck(code, typ):
if code[4:6] == typcode:
try:
int(code[6:9])
status = 0
statustxt = 'Wprowadzono właściwy kod'
if int(code[6:9]) < codemin or int(code[6:9]) > codemax:
status = 5
statustxt = 'Wprowadzono kod spoza zakresu'
else:
status = 0
statustxt = 'Wprowadzono właściwy kod'
except:
status = 2
statustxt = 'Wprowadzono niewłaściwy kod!'
Expand Down

0 comments on commit 42e4de3

Please sign in to comment.