def METHOD_NAME(doc, gst_settings):
    if not gst_settings.enable_e_invoice or not validate_e_invoice_applicability(
        doc, gst_settings=gst_settings, throw=False
    ):
        doc.einvoice_status = "Not Applicable"
        return
    validate_mandatory_fields(
        doc,
        "customer_address",
        _("{0} is a mandatory field for generating e-Invoices"),
    )
    if is_foreign_doc(doc):
        country = frappe.db.get_value("Address", doc.customer_address, "country")
        get_validated_country_code(country)
    if doc.docstatus == 1 and not doc.irn:
        doc.einvoice_status = "Pending"