diff --git a/gkcore/models/gkdb.py b/gkcore/models/gkdb.py index db7d9af9b987f91d22c8c8ba2e7916168e5693fc..4c0d9821ee853defedff5af87bf5bdec28792264 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 10a8900601330b1f0394b546ffee519836610447..649ae4ff7c8f4a576fe74b17a37905b18c109438 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 @@ -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))") @@ -463,11 +465,24 @@ 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 ->> '%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 : + gstinrow = gstinResult.fetchone() + gstinval = str(gstinrow["stgstin"]) + return{"gkstatus":enumdict["Success"],"gkresult":gstinval} + except: + return {"gkstatus": enumdict["ConnectionFailed"]} + @view_config(request_method='PUT', renderer='json') def putOrg(self): token = self.request.headers['gktoken']