| 5944 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 22-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
from elixir import metadata, setup_all
|
|
|
7 |
from elixir.entity import Entity
|
|
|
8 |
from elixir.fields import Field
|
|
|
9 |
from elixir.options import using_options, using_table_options
|
|
|
10 |
from elixir.relationships import OneToMany, ManyToOne
|
|
|
11 |
from sqlalchemy import create_engine
|
| 12357 |
manish.sha |
12 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Enum, Date, Text
|
| 5944 |
mandeep.dh |
13 |
import datetime
|
| 12363 |
kshitij.so |
14 |
|
| 5944 |
mandeep.dh |
15 |
class Vendor(Entity):
|
|
|
16 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
17 |
name = Field(String(50))
|
|
|
18 |
warehouses = OneToMany('Warehouse')
|
|
|
19 |
using_options(shortnames=True)
|
|
|
20 |
using_table_options(mysql_engine="InnoDB")
|
| 6498 |
vikram.rag |
21 |
|
| 6531 |
vikram.rag |
22 |
class IgnoredInventoryUpdateItems(Entity):
|
| 6498 |
vikram.rag |
23 |
warehouse_id = Field(Integer,primary_key=True,autoincrement=False)
|
|
|
24 |
item_id = Field(Integer,primary_key=True,autoincrement=False)
|
|
|
25 |
using_options(shortnames=True)
|
|
|
26 |
using_table_options(mysql_engine="InnoDB")
|
| 5944 |
mandeep.dh |
27 |
|
| 7330 |
amit.gupta |
28 |
class StateMaster(Entity):
|
|
|
29 |
id = Field(Integer, primary_key=True, autoincrement=False)
|
| 21841 |
amit.gupta |
30 |
name= Field(String(100), unique=True, index=True)
|
|
|
31 |
stateCode = Field(String(4), unique=True)
|
|
|
32 |
shortName = Field(String(4), unique=True, index=True)
|
| 7330 |
amit.gupta |
33 |
using_options(shortnames=True)
|
|
|
34 |
using_table_options(mysql_engine="InnoDB")
|
|
|
35 |
|
| 5944 |
mandeep.dh |
36 |
class Warehouse(Entity):
|
|
|
37 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
38 |
displayName = Field(String(50))
|
|
|
39 |
location = Field(String(200))
|
|
|
40 |
status = Field(Integer)
|
|
|
41 |
addedOn = Field(DateTime)
|
|
|
42 |
lastCheckedOn = Field(DateTime)
|
|
|
43 |
tinNumber = Field(String(50))
|
|
|
44 |
pincode = Field(String(10))
|
|
|
45 |
vendorString = Field(String(50))
|
|
|
46 |
badInventory = OneToMany('BadInventorySnapshot')
|
|
|
47 |
inventory = OneToMany('CurrentInventorySnapshot')
|
|
|
48 |
inventoryHistory = OneToMany('ItemInventoryHistory')
|
| 7330 |
amit.gupta |
49 |
state = ManyToOne('StateMaster')
|
| 5944 |
mandeep.dh |
50 |
logisticsLocation = Field(Integer)
|
|
|
51 |
vendor = ManyToOne('Vendor')
|
|
|
52 |
billingType = Field(Integer)
|
|
|
53 |
inventoryType = Field(Enum('GOOD', 'BAD', 'VIRTUAL'))
|
|
|
54 |
warehouseType = Field(Enum('OURS', 'THIRD_PARTY'))
|
|
|
55 |
shippingWarehouseId = Field(Integer)
|
|
|
56 |
billingWarehouseId = Field(Integer)
|
|
|
57 |
transferDelayInHours = Field(Integer)
|
|
|
58 |
isAvailabilityMonitored = Field(Boolean)
|
| 12357 |
manish.sha |
59 |
source = Field(Integer)
|
| 5944 |
mandeep.dh |
60 |
using_options(shortnames=True)
|
|
|
61 |
using_table_options(mysql_engine="InnoDB")
|
|
|
62 |
|
|
|
63 |
def __repr__(self):
|
|
|
64 |
return "<warehouse>%s</warehouse>" %(self.location)
|
|
|
65 |
|
|
|
66 |
class VendorItemMapping(Entity):
|
|
|
67 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
68 |
item_key = Field(String(200), primary_key=True)
|
|
|
69 |
item_id = Field(Integer)
|
|
|
70 |
using_options(shortnames=True)
|
|
|
71 |
using_table_options(mysql_engine="InnoDB")
|
|
|
72 |
|
|
|
73 |
class VendorItemPricing(Entity):
|
|
|
74 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
75 |
item_id = Field(Integer, primary_key=True)
|
|
|
76 |
mop = Field(Float)
|
|
|
77 |
dealerPrice = Field(Float)
|
|
|
78 |
transfer_price = Field(Float)
|
| 6751 |
amar.kumar |
79 |
nlc = Field(Float)
|
| 5944 |
mandeep.dh |
80 |
using_options(shortnames=True)
|
|
|
81 |
using_table_options(mysql_engine="InnoDB")
|
|
|
82 |
|
|
|
83 |
class VendorHolidays(Entity):
|
|
|
84 |
vendor = ManyToOne('Vendor', primary_key=True)
|
| 8491 |
rajveer |
85 |
date = Field(Date, primary_key=True)
|
| 5944 |
mandeep.dh |
86 |
occasion = Field(String(100))
|
|
|
87 |
using_options(shortnames=True)
|
|
|
88 |
using_table_options(mysql_engine="InnoDB")
|
|
|
89 |
|
|
|
90 |
class CurrentInventorySnapshot(Entity):
|
|
|
91 |
item_id = Field(Integer, primary_key=True)
|
|
|
92 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
93 |
availability = Field(Integer)
|
|
|
94 |
reserved = Field(Integer)
|
| 8205 |
amar.kumar |
95 |
held = Field(Integer, default=0, server_default="0")
|
| 5944 |
mandeep.dh |
96 |
using_options(shortnames=True)
|
|
|
97 |
using_table_options(mysql_engine="InnoDB")
|
| 5966 |
rajveer |
98 |
|
| 8182 |
amar.kumar |
99 |
class HoldInventoryDetail(Entity):
|
|
|
100 |
item_id = Field(Integer, primary_key=True)
|
|
|
101 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
102 |
held = Field(Integer)
|
| 8718 |
amar.kumar |
103 |
source = Field(Integer, primary_key=True)
|
| 8182 |
amar.kumar |
104 |
using_options(shortnames=True)
|
|
|
105 |
using_table_options(mysql_engine="InnoDB")
|
|
|
106 |
|
| 5966 |
rajveer |
107 |
class CurrentReservationSnapshot(Entity):
|
|
|
108 |
item_id = Field(Integer, primary_key=True)
|
|
|
109 |
warehouse_id = Field(Integer, primary_key=True)
|
|
|
110 |
source_id = Field(Integer, primary_key=True)
|
|
|
111 |
order_id = Field(Integer, primary_key=True)
|
|
|
112 |
created_timestamp = Field(DateTime)
|
|
|
113 |
promised_shipping_timestamp = Field(DateTime)
|
|
|
114 |
reserved = Field(Integer)
|
|
|
115 |
using_options(shortnames=True)
|
|
|
116 |
using_table_options(mysql_engine="InnoDB")
|
|
|
117 |
|
| 5944 |
mandeep.dh |
118 |
class BadInventorySnapshot(Entity):
|
|
|
119 |
item_id = Field(Integer, primary_key=True)
|
|
|
120 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
121 |
availability = Field(Integer)
|
|
|
122 |
using_options(shortnames=True)
|
|
|
123 |
using_table_options(mysql_engine="InnoDB")
|
|
|
124 |
|
|
|
125 |
class SupplierInventorySnapshot(Entity):
|
|
|
126 |
item_id = Field(Integer, primary_key=True)
|
|
|
127 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
128 |
availability = Field(Integer)
|
|
|
129 |
using_options(shortnames=True)
|
|
|
130 |
using_table_options(mysql_engine="InnoDB")
|
|
|
131 |
|
|
|
132 |
class ItemInventoryHistory(Entity):
|
|
|
133 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
134 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
|
|
135 |
availability = Field(Integer)
|
|
|
136 |
item_id = Field(Integer)
|
|
|
137 |
warehouse = ManyToOne("Warehouse")
|
|
|
138 |
using_options(shortnames=True)
|
|
|
139 |
using_table_options(mysql_engine="InnoDB")
|
|
|
140 |
|
|
|
141 |
def __repr__(self):
|
|
|
142 |
pass
|
|
|
143 |
|
|
|
144 |
class MissedInventoryUpdate(Entity):
|
|
|
145 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
146 |
itemKey = Field(String(200))
|
|
|
147 |
quantity = Field(Integer)
|
|
|
148 |
warehouseId = Field(Integer)
|
|
|
149 |
isIgnored = Field(Boolean)
|
|
|
150 |
timestamp = Field(DateTime)
|
|
|
151 |
using_options(shortnames=True)
|
|
|
152 |
using_table_options(mysql_engine="InnoDB")
|
|
|
153 |
|
|
|
154 |
class ItemAvailabilityCache(Entity):
|
|
|
155 |
itemId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5978 |
rajveer |
156 |
sourceId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5944 |
mandeep.dh |
157 |
warehouseId = Field(Integer)
|
|
|
158 |
expectedDelay = Field(Integer)
|
|
|
159 |
billingWarehouseId = Field(Integer)
|
|
|
160 |
sellingPrice = Field(Float)
|
|
|
161 |
totalAvailability = Field(Integer)
|
| 7589 |
rajveer |
162 |
weight = Field(Integer, default=300, server_default="300")
|
| 5944 |
mandeep.dh |
163 |
using_options(shortnames=True)
|
|
|
164 |
using_table_options(mysql_engine="InnoDB")
|
| 19413 |
amit.gupta |
165 |
|
|
|
166 |
class ItemLocationAvailabilityCache(Entity):
|
|
|
167 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
168 |
location_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
169 |
physical_availability = Field(Integer)
|
|
|
170 |
virtual_availability = Field(Integer)
|
|
|
171 |
min_transfer_delay = Field(Integer)
|
|
|
172 |
max_transfer_delay = Field(Integer)
|
|
|
173 |
using_options(shortnames=True)
|
|
|
174 |
using_table_options(mysql_engine="InnoDB")
|
| 5944 |
mandeep.dh |
175 |
|
| 6821 |
amar.kumar |
176 |
class ItemStockPurchaseParams(Entity):
|
|
|
177 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
178 |
numOfDaysStock = Field(Integer)
|
|
|
179 |
minStockLevel = Field(Integer)
|
|
|
180 |
using_options(shortnames=True)
|
|
|
181 |
using_table_options(mysql_engine="InnoDB")
|
|
|
182 |
|
|
|
183 |
class OOSStatus(Entity):
|
|
|
184 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 9665 |
rajveer |
185 |
sourceId = Field(Integer, primary_key=True, autoincrement=False)
|
| 6821 |
amar.kumar |
186 |
date = Field(DateTime, primary_key=True, autoincrement=False)
|
|
|
187 |
is_oos = Field(Boolean)
|
|
|
188 |
num_orders = Field(Integer)
|
| 8182 |
amar.kumar |
189 |
rto_orders = Field(Integer)
|
| 6821 |
amar.kumar |
190 |
using_options(shortnames=True)
|
|
|
191 |
using_table_options(mysql_engine="InnoDB")
|
|
|
192 |
|
| 7281 |
kshitij.so |
193 |
class AmazonInventorySnapshot(Entity):
|
| 10452 |
vikram.rag |
194 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
| 7281 |
kshitij.so |
195 |
availability = Field(Integer)
|
|
|
196 |
reserved = Field(Integer)
|
| 10450 |
vikram.rag |
197 |
is_oos = Field(Boolean)
|
|
|
198 |
lastUpdatedOnAmazon = Field(DateTime)
|
| 7281 |
kshitij.so |
199 |
using_options(shortnames=True)
|
|
|
200 |
using_table_options(mysql_engine="InnoDB")
|
| 8282 |
kshitij.so |
201 |
|
|
|
202 |
class AmazonFbaInventorySnapshot(Entity):
|
| 8374 |
vikram.rag |
203 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
| 8282 |
kshitij.so |
204 |
availability = Field(Integer)
|
| 11173 |
vikram.rag |
205 |
inbound = Field(Integer)
|
|
|
206 |
reserved = Field(Integer)
|
|
|
207 |
unfulfillable = Field(Integer)
|
|
|
208 |
location = Field(Integer,primary_key=True,autoincrement=False)
|
| 8282 |
kshitij.so |
209 |
using_options(shortnames=True)
|
|
|
210 |
using_table_options(mysql_engine="InnoDB")
|
| 7281 |
kshitij.so |
211 |
|
| 9404 |
vikram.rag |
212 |
class SnapdealInventorySnapshot(Entity):
|
|
|
213 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
|
|
214 |
availability = Field(Integer)
|
|
|
215 |
lastUpdatedOnSnapdeal = Field(DateTime)
|
| 9495 |
vikram.rag |
216 |
pendingOrders = Field(Integer)
|
| 10450 |
vikram.rag |
217 |
is_oos = Field(Boolean)
|
| 9404 |
vikram.rag |
218 |
using_options(shortnames=True)
|
|
|
219 |
using_table_options(mysql_engine="InnoDB")
|
| 10450 |
vikram.rag |
220 |
|
| 10050 |
vikram.rag |
221 |
class FlipkartInventorySnapshot(Entity):
|
|
|
222 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
|
|
223 |
availability = Field(Integer)
|
|
|
224 |
createdOrders = Field(Integer)
|
|
|
225 |
heldOrders = Field(Integer)
|
| 10450 |
vikram.rag |
226 |
is_oos = Field(Boolean)
|
|
|
227 |
lastUpdatedOnFlipkart = Field(DateTime)
|
| 10050 |
vikram.rag |
228 |
using_options(shortnames=True)
|
|
|
229 |
using_table_options(mysql_engine="InnoDB")
|
|
|
230 |
|
| 10544 |
vikram.rag |
231 |
class SnapdealStockAtEOD(Entity):
|
|
|
232 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
| 10567 |
vikram.rag |
233 |
availability = Field(Integer)
|
|
|
234 |
date = Field(DateTime, primary_key=True,autoincrement=False)
|
| 10544 |
vikram.rag |
235 |
using_options(shortnames=True)
|
|
|
236 |
using_table_options(mysql_engine="InnoDB")
|
|
|
237 |
|
|
|
238 |
class FlipkartStockAtEOD(Entity):
|
|
|
239 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
| 10567 |
vikram.rag |
240 |
availability = Field(Integer)
|
|
|
241 |
date = Field(DateTime, primary_key=True,autoincrement=False)
|
| 10544 |
vikram.rag |
242 |
using_options(shortnames=True)
|
|
|
243 |
using_table_options(mysql_engine="InnoDB")
|
|
|
244 |
|
| 12357 |
manish.sha |
245 |
class StockWeightedNlcInfo(Entity):
|
|
|
246 |
itemId = Field(Integer, primary_key=True,autoincrement=False)
|
|
|
247 |
source = Field(Integer, primary_key=True,autoincrement=False)
|
|
|
248 |
updatedTimestamp = Field(DateTime, primary_key=True,autoincrement=False)
|
|
|
249 |
grnDetail = Field(Text)
|
|
|
250 |
stockQuantity = Field(Integer)
|
|
|
251 |
avgWeightedNlc = Field(Float)
|
|
|
252 |
using_options(shortnames=True)
|
|
|
253 |
using_table_options(mysql_engine="InnoDB")
|
| 17769 |
kshitij.so |
254 |
def initialize(dbname='inventory', db_hostname="localhost", setup=True):
|
| 5944 |
mandeep.dh |
255 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
|
|
256 |
#metadata.bind = 'mysql://root:shop2020@localhost/inventory'
|
| 6532 |
amit.gupta |
257 |
iengine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
|
|
258 |
metadata.bind = iengine
|
| 5944 |
mandeep.dh |
259 |
metadata.bind.echo = True
|
| 17769 |
kshitij.so |
260 |
setup_all(setup)
|
| 5944 |
mandeep.dh |
261 |
|
|
|
262 |
if __name__=="__main__":
|
|
|
263 |
initialize()
|