From a6d725f12ce0861dd1ab0a441eaa9f988260cc78 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 7 Apr 2026 23:26:45 +0200 Subject: [PATCH] handle all invoice links --- downloader.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/downloader.py b/downloader.py index e28e6e4..41e3c3f 100644 --- a/downloader.py +++ b/downloader.py @@ -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