| 94 |
ashish |
1 |
'''
|
|
|
2 |
Created on 22-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 4873 |
mandeep.dh |
6 |
from elixir import metadata, setup_all
|
| 94 |
ashish |
7 |
from elixir.entity import Entity
|
|
|
8 |
from elixir.fields import Field
|
| 4873 |
mandeep.dh |
9 |
from elixir.options import using_options, using_table_options
|
| 5318 |
rajveer |
10 |
from elixir.relationships import OneToMany, ManyToOne
|
| 4873 |
mandeep.dh |
11 |
from sqlalchemy import create_engine
|
| 6903 |
anupam.sin |
12 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Text, Enum, BigInteger
|
| 4873 |
mandeep.dh |
13 |
import datetime
|
|
|
14 |
import elixir
|
| 94 |
ashish |
15 |
|
| 626 |
chandransh |
16 |
class EntityIDGenerator(Entity):
|
|
|
17 |
id=Field(Integer, primary_key=True)
|
|
|
18 |
using_options(shortnames=True)
|
| 746 |
rajveer |
19 |
using_table_options(mysql_engine="InnoDB")
|
| 122 |
ashish |
20 |
|
| 94 |
ashish |
21 |
class Item(Entity):
|
| 122 |
ashish |
22 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 963 |
chandransh |
23 |
product_group = Field(String(100))
|
| 4917 |
phani.kuma |
24 |
brand = Field(String(100), default='', server_default='')
|
|
|
25 |
model_number = Field(String(50), default='', server_default='')
|
|
|
26 |
model_name = Field(String(100), default='', server_default='')
|
|
|
27 |
color = Field(String(20), default='', server_default='')
|
|
|
28 |
category = Field(Integer, default=0, server_default="0")
|
| 483 |
rajveer |
29 |
comments = Field(String(200))
|
| 122 |
ashish |
30 |
catalog_item_id = Field(Integer)
|
|
|
31 |
feature_id = Field(Integer)
|
|
|
32 |
feature_description = Field(String(200))
|
| 483 |
rajveer |
33 |
mrp = Field(Float)
|
|
|
34 |
sellingPrice = Field(Float)
|
|
|
35 |
weight = Field(Float)
|
| 122 |
ashish |
36 |
addedOn = Field(DateTime)
|
| 609 |
chandransh |
37 |
updatedOn = Field(DateTime)
|
| 122 |
ashish |
38 |
startDate = Field(DateTime)
|
|
|
39 |
retireDate = Field(DateTime)
|
| 5217 |
amit.gupta |
40 |
comingSoonStartDate = Field(DateTime)
|
|
|
41 |
expectedArrivalDate = Field(DateTime)
|
| 483 |
rajveer |
42 |
status = Field(Integer)
|
| 2035 |
rajveer |
43 |
status_description = Field(String(100))
|
| 609 |
chandransh |
44 |
bestDealText = Field(String(100))
|
| 6777 |
vikram.rag |
45 |
bestDealsDetailsText = Field(String(1000))
|
|
|
46 |
bestDealsDetailsLink = Field(String(200))
|
| 630 |
chandransh |
47 |
bestDealValue = Field(Float)
|
| 621 |
chandransh |
48 |
bestSellingRank = Field(Integer)
|
| 103 |
ashish |
49 |
statusChangeLog = OneToMany("ItemChangeLog")
|
| 1910 |
varun.gupt |
50 |
defaultForEntity = Field(Boolean)
|
| 2251 |
ankur.sing |
51 |
risky = Field(Boolean)
|
| 3355 |
chandransh |
52 |
expectedDelay = Field(Integer)
|
| 4295 |
varun.gupt |
53 |
warranty_period = Field(Integer)
|
| 4406 |
anupam.sin |
54 |
isWarehousePreferenceSticky = Field(Boolean)
|
| 4506 |
phani.kuma |
55 |
preferredVendor = Field(Integer)
|
| 5135 |
mandeep.dh |
56 |
type = Field(Enum('SERIALIZED', 'NON_SERIALIZED'), default = 'NON_SERIALIZED', server_default='NON_SERIALIZED')
|
| 5385 |
phani.kuma |
57 |
hasItemNo = Field(Boolean)
|
| 7256 |
rajveer |
58 |
activeOnStore = Field(Boolean)
|
| 6241 |
amit.gupta |
59 |
showSellingPrice = Field(Boolean)
|
| 6805 |
anupam.sin |
60 |
preferredInsurer = Field(Integer)
|
| 7291 |
vikram.rag |
61 |
asin = Field(String(20))
|
|
|
62 |
holdInventory = Field(Integer, default=0, server_default="0")
|
|
|
63 |
defaultInventory = Field(Integer, default=0, server_default="0")
|
| 746 |
rajveer |
64 |
using_options(shortnames=True)
|
|
|
65 |
using_table_options(mysql_engine="InnoDB")
|
| 103 |
ashish |
66 |
|
| 94 |
ashish |
67 |
def __repr__(self):
|
| 122 |
ashish |
68 |
return "<Item>%d</item>" % (self.id)
|
| 1308 |
chandransh |
69 |
|
| 7330 |
amit.gupta |
70 |
class ItemVatMaster(Entity):
|
|
|
71 |
itemId = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
72 |
stateId = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
73 |
vatPercentage = Field(Float)
|
|
|
74 |
using_options(shortnames=True)
|
|
|
75 |
using_table_options(mysql_engine="InnoDB")
|
|
|
76 |
|
|
|
77 |
|
| 103 |
ashish |
78 |
class ItemChangeLog(Entity):
|
| 122 |
ashish |
79 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 103 |
ashish |
80 |
old_status = Field(Integer)
|
|
|
81 |
new_status = Field(Integer)
|
| 1308 |
chandransh |
82 |
timestamp = Field(DateTime)
|
| 103 |
ashish |
83 |
item = ManyToOne("Item")
|
| 746 |
rajveer |
84 |
using_options(shortnames=True)
|
|
|
85 |
using_table_options(mysql_engine="InnoDB")
|
| 94 |
ashish |
86 |
|
| 103 |
ashish |
87 |
def __repr__(self):
|
|
|
88 |
return "<Log><id>%d</id><item>%d</item><old_status>%d</old_status><new_status>%d</new_status></Log>" %(self.id,self.item.id, self.old_status, self.new_status)
|
| 94 |
ashish |
89 |
|
| 635 |
rajveer |
90 |
class Category(Entity):
|
| 1970 |
rajveer |
91 |
id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
92 |
label = Field(String(50))
|
|
|
93 |
description = Field(String(200))
|
|
|
94 |
parent_category_id = Field(Integer)
|
| 4762 |
phani.kuma |
95 |
display_name = Field(String(50))
|
| 746 |
rajveer |
96 |
using_options(shortnames=True)
|
|
|
97 |
using_table_options(mysql_engine="InnoDB")
|
| 1970 |
rajveer |
98 |
|
| 3008 |
rajveer |
99 |
class SimilarItems(Entity):
|
|
|
100 |
item = ManyToOne('Item', primary_key=True)
|
|
|
101 |
catalog_item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
102 |
using_options(shortnames=True)
|
|
|
103 |
using_table_options(mysql_engine="InnoDB")
|
|
|
104 |
|
| 3079 |
rajveer |
105 |
class ProductNotification(Entity):
|
|
|
106 |
item = ManyToOne('Item', primary_key=True)
|
|
|
107 |
email = Field(String(100), primary_key=True, autoincrement=False)
|
|
|
108 |
addedOn = Field(DateTime, primary_key=True, autoincrement=False)
|
|
|
109 |
using_options(shortnames=True)
|
|
|
110 |
using_table_options(mysql_engine="InnoDB")
|
| 3557 |
rajveer |
111 |
|
|
|
112 |
class Source(Entity):
|
|
|
113 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
114 |
name = Field(String(50))
|
|
|
115 |
identifier = Field(String(100))
|
|
|
116 |
using_options(shortnames=True)
|
|
|
117 |
using_table_options(mysql_engine="InnoDB")
|
| 6511 |
kshitij.so |
118 |
|
| 3557 |
rajveer |
119 |
class SourceItemPricing(Entity):
|
|
|
120 |
source = ManyToOne('Source', primary_key=True)
|
|
|
121 |
item = ManyToOne('Item', primary_key=True)
|
|
|
122 |
mrp = Field(Float)
|
|
|
123 |
sellingPrice = Field(Float)
|
|
|
124 |
using_options(shortnames=True)
|
|
|
125 |
using_table_options(mysql_engine="InnoDB")
|
| 746 |
rajveer |
126 |
|
| 4649 |
phani.kuma |
127 |
class AuthorizationLog(Entity):
|
|
|
128 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
129 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
|
|
130 |
item = ManyToOne('Item')
|
|
|
131 |
username = Field(String(30))
|
|
|
132 |
reason = Field(Text)
|
|
|
133 |
using_options(shortnames=True)
|
|
|
134 |
using_table_options(mysql_engine="InnoDB")
|
|
|
135 |
|
| 5504 |
phani.kuma |
136 |
class VoucherItemMapping(Entity):
|
| 5512 |
rajveer |
137 |
voucherType = Field(Integer, primary_key=True)
|
| 5504 |
phani.kuma |
138 |
item = ManyToOne('Item', primary_key=True)
|
|
|
139 |
amount = Field(Integer, default=0, server_default="0")
|
|
|
140 |
using_options(shortnames=True)
|
|
|
141 |
using_table_options(mysql_engine="InnoDB")
|
|
|
142 |
|
| 6039 |
amit.gupta |
143 |
class CategoryVatMaster(Entity):
|
| 7330 |
amit.gupta |
144 |
categoryId = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
145 |
stateId = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
146 |
minVal = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
147 |
maxVal = Field(Integer, primary_key=True, autoincrement=False)
|
| 6039 |
amit.gupta |
148 |
vatPercent = Field(Float)
|
|
|
149 |
using_options(shortnames=True)
|
|
|
150 |
using_table_options(mysql_engine="InnoDB")
|
|
|
151 |
|
| 6255 |
rajveer |
152 |
class OOSTracker(Entity):
|
|
|
153 |
itemId = Field(Integer, primary_key=True)
|
|
|
154 |
using_options(shortnames=True)
|
|
|
155 |
using_table_options(mysql_engine="InnoDB")
|
| 6532 |
amit.gupta |
156 |
|
|
|
157 |
class EntityTag(Entity):
|
|
|
158 |
tag = Field(String(100),primary_key=True)
|
|
|
159 |
entityId = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
160 |
using_options(shortnames=True)
|
|
|
161 |
using_table_options(mysql_engine="InnoDB")
|
| 6848 |
kshitij.so |
162 |
|
|
|
163 |
class Banner(Entity):
|
|
|
164 |
bannerName = Field(String(100),primary_key=True)
|
|
|
165 |
imageName = Field(String(100))
|
|
|
166 |
link = Field(String(400))
|
|
|
167 |
priority = Field(Integer)
|
|
|
168 |
hasMap = Field(Boolean)
|
| 9156 |
amit.gupta |
169 |
bannerType = Field(Integer,primary_key=True, autoincrement=False)
|
| 6848 |
kshitij.so |
170 |
using_options(shortnames=True)
|
|
|
171 |
using_table_options(mysql_engine="InnoDB")
|
|
|
172 |
|
|
|
173 |
class BannerMap(Entity):
|
|
|
174 |
bannerName = Field(String(100))
|
|
|
175 |
mapLink = Field(String(400))
|
|
|
176 |
coordinates = Field(String(20))
|
| 9155 |
kshitij.so |
177 |
bannerType = Field(Integer)
|
| 6848 |
kshitij.so |
178 |
using_options(shortnames=True)
|
|
|
179 |
using_table_options(mysql_engine="InnoDB")
|
| 8579 |
kshitij.so |
180 |
|
|
|
181 |
class BannerUriMapping(Entity):
|
|
|
182 |
bannerName = Field(String(100))
|
|
|
183 |
uri = Field(String(100))
|
|
|
184 |
isActive = Field(Boolean)
|
| 9155 |
kshitij.so |
185 |
bannerType = Field(Integer)
|
| 8579 |
kshitij.so |
186 |
using_options(shortnames=True)
|
|
|
187 |
using_table_options(mysql_engine="InnoDB")
|
|
|
188 |
|
|
|
189 |
class Campaign(Entity):
|
|
|
190 |
id = Field(Integer,primary_key=True)
|
|
|
191 |
campaignName = Field(String(255))
|
|
|
192 |
imageName = Field(String(255))
|
|
|
193 |
using_options(shortnames=True)
|
|
|
194 |
using_table_options(mysql_engine="InnoDB")
|
| 6255 |
rajveer |
195 |
|
| 6805 |
anupam.sin |
196 |
class ItemInsurerMapping(Entity):
|
|
|
197 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
198 |
itemId = Field(Integer)
|
|
|
199 |
insurerId = Field(Integer)
|
|
|
200 |
premiumType = Field(Integer)
|
|
|
201 |
premiumAmount = Field(Float)
|
| 9299 |
kshitij.so |
202 |
insurerType = Field(Integer)
|
| 6805 |
anupam.sin |
203 |
using_options(shortnames=True)
|
|
|
204 |
using_table_options(mysql_engine="InnoDB")
|
|
|
205 |
|
|
|
206 |
class Insurer(Entity):
|
|
|
207 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
208 |
name = Field(String(255))
|
|
|
209 |
address = Field(String(255))
|
| 6903 |
anupam.sin |
210 |
declaredAmount = Field(BigInteger)
|
|
|
211 |
creditedAmount = Field(BigInteger)
|
| 9299 |
kshitij.so |
212 |
insurerType = Field(Integer)
|
| 6805 |
anupam.sin |
213 |
using_options(shortnames=True)
|
|
|
214 |
using_table_options(mysql_engine="InnoDB")
|
| 7190 |
amar.kumar |
215 |
|
|
|
216 |
class FreebieItem(Entity):
|
|
|
217 |
itemId = Field(Integer, primary_key=True)
|
|
|
218 |
freebieItemId = Field(Integer)
|
|
|
219 |
using_options(shortnames=True)
|
|
|
220 |
using_table_options(mysql_engine="InnoDB")
|
| 7256 |
rajveer |
221 |
|
| 7272 |
amit.gupta |
222 |
class BrandInfo(Entity):
|
|
|
223 |
name = Field(String(255), primary_key=True)
|
|
|
224 |
serviceCenterLocatorUrl = Field(String(255))
|
|
|
225 |
using_options(shortnames=True)
|
|
|
226 |
using_table_options(mysql_engine="InnoDB")
|
|
|
227 |
|
| 7256 |
rajveer |
228 |
class StorePricing(Entity):
|
|
|
229 |
item = ManyToOne('Item', primary_key=True)
|
|
|
230 |
recommendedPrice = Field(Float)
|
|
|
231 |
minPrice = Field(Float)
|
|
|
232 |
maxPrice = Field(Float)
|
|
|
233 |
minAdvancePrice = Field(Float)
|
| 7308 |
rajveer |
234 |
freebieItemId = Field(Integer)
|
| 7351 |
rajveer |
235 |
absoluteMinPrice = Field(Float)
|
| 7308 |
rajveer |
236 |
bestDealText = Field(String(100))
|
| 7256 |
rajveer |
237 |
using_options(shortnames=True)
|
| 7291 |
vikram.rag |
238 |
using_table_options(mysql_engine="InnoDB")
|
|
|
239 |
|
| 7281 |
kshitij.so |
240 |
class Amazonlisted(Entity):
|
| 7396 |
kshitij.so |
241 |
itemId = Field(Integer, primary_key=True, autoincrement=False)
|
| 7281 |
kshitij.so |
242 |
asin = Field(String(255))
|
|
|
243 |
name = Field(String(255))
|
|
|
244 |
brand = Field(String(255))
|
|
|
245 |
model = Field(String(255))
|
|
|
246 |
manufacturer_name = Field(String(255))
|
|
|
247 |
part_number = Field(String(255))
|
|
|
248 |
ean = Field(String(255))
|
|
|
249 |
upc = Field(String(255))
|
|
|
250 |
fbaPrice = Field(Float)
|
|
|
251 |
sellingPrice = Field(Float)
|
|
|
252 |
isFba = Field(Boolean)
|
|
|
253 |
isNonFba = Field(Boolean)
|
|
|
254 |
isInventoryOverride = Field(Boolean)
|
|
|
255 |
color = Field(String(255))
|
|
|
256 |
category = Field(String(255))
|
| 7367 |
kshitij.so |
257 |
handlingTime = Field(Integer)
|
|
|
258 |
isCustomTime = Field(Boolean)
|
| 7516 |
vikram.rag |
259 |
category_code = Field(Integer, default=0, server_default="0")
|
| 7770 |
kshitij.so |
260 |
mfnPriceLastUpdatedOn = Field(DateTime)
|
|
|
261 |
fbaPriceLastUpdatedOn = Field(DateTime)
|
|
|
262 |
mfnPriceLastUpdatedOnSc = Field(DateTime)
|
|
|
263 |
fbaPriceLastUpdatedOnSc = Field(DateTime)
|
| 8139 |
kshitij.so |
264 |
suppressMfnPriceUpdate = Field(Boolean)
|
| 8140 |
kshitij.so |
265 |
suppressFbaPriceUpdate = Field(Boolean)
|
| 8619 |
kshitij.so |
266 |
taxCode = Field(String(255))
|
| 7281 |
kshitij.so |
267 |
using_options(shortnames=True)
|
|
|
268 |
using_table_options(mysql_engine="InnoDB")
|
|
|
269 |
|
| 7977 |
kshitij.so |
270 |
class PageViewEvents(Entity):
|
|
|
271 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 8139 |
kshitij.so |
272 |
catalogId = Field(Integer,index=True)
|
|
|
273 |
url = Field(String(255),index=True)
|
| 7977 |
kshitij.so |
274 |
sellingPrice = Field(Float)
|
|
|
275 |
comingSoon = Field(Boolean)
|
|
|
276 |
ip = Field(String(255))
|
|
|
277 |
sessionId = Field(String(255))
|
| 8139 |
kshitij.so |
278 |
eventTimestamp = Field(DateTime,index=True)
|
| 7977 |
kshitij.so |
279 |
using_options(shortnames=True)
|
|
|
280 |
using_table_options(mysql_engine="InnoDB")
|
|
|
281 |
|
|
|
282 |
class CartEvents(Entity):
|
|
|
283 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 8139 |
kshitij.so |
284 |
catalogId = Field(Integer,index=True)
|
|
|
285 |
itemId = Field(Integer,index=True)
|
| 7977 |
kshitij.so |
286 |
sellingPrice = Field(Float)
|
|
|
287 |
inStock = Field(Boolean)
|
|
|
288 |
comingSoon = Field(Boolean)
|
|
|
289 |
ip = Field(String(255))
|
|
|
290 |
sessionId = Field(String(255))
|
| 8139 |
kshitij.so |
291 |
eventTimestamp = Field(DateTime,index=True)
|
| 7977 |
kshitij.so |
292 |
using_options(shortnames=True)
|
|
|
293 |
using_table_options(mysql_engine="InnoDB")
|
|
|
294 |
|
| 8182 |
amar.kumar |
295 |
class EbayItem(Entity):
|
|
|
296 |
ebayListingId = Field(String(32), primary_key=True)
|
|
|
297 |
itemId = Field(Integer, primary_key=True, autoincrement = False)
|
|
|
298 |
listingName = Field(String(255))
|
|
|
299 |
listingPrice = Field(Float)
|
|
|
300 |
listingExpiryDate = Field(DateTime)
|
|
|
301 |
subsidy = Field(Float)
|
|
|
302 |
defaultWarehouseId = Field(Integer)
|
|
|
303 |
using_options(shortnames=True)
|
|
|
304 |
using_table_options(mysql_engine="InnoDB")
|
| 8739 |
vikram.rag |
305 |
|
|
|
306 |
class SnapdealItem(Entity):
|
|
|
307 |
item_id = Field(Integer, primary_key=True, autoincrement = False)
|
|
|
308 |
exceptionPrice = Field(Float)
|
|
|
309 |
warehouseId = Field(Integer)
|
| 9242 |
kshitij.so |
310 |
transferPrice = Field(Float)
|
|
|
311 |
sellingPrice = Field(Float)
|
|
|
312 |
courierCost = Field(Float)
|
|
|
313 |
commission = Field(Float)
|
|
|
314 |
serviceTax = Field(Float)
|
|
|
315 |
updatedOn = Field(DateTime)
|
| 9404 |
vikram.rag |
316 |
maxNlc = Field(Float)
|
| 9478 |
kshitij.so |
317 |
skuAtSnapdeal = Field(String(255))
|
| 9242 |
kshitij.so |
318 |
isListedOnSnapdeal = Field(Boolean)
|
|
|
319 |
suppressPriceFeed = Field(Boolean)
|
|
|
320 |
suppressInventoryFeed = Field(Boolean)
|
| 8739 |
vikram.rag |
321 |
using_options(shortnames=True)
|
|
|
322 |
using_table_options(mysql_engine="InnoDB")
|
| 9242 |
kshitij.so |
323 |
|
|
|
324 |
class SnapdealItemUpdateHistory(Entity):
|
|
|
325 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
326 |
item_id = Field(Integer)
|
|
|
327 |
isListedOnSnapdeal = Field(Boolean)
|
|
|
328 |
exceptionPrice = Field(Float)
|
|
|
329 |
warehouseId = Field(Integer)
|
|
|
330 |
transferPrice = Field(Float)
|
|
|
331 |
sellingPrice = Field(Float)
|
|
|
332 |
courierCost = Field(Float)
|
|
|
333 |
commission = Field(Float)
|
|
|
334 |
serviceTax = Field(Float)
|
|
|
335 |
suppressPriceFeed = Field(Boolean)
|
|
|
336 |
suppressInventoryFeed = Field(Boolean)
|
| 9478 |
kshitij.so |
337 |
maxNlc = Field(Float)
|
|
|
338 |
skuAtSnapdeal = Field(String(255))
|
| 9242 |
kshitij.so |
339 |
updatedOn = Field(DateTime)
|
|
|
340 |
using_options(shortnames=True)
|
|
|
341 |
using_table_options(mysql_engine="InnoDB")
|
| 7977 |
kshitij.so |
342 |
|
| 9242 |
kshitij.so |
343 |
|
| 3187 |
rajveer |
344 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
| 746 |
rajveer |
345 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
| 1122 |
chandransh |
346 |
#metadata.bind = 'mysql://root:shop2020@localhost/catalog'
|
| 6532 |
amit.gupta |
347 |
cengine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
|
|
348 |
metadata.bind = cengine
|
| 94 |
ashish |
349 |
metadata.bind.echo = True
|
|
|
350 |
setup_all(True)
|
| 115 |
ashish |
351 |
|
|
|
352 |
if __name__=="__main__":
|
| 9242 |
kshitij.so |
353 |
initialize()
|