From 42e4de3921cac3cbc3c8e37314495363a8f4e75a Mon Sep 17 00:00:00 2001 From: Jacek Date: Tue, 25 Jun 2019 18:09:58 +0200 Subject: [PATCH] Sprawdzenie czy barcode jest w zakresie podanym w pliku settings.cfg --- data/settings.cfg | 7 ++++++- magazyn.py | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/data/settings.cfg b/data/settings.cfg index 70edbaf..a6ccfa2 100644 --- a/data/settings.cfg +++ b/data/settings.cfg @@ -1,2 +1,7 @@ year = 2019 -year2 2018 \ No newline at end of file +areamin = 1 +areamax = 100 +itemmin = 1 +itemmax = 600 +orchmin = 1 +orchmax = 100 \ No newline at end of file diff --git a/magazyn.py b/magazyn.py index 0d30896..13ba9db 100644 --- a/magazyn.py +++ b/magazyn.py @@ -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: @@ -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!'