printpayment directly if no anchor

This commit is contained in:
Jan Bader
2026-04-07 23:37:48 +02:00
parent 1cbe80ac00
commit 0b3e11d6a5

View File

@@ -265,7 +265,14 @@ def export_invoice_pdf(
selector = f"a[data-reference-object-id='{invoice['reference_id']}']" selector = f"a[data-reference-object-id='{invoice['reference_id']}']"
anchor = page.locator(selector).first anchor = page.locator(selector).first
if anchor.count() == 0: if anchor.count() == 0:
try:
with page.expect_popup() as popup_info:
page.evaluate("printPayment", invoice["reference_id"])
invoice_page = popup_info.value
invoice_page.wait_for_load_state("domcontentloaded")
except Exception:
raise RuntimeError(f"Invoice link not found for reference id {invoice['reference_id']}") raise RuntimeError(f"Invoice link not found for reference id {invoice['reference_id']}")
else:
anchor.scroll_into_view_if_needed() anchor.scroll_into_view_if_needed()
with page.expect_popup() as popup_info: with page.expect_popup() as popup_info:
anchor.click() anchor.click()