Commit 8bd467a6 authored by Prajkta Patkar's avatar Prajkta Patkar
Browse files

Merge branch 'newcustbank' into 'devel'

Changes in custmerandsuppliers 'get' and 'put'

1. condition is checking for bankdetails in 'get'.
    - If bank details equal to none we will get none value otherwise bank details respected value.

2. Update query is added in 'PUT', if bankdetails are null, set bankdetails as null in database.

closes#373

See merge request !35
parents 9a31d936 d141c7c1
......@@ -89,15 +89,17 @@ class api_customer(object):
dataset = self.request.params
result = self.con.execute(select([gkdb.customerandsupplier]).where(gkdb.customerandsupplier.c.custid == dataset["custid"] ))
row = result.fetchone()
Customer = {"custid":row["custid"], "custname":row["custname"], "custaddr":row["custaddr"], "custphone":row["custphone"], "custemail":row["custemail"], "custfax":row["custfax"], "custpan":row["custpan"], "custtan":row["custtan"],"state":row["state"], "custdoc":row["custdoc"], "csflag":row["csflag"],"gstin":row["gstin"] }
if(row["bankdetails"] == None):
bankdetails = ""
else:
bankdetails = row["bankdetails"]
Customer = {"custid":row["custid"], "custname":row["custname"], "custaddr":row["custaddr"], "custphone":row["custphone"], "custemail":row["custemail"], "custfax":row["custfax"], "custpan":row["custpan"], "custtan":row["custtan"],"state":row["state"], "custdoc":row["custdoc"], "csflag":row["csflag"],"gstin":row["gstin"], "bankdetails":bankdetails }
return {"gkstatus": gkcore.enumdict["Success"], "gkresult":Customer}
except:
return {"gkstatus":gkcore.enumdict["ConnectionFailed"] }
finally:
self.con.close()
@view_config(request_method='PUT', renderer='json')
def editCustomerSupplier(self):
try:
......@@ -112,7 +114,11 @@ class api_customer(object):
self.con = eng.connect()
dataset = self.request.json_body
dataset["orgcode"] = authDetails["orgcode"]
custcode = dataset["custid"]
result = self.con.execute(gkdb.customerandsupplier.update().where(gkdb.customerandsupplier.c.custid==dataset["custid"]).values(dataset))
if 'bankdetails' not in dataset:
#if bankdetails are null, set bankdetails as null in database.
self.con.execute("update customerandsupplier set bankdetails = NULL where bankdetails is NOT NULL and custid = %d"%int(custcode))
return {"gkstatus":enumdict["Success"]}
except exc.IntegrityError:
return {"gkstatus":enumdict["DuplicateEntry"]}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment