Skip to content

Commit

Permalink
fix: add Not Applicable e-Inovice status (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljain112 authored Aug 11, 2023
1 parent 763635b commit d5fca0e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,13 @@
"label": "e-Invoice Status",
"fieldtype": "Select",
"insert_after": "status",
"options": "\nPending\nGenerated\nCancelled\nFailed",
"options": "\nPending\nGenerated\nCancelled\nFailed\nNot Applicable",
"default": None,
"hidden": 1,
"no_copy": 1,
"print_hide": 1,
"read_only": 1,
"translatable": 0,
"translatable": 1,
},
]
}
Expand Down
1 change: 1 addition & 0 deletions india_compliance/gst_india/overrides/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def validate_fields_and_set_status_for_e_invoice(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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ frappe.query_reports["e-Invoice Summary"] = {
fieldtype: "Select",
fieldname: "status",
label: __("e-Invoice Status"),
options: "\nPending\nGenerated\nCancelled\nFailed",
options: "\nPending\nGenerated\nCancelled\nFailed\nNot Applicable",
},
{
fieldtype: "Select",
Expand Down
3 changes: 2 additions & 1 deletion india_compliance/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ execute:import frappe; frappe.delete_doc_if_exists("DocType", "GSTIN")

[post_model_sync]
india_compliance.patches.v14.set_default_for_overridden_accounts_setting
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #23
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #24
execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #3
india_compliance.patches.post_install.remove_old_fields
india_compliance.patches.post_install.update_company_gstin
Expand All @@ -24,3 +24,4 @@ india_compliance.patches.v14.set_autogenerate_e_waybill_with_e_invoice
execute:import frappe; frappe.db.set_value("GST Settings", None, "archive_party_info_days", 7)
india_compliance.patches.v14.set_reverse_charge_applicability_in_supplier
india_compliance.patches.post_install.update_e_waybill_status
india_compliance.patches.post_install.add_einvoice_status_field
14 changes: 14 additions & 0 deletions india_compliance/patches/post_install/add_einvoice_status_field.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import frappe
from frappe.query_builder.functions import Coalesce
from frappe.utils import sbool


Expand All @@ -11,6 +12,7 @@ def execute():
"E Invoice Settings", "E Invoice Settings", "enable", ignore=True
)
):
set_not_applicable_status()
return

frappe.db.sql(
Expand Down Expand Up @@ -38,3 +40,15 @@ def execute():
"""UPDATE `tabSales Invoice` SET einvoice_status = 'Cancelled'
WHERE IFNULL(einvoice_status, '') = '' AND IFNULL(irn_cancelled, 0) = 1"""
)

set_not_applicable_status()


def set_not_applicable_status():
sales_invoice = frappe.qb.DocType("Sales Invoice")

frappe.qb.update(sales_invoice).set("einvoice_status", "Not Applicable").where(
(sales_invoice.docstatus != 0)
& (Coalesce(sales_invoice.einvoice_status, "") == "")
& (Coalesce(sales_invoice.irn, "") == "")
).run()

0 comments on commit d5fca0e

Please sign in to comment.