handle all invoice links

This commit is contained in:
Jan Bader
2026-04-07 23:26:45 +02:00
parent c493d21403
commit a6d725f12c

View File

@@ -149,29 +149,28 @@ def get_invoice_links(page: Page) -> list[dict]:
href = f"{BASE_URL}/{href.lstrip('/')}"
_add_link(href, text)
if not links:
print_links = page.locator("a.no-print[data-reference-object-id], a[data-reference-object-id]").all()
for anchor in print_links:
href = anchor.get_attribute("href") or ""
ref_id = anchor.get_attribute("data-reference-object-id") or ""
label = anchor.inner_text().strip() or ref_id
print_links = page.locator("a.no-print[data-reference-object-id], a[data-reference-object-id]").all()
for anchor in print_links:
href = anchor.get_attribute("href") or ""
ref_id = anchor.get_attribute("data-reference-object-id") or ""
label = anchor.inner_text().strip() or ref_id
if href:
if not href.startswith("http"):
href = f"{BASE_URL}/{href.lstrip('/')}"
_add_link(href, label)
continue
if href:
if not href.startswith("http"):
href = f"{BASE_URL}/{href.lstrip('/')}"
_add_link(href, label)
continue
if ref_id:
_add_link(
f"{BASE_URL}/billing_print_invoice.htm",
label,
reference_id=ref_id,
open_via_popup=True,
)
continue
if ref_id:
_add_link(
f"{BASE_URL}/billing_print_invoice.htm",
label,
reference_id=ref_id,
open_via_popup=True,
)
continue
logger.warning("Invoice link missing href and reference id")
logger.warning("Invoice link missing href and reference id")
return links