wbs wbw fix

This commit is contained in:
Aron Petau 2026-01-09 11:06:09 +01:00
parent 0d1de13420
commit 856f683ec3

View file

@ -231,6 +231,7 @@ class GewobagHandler(BaseHandler):
logger.warning(f"[GEWOBAG] Could not fill Mobilfunknummer: {e}") logger.warning(f"[GEWOBAG] Could not fill Mobilfunknummer: {e}")
# WBS (Wohnberechtigungsschein) - Handle both regular and special needs WBS # WBS (Wohnberechtigungsschein) - Handle both regular and special needs WBS
wbs_fields_should_be_filled = False
try: try:
# Check for regular WBS first (click Ja) # Check for regular WBS first (click Ja)
wbs_ja = await iframe_page.query_selector('input[type="radio"][id*="wbs_available"][id*="-Ja"]') wbs_ja = await iframe_page.query_selector('input[type="radio"][id*="wbs_available"][id*="-Ja"]')
@ -250,6 +251,7 @@ class GewobagHandler(BaseHandler):
logger.warning(f"[GEWOBAG] Could not save WBS debug HTML: {e}") logger.warning(f"[GEWOBAG] Could not save WBS debug HTML: {e}")
form_filled = True form_filled = True
wbs_fields_should_be_filled = True # Only fill WBS fields if we selected Ja
# Check for special needs WBS (click Nein - we don't have this) # Check for special needs WBS (click Nein - we don't have this)
wbs_special_nein = await iframe_page.query_selector('input[type="radio"][id*="wbs_mit_besonderem_wohnbedarf"][id*="-Nein"]') wbs_special_nein = await iframe_page.query_selector('input[type="radio"][id*="wbs_mit_besonderem_wohnbedarf"][id*="-Nein"]')
@ -257,49 +259,55 @@ class GewobagHandler(BaseHandler):
await wbs_special_nein.click() await wbs_special_nein.click()
logger.info("[GEWOBAG] Selected WBS mit besonderem Wohnbedarf: Nein") logger.info("[GEWOBAG] Selected WBS mit besonderem Wohnbedarf: Nein")
form_filled = True form_filled = True
# Don't fill WBS fields when we select Nein for special WBS
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not select WBS: {e}") # WBS Gültigkeit (validity date) - appears after selecting Ja logger.warning(f"[GEWOBAG] Could not select WBS: {e}")
try:
wbs_valid_until = os.environ.get("FORM_WBS_VALID_UNTIL", "26.11.2026")
wbs_date_input = await iframe_page.query_selector('#formly_6_input_\\$\\$_wbs_valid_until_\\$\\$_0')
if wbs_date_input:
await wbs_date_input.fill(wbs_valid_until)
logger.info(f"[GEWOBAG] Filled WBS Gültigkeit: {wbs_valid_until}")
form_filled = True
except Exception as e:
logger.warning(f"[GEWOBAG] Could not fill WBS Gültigkeit: {e}")
# WBS Art/Bezeichnung (type) dropdown - appears after selecting Ja # WBS Gültigkeit (validity date) - only fill if regular WBS was selected
try: if wbs_fields_should_be_filled:
wbs_type = os.environ.get("FORM_WBS_TYPE", "WBS 100") try:
wbs_type_input = await iframe_page.query_selector('#formly_6_select_gewobag_art_bezeichnung_des_wbs_1') wbs_valid_until = os.environ.get("FORM_WBS_VALID_UNTIL", "26.11.2026")
if wbs_type_input: wbs_date_input = await iframe_page.query_selector('#formly_6_input_\\$\\$_wbs_valid_until_\\$\\$_0')
await wbs_type_input.click() if wbs_date_input:
await iframe_page.wait_for_timeout(300) await wbs_date_input.fill(wbs_valid_until)
wbs_type_option = await iframe_page.query_selector(f'.ng-option:has-text("{wbs_type}")') logger.info(f"[GEWOBAG] Filled WBS Gültigkeit: {wbs_valid_until}")
if wbs_type_option:
await wbs_type_option.click()
logger.info(f"[GEWOBAG] Selected WBS Type: {wbs_type}")
form_filled = True form_filled = True
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not select WBS Type: {e}") logger.warning(f"[GEWOBAG] Could not fill WBS Gültigkeit: {e}")
# WBS Anzahl Räume (number of rooms) dropdown - appears after selecting Ja # WBS Art/Bezeichnung (type) dropdown - only fill if regular WBS was selected
try: if wbs_fields_should_be_filled:
wbs_rooms = os.environ.get("FORM_WBS_ROOMS", "1") try:
wbs_rooms_input = await iframe_page.query_selector('#formly_7_select_\\$\\$_wbs_max_number_rooms_\\$\\$_0') wbs_type = os.environ.get("FORM_WBS_TYPE", "WBS 100")
if wbs_rooms_input: wbs_type_input = await iframe_page.query_selector('#formly_6_select_gewobag_art_bezeichnung_des_wbs_1')
await wbs_rooms_input.click() if wbs_type_input:
await iframe_page.wait_for_timeout(300) await wbs_type_input.click()
wbs_rooms_option = await iframe_page.query_selector(f'.ng-option:has-text("{wbs_rooms}")') await iframe_page.wait_for_timeout(300)
if wbs_rooms_option: wbs_type_option = await iframe_page.query_selector(f'.ng-option:has-text("{wbs_type}")')
await wbs_rooms_option.click() if wbs_type_option:
logger.info(f"[GEWOBAG] Selected WBS Rooms: {wbs_rooms}") await wbs_type_option.click()
form_filled = True logger.info(f"[GEWOBAG] Selected WBS Type: {wbs_type}")
except Exception as e: form_filled = True
logger.warning(f"[GEWOBAG] Could not select WBS Rooms: {e}") except Exception as e:
logger.warning(f"[GEWOBAG] Could not select WBS Type: {e}")
# WBS file upload - Upload the WBS PDF and PNG from data/uploads # WBS Anzahl Räume (number of rooms) dropdown - only fill if regular WBS was selected
if wbs_fields_should_be_filled:
try:
wbs_rooms = os.environ.get("FORM_WBS_ROOMS", "1")
wbs_rooms_input = await iframe_page.query_selector('#formly_7_select_\\$\\$_wbs_max_number_rooms_\\$\\$_0')
if wbs_rooms_input:
await wbs_rooms_input.click()
await iframe_page.wait_for_timeout(300)
wbs_rooms_option = await iframe_page.query_selector(f'.ng-option:has-text("{wbs_rooms}")')
if wbs_rooms_option:
await wbs_rooms_option.click()
logger.info(f"[GEWOBAG] Selected WBS Rooms: {wbs_rooms}")
form_filled = True
except Exception as e:
logger.warning(f"[GEWOBAG] Could not select WBS Rooms: {e}")
# WBS file upload - Upload the WBS PDF and PNG from data/uploads (always upload regardless of WBS type)
try: try:
wbs_files = [ wbs_files = [
Path("data/uploads/WBS_Antrag_Bestaetigung.pdf"), Path("data/uploads/WBS_Antrag_Bestaetigung.pdf"),