Skip to content

Commit

Permalink
feat: build automations for ineligible ITC
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Oct 19, 2023
1 parent fef386b commit 8566447
Show file tree
Hide file tree
Showing 17 changed files with 1,460 additions and 28 deletions.
62 changes: 53 additions & 9 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
"options": "Account",
"insert_after": "default_finance_book",
},
{
"fieldname": "default_gst_expense_account",
"label": "Default GST Expense Account",
"fieldtype": "Link",
"options": "Account",
"insert_after": "default_customs_expense_account",
},
],
("Customer", "Supplier"): party_fields,
# Purchase Fields
Expand Down Expand Up @@ -308,6 +315,7 @@
"Sales Invoice Item",
"POS Invoice Item",
"Purchase Invoice Item",
"Purchase Receipt Item",
): [
{
"fieldname": "taxable_value",
Expand All @@ -320,6 +328,22 @@
"no_copy": 1,
},
],
(
"Supplier Quotation Item",
"Purchase Order Item",
"Purchase Receipt Item",
"Purchase Invoice Item",
): [
{
"fieldname": "is_ineligible_for_itc",
"label": "Is Ineligible for Input Tax Credit",
"fieldtype": "Check",
"fetch_from": "item_code.is_ineligible_for_itc",
"insert_after": "is_nil_exempt",
"fetch_if_empty": 1,
"print_hide": 1,
},
],
"Sales Invoice": [
{
"fieldname": "port_address",
Expand Down Expand Up @@ -377,24 +401,34 @@
"collapsible": 1,
},
{
"fieldname": "eligibility_for_itc",
"label": "Eligibility For ITC",
"fieldname": "itc_classification",
"label": "ITC Classification",
"fieldtype": "Select",
"insert_after": "gst_section",
"print_hide": 1,
"options": (
"Input Service Distributor\nImport Of Service\nImport Of"
" Goods\nITC on Reverse Charge\nIneligible As Per Section"
" 17(5)\nIneligible Others\nAll Other ITC"
" Goods\nITC on Reverse Charge\nAll Other ITC"
),
"default": "All Other ITC",
"translatable": 0,
},
{
"fieldname": "ineligibility_reason",
"label": "Reason for Ineligibility",
"fieldtype": "Select",
"insert_after": "itc_classification",
"options": (
"\nIneligible As Per Section 17(5)\nITC restricted due to PoS rules"
),
"read_only": 1,
"print_hide": 1,
},
{
"fieldname": "reconciliation_status",
"label": "Reconciliation Status",
"fieldtype": "Select",
"insert_after": "eligibility_for_itc",
"insert_after": "ineligibility_reason",
"print_hide": 1,
"options": ("\nNot Applicable\nReconciled\nUnreconciled\nIgnored"),
"no_copy": 1,
Expand All @@ -407,26 +441,29 @@
},
{
"fieldname": "itc_integrated_tax",
"label": "Availed ITC Integrated Tax",
"label": "Integrated Tax",
"fieldtype": "Currency",
"insert_after": "gst_col_break",
"options": "Company:company:default_currency",
"read_only": 1,
"print_hide": 1,
},
{
"fieldname": "itc_central_tax",
"label": "Availed ITC Central Tax",
"label": "Central Tax",
"fieldtype": "Currency",
"insert_after": "itc_integrated_tax",
"options": "Company:company:default_currency",
"read_only": 1,
"print_hide": 1,
},
{
"fieldname": "itc_state_tax",
"label": "Availed ITC State/UT Tax",
"label": "State/UT Tax",
"fieldtype": "Currency",
"insert_after": "itc_central_tax",
"options": "Company:company:default_currency",
"read_only": 1,
"print_hide": 1,
},
{
Expand All @@ -435,6 +472,7 @@
"fieldtype": "Currency",
"insert_after": "itc_state_tax",
"options": "Company:company:default_currency",
"read_only": 1,
"print_hide": 1,
},
],
Expand Down Expand Up @@ -584,7 +622,7 @@
],
"Journal Entry": [
{
"fieldname": "reversal_type",
"fieldname": "ineligibility_reason",
"label": "Reversal Type",
"fieldtype": "Select",
"insert_after": "voucher_type",
Expand Down Expand Up @@ -647,6 +685,12 @@
"fieldtype": "Check",
"insert_after": "is_nil_exempt",
},
{
"fieldname": "is_ineligible_for_itc",
"label": "Is Ineligible for Input Tax Credit",
"fieldtype": "Check",
"insert_after": "item_tax_section_break",
},
],
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ def set_itc_details(self, itc_details):
def get_itc_reversal_entries(self):
reversal_entries = frappe.db.sql(
"""
SELECT ja.account, j.reversal_type, sum(credit_in_account_currency) as amount
SELECT ja.account, j.ineligibility_reason, sum(credit_in_account_currency) as amount
FROM `tabJournal Entry` j, `tabJournal Entry Account` ja
where j.docstatus = 1
and j.is_opening = 'No'
and ja.parent = j.name
and j.voucher_type = 'Reversal Of ITC'
and month(j.posting_date) = %s and year(j.posting_date) = %s
and j.company = %s and j.company_gstin = %s
GROUP BY ja.account, j.reversal_type""",
GROUP BY ja.account, j.ineligibility_reason""",
(self.month_no, self.year, self.company, self.gst_details.get("gstin")),
as_dict=1,
)

net_itc = self.report_dict["itc_elg"]["itc_net"]

for entry in reversal_entries:
if entry.reversal_type == "As per rules 42 & 43 of CGST Rules":
if entry.ineligibility_reason == "As per rules 42 & 43 of CGST Rules":
index = 0
else:
index = 1
Expand All @@ -124,7 +124,7 @@ def get_itc_reversal_entries(self):
def get_itc_details(self):
itc_amounts = frappe.db.sql(
"""
SELECT eligibility_for_itc, sum(itc_integrated_tax) as itc_integrated_tax,
SELECT itc_classification, sum(itc_integrated_tax) as itc_integrated_tax,
sum(itc_central_tax) as itc_central_tax,
sum(itc_state_tax) as itc_state_tax,
sum(itc_cess_amount) as itc_cess_amount
Expand All @@ -133,7 +133,7 @@ def get_itc_details(self):
and is_opening = 'No'
and month(posting_date) = %s and year(posting_date) = %s and company = %s
and company_gstin = %s
GROUP BY eligibility_for_itc
GROUP BY itc_classification
""",
(self.month_no, self.year, self.company, self.gst_details.get("gstin")),
as_dict=1,
Expand All @@ -142,7 +142,7 @@ def get_itc_details(self):
itc_details = {}
for d in itc_amounts:
itc_details.setdefault(
d.eligibility_for_itc,
d.itc_classification,
{
"iamt": d.itc_integrated_tax,
"camt": d.itc_central_tax,
Expand Down
10 changes: 10 additions & 0 deletions india_compliance/gst_india/overrides/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def make_company_fixtures(doc, method=None):
def create_company_fixtures(company):
make_default_tax_templates(company)
make_default_customs_accounts(company)
make_default_gst_expense_accounts(company)


def make_default_customs_accounts(company):
Expand All @@ -46,6 +47,15 @@ def make_default_customs_accounts(company):
)


def make_default_gst_expense_accounts(company):
create_default_company_account(
company,
account_name="GST Expense",
parent="Indirect Expenses",
default_fieldname="default_gst_expense_account",
)


@frappe.whitelist()
def make_default_tax_templates(company: str):
frappe.has_permission("Company", ptype="write", doc=company, throw=True)
Expand Down
Loading

0 comments on commit 8566447

Please sign in to comment.