Skip to content

Commit

Permalink
fix: common constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninad1306 committed Dec 5, 2024
1 parent 2733fd4 commit 5cfe434
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
8 changes: 8 additions & 0 deletions india_compliance/gst_india/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
"Input Service Distributor": "B2B",
}

GST_CATEGORY_MAP = {
"R": "Regular",
"SEZWP": "SEZ supplies with payment of tax",
"SEZWOP": "SEZ supplies with out payment of tax",
"DE": "Deemed exports",
"CBW": "Intra-State Supplies attracting IGST",
}

EXPORT_TYPES = (
"WOP", # Without Payment of Tax [0]
"WP", # With Payment of Tax [1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ frappe.ui.form.on("GST Invoice Management System", {
if (!frm.doc.is_data_loaded) {
frm.page.clear_primary_action();

frm.page.set_primary_action(__("Generate"), async () => {
frm.page.set_primary_action(__("Show Invoices"), async () => {
const { message } = await frm.call("get_invoice_data");
frm.doc.__invoice_data = message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from india_compliance.gst_india.utils import parse_datetime
from india_compliance.gst_india.utils.gstr_2 import download_ims_invoices, ims
from india_compliance.gst_india.utils.gstr_2.ims import ACTION_MAP, GST_CATEGORY
from india_compliance.gst_india.utils.gstr_2.ims import ACTION_MAP, GST_CATEGORY_MAP


class GSTInvoiceManagementSystem(Document):
Expand Down Expand Up @@ -257,7 +257,7 @@ def convert_data_to_gov_format(gst_inward_supply_list, company_gstin, is_reset=F
"Credit Note_1": "b2bcna",
}

gst_category_map = {v: k for k, v in GST_CATEGORY.items()}
gst_category_map = {v: k for k, v in GST_CATEGORY_MAP.items()}
action_map = {v: k for k, v in ACTION_MAP.items()}

upload_data = {}
Expand Down
7 changes: 0 additions & 7 deletions india_compliance/gst_india/utils/gstr_2/gstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ class GSTR:
{
"Y_N_to_check": {"Y": 1, "N": 0},
"yes_no": {"Y": "Yes", "N": "No"},
"gst_category": {
"R": "Regular",
"SEZWP": "SEZ supplies with payment of tax",
"SEZWOP": "SEZ supplies with out payment of tax",
"DE": "Deemed exports",
"CBW": "Intra-State Supplies attracting IGST",
},
"states": {value: f"{value}-{key}" for key, value in STATE_NUMBERS.items()},
"note_type": {"C": "Credit Note", "D": "Debit Note"},
"isd_type_2a": {"ISDCN": "ISD Credit Note", "ISD": "ISD Invoice"},
Expand Down
5 changes: 2 additions & 3 deletions india_compliance/gst_india/utils/gstr_2/gstr_2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import frappe

from india_compliance.gst_india.constants import GST_CATEGORY_MAP
from india_compliance.gst_india.utils import get_datetime, parse_datetime
from india_compliance.gst_india.utils.gstr_2.gstr import GSTR, get_mapped_value

Expand Down Expand Up @@ -129,9 +130,7 @@ def setup(self):
def get_invoice_details(self, invoice):
return {
"bill_no": invoice.inum,
"supply_type": get_mapped_value(
invoice.inv_typ, self.VALUE_MAPS.gst_category
),
"supply_type": get_mapped_value(invoice.inv_typ, GST_CATEGORY_MAP),
"bill_date": parse_datetime(invoice.idt, day_first=True),
"document_value": invoice.val,
"place_of_supply": get_mapped_value(invoice.pos, self.VALUE_MAPS.states),
Expand Down
7 changes: 3 additions & 4 deletions india_compliance/gst_india/utils/gstr_2/gstr_2b.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import frappe

from india_compliance.gst_india.constants import GST_CATEGORY_MAP
from india_compliance.gst_india.utils import parse_datetime
from india_compliance.gst_india.utils.gstr_2.gstr import GSTR, get_mapped_value

Expand Down Expand Up @@ -40,7 +41,7 @@ def setup(self):
def get_invoice_details(self, invoice):
return {
"bill_no": invoice.inum,
"supply_type": get_mapped_value(invoice.typ, self.VALUE_MAPS.gst_category),
"supply_type": get_mapped_value(invoice.typ, GST_CATEGORY_MAP),
"bill_date": parse_datetime(invoice.dt, day_first=True),
"taxable_value": invoice.txval,
"igst": invoice.igst,
Expand Down Expand Up @@ -98,9 +99,7 @@ def get_invoice_details(self, invoice):
{
"bill_no": invoice.ntnum,
"doc_type": get_mapped_value(invoice.typ, self.VALUE_MAPS.note_type),
"supply_type": get_mapped_value(
invoice.suptyp, self.VALUE_MAPS.gst_category
),
"supply_type": get_mapped_value(invoice.suptyp, GST_CATEGORY_MAP),
}
)
return invoice_details
Expand Down
11 changes: 2 additions & 9 deletions india_compliance/gst_india/utils/gstr_2/ims.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import frappe
from frappe.utils.data import format_date

from india_compliance.gst_india.constants import STATE_NUMBERS
from india_compliance.gst_india.constants import GST_CATEGORY_MAP, STATE_NUMBERS
from india_compliance.gst_india.doctype.gst_inward_supply.gst_inward_supply import (
create_inward_supply,
update_previous_ims_action,
)
from india_compliance.gst_india.utils import parse_datetime

ACTION_MAP = {"A": "Accepted", "R": "Rejected", "P": "Pending", "N": "No Action"}
GST_CATEGORY = {
"R": "Regular",
"SEZWP": "SEZ supplies with payment of tax",
"SEZWOP": "SEZ supplies with out payment of tax",
"DE": "Deemed exports",
"CBW": "Intra-State Supplies attracting IGST",
}


class IMS:
Expand Down Expand Up @@ -64,7 +57,7 @@ def update_transaction(self, invoice):
return {
"supplier_gstin": invoice.stin,
"sup_return_period": invoice.rtnprd,
"supply_type": GST_CATEGORY[invoice.inv_typ],
"supply_type": GST_CATEGORY_MAP[invoice.inv_typ],
"place_of_supply": self.STATE_MAP[invoice.pos],
"document_value": invoice.val,
"company": self.company,
Expand Down

0 comments on commit 5cfe434

Please sign in to comment.