Subversion Repositories SmartDukaan

Rev

Rev 477 | Rev 669 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 477 Rev 644
Line 7... Line 7...
7
import datetime
7
import datetime
8
 
8
 
9
class Provider(Entity):
9
class Provider(Entity):
10
    id = Field(Integer, primary_key=True, autoincrement=True)
10
    id = Field(Integer, primary_key=True, autoincrement=True)
11
    name = Field(String(100))
11
    name = Field(String(100))
12
    awb = OneToMany("AWB")
12
    email = Field(String(100))
-
 
13
    phone = Field(String(15))
-
 
14
    using_options(shortnames=True)
13
 
15
 
-
 
16
class Slab(Entity):
-
 
17
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
18
    description = Field(String(50))
-
 
19
    using_options(shortnames=True)
-
 
20
 
-
 
21
class Cost(Entity):
-
 
22
    provider = ManyToOne("Provider", primary_key=True)
-
 
23
    slab = ManyToOne("Slab", primary_key=True)
-
 
24
    cost = Field(Float)
-
 
25
    using_options(shortnames=True)
-
 
26
 
14
class AWB(Entity):
27
class Awb(Entity):
15
    id = Field(Integer, primary_key=True, autoincrement=True)
28
    id = Field(Integer, primary_key=True, autoincrement=True)
16
    awb_number = Field(String(100))
29
    awb_number = Field(String(100))
17
    is_available = Field(Boolean)
-
 
18
    provider = ManyToOne("Provider")
30
    provider = ManyToOne("Provider")
-
 
31
    is_available = Field(Boolean)
-
 
32
    type = Field(String(50))
19
    #shipment = OneToOne("Shipment", inverse="awb")
33
    updates = OneToMany("AwbUpdate")
-
 
34
    using_options(shortnames=True)
20
    
35
    
21
class ShipmentUpdate(Entity):
36
class AwbUpdate(Entity):
22
    id = Field(Integer, primary_key=True, autoincrement=True)
37
    id = Field(Integer, primary_key=True, autoincrement=True)
-
 
38
    awb = ManyToOne("Awb")
23
    pin = Field(String(20))
39
    location = Field(String(50))
24
    timestamp = Field(DateTime)
40
    entry_date = Field(DateTime)
25
    description = Field(String(100))
41
    description = Field(String(100))
26
    #awb = ManyToOne("AWB")
42
    comments = Field(String(100))
27
    shipment = ManyToOne("Shipment")    
43
    using_options(shortnames=True)
28
    
44
    
29
class Shipment(Entity):
45
class WarehouseAllocation(Entity):
30
    id = Field(Integer, primary_key=True, autoincrement=True) 
46
    pincode = Field(String(6), primary_key=True)
31
    warehouse_name = Field(String(100))
47
    primary_warehouse_location = Field(Integer)
32
    awb = Field(String(100))
-
 
33
    origin = Field(String(100))
48
    using_options(shortnames=True)
-
 
49
 
34
    destination = Field(String(100))
50
class ServiceableLocationDetails(Entity):
35
    timestamp = Field(DateTime)
-
 
36
    recepient_name = Field(String(100))
-
 
37
    recepient_address = Field(String(200))
51
    provider = ManyToOne("Provider", primary_key=True)
38
    recepient_pincode = Field(String(20))
52
    dest_pincode = Field(String(6), primary_key=True)
39
    recepient_phone = Field(String(20))
53
    dest_code = Field(String(5))
40
    shipment_weight = Field(String(20))
54
    exp = Field(Boolean)
41
    shipment_contents = Field(String(100))
55
    cod = Field(Boolean)
42
    status_message = Field(String(100))
56
    station_type = Field(Integer)
43
    #awb = ManyToOne("AWB")
-
 
44
    shipment_update = OneToMany("ShipmentUpdate")
-
 
45
 
-
 
46
class PincodeWarehouseMapping(Entity):
-
 
47
    pincode = Field(String(20), primary_key=True)
57
    using_options(shortnames=True)
48
    warehouse_id = Field(Integer, primary_key=True)
-
 
49
    warehouse_pin = Field(String(20))
-
 
50
 
58
 
51
class DeliveryEstimate(Entity):
59
class DeliveryEstimate(Entity):
52
    source_pin = Field(String(20), primary_key=True)
-
 
53
    destination_pin = Field(String(20), primary_key=True)
60
    destination_pin = Field(String(6), primary_key=True)
54
    provider = ManyToOne("Provider", primary_key=True)
61
    provider = ManyToOne("Provider", primary_key=True)
-
 
62
    warehouse_location = Field(Integer, primary_key=True)
-
 
63
    #slab = ManyToOne("Slab")
55
    delivery_time = Field(Integer)
64
    delivery_time = Field(Integer)
56
    realibility = Field(Integer)
65
    reliability = Field(Integer)
57
    
-
 
58
'''
-
 
59
struct Shipment{
-
 
60
    1:string warehouse_id,
-
 
61
    2:string awb,
-
 
62
    3:string origin,
-
 
63
    4:string destination,
-
 
64
    5:i64 timestamp,
-
 
65
    6:string recepient_name,
-
 
66
    7:string recepient_address,
-
 
67
    8:string recepient_pincode,
-
 
68
    9:string recepient_phone,
66
    using_options(shortnames=True)
69
    10:string shipment_weight,
-
 
70
    11:string shipment_contents
-
 
71
}
-
 
72
'''
-
 
73
   
67
   
74
def initialize():
68
def initialize():
75
    metadata.bind = "sqlite:///logistics.sqlite" #need to read it from configserver.
69
    metadata.bind = "sqlite:///logistics.sqlite" #need to read it from configserver.
76
    metadata.bind.echo = True
70
    metadata.bind.echo = True
77
    setup_all(True)
71
    setup_all(True)