Skip to content

Commit

Permalink
feat: attach eInvoice if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Dec 19, 2024
1 parent df426f8 commit 6bbec45
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ def attach_print(doctype, name, language, print_format):
with print_language(language):
data = frappe.get_print(doctype, name, print_format, as_pdf=True)

if doctype == "Sales Invoice" and "eu_einvoice" in frappe.get_installed_apps():
try:
from eu_einvoice.european_e_invoice.custom.sales_invoice import attach_xml_to_pdf

data = attach_xml_to_pdf(name, data)
except Exception:
msg = _("Failed to attach XML to Sales Invoice PDF for DATEV")
frappe.log_error(title=msg, reference_doctype=doctype, reference_name=name)
frappe.msgprint(msg, indicator="red", alert=True)

file = frappe.new_doc("File")
file.file_name = f"{name}.pdf"
file.content = data
Expand Down

0 comments on commit 6bbec45

Please sign in to comment.