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