Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@ def process_doc_issue_data(self, data):
"""
Add draft count to cancelled count for DOC_ISSUE category
"""
for doc in data:
for doc in data.copy():
if doc.get(GSTR1_DataField.DOC_TYPE.value).startswith(
"Excluded from Report"
):
data.remove(doc)
continue

doc[GSTR1_DataField.CANCELLED_COUNT.value] += doc.get(
GSTR1_DataField.DRAFT_COUNT.value, 0
)
Expand Down
9 changes: 8 additions & 1 deletion india_compliance/gst_india/report/gstr_1/gstr_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
get_gst_accounts_by_type,
get_gstin_list,
)
from india_compliance.gst_india.utils.__init__ import validate_invoice_number
from india_compliance.gst_india.utils.exporter import ExcelExporter
from india_compliance.gst_india.utils.gstr_1 import SUPECOM

Expand Down Expand Up @@ -1590,6 +1591,7 @@ def is_same_naming_series(self, name_1, name_2):

def seperate_data_by_nature_of_document(self, data, doctype):
nature_of_document = {
"Excluded from Report (Invalid Invoice Number)": [],
"Excluded from Report (Same GSTIN Billing)": [],
"Excluded from Report (Is Opening Entry)": [],
"Invoices for outward supply": [],
Expand All @@ -1600,7 +1602,12 @@ def seperate_data_by_nature_of_document(self, data, doctype):
}

for doc in data:
if doc.is_opening == "Yes":
if not validate_invoice_number(doc, throw=False):
nature_of_document[
"Excluded from Report (Invalid Invoice Number)"
].append(doc)

elif doc.is_opening == "Yes":
nature_of_document["Excluded from Report (Is Opening Entry)"].append(
doc
)
Expand Down
12 changes: 9 additions & 3 deletions india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,22 @@ def disable_new_gst_category_notification():
frappe.defaults.clear_user_default("needs_new_gst_category_notification")


def validate_invoice_number(doc):
def validate_invoice_number(doc, throw=True):
"""Validate GST invoice number requirements."""

if len(doc.name) > 16:
is_valid_length = len(doc.name) <= 16
is_valid_format = GST_INVOICE_NUMBER_FORMAT.match(doc.name)

if not throw:
return is_valid_length and is_valid_format

if not is_valid_length:
frappe.throw(
_("GST Invoice Number cannot exceed 16 characters"),
title=_("Invalid GST Invoice Number"),
)

if not GST_INVOICE_NUMBER_FORMAT.match(doc.name):
if not is_valid_format:
frappe.throw(
_(
"GST Invoice Number should start with an alphanumeric character and can"
Expand Down
5 changes: 5 additions & 0 deletions india_compliance/gst_india/utils/gstr_1/gstr_1_json_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,11 @@ def convert_to_gov_data_format(self, input_data, **kwargs):
doc_nature_wise_data = {}

for invoice in input_data:
if invoice[GSTR1_DataField.DOC_TYPE.value].startswith(
"Excluded from Report"
):
continue

doc_nature_wise_data.setdefault(
invoice[GSTR1_DataField.DOC_TYPE.value], []
).append(invoice)
Expand Down

0 comments on commit 5098544

Please sign in to comment.