| 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
|
| 8491 |
rajveer |
12 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Enum, Date
|
| 5944 |
mandeep.dh |
13 |
import datetime
|
|
|
14 |
|
|
|
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)
|
|
|
30 |
name= Field(String(100))
|
|
|
31 |
using_options(shortnames=True)
|
|
|
32 |
using_table_options(mysql_engine="InnoDB")
|
|
|
33 |
|
| 5944 |
mandeep.dh |
34 |
class Warehouse(Entity):
|
|
|
35 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
36 |
displayName = Field(String(50))
|
|
|
37 |
location = Field(String(200))
|
|
|
38 |
status = Field(Integer)
|
|
|
39 |
addedOn = Field(DateTime)
|
|
|
40 |
lastCheckedOn = Field(DateTime)
|
|
|
41 |
tinNumber = Field(String(50))
|
|
|
42 |
pincode = Field(String(10))
|
|
|
43 |
vendorString = Field(String(50))
|
|
|
44 |
badInventory = OneToMany('BadInventorySnapshot')
|
|
|
45 |
inventory = OneToMany('CurrentInventorySnapshot')
|
|
|
46 |
inventoryHistory = OneToMany('ItemInventoryHistory')
|
| 7330 |
amit.gupta |
47 |
state = ManyToOne('StateMaster')
|
| 5944 |
mandeep.dh |
48 |
logisticsLocation = Field(Integer)
|
|
|
49 |
vendor = ManyToOne('Vendor')
|
|
|
50 |
billingType = Field(Integer)
|
|
|
51 |
inventoryType = Field(Enum('GOOD', 'BAD', 'VIRTUAL'))
|
|
|
52 |
warehouseType = Field(Enum('OURS', 'THIRD_PARTY'))
|
|
|
53 |
shippingWarehouseId = Field(Integer)
|
|
|
54 |
billingWarehouseId = Field(Integer)
|
|
|
55 |
transferDelayInHours = Field(Integer)
|
|
|
56 |
isAvailabilityMonitored = Field(Boolean)
|
|
|
57 |
using_options(shortnames=True)
|
|
|
58 |
using_table_options(mysql_engine="InnoDB")
|
|
|
59 |
|
|
|
60 |
def __repr__(self):
|
|
|
61 |
return "<warehouse>%s</warehouse>" %(self.location)
|
|
|
62 |
|
|
|
63 |
class VendorItemMapping(Entity):
|
|
|
64 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
65 |
item_key = Field(String(200), primary_key=True)
|
|
|
66 |
item_id = Field(Integer)
|
|
|
67 |
using_options(shortnames=True)
|
|
|
68 |
using_table_options(mysql_engine="InnoDB")
|
|
|
69 |
|
|
|
70 |
class VendorItemPricing(Entity):
|
|
|
71 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
72 |
item_id = Field(Integer, primary_key=True)
|
|
|
73 |
mop = Field(Float)
|
|
|
74 |
dealerPrice = Field(Float)
|
|
|
75 |
transfer_price = Field(Float)
|
| 6751 |
amar.kumar |
76 |
nlc = Field(Float)
|
| 5944 |
mandeep.dh |
77 |
using_options(shortnames=True)
|
|
|
78 |
using_table_options(mysql_engine="InnoDB")
|
|
|
79 |
|
|
|
80 |
class VendorHolidays(Entity):
|
|
|
81 |
vendor = ManyToOne('Vendor', primary_key=True)
|
| 8491 |
rajveer |
82 |
date = Field(Date, primary_key=True)
|
| 5944 |
mandeep.dh |
83 |
occasion = Field(String(100))
|
|
|
84 |
using_options(shortnames=True)
|
|
|
85 |
using_table_options(mysql_engine="InnoDB")
|
|
|
86 |
|
|
|
87 |
class CurrentInventorySnapshot(Entity):
|
|
|
88 |
item_id = Field(Integer, primary_key=True)
|
|
|
89 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
90 |
availability = Field(Integer)
|
|
|
91 |
reserved = Field(Integer)
|
| 8205 |
amar.kumar |
92 |
held = Field(Integer, default=0, server_default="0")
|
| 5944 |
mandeep.dh |
93 |
using_options(shortnames=True)
|
|
|
94 |
using_table_options(mysql_engine="InnoDB")
|
| 5966 |
rajveer |
95 |
|
| 8182 |
amar.kumar |
96 |
class HoldInventoryDetail(Entity):
|
|
|
97 |
item_id = Field(Integer, primary_key=True)
|
|
|
98 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
99 |
held = Field(Integer)
|
| 8718 |
amar.kumar |
100 |
source = Field(Integer, primary_key=True)
|
| 8182 |
amar.kumar |
101 |
using_options(shortnames=True)
|
|
|
102 |
using_table_options(mysql_engine="InnoDB")
|
|
|
103 |
|
| 5966 |
rajveer |
104 |
class CurrentReservationSnapshot(Entity):
|
|
|
105 |
item_id = Field(Integer, primary_key=True)
|
|
|
106 |
warehouse_id = Field(Integer, primary_key=True)
|
|
|
107 |
source_id = Field(Integer, primary_key=True)
|
|
|
108 |
order_id = Field(Integer, primary_key=True)
|
|
|
109 |
created_timestamp = Field(DateTime)
|
|
|
110 |
promised_shipping_timestamp = Field(DateTime)
|
|
|
111 |
reserved = Field(Integer)
|
|
|
112 |
using_options(shortnames=True)
|
|
|
113 |
using_table_options(mysql_engine="InnoDB")
|
|
|
114 |
|
| 5944 |
mandeep.dh |
115 |
class BadInventorySnapshot(Entity):
|
|
|
116 |
item_id = Field(Integer, primary_key=True)
|
|
|
117 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
118 |
availability = Field(Integer)
|
|
|
119 |
using_options(shortnames=True)
|
|
|
120 |
using_table_options(mysql_engine="InnoDB")
|
|
|
121 |
|
|
|
122 |
class SupplierInventorySnapshot(Entity):
|
|
|
123 |
item_id = Field(Integer, primary_key=True)
|
|
|
124 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
125 |
availability = Field(Integer)
|
|
|
126 |
using_options(shortnames=True)
|
|
|
127 |
using_table_options(mysql_engine="InnoDB")
|
|
|
128 |
|
|
|
129 |
class ItemInventoryHistory(Entity):
|
|
|
130 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
131 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
|
|
132 |
availability = Field(Integer)
|
|
|
133 |
item_id = Field(Integer)
|
|
|
134 |
warehouse = ManyToOne("Warehouse")
|
|
|
135 |
using_options(shortnames=True)
|
|
|
136 |
using_table_options(mysql_engine="InnoDB")
|
|
|
137 |
|
|
|
138 |
def __repr__(self):
|
|
|
139 |
pass
|
|
|
140 |
|
|
|
141 |
class MissedInventoryUpdate(Entity):
|
|
|
142 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
143 |
itemKey = Field(String(200))
|
|
|
144 |
quantity = Field(Integer)
|
|
|
145 |
warehouseId = Field(Integer)
|
|
|
146 |
isIgnored = Field(Boolean)
|
|
|
147 |
timestamp = Field(DateTime)
|
|
|
148 |
using_options(shortnames=True)
|
|
|
149 |
using_table_options(mysql_engine="InnoDB")
|
|
|
150 |
|
|
|
151 |
class ItemAvailabilityCache(Entity):
|
|
|
152 |
itemId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5978 |
rajveer |
153 |
sourceId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5944 |
mandeep.dh |
154 |
warehouseId = Field(Integer)
|
|
|
155 |
expectedDelay = Field(Integer)
|
|
|
156 |
billingWarehouseId = Field(Integer)
|
|
|
157 |
sellingPrice = Field(Float)
|
|
|
158 |
totalAvailability = Field(Integer)
|
| 7589 |
rajveer |
159 |
weight = Field(Integer, default=300, server_default="300")
|
| 5944 |
mandeep.dh |
160 |
using_options(shortnames=True)
|
|
|
161 |
using_table_options(mysql_engine="InnoDB")
|
|
|
162 |
|
| 6821 |
amar.kumar |
163 |
class ItemStockPurchaseParams(Entity):
|
|
|
164 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
165 |
numOfDaysStock = Field(Integer)
|
|
|
166 |
minStockLevel = Field(Integer)
|
|
|
167 |
using_options(shortnames=True)
|
|
|
168 |
using_table_options(mysql_engine="InnoDB")
|
|
|
169 |
|
|
|
170 |
class OOSStatus(Entity):
|
|
|
171 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
172 |
date = Field(DateTime, primary_key=True, autoincrement=False)
|
|
|
173 |
is_oos = Field(Boolean)
|
|
|
174 |
num_orders = Field(Integer)
|
| 8182 |
amar.kumar |
175 |
rto_orders = Field(Integer)
|
| 6821 |
amar.kumar |
176 |
using_options(shortnames=True)
|
|
|
177 |
using_table_options(mysql_engine="InnoDB")
|
|
|
178 |
|
| 7281 |
kshitij.so |
179 |
class AmazonInventorySnapshot(Entity):
|
|
|
180 |
item_id = Field(Integer, primary_key=True)
|
|
|
181 |
availability = Field(Integer)
|
|
|
182 |
reserved = Field(Integer)
|
|
|
183 |
using_options(shortnames=True)
|
|
|
184 |
using_table_options(mysql_engine="InnoDB")
|
| 8282 |
kshitij.so |
185 |
|
|
|
186 |
class AmazonFbaInventorySnapshot(Entity):
|
| 8374 |
vikram.rag |
187 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
| 8282 |
kshitij.so |
188 |
availability = Field(Integer)
|
|
|
189 |
using_options(shortnames=True)
|
|
|
190 |
using_table_options(mysql_engine="InnoDB")
|
| 7281 |
kshitij.so |
191 |
|
| 9404 |
vikram.rag |
192 |
class SnapdealInventorySnapshot(Entity):
|
|
|
193 |
item_id = Field(Integer, primary_key=True,autoincrement=False)
|
|
|
194 |
availability = Field(Integer)
|
|
|
195 |
lastUpdatedOnSnapdeal = Field(DateTime)
|
|
|
196 |
using_options(shortnames=True)
|
|
|
197 |
using_table_options(mysql_engine="InnoDB")
|
| 8282 |
kshitij.so |
198 |
|
| 5944 |
mandeep.dh |
199 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
|
|
200 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
|
|
201 |
#metadata.bind = 'mysql://root:shop2020@localhost/inventory'
|
| 6532 |
amit.gupta |
202 |
iengine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
|
|
203 |
metadata.bind = iengine
|
| 5944 |
mandeep.dh |
204 |
metadata.bind.echo = True
|
|
|
205 |
setup_all(True)
|
|
|
206 |
|
|
|
207 |
if __name__=="__main__":
|
|
|
208 |
initialize()
|