diff --git a/zatca2024/zatca2024/createxml.py b/zatca2024/zatca2024/createxml.py index b2859d3..3ffb6c1 100644 --- a/zatca2024/zatca2024/createxml.py +++ b/zatca2024/zatca2024/createxml.py @@ -629,8 +629,8 @@ def xml_structuring(invoice,sales_invoice_doc): file.write(pretty_xml_string) # Attach the getting xml for each invoice try: - if frappe.db.exists("File",{ "attached_to_name": sales_invoice_doc.name, "attached_to_doctype": sales_invoice_doc.doctype }): - frappe.db.delete("File",{ "attached_to_name":sales_invoice_doc.name, "attached_to_doctype": sales_invoice_doc.doctype }) + if frappe.db.exists("File",{"file_name": "E-invoice-" + sales_invoice_doc.name + ".xml" }): + frappe.db.delete("File",{"file_name": "E-invoice-" + sales_invoice_doc.name + ".xml" }) except Exception as e: frappe.throw(frappe.get_traceback()) @@ -652,4 +652,4 @@ def xml_structuring(invoice,sales_invoice_doc): except Exception as e: frappe.throw(frappe.get_traceback()) except Exception as e: - frappe.throw("Error occured in XML structuring and attach. Please contact your system administrator"+ str(e) ) \ No newline at end of file + frappe.throw("Error occured in XML structuring and attach. Please contact your system administrator"+ str(e) ) diff --git a/zatca2024/zatca2024/zatcasdkcode.py b/zatca2024/zatca2024/zatcasdkcode.py index df211d3..3f0fa40 100644 --- a/zatca2024/zatca2024/zatcasdkcode.py +++ b/zatca2024/zatca2024/zatcasdkcode.py @@ -506,6 +506,7 @@ def attach_QR_Image_For_Reporting(qr_code_value,sales_invoice_doc): }) file.save(ignore_permissions=True) + frappe.db.set_value("Sales Invoice",sales_invoice_doc.name,'ksa_einv_qr',file.file_url) except Exception as e: frappe.throw("Error in qr image attach for reporting api " + str(e)) @@ -753,6 +754,7 @@ def attach_QR_Image_For_Clearance(xml_cleared,sales_invoice_doc): }) file.save(ignore_permissions=True) + frappe.db.set_value("Sales Invoice",sales_invoice_doc.name,'ksa_einv_qr',file.file_url) except Exception as e: frappe.throw("error in qrcode from cleared xml: " + str(e) ) @@ -955,4 +957,4 @@ def zatca_Background_on_submit(doc, method=None): # # queue="short", # # timeout=200, # # invoice_number=invoice_number) -# # frappe.msgprint("queued") \ No newline at end of file +# # frappe.msgprint("queued")