Skip to content

Commit

Permalink
Merge pull request resilient-tech#2712 from vorasmit/b2c-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit authored Nov 13, 2024
2 parents 5e01f55 + ed3e239 commit 18a5651
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 21 deletions.
49 changes: 32 additions & 17 deletions india_compliance/gst_india/report/gstr_1/gstr_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +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_TAX_TYPES
from india_compliance.gst_india.constants 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 @@ -26,12 +26,10 @@
get_escaped_name,
get_gst_accounts_by_type,
get_gstin_list,
validate_invoice_number,
)
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

B2C_LIMIT = 2_50_000
from india_compliance.gst_india.utils.gstr_1 import SUPECOM, get_b2c_limit

TYPES_OF_BUSINESS = {
"B2B": "b2b",
Expand Down Expand Up @@ -260,7 +258,8 @@ def is_b2cl_cdn(self, invoice):
grand_total = invoice.return_against_invoice_total or abs(
invoice.base_grand_total
)
return grand_total > B2C_LIMIT

return grand_total > get_b2c_limit(invoice.posting_date)

def get_row_data_for_invoice(self, invoice_details, tax_rate, item_detail):
"""
Expand Down Expand Up @@ -379,20 +378,36 @@ def get_conditions(self):
)

if self.filters.get("type_of_business") == "B2C Large":
conditions += """ AND ifnull(SUBSTR(place_of_supply, 1, 2),'') != ifnull(SUBSTR(company_gstin, 1, 2),'')
AND grand_total > {0} AND is_return != 1 AND is_debit_note !=1
# get_b2c_limit hardcoded
conditions += """
AND ifnull(SUBSTR(place_of_supply, 1, 2),'') != ifnull(SUBSTR(company_gstin, 1, 2),'')
AND grand_total > (
CASE
WHEN posting_date <= '2024-07-31' THEN 250000
ELSE 100000
END
)
AND is_return != 1
AND is_debit_note !=1
AND IFNULL(gst_category, "") in ('Unregistered', 'Overseas')
AND SUBSTR(place_of_supply, 1, 2) != '96'""".format(
B2C_LIMIT
)
AND SUBSTR(place_of_supply, 1, 2) != '96'
"""

elif self.filters.get("type_of_business") == "B2C Small":
conditions += """ AND (
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)
OR grand_total <= {0}) AND IFNULL(gst_category, "") in ('Unregistered', 'Overseas')
AND SUBSTR(place_of_supply, 1, 2) != '96' """.format(
B2C_LIMIT
)
# get_b2c_limit hardcoded
conditions += """
AND (
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)
OR grand_total <= (
CASE
WHEN posting_date <= '2024-07-31' THEN 250000
ELSE 100000
END
)
)
AND IFNULL(gst_category, "") in ('Unregistered', 'Overseas')
AND SUBSTR(place_of_supply, 1, 2) != '96'
"""

elif self.filters.get("type_of_business") == "CDNR-REG":
conditions += """ AND (is_return = 1 OR is_debit_note = 1) AND IFNULL(gst_category, '') not in ('Unregistered', 'Overseas')"""
Expand Down
19 changes: 19 additions & 0 deletions india_compliance/gst_india/utils/gstr_1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from enum import Enum

from frappe.utils import getdate


class GSTR1_Category(Enum):
"""
Expand Down Expand Up @@ -333,3 +335,20 @@ class GSTR1_B2B_InvoiceType(Enum):
GSTR1_SubCategory.B2B_REVERSE_CHARGE.value,
*SUBCATEGORIES_NOT_CONSIDERED_IN_TOTAL_TAXABLE_VALUE,
]


B2C_LIMIT = [
("2024-07-31", 2_50_000),
("2099-03-31", 1_00_000),
]


def get_b2c_limit(date):
if isinstance(date, str):
date = getdate(date)

for limit_date, limit in B2C_LIMIT:
if date <= getdate(limit_date):
return limit

return B2C_LIMIT[-1][1]
11 changes: 7 additions & 4 deletions india_compliance/gst_india/utils/gstr_1/gstr_1_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
GSTR1_B2B_InvoiceType,
GSTR1_Category,
GSTR1_SubCategory,
get_b2c_limit,
)

B2C_LIMIT = 2_50_000

CATEGORY_CONDITIONS = {
GSTR1_Category.B2B.value: {
"category": "is_b2b_invoice",
Expand Down Expand Up @@ -234,11 +233,15 @@ def is_b2cl_cn_dn(self, invoice):
else invoice.invoice_total
)

return (abs(invoice_total) > B2C_LIMIT) and self.is_inter_state(invoice)
return (
abs(invoice_total) > get_b2c_limit(invoice.posting_date)
) and self.is_inter_state(invoice)

@cache_invoice_condition
def is_b2cl_inv(self, invoice):
return abs(invoice.invoice_total) > B2C_LIMIT and self.is_inter_state(invoice)
return abs(invoice.invoice_total) > get_b2c_limit(
invoice.posting_date
) and self.is_inter_state(invoice)


class GSTR1CategoryConditions(GSTR1Conditions):
Expand Down

0 comments on commit 18a5651

Please sign in to comment.