fix: shipping options are not applied when shipping_costs set to 0 #541

This commit is contained in:
sebthom
2025-06-09 20:43:16 +02:00
committed by Sebastian Thomschke
parent 3978d85cb4
commit ebfdbc4313
3 changed files with 27 additions and 7 deletions

View File

@@ -961,10 +961,7 @@ class KleinanzeigenBot(WebScrapingMixin):
await self.web_click(By.XPATH, '//*[contains(@class, "SubSection")]//button[contains(@class, "SelectionButton")]')
await self.web_click(By.XPATH, '//*[contains(@class, "CarrierSelectionModal")]//button[contains(., "Andere Versandmethoden")]')
await self.web_click(By.XPATH, '//*[contains(@id, "INDIVIDUAL") and contains(@data-testid, "Individueller Versand")]')
if ad_cfg.shipping_costs:
await self.web_input(By.CSS_SELECTOR, '.IndividualShippingInput input[type="text"]',
str.replace(str(ad_cfg.shipping_costs), ".", ","))
await self.web_input(By.CSS_SELECTOR, '.IndividualShippingInput input[type="text"]', str.replace(str(ad_cfg.shipping_costs), ".", ","))
await self.web_click(By.XPATH, '//dialog//button[contains(., "Fertig")]')
except TimeoutError as ex:
LOG.debug(ex, exc_info = True)

View File

@@ -93,9 +93,9 @@ class AdPartial(ContextualModel):
@field_validator("shipping_costs", mode = "before")
@classmethod
def _parse_shipping_costs(cls, v:float | int | str) -> Any:
if v:
return round(parse_decimal(v), 2)
return None
if v is None or (isinstance(v, str) and not v.strip()):
return None
return round(parse_decimal(v), 2)
@field_validator("description")
@classmethod