Skip to content

Commit

Permalink
fix: more readable settings, generate without creds
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Jun 9, 2024
1 parent 0f58672 commit 97595c7
Show file tree
Hide file tree
Showing 6 changed files with 38 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

Check warning on line 296 in india_compliance/gst_india/doctype/gst_settings/gst_settings.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gst_settings/gst_settings.py#L294-L296

Added lines #L294 - L296 were not covered by tests
else:
message = _(

Check warning on line 298 in india_compliance/gst_india/doctype/gst_settings/gst_settings.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gst_settings/gst_settings.py#L298

Added line #L298 was not covered by tests
"No credential found for the GSTIN {0} in the GST Settings"
).format(gstin)

if throw:
frappe.throw(message)

Check warning on line 303 in india_compliance/gst_india/doctype/gst_settings/gst_settings.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gst_settings/gst_settings.py#L302-L303

Added lines #L302 - L303 were not covered by tests

return False

Check warning on line 305 in india_compliance/gst_india/doctype/gst_settings/gst_settings.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gst_settings/gst_settings.py#L305

Added line #L305 was not covered by tests

return True

Check warning on line 307 in india_compliance/gst_india/doctype/gst_settings/gst_settings.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gst_settings/gst_settings.py#L307

Added line #L307 was not covered by tests


@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
6 changes: 5 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 @@ -777,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 (

Check warning on line 780 in india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py

View check run for this annotation

Codecov / codecov/patch

india_compliance/gst_india/doctype/gstr_1_log/gstr_1_log.py#L780

Added line #L780 was not covered by tests
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 97595c7

Please sign in to comment.