Subversion Repositories SmartDukaan

Rev

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

Rev 494 Rev 644
Line 1... Line 1...
1
from shop2020.thriftpy.logistics.ttypes import Provider as TProvider,\
1
from shop2020.thriftpy.logistics.ttypes import Provider as TProvider, AwbUpdate as TAwbUpdate
2
    ShipmentUpdate as TShipmentUpdate, ShipmentStatusInfo as TShipmentStatusInfo,\
-
 
3
    Shipment as TShipment, ItemLogistics as TItemLogistics
-
 
4
from shop2020.logistics.service.impl.DataService import Shipment
-
 
5
from shop2020.utils.Utils import to_java_date
2
from shop2020.utils.Utils import to_java_date
6
 
3
 
7
 
4
 
8
def to_t_provider(provider):
5
def to_t_provider(provider):
9
    t_provider = TProvider()
6
    t_provider = TProvider()
10
    t_provider.id = provider.id
7
    t_provider.id = provider.id
11
    t_provider.name = provider.name
8
    t_provider.name = provider.name
12
    return t_provider
9
    return t_provider
13
 
-
 
14
def to_t_shipment(shipment):
-
 
15
    t_shipment = TShipment()
-
 
16
    t_shipment.awb = shipment.awb
-
 
17
    t_shipment.destination = shipment.destination
-
 
18
    t_shipment.origin = shipment.origin
-
 
19
    t_shipment.recepient_address = shipment.recepient_address
-
 
20
    t_shipment.recepient_name = shipment.recepient_name
-
 
21
    t_shipment.recepient_phone = shipment.recepient_phone
-
 
22
    t_shipment.recepient_pincode = shipment.recepient_pincode
-
 
23
    t_shipment.shipment_contents = shipment.shipment_contents
-
 
24
    t_shipment.shipment_weight = shipment.shipment_weight
-
 
25
    t_shipment.timestamp = to_java_date(shipment.timestamp)
-
 
26
    t_shipment.warehouse_name = shipment.warehouse_name
-
 
27
    return t_shipment
-
 
28
 
-
 
29
def to_t_shipmentstatusinfo(updates):
-
 
30
    t_shipment_status = TShipmentStatusInfo()
-
 
31
    
-
 
32
    ret_updates = []
-
 
33
    for update in updates:
-
 
34
        ret_updates.append(to_t_shipmentupdate(update))
-
 
35
    
-
 
36
    t_shipment_status.updates = ret_updates
-
 
37
    
-
 
38
    t_shipment_status.awb = "129102"
-
 
39
    t_shipment_status.provider_id = 1 
-
 
40
    t_shipment_status.currentUpdate = to_t_shipmentupdate(update)  #last update is added right now
-
 
41
    return t_shipment_status
-
 
42
        
10
        
43
def to_t_shipmentupdate(update):
-
 
44
    t_update = TShipmentUpdate()
-
 
45
    t_update.pin =  update.pin 
-
 
46
    t_update.description = update.description
-
 
47
    t_update.timestamp = to_java_date(update.timestamp)
-
 
48
    return t_update
-
 
49
 
-
 
50
def to_t_itemLogistics(delivery_time, items_in_inventory, warehouse_id):
-
 
51
    t_item_logistics = TItemLogistics()
-
 
52
    t_item_logistics.warehouseId = warehouse_id
-
 
53
    t_item_logistics.availability = items_in_inventory 
-
 
54
    t_item_logistics.shippingTime = delivery_time
-
 
55
    return t_item_logistics
-
 
56
11
def to_t_awbupdate(update):
-
 
12
    t_update = TAwbUpdate()
-
 
13
    t_update.awbNumber    = update.awb.awb_number
-
 
14
    t_update.providerName = update.awb.provider.name
-
 
15
    t_update.description  = update.description + " - " + update.comments
-
 
16
    t_update.location     = update.location
-
 
17
    t_update.entryDate    = to_java_date(update.entry_date)
-
 
18
    return t_update
-
 
19
57
20