Skip to content

Commit

Permalink
Merge pull request #2226 from vorasmit/correct-upload-status
Browse files Browse the repository at this point in the history
fix: correct upload status for GSTR-1 books
  • Loading branch information
vorasmit committed Jun 9, 2024
2 parents c191871 + 97595c7 commit 6cdf314
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
25 changes: 13 additions & 12 deletions india_compliance/gst_india/doctype/gst_settings/gst_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"e_invoice_applicable_from",
"e_invoice_applicable_companies",
"gstr_1_section_break",
"analyze_filed_data",
"compare_gstr_1_data",
"filing_frequency",
"column_break_cxmn",
"restrict_changes_after_gstr_1",
Expand Down Expand Up @@ -572,14 +572,6 @@
"fieldtype": "Section Break",
"label": "GSTR-1"
},
{
"default": "0",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"description": "Compare Books with GSTR 1 Filed or Invoice data before filing",
"fieldname": "analyze_filed_data",
"fieldtype": "Check",
"label": "Analyze Filed Data"
},
{
"fieldname": "column_break_cxmn",
"fieldtype": "Column Break"
Expand All @@ -591,6 +583,7 @@
"options": "Monthly\nQuarterly"
},
{
"depends_on": "eval: doc.restrict_changes_after_gstr_1",
"fieldname": "role_allowed_to_modify",
"fieldtype": "Link",
"label": "Role Allowed to Modify Transactions",
Expand All @@ -599,16 +592,24 @@
{
"default": "0",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"description": "Ensures restrictions to cancel or create transactions after return is marked as filed",
"description": "Prevent any modifications to transactions once they have been reported in GSTR-1",
"fieldname": "restrict_changes_after_gstr_1",
"fieldtype": "Check",
"label": "Restrict changes after GSTR 1 is filed"
"label": "Restrict Changes to Transactions After Filing"
},
{
"default": "0",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"description": "Use APIs to compare records with GST Portal Data Before and After Filing",
"fieldname": "compare_gstr_1_data",
"fieldtype": "Check",
"label": "Compare Data with GST Portal"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-05-17 15:46:11.169920",
"modified": "2024-06-09 17:27:54.720233",
"modified_by": "Administrator",
"module": "GST India",
"name": "GST Settings",
Expand Down
18 changes: 17 additions & 1 deletion india_compliance/gst_india/doctype/gst_settings/gst_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def validate_e_invoice_applicable_companies(self):

company_list.append(row.company)

def is_sek_valid(self, gstin, throw=True, threshold=30):
def is_sek_valid(self, gstin, throw=False, threshold=30):
for credential in self.credentials:
if credential.service == "Returns" and credential.gstin == gstin:
break
Expand All @@ -290,6 +290,22 @@ def is_sek_valid(self, gstin, throw=True, threshold=30):
):
return True

def has_valid_credentials(self, gstin, service, throw=False):
for credential in self.credentials:
if credential.gstin == gstin and credential.service == service:
break
else:
message = _(
"No credential found for the GSTIN {0} in the GST Settings"
).format(gstin)

if throw:
frappe.throw(message)

return False

return True


@frappe.whitelist()
def disable_api_promo():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ function is_gstr1_api_enabled() {
return (
india_compliance.is_api_enabled() &&
!gst_settings.sandbox_mode &&
gst_settings.analyze_filed_data
gst_settings.compare_gstr_1_data
);
}

Expand Down
7 changes: 6 additions & 1 deletion india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def get_reconcile_gstr1_data(self, gov_data, books_data):

if not gov_value:
row["upload_status"] = "Not Uploaded"
continue

if reconcile_row:
row["upload_status"] = "Mismatch"
Expand Down Expand Up @@ -776,7 +777,11 @@ def is_gstr1_api_enabled(self, settings=None):
if not settings:
settings = frappe.get_cached_doc("GST Settings")

return is_production_api_enabled(settings) and settings.analyze_filed_data
return (
is_production_api_enabled(settings)
and settings.compare_gstr_1_data
and settings.has_valid_credentials(self.gstin, "Returns")
)

def is_sek_needed(self, settings=None):
if not self.is_gstr1_api_enabled(settings):
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/gst_india/setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def set_default_gst_settings():
"reconcile_for_b2b": 1,
"reconcile_for_cdnr": 1,
# GSTR-1
"analyze_filed_data": 1,
"compare_gstr_1_data": 1,
"freeze_transactions": 1,
"filing_frequency": "Monthly",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def execute():
frappe.db.set_single_value(
"GST Settings",
{
"analyze_filed_data": 1,
"compare_gstr_1_data": 1,
"freeze_transactions": 1,
"filing_frequency": "Monthly",
},
Expand Down

0 comments on commit 6cdf314

Please sign in to comment.