Subversion Repositories SmartDukaan

Rev

Rev 483 | Rev 669 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
104 ashish 1
'''
2
Created on 29-Mar-2010
3
 
4
@author: ashish
5
'''
6
 
7
from elixir import *
8
from elixir.entity import Entity
9
from elixir.fields import Field
10
from sqlalchemy.types import Integer
11
from elixir.relationships import OneToMany, ManyToOne
12
import datetime
13
 
14
 
15
 
16
#===============================================================================
17
# Different entities in the model
18
#===============================================================================
19
 
483 rajveer 20
def initialize():
21
    metadata.bind = "sqlite:///Transactionsnew.sqlite"
22
    metadata.bind.echo = True
23
    setup_all(True)
24
 
25
 
26
if __name__=="__main__":
27
    initialize()
28
 
29
 
30
class LineItem(Entity):
31
    id = Field(Integer, primary_key=True, autoincrement=True)
32
    sku_id = Field(String(30))
33
    brand = Field(String(30))
34
    model_number = Field(String(30))
35
    model_name = Field(String(30)) 
36
    extra_info = Field(String(100))
37
    quantity = Field(Float)
38
    unit_price = Field(Float)
39
    unit_weight = Field(Float)
40
    total_price = Field(Float)
41
    total_weight = Field(Float)
42
    order = ManyToOne("Order")
43
 
44
class Order(Entity):
45
    id = Field(Integer, primary_key=True, autoincrement=True)
46
    warehouse_id = Field(Integer)
47
    logistics_provider_id = Field(Integer)
48
    airwaybill_no = Field(String(50))
49
    tracking_id = Field(String(50))
50
    expected_delivery_time = Field(DateTime)
51
    customer_id = Field(Integer)
52
    customer_name = Field(String(50))
53
    customer_mobilenumber = Field(String(20))
54
    customer_pincode = Field(String(10))
55
    customer_address = Field(String(200))
56
    customer_email = Field(String(50))
57
    status = Field(Integer)
58
    statusDescription = Field(String(50))
59
    total_amount = Field(Float)
60
    total_weight = Field(Float)
61
    invoice_number = Field(String(30))
62
    billed_by = Field(String(30))
63
    created_timestamp = Field(DateTime)
64
    accepted_timestamp = Field(DateTime)
65
    billing_timestamp = Field(DateTime)
66
    shipping_timestamp = Field(DateTime)
67
    delivery_timestamp = Field(DateTime)
68
    lineitems = OneToMany("LineItem")
69
    transaction = ManyToOne("Transaction")
642 chandransh 70
    jacket_number = Field(Integer)
483 rajveer 71
 
72
 
104 ashish 73
class Transaction(Entity):
483 rajveer 74
    id = Field(Integer, primary_key=True, autoincrement=True)
75
    createdOn = Field(DateTime)
76
    status = Field(Integer)
77
    status_message = Field(String(100))
78
    customer_id = Field(Integer)
79
    shopping_cart_id = Field(Integer)
80
    payments = OneToMany("Payment")
81
    orders = OneToMany("Order")
82
 
83
class Payment(Entity):
84
    id = Field(Integer, primary_key=True, autoincrement=True)
85
    payment_id = Field(Integer)
86
    merchant_tx_id = Field(String(30))
87
    bank_tx_id = Field(String(30))
88
    mode = Field(String(30))
89
    amount = Field(Float)
90
    status = Field(Integer)
91
    status_message = Field(String(100))
92
    start_time = Field(DateTime)
93
    finish_time = Field(DateTime)
94
    transaction = ManyToOne("Transaction")
132 ashish 95
 
483 rajveer 96
    def __repr__(self):
97
        return "Payment: id %d"%(self.id)
98
 
99
 
100
class Alerts(Entity):
132 ashish 101
    id = Field(Integer, primary_key=True, autoincrement=True)
483 rajveer 102
    order_id = Field(Integer)
103
    valid = Field(Boolean)
104
    type = Field(Integer)
105
    time_set = Field(DateTime)
106
    comment = Field(String(100))
107
    time_unset = Field(DateTime)
108
 
109
 
