From 62ffcbbf0d8a04f06234c31c4f1a01d87f0e6ef7 Mon Sep 17 00:00:00 2001 From: reshma1 Date: Wed, 8 Nov 2017 15:25:11 +0530 Subject: [PATCH 1/7] orgstategstin column is added in invoice table. --- gkcore/models/gkdb.py | 2 ++ gkcore/views/api_organisation.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/gkcore/models/gkdb.py b/gkcore/models/gkdb.py index db7d9af..4c0d982 100644 --- a/gkcore/models/gkdb.py +++ b/gkcore/models/gkdb.py @@ -295,6 +295,7 @@ Bankdetails is a dictionary will have bankname,accountno., branchname and ifscco taxstate is a destination sate. sourcestate is source state from where invoice is initiated. Structure of a tax field is {productcode:taxrate} +save orgstategstin of sourcestate for organisation. """ invoice = Table('invoice',metadata, Column('invid',Integer,primary_key=True), @@ -311,6 +312,7 @@ invoice = Table('invoice',metadata, Column('icflag',Integer,default=9), Column('taxstate',UnicodeText), Column('sourcestate',UnicodeText), + Column('orgstategstin',UnicodeText), Column('attachment',JSON), Column('attachmentcount',Integer,default=0), Column('orderid', Integer,ForeignKey('purchaseorder.orderid')), diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index 10a8900..15a85ac 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -60,6 +60,7 @@ class api_organisation(object): """ self.con = eng.connect() try: + self.con.execute(select([func.count(gkdb.invoice.c.orgstategstin)])) self.con.execute(select([func.count(gkdb.invoice.c.cess)])) self.con.execute(select([func.count(gkdb.state.c.statecode)])) self.con.execute(select([func.count(gkdb.invoice.c.reversecharge)])) @@ -79,6 +80,7 @@ class api_organisation(object): self.con.execute(select(gkdb.organisation.c.billflag)) self.con.execute(select([func.count(gkdb.billwise.c.billid)])) except: + self.con.execute("alter table invoice add orgstategstin text") self.con.execute("alter table invoice add cess jsonb") self.con.execute("alter table product add UNIQUE(productdesc,orgcode)") self.con.execute("create table state( statecode integer,statename text,primary key (statecode))") -- GitLab From 799e18988aef17bc29637c89ab86784d7d654987 Mon Sep 17 00:00:00 2001 From: kk Date: Wed, 8 Nov 2017 16:57:53 +0530 Subject: [PATCH 2/7] Added function to only return state gstin for an organisation. --- gkcore/views/api_organisation.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index 15a85ac..f5bd0d3 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -465,11 +465,22 @@ class api_organisation(object): except: self.con.close() return {"gkstatus":enumdict["ConnectionFailed"]} - - - - - + @view_config(request_method="GET",renderer="json",request_param="osg=true") + def getOrgStateGstin(self): + token = self.request.headers['gktoken'] + authDetails = authCheck(token) + if authDetails["auth"]==False: + return {"gkstatus":enumdict["UnauthorisedAccess"]} + else: + try: + self.con =eng.connect() + gstinResult = self.con.execute("select gstin ->>'%s' as stgstin from organisation where orgcode = %d and statecode = %d"%(authDetails["orgcode"],self.request.params["statecode"] ) ) + gstinrow = gstinResult.fetchone() + + return{"gkstatus":enumdict["Succes"],"gkresult":str(gstinrow["stgstin"])} + except: + return {"gkstatus": enumdict["ConnectionFailed"]} + @view_config(request_method='PUT', renderer='json') def putOrg(self): token = self.request.headers['gktoken'] -- GitLab From 14c90369ef64f6058534f859e5d6debf5a61a793 Mon Sep 17 00:00:00 2001 From: reshma1 Date: Wed, 8 Nov 2017 19:28:43 +0530 Subject: [PATCH 3/7] Few changes in select query for getting GSTIN. --- gkcore/views/api_organisation.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index f5bd0d3..83f32e3 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -472,13 +472,15 @@ class api_organisation(object): if authDetails["auth"]==False: return {"gkstatus":enumdict["UnauthorisedAccess"]} else: - try: + # try: self.con =eng.connect() - gstinResult = self.con.execute("select gstin ->>'%s' as stgstin from organisation where orgcode = %d and statecode = %d"%(authDetails["orgcode"],self.request.params["statecode"] ) ) - gstinrow = gstinResult.fetchone() - - return{"gkstatus":enumdict["Succes"],"gkresult":str(gstinrow["stgstin"])} - except: + gstinResult = self.con.execute("select gstin ->>'%s' as stgstin from organisation where gstin ? '%s' and orgcode = %d and statecode = %d"%(authDetails["orgcode"],self.request.params["statecode"] ) ) + gstinval = "" + if gstinResult.rowcount()>0 : + gstinrow = gstinResult.fetchone() + gstinval = str(gstinrow["stgstin"]) + return{"gkstatus":enumdict["Succes"],"gkresult":gstinval} + # except: return {"gkstatus": enumdict["ConnectionFailed"]} @view_config(request_method='PUT', renderer='json') -- GitLab From 892eef544015dabbc132aff1bd56ff25d3ef4e83 Mon Sep 17 00:00:00 2001 From: reshma1 Date: Thu, 9 Nov 2017 12:25:14 +0530 Subject: [PATCH 4/7] Few changes in api_organisation.py for getting gstin. --- gkcore/views/api_organisation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index 83f32e3..ffed191 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -474,7 +474,9 @@ class api_organisation(object): else: # try: self.con =eng.connect() - gstinResult = self.con.execute("select gstin ->>'%s' as stgstin from organisation where gstin ? '%s' and orgcode = %d and statecode = %d"%(authDetails["orgcode"],self.request.params["statecode"] ) ) + print self.request.params["statecode"] + gstinResult = self.con.execute("select gstin ->>'%d' as stgstin from organisation where gstin ? '%d' and orgcode = %d "%(int(self.request.params["statecode"]),int(authDetails["orgcode"]) ) ) + gstinval = "" if gstinResult.rowcount()>0 : gstinrow = gstinResult.fetchone() -- GitLab From 46ce097b6e2dbc93141661632a70bbb8bfeed3e7 Mon Sep 17 00:00:00 2001 From: kk Date: Thu, 9 Nov 2017 15:30:22 +0530 Subject: [PATCH 5/7] corrected integer formats for sql. Under trial. --- gkcore/views/api_organisation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index ffed191..c3adfd5 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -20,11 +20,11 @@ Copyright (C) 2013, 2014, 2015, 2016 Digital Freedom Foundation Contributors: -"Krishnakant Mane" +"Krishnakant Mane" "Ishan Masdekar " "Navin Karkera" 'Prajkta Patkar' -'Reshma Bhatwadekar' +'Reshma Bhatwadekar' """ from pyramid.view import view_defaults, view_config @@ -475,7 +475,7 @@ class api_organisation(object): # try: self.con =eng.connect() print self.request.params["statecode"] - gstinResult = self.con.execute("select gstin ->>'%d' as stgstin from organisation where gstin ? '%d' and orgcode = %d "%(int(self.request.params["statecode"]),int(authDetails["orgcode"]) ) ) + gstinResult = self.con.execute("select gstin ->> %d as stgstin from organisation where gstin ? %d and orgcode = %d "%(int(self.request.params["statecode"]),int(authDetails["orgcode"])) ) gstinval = "" if gstinResult.rowcount()>0 : -- GitLab From 3e26f0c7c1612da3bd38fbf91a74426d99ef3d10 Mon Sep 17 00:00:00 2001 From: kk Date: Thu, 9 Nov 2017 15:51:15 +0530 Subject: [PATCH 6/7] Added matching params which were missing. --- gkcore/views/api_organisation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index c3adfd5..25ccc30 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -475,7 +475,7 @@ class api_organisation(object): # try: self.con =eng.connect() print self.request.params["statecode"] - gstinResult = self.con.execute("select gstin ->> %d as stgstin from organisation where gstin ? %d and orgcode = %d "%(int(self.request.params["statecode"]),int(authDetails["orgcode"])) ) + gstinResult = self.con.execute("select gstin ->> '%d' as stgstin from organisation where gstin ? '%d' and orgcode = %d "%(self.request.params["statecode"],self.request.params["statecode"],int(authDetails["orgcode"]))) gstinval = "" if gstinResult.rowcount()>0 : -- GitLab From 5e9f040f20b9f4ca9cfb4265d9b08739f68b26d9 Mon Sep 17 00:00:00 2001 From: reshma1 Date: Thu, 9 Nov 2017 16:08:01 +0530 Subject: [PATCH 7/7] All work is done. --- gkcore/views/api_organisation.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gkcore/views/api_organisation.py b/gkcore/views/api_organisation.py index 25ccc30..649ae4f 100644 --- a/gkcore/views/api_organisation.py +++ b/gkcore/views/api_organisation.py @@ -472,17 +472,15 @@ class api_organisation(object): if authDetails["auth"]==False: return {"gkstatus":enumdict["UnauthorisedAccess"]} else: - # try: + try: self.con =eng.connect() - print self.request.params["statecode"] - gstinResult = self.con.execute("select gstin ->> '%d' as stgstin from organisation where gstin ? '%d' and orgcode = %d "%(self.request.params["statecode"],self.request.params["statecode"],int(authDetails["orgcode"]))) - + gstinResult = self.con.execute("select gstin ->> '%d' as stgstin from organisation where gstin ? '%d' and orgcode = %d "%(int(self.request.params["statecode"]),int(self.request.params["statecode"]),int(authDetails["orgcode"]))) gstinval = "" - if gstinResult.rowcount()>0 : + if gstinResult.rowcount > 0 : gstinrow = gstinResult.fetchone() gstinval = str(gstinrow["stgstin"]) - return{"gkstatus":enumdict["Succes"],"gkresult":gstinval} - # except: + return{"gkstatus":enumdict["Success"],"gkresult":gstinval} + except: return {"gkstatus": enumdict["ConnectionFailed"]} @view_config(request_method='PUT', renderer='json') -- GitLab