Skip to content

Commit

Permalink
Merge branch 'develop' into quartely_in_gstr_1_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed Jan 22, 2025
2 parents dbe34d2 + 465eced commit 8be093d
Show file tree
Hide file tree
Showing 77 changed files with 5,384 additions and 1,277 deletions.
11 changes: 3 additions & 8 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ echo "Setting Up System Dependencies..."
sudo apt update

sudo apt remove mysql-server mysql-client
sudo apt install libcups2-dev redis-server mariadb-client-10.6
sudo apt install libcups2-dev redis-server mariadb-client

install_whktml() {
if [ "$(lsb_release -rs)" = "22.04" ]; then
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt install /tmp/wkhtmltox.deb
else
echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)"
exit 1
fi
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt install /tmp/wkhtmltox.deb
}
install_whktml &
wkpid=$!
Expand Down
13 changes: 13 additions & 0 deletions india_compliance/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import frappe
from frappe.utils.user import is_website_user

__version__ = "16.0.0-dev"


def check_app_permission():
if frappe.session.user == "Administrator":
return True

if is_website_user():
return False

return True
2 changes: 2 additions & 0 deletions india_compliance/gst_india/api_classes/e_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class EInvoiceAPI(BaseAPI):
# Cancel IRN errors
"9999": "Invoice is not active",
"4002": "EwayBill is already generated for this IRN",
# IRN Generated in different Portal
"2148": "Requested IRN data is not available",
# Invalid GSTIN error
"3028": "GSTIN is invalid",
"3029": "GSTIN is not active",
Expand Down
3 changes: 1 addition & 2 deletions india_compliance/gst_india/api_classes/taxpayer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,12 @@ def generate_app_key(self):

return app_key

def get_files(self, return_period, token, action, endpoint, otp=None):
def get_files(self, return_period, token, action, endpoint):
response = self.get(
action=action,
return_period=return_period,
params={"ret_period": return_period, "token": token},
endpoint=endpoint,
otp=otp,
)

if response.error_type == "queued":
Expand Down
261 changes: 249 additions & 12 deletions india_compliance/gst_india/api_classes/taxpayer_returns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import frappe
from frappe import _

from india_compliance.gst_india.api_classes.taxpayer_base import TaxpayerBaseAPI
from india_compliance.gst_india.api_classes.taxpayer_base import (
FilesAPI,
TaxpayerBaseAPI,
)


class ReturnsAPI(TaxpayerBaseAPI):
Expand All @@ -23,9 +26,9 @@ class ReturnsAPI(TaxpayerBaseAPI):
"RET2B1010": "authorization_failed", # API Authorization Failed for 2B
}

def download_files(self, return_period, token, otp=None):
def download_files(self, return_period, token):
return super().get_files(
return_period, token, action="FILEDET", endpoint="returns", otp=otp
return_period, token, action="FILEDET", endpoint="returns"
)

def get_return_status(self, return_period, reference_id, otp=None):
Expand All @@ -37,24 +40,27 @@ def get_return_status(self, return_period, reference_id, otp=None):
otp=otp,
)

def proceed_to_file(self, return_type, return_period, otp=None):
def proceed_to_file(self, return_type, return_period, is_nil_return, otp=None):
data = {
"gstin": self.company_gstin,
"ret_period": return_period,
}

if is_nil_return:
data["isnil"] = "Y"

return self.post(
return_type=return_type,
return_period=return_period,
json={
"action": "RETNEWPTF",
"data": {
"gstin": self.company_gstin,
"ret_period": return_period,
}, # "isnil": "N" / "Y"
},
json={"action": "RETNEWPTF", "data": data},
endpoint="returns/gstrptf",
otp=otp,
)


class GSTR2bAPI(ReturnsAPI):
API_NAME = "GSTR-2B"
END_POINT = "returns/gstr2b"

def get_data(self, return_period, otp=None, file_num=None):
params = {"rtnprd": return_period}
Expand All @@ -65,10 +71,29 @@ def get_data(self, return_period, otp=None, file_num=None):
action="GET2B",
return_period=return_period,
params=params,
endpoint="returns/gstr2b",
endpoint=self.END_POINT,
otp=otp,
)

def regenerate_2b(self, return_period):
return self.put(
json={
"action": "GEN2B",
"data": {"rtin": self.company_gstin, "itcprd": return_period},
},
endpoint=self.END_POINT,
)

def get_2b_gen_status(self, transaction_id):
return self.get(
action="GENSTS2B",
params={
"gstin": self.company_gstin,
"int_tran_id": transaction_id,
},
endpoint=self.END_POINT,
)


class GSTR2aAPI(ReturnsAPI):
API_NAME = "GSTR-2A"
Expand Down Expand Up @@ -151,3 +176,215 @@ def file_gstr_1(self, return_period, summary_data, pan, evc_otp):
},
endpoint="returns/gstr1",
)


class GSTR3bAPI(ReturnsAPI):
END_POINT = "returns/gstr3b"

def setup(self, company_gstin, return_period):
self.return_period = return_period
super().setup(company_gstin=company_gstin)

def get_data(self):
return self.get(
action="RETSUM",
return_period=self.return_period,
params={"gstin": self.company_gstin, "ret_period": self.return_period},
endpoint=self.END_POINT,
)

