FEAT: Corporate onboarding implemented with Tax ID validation (HU) and isolated NAS storage
This commit is contained in:
Binary file not shown.
BIN
backend/app/core/__pycache__/validators.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/validators.cpython-312.pyc
Normal file
Binary file not shown.
47
backend/app/core/validators.py
Normal file
47
backend/app/core/validators.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import re
|
||||
|
||||
class VINValidator:
|
||||
@staticmethod
|
||||
def validate(vin: str) -> bool:
|
||||
"""VIN (Vehicle Identification Number) ellenőrzése ISO 3779 szerint."""
|
||||
vin = vin.upper().strip()
|
||||
|
||||
# Alapvető formátum: 17 karakter, tiltott betűk (I, O, Q) nélkül
|
||||
if not re.match(r"^[A-Z0-9]{17}$", vin) or any(c in vin for c in "IOQ"):
|
||||
return False
|
||||
|
||||
# Karakterértékek táblázata
|
||||
values = {
|
||||
'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6, 'G':7, 'H':8, 'J':1, 'K':2, 'L':3, 'M':4,
|
||||
'N':5, 'P':7, 'R':9, 'S':2, 'T':3, 'U':4, 'V':5, 'W':6, 'X':7, 'Y':8, 'Z':9,
|
||||
'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9
|
||||
}
|
||||
|
||||
# Súlyozás a pozíciók alapján
|
||||
weights = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
|
||||
|
||||
try:
|
||||
# 1. Összegzés: érték * súly
|
||||
total = sum(values[vin[i]] * weights[i] for i in range(17))
|
||||
|
||||
# 2. Maradék számítás 11-el
|
||||
check_digit = total % 11
|
||||
|
||||
# 3. A 10-es maradékot 'X'-nek jelöljük
|
||||
expected = 'X' if check_digit == 10 else str(check_digit)
|
||||
|
||||
# 4. Összevetés a 9. karakterrel (index 8)
|
||||
return vin[8] == expected
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def get_factory_data(vin: str) -> dict:
|
||||
"""Kinyeri az alapadatokat a VIN-ből (WMI, Évjárat, Gyártó ország)."""
|
||||
# Ez a 'Mágikus Gomb' alapja
|
||||
countries = {"1": "USA", "2": "Kanada", "J": "Japán", "W": "Németország", "S": "Anglia"}
|
||||
return {
|
||||
"country": countries.get(vin[0], "Ismeretlen"),
|
||||
"year_code": vin[9], # Modellév kódja
|
||||
"wmi": vin[0:3] # World Manufacturer Identifier
|
||||
}
|
||||
Reference in New Issue
Block a user