| 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
|
|
|
12 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Enum
|
|
|
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 |
|
|
|
28 |
class Warehouse(Entity):
|
|
|
29 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
30 |
displayName = Field(String(50))
|
|
|
31 |
location = Field(String(200))
|
|
|
32 |
status = Field(Integer)
|
|
|
33 |
addedOn = Field(DateTime)
|
|
|
34 |
lastCheckedOn = Field(DateTime)
|
|
|
35 |
tinNumber = Field(String(50))
|
|
|
36 |
pincode = Field(String(10))
|
|
|
37 |
vendorString = Field(String(50))
|
|
|
38 |
badInventory = OneToMany('BadInventorySnapshot')
|
|
|
39 |
inventory = OneToMany('CurrentInventorySnapshot')
|
|
|
40 |
inventoryHistory = OneToMany('ItemInventoryHistory')
|
|
|
41 |
logisticsLocation = Field(Integer)
|
|
|
42 |
vendor = ManyToOne('Vendor')
|
|
|
43 |
billingType = Field(Integer)
|
|
|
44 |
inventoryType = Field(Enum('GOOD', 'BAD', 'VIRTUAL'))
|
|
|
45 |
warehouseType = Field(Enum('OURS', 'THIRD_PARTY'))
|
|
|
46 |
shippingWarehouseId = Field(Integer)
|
|
|
47 |
billingWarehouseId = Field(Integer)
|
|
|
48 |
transferDelayInHours = Field(Integer)
|
|
|
49 |
isAvailabilityMonitored = Field(Boolean)
|
|
|
50 |
using_options(shortnames=True)
|
|
|
51 |
using_table_options(mysql_engine="InnoDB")
|
|
|
52 |
|
|
|
53 |
def __repr__(self):
|
|
|
54 |
return "<warehouse>%s</warehouse>" %(self.location)
|
|
|
55 |
|
|
|
56 |
class VendorItemMapping(Entity):
|
|
|
57 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
58 |
item_key = Field(String(200), primary_key=True)
|
|
|
59 |
item_id = Field(Integer)
|
|
|
60 |
using_options(shortnames=True)
|
|
|
61 |
using_table_options(mysql_engine="InnoDB")
|
|
|
62 |
|
|
|
63 |
class VendorItemPricing(Entity):
|
|
|
64 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
65 |
item_id = Field(Integer, primary_key=True)
|
|
|
66 |
mop = Field(Float)
|
|
|
67 |
dealerPrice = Field(Float)
|
|
|
68 |
transfer_price = Field(Float)
|
| 6751 |
amar.kumar |
69 |
nlc = Field(Float)
|
| 5944 |
mandeep.dh |
70 |
using_options(shortnames=True)
|
|
|
71 |
using_table_options(mysql_engine="InnoDB")
|
|
|
72 |
|
|
|
73 |
class VendorItemProcurementDelay(Entity):
|
|
|
74 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
75 |
item_id = Field(Integer, primary_key=True)
|
|
|
76 |
procurementDelay = Field(Integer)
|
|
|
77 |
using_options(shortnames=True)
|
|
|
78 |
using_table_options(mysql_engine="InnoDB")
|
|
|
79 |
|
|
|
80 |
class VendorHolidays(Entity):
|
|
|
81 |
vendor = ManyToOne('Vendor', primary_key=True)
|
|
|
82 |
holidayType = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
83 |
holidayValue = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
84 |
occasion = Field(String(100))
|
|
|
85 |
using_options(shortnames=True)
|
|
|
86 |
using_table_options(mysql_engine="InnoDB")
|
|
|
87 |
|
|
|
88 |
class CurrentInventorySnapshot(Entity):
|
|
|
89 |
item_id = Field(Integer, primary_key=True)
|
|
|
90 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
91 |
availability = Field(Integer)
|
|
|
92 |
reserved = Field(Integer)
|
|
|
93 |
using_options(shortnames=True)
|
|
|
94 |
using_table_options(mysql_engine="InnoDB")
|
| 5966 |
rajveer |
95 |
|
|
|
96 |
class CurrentReservationSnapshot(Entity):
|
|
|
97 |
item_id = Field(Integer, primary_key=True)
|
|
|
98 |
warehouse_id = Field(Integer, primary_key=True)
|
|
|
99 |
source_id = Field(Integer, primary_key=True)
|
|
|
100 |
order_id = Field(Integer, primary_key=True)
|
|
|
101 |
created_timestamp = Field(DateTime)
|
|
|
102 |
promised_shipping_timestamp = Field(DateTime)
|
|
|
103 |
reserved = Field(Integer)
|
|
|
104 |
using_options(shortnames=True)
|
|
|
105 |
using_table_options(mysql_engine="InnoDB")
|
|
|
106 |
|
| 5944 |
mandeep.dh |
107 |
class BadInventorySnapshot(Entity):
|
|
|
108 |
item_id = Field(Integer, primary_key=True)
|
|
|
109 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
110 |
availability = Field(Integer)
|
|
|
111 |
using_options(shortnames=True)
|
|
|
112 |
using_table_options(mysql_engine="InnoDB")
|
|
|
113 |
|
|
|
114 |
class SupplierInventorySnapshot(Entity):
|
|
|
115 |
item_id = Field(Integer, primary_key=True)
|
|
|
116 |
warehouse = ManyToOne("Warehouse", primary_key=True)
|
|
|
117 |
availability = Field(Integer)
|
|
|
118 |
using_options(shortnames=True)
|
|
|
119 |
using_table_options(mysql_engine="InnoDB")
|
|
|
120 |
|
|
|
121 |
class ItemInventoryHistory(Entity):
|
|
|
122 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
123 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
|
|
124 |
availability = Field(Integer)
|
|
|
125 |
item_id = Field(Integer)
|
|
|
126 |
warehouse = ManyToOne("Warehouse")
|
|
|
127 |
using_options(shortnames=True)
|
|
|
128 |
using_table_options(mysql_engine="InnoDB")
|
|
|
129 |
|
|
|
130 |
def __repr__(self):
|
|
|
131 |
pass
|
|
|
132 |
|
|
|
133 |
class MissedInventoryUpdate(Entity):
|
|
|
134 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
135 |
itemKey = Field(String(200))
|
|
|
136 |
quantity = Field(Integer)
|
|
|
137 |
warehouseId = Field(Integer)
|
|
|
138 |
isIgnored = Field(Boolean)
|
|
|
139 |
timestamp = Field(DateTime)
|
|
|
140 |
using_options(shortnames=True)
|
|
|
141 |
using_table_options(mysql_engine="InnoDB")
|
|
|
142 |
|
|
|
143 |
class ItemAvailabilityCache(Entity):
|
|
|
144 |
itemId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5978 |
rajveer |
145 |
sourceId = Field(Integer, primary_key=True, autoincrement=False)
|
| 5944 |
mandeep.dh |
146 |
warehouseId = Field(Integer)
|
|
|
147 |
expectedDelay = Field(Integer)
|
|
|
148 |
billingWarehouseId = Field(Integer)
|
|
|
149 |
sellingPrice = Field(Float)
|
|
|
150 |
totalAvailability = Field(Integer)
|
|
|
151 |
using_options(shortnames=True)
|
|
|
152 |
using_table_options(mysql_engine="InnoDB")
|
|
|
153 |
|
|
|
154 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
|
|
155 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
|
|
156 |
#metadata.bind = 'mysql://root:shop2020@localhost/inventory'
|
| 6532 |
amit.gupta |
157 |
iengine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
|
|
158 |
metadata.bind = iengine
|
| 5944 |
mandeep.dh |
159 |
metadata.bind.echo = True
|
|
|
160 |
setup_all(True)
|
|
|
161 |
|
|
|
162 |
if __name__=="__main__":
|
|
|
163 |
initialize()
|