110
"""
111
class Transaction(Entity):
112
 
113
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 114
    createdOn = Field(DateTime)
115
    expected_delivery_time = Field(DateTime)
116
    status = Field(Integer)
117
    status_message = Field(String(100))
118
    customer_id = Field(Integer)
358 ashish 119
    warehouse_id = Field(Integer)
132 ashish 120
    shopping_cart_id = Field(Integer)
104 ashish 121
    payments = OneToMany("Payment")
122
    shipments = OneToMany("Shipment")
123
    lineitems = OneToMany("LineItem")
124
    trails = OneToMany("TransactionTrail")
194 ashish 125
 
104 ashish 126
 
127
 
128
class Payment(Entity):
115 ashish 129
    #using_options(auto_primarykey=False)
132 ashish 130
    id = Field(Integer, primary_key=True, autoincrement=True)
131
    payment_id = Field(Integer)
104 ashish 132
    merchant_tx_id = Field(String(30))
133
    bank_tx_id = Field(String(30))
132 ashish 134
    mode = Field(String(30))
104 ashish 135
    amount = Field(Float)
136
    status = Field(Integer)
137
    status_message = Field(String(100))
138
    start_time = Field(DateTime)
139
    finish_time = Field(DateTime)
140
    transaction = ManyToOne("Transaction")
141
 
142
    def __repr__(self):
143
        return "Payment: id %d"%(self.id)
144
 
145
 
146
class Shipment(Entity):
115 ashish 147
    #using_options(auto_primarykey=False)
132 ashish 148
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 149
    address = Field(String(100))
150
    tracking_id = Field(String(100))
151
    status = Field(Integer)
152
    status_message = Field(String(100))
153
    shipment_time = Field(DateTime)
154
    delivery_time = Field(DateTime)
155
    declared_value = Field(Float)
156
    insurance_value = Field(Float)
157
    weight = Field(Float)
158
    airway_bill_no = Field(String(30))
159
    provider = Field(String(30))
160
    transaction = ManyToOne("Transaction")
161
    lineitems = OneToMany("LineItem")
162
 
163
    def __repr__(self):
164
        return "Shipment: id %d"%(self.id)
165
 
166
 
167
class LineItem(Entity):
115 ashish 168
    #using_options(auto_primarykey=False)
132 ashish 169
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 170
    added_on = Field(DateTime)
171
    item_id = Field(Integer)
172
    additional_info = OneToMany("AdditionalInfo")
173
    transaction = ManyToOne("Transaction")
115 ashish 174
    billing = ManyToOne("Billing")
104 ashish 175
    shipment = ManyToOne("Shipment")
132 ashish 176
    item_info = OneToOne("ItemInfo")
104 ashish 177
    def __repr__(self):
178
        return "id %d item_id %d"%(self.id, self.item_id)
179
 
132 ashish 180
class ItemInfo(Entity):
181
    id = Field(Integer, primary_key=True, autoincrement=True)
182
    price = Field(Float)
183
    weight = Field(Float)
184
    line_item = ManyToOne("LineItem")
104 ashish 185
 
186
class AdditionalInfo(Entity):
115 ashish 187
    #using_options(auto_primarykey=False)
132 ashish 188
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 189
    key = Field(String(30))
190
    value = Field(String(100))
191
    line_item = ManyToOne("LineItem")
192
 
193
    def __repr__(self):
194
        return "Additonal info id %d key %s value %s" %(self.id, self.key, self.value)
195
 
196
 
197
class Billing(Entity):
115 ashish 198
    #using_options(auto_primarykey=False)
132 ashish 199
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 200
    bill_number = Field(String(30))
201
    created_on = Field(DateTime)
202
    generated_by = Field(String(30))
115 ashish 203
    line_item = OneToMany("LineItem")
104 ashish 204
 
132 ashish 205
 
104 ashish 206
    def __repr__(self):
207
        return "Billing: billing id %d billno %s " % (self.id, self.bill_number)
208
 
209
class TransactionTrail(Entity):
115 ashish 210
    #using_options(auto_primarykey=False)
132 ashish 211
    id = Field(Integer, primary_key=True, autoincrement=True)
104 ashish 212
    field_changed = Field(String(30))
213
    old_value = Field(String(30))
214
    new_value = Field(String(30))
215
    description = Field(String(100))
216
    timestamp = Field(DateTime)
217
    transaction = ManyToOne("Transaction")
218
 
304 ashish 219
class Alerts(Entity):
220
    id = Field(Integer, primary_key=True, autoincrement=True)
221
    transaction_id = Field(Integer)
222
    valid = Field(Boolean)
223
    type = Field(Integer)
224
    time_set = Field(DateTime)
225
    comment = Field(String(100))
226
    time_unset = Field(DateTime)
227
 
228
class ExtraItemInfo(Entity):
229
    id = Field(Integer, primary_key=True, autoincrement=True)
230
    transaction_id = Field(Integer)
231
    sku_id = Field(Integer)
232
    model = Field(String(50))
233
    vendor = Field(String(50))
234
    colour = Field(String(50))
483 rajveer 235
"""