Subversion Repositories SmartDukaan

Rev

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