Commit 28f9a0e8 authored by Prajkta_Patkar's avatar Prajkta_Patkar
Browse files

product desc and orgcode must be unique

code added to gkupgrade for same.
also code tested for duplicate product in post and edit
parent cbb212c7
......@@ -171,6 +171,7 @@ This table is for product, based on a certain category.
The products are stored on the basis of the selected category and must have data exactly matching the attributes or properties as one may call it.
The table is having a json field which has the keys matching the attributes from the spects table for a certain category.
gscode is to store gstin or accounting service code, gsflag is 7 for gstin and 19 for service code.
1 organisation cannot have same products.
"""
product = Table('product',metadata,
Column('productcode',Integer,primary_key=True),
......@@ -183,6 +184,7 @@ product = Table('product',metadata,
Column('uomid',Integer,ForeignKey('unitofmeasurement.uomid',ondelete="CASCADE")),
Column('orgcode',Integer, ForeignKey('organisation.orgcode', ondelete="CASCADE"), nullable=False),
UniqueConstraint('categorycode','productdesc'),
UniqueConstraint('productdesc','orgcode'),
Index("product_orgcodeindex","orgcode"),
Index("product_categorycode","categorycode")
)
......
......@@ -78,6 +78,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 product add UNIQUE(productdesc,orgcode)")
self.con.execute("create table state( statecode integer,statename text,primary key (statecode))")
self.con.execute("insert into state( statecode, statename)values(1, 'Jammu and Kashmir')")
self.con.execute("insert into state( statecode, statename)values(2, 'Himachal Pradesh')")
......
Supports Markdown
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