def save_gstr3b(self, data):
return self.put(
return_period=self.return_period,
json={
"action": "RETSAVE",
"data": data,
},
endpoint=self.END_POINT,
)

def submit_gstr3b(self, data):
return self.post(
return_period=self.return_period,
json={
"action": "RETSUBMIT",
"data": data,
},
endpoint=self.END_POINT,
)

def save_offset_liability_gstr3b(self, data):
return self.put(
return_period=self.return_period,
json={
"action": "RETOFFSET",
"data": data,
},
endpoint=self.END_POINT,
)

def file_gstr_3b(self, data, pan, evc_otp):
return self.post(
return_period=self.return_period,
json={
"action": "RETFILE",
"data": data,
"st": "EVC",
"sid": f"{pan}|{evc_otp}",
},
endpoint=self.END_POINT,
)

def get_itc_liab_data(self):
return self.get(
action="AUTOLIAB",
return_period=self.return_period,
params={"gstin": self.company_gstin, "ret_period": self.return_period},
endpoint=self.END_POINT,
)

def validate_3b_against_auto_calc(self, data):
return self.post(
return_period=self.return_period,
json={
"action": "VALID",
"data": data,
},
endpoint=self.END_POINT,
)

def get_system_calc_interest(self):
return self.get(
action="RETINT",
return_period=self.return_period,
params={"gstin": self.company_gstin, "ret_period": self.return_period},
endpoint=self.END_POINT,
)

def recompute_interest(self):
return self.post(
return_period=self.return_period,
json={
"action": "CMPINT",
"data": {"gstn": self.company_gstin, "ret_period": self.return_period},
},
endpoint=self.END_POINT,
)

def save_past_liab(self, data):
return self.put(
return_period=self.return_period,
json={"action": "RETBKP", "data": data},
endpoint=self.END_POINT,
)

def get_itc_reversal_bal(self):
return self.get(
action="CLOSINGBAL",
return_period=self.return_period,
params={"gstin": self.company_gstin},
endpoint=self.END_POINT,
)

def get_rcm_bal(self):
return self.get(
action="RCMCLOSINGBAL",
return_period=self.return_period,
params={"gstin": self.company_gstin},
endpoint=self.END_POINT,
)

def get_opening_bal(self):
return self.get(
action="OPENINGBAL",
return_period=self.return_period,
params={"gstin": self.company_gstin},
endpoint=self.END_POINT,
)

def get_rcm_opening_bal(self):
return self.get(
action="RCMOPNBAL",
return_period=self.return_period,
params={"gstin": self.company_gstin},
endpoint=self.END_POINT,
)

def save_opening_bal(self, data):
return self.post(
return_period=self.return_period,
json={"action": "SAVEOB", "data": data},
endpoint=self.END_POINT,
)

def submit_rcm_opening_bal(self, data):
return self.post(
return_period=self.return_period,
json={
"action": "SAVERCMOPNBAL",
"data": data,
},
endpoint=self.END_POINT,
)


class IMSAPI(ReturnsAPI):
API_NAME = "IMS"
END_POINT = "returns/ims"

def get_data(self, section):
return self.get(
action="GETINV",
params={
"gstin": self.company_gstin,
"section": section,
},
endpoint=self.END_POINT,
)

def download_files(self, return_period, token):
return self.get_files(
return_period, token, action="FILEDET", endpoint=self.END_POINT
)

def get_files(self, return_period, token, action, endpoint):
response = self.get(
action=action,
return_period=return_period,
params={"gstin": self.company_gstin, "token": token},
endpoint=endpoint,
)

if response.error_type == "queued":
return response

return FilesAPI().get_all(response)

def save(self, data):
return self.put(
endpoint=self.END_POINT,
json={
"action": "SAVE",
"data": {"rtin": self.company_gstin, "reqtyp": "SAVE", "invdata": data},
},
)

def reset(self, data):
return self.put(
endpoint=self.END_POINT,
json={
"action": "RESETIMS",
"data": {
"rtin": self.company_gstin,
"reqtyp": "RESET",
"invdata": data,
},
},
)

def get_request_status(self, transaction_id):
return self.get(
action="REQSTS",
endpoint=self.END_POINT,
params={"gstin": self.company_gstin, "int_tran_id": transaction_id},
)
11 changes: 5 additions & 6 deletions india_compliance/gst_india/client_scripts/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,19 @@ frappe.ui.form.on(DOCTYPE, {

on_submit: function (frm) {
if (!frm._inward_supply) return;

// go back to previous page and match the invoice with the inward supply
setTimeout(() => {
frappe.route_hooks.after_load = reco_frm => {
if (!reco_frm.purchase_reconciliation_tool) return;
purchase_reconciliation_tool.link_documents(
reco_frm,
frappe.route_hooks.after_load = source_frm => {
if (!source_frm.reconciliation_tabs) return;
reconciliation.link_documents(
source_frm,
frm.doc.name,
frm._inward_supply.name,
"Purchase Invoice",
false
);
};
frappe.set_route("Form", "Purchase Reconciliation Tool");
frappe.set_route("Form", frm._inward_supply.source_doc);
}, 2000);
},
});
Expand Down
Loading

0 comments on commit 8be093d

Please sign in to comment.