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