Skip to content

Commit

Permalink
fix: change name of nature of document
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Oct 2, 2024
1 parent 2f728a2 commit 7f1610a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,9 @@ def process_doc_issue_data(self, data):
Add draft count to cancelled count for DOC_ISSUE category
"""
for doc in data.copy():
if doc.get(GSTR1_DataField.DOC_TYPE.value) in [
"Invalid Invoice Number (length greater than 16)",
"Excluded from Report (Same GSTIN Billing)",
"Excluded from Report (Is Opening Entry)",
]:
if doc.get(GSTR1_DataField.DOC_TYPE.value).startswith(
"Excluded from Report"
):
data.remove(doc)
continue

Expand Down
13 changes: 6 additions & 7 deletions india_compliance/gst_india/report/gstr_1/gstr_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
from frappe.query_builder.functions import Date, IfNull, Sum
from frappe.utils import cint, flt, formatdate, getdate

from india_compliance.gst_india.constants.__init__ import (
GST_INVOICE_NUMBER_FORMAT,
GST_TAX_TYPES,
)
from india_compliance.gst_india.constants.__init__ import GST_TAX_TYPES
from india_compliance.gst_india.report.hsn_wise_summary_of_outward_supplies.hsn_wise_summary_of_outward_supplies import (
get_columns as get_hsn_columns,
)
Expand All @@ -30,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 @@ -1593,7 +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 = {
"Invalid Invoice Number (length greater than 16)": [],
"Excluded from Report (Invalid Invoice Number)": [],
"Excluded from Report (Same GSTIN Billing)": [],
"Excluded from Report (Is Opening Entry)": [],
"Invoices for outward supply": [],
Expand All @@ -1604,10 +1602,11 @@ def seperate_data_by_nature_of_document(self, data, doctype):
}

for doc in data:
if len(doc.name) > 16 or not GST_INVOICE_NUMBER_FORMAT.match(doc.name):
if not validate_invoice_number(doc, throw=False):
nature_of_document[
"Invalid Invoice Number (length greater than 16)"
"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 @@ -906,16 +906,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

0 comments on commit 7f1610a

Please sign in to comment.