Skip to content

Commit 8bc16a8

Browse files
authored
Merge pull request #107 from 8848digital/oct_1st_to_last_month
Oct 1st to last month
2 parents 316c055 + 5b60b2b commit 8bc16a8

22 files changed

Lines changed: 657 additions & 64 deletions

india_compliance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "15.22.1"
1+
__version__ = "15.23.0"

india_compliance/exceptions.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
class GSPServerError(Exception):
2-
def __init__(self, message="GSP/GST server is down", *args, **kwargs):
3-
super().__init__(message, *args, **kwargs)
1+
import frappe
2+
43

4+
class GSPServerError(frappe.ValidationError):
5+
message = "GSP/GST server is down"
6+
title = "GSP/GST Server Error"
7+
8+
class GSPLimitExceededError(GSPServerError):
9+
message = "GSP/GST account limit exceeded"
10+
http_status_code = 429
511

612
class GatewayTimeoutError(GSPServerError):
7-
def __init__(self, message="The server took too long to respond", *args, **kwargs):
8-
super().__init__(message, *args, **kwargs)
13+
message = "The server took too long to respond"
14+
http_status_code = 504
915

1016

1117
class OTPRequestedError(Exception):

india_compliance/gst_india/api_classes/base.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
from frappe.utils import sbool
99
from frappe.utils.scheduler import is_scheduler_disabled
1010

11-
from india_compliance.exceptions import GatewayTimeoutError, GSPServerError
11+
from india_compliance.exceptions import (
12+
GatewayTimeoutError,
13+
GSPLimitExceededError,
14+
GSPServerError,
15+
)
1216
from india_compliance.gst_india.utils import is_api_enabled
1317
from india_compliance.gst_india.utils.api import enqueue_integration_request
1418

@@ -224,18 +228,25 @@ def handle_error_response(self, response_json):
224228
title=_("API Request Failed"),
225229
)
226230

227-
def handle_server_error(self, error_messages):
228-
error_message_list = [
231+
ERROR_MESSAGES = {
232+
GSPServerError: (
229233
"GSPGSTDOWN",
230234
"GSPERR300",
231235
"Connection reset",
232236
"No route to host",
233-
]
237+
),
238+
GSPLimitExceededError: ("GEN5005",),
239+
}
234240

235-
for message in error_messages:
236-
for error in error_message_list:
237-
if error in message:
238-
raise GSPServerError
241+
def handle_server_error(self, error_messages):
242+
for exception, error_message_list in self.ERROR_MESSAGES.items():
243+
for error_pattern in error_message_list:
244+
if any(error_pattern in msg for msg in error_messages if msg):
245+
frappe.throw(
246+
msg=exception.message,
247+
exc=exception,
248+
title=exception.title,
249+
)
239250

240251
def is_ignored_error(self, response_json):
241252
# Override in subclass, return truthy value to stop frappe.throw
20.3 KB
Binary file not shown.

india_compliance/gst_india/doctype/gst_return_log/generate_gstr_1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ def default_subcategory_summary(self, subcategory):
238238

239239
@staticmethod
240240
def count_doc_issue_summary(summary_row, data_row):
241+
if data_row.get(inv_f.DOC_TYPE) in (
242+
"Excluded from Report (Invalid Invoice Number)",
243+
"Excluded from Report (Same GSTIN Billing)",
244+
"Excluded from Report (Is Opening Entry)",
245+
):
246+
return
247+
241248
summary_row["no_of_records"] += (
242249
data_row.get(inv_f.TOTAL_COUNT, 0)
243250
- data_row.get(inv_f.CANCELLED_COUNT, 0)

india_compliance/gst_india/doctype/gstr_3b_report/gstr_3b_report.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ frappe.ui.form.on("GSTR 3B Report", {
2525
frm.set_intro(__("Please save the report again to rebuild or update"));
2626
frm.doc.__unsaved = 1;
2727

28-
// Download Button
28+
// Download JSON Button
2929
frm.add_custom_button(__("Download JSON"), function () {
3030
var w = window.open(
3131
frappe.urllib.get_full_url(
@@ -41,6 +41,22 @@ frappe.ui.form.on("GSTR 3B Report", {
4141
}
4242
});
4343

44+
// Download Excel Button
45+
frm.add_custom_button(__("Download Excel"), function () {
46+
var w = window.open(
47+
frappe.urllib.get_full_url(
48+
"/api/method/india_compliance.gst_india.doctype.gstr_3b_report.gstr_3b_report.download_gstr3b_as_excel?" +
49+
"name=" +
50+
encodeURIComponent(frm.doc.name)
51+
)
52+
);
53+
54+
if (!w) {
55+
frappe.msgprint(__("Please enable pop-ups"));
56+
return;
57+
}
58+
});
59+
4460
// View Form Button
4561
frm.add_custom_button(__("View Form"), function () {
4662
frappe.call({

0 commit comments

Comments
 (0)