Subversion Repositories SmartDukaan

Rev

Rev 1220 | Rev 2219 | 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 shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
699 chandransh 8
    LineItem as T_LineItem, Order as T_Order, Alert as T_Alert, OrderStatus
104 ashish 9
from shop2020.utils.Utils import to_java_date
483 rajveer 10
from shop2020.model.v1.order.impl.DataService import Alerts
104 ashish 11
 
12
def to_t_transaction(transaction):
13
    t_transaction = T_Transaction()
14
    t_transaction.id = transaction.id
483 rajveer 15
    t_transaction.createdOn = to_java_date(transaction.createdOn)
699 chandransh 16
    t_transaction.transactionStatus = transaction.status
483 rajveer 17
    t_transaction.statusDescription = transaction.status_message
18
    t_transaction.customer_id = transaction.customer_id
19
    t_transaction.shoppingCartid = transaction.shopping_cart_id
20
    t_transaction.orders = []
21
    #populate orders
22
    for order in transaction.orders:
23
        t_order = to_t_order(order)
24
        t_transaction.orders.append(t_order)
25
    return t_transaction
26
 
27
def to_t_order(order):
28
    t_order = T_Order()
29
    t_order.id = order.id
30
    t_order.warehouse_id = order.warehouse_id
31
    t_order.logistics_provider_id = order.logistics_provider_id
32
    t_order.airwaybill_no = order.airwaybill_no
33
    t_order.tracking_id = order.tracking_id
34
    t_order.expected_delivery_time = to_java_date(order.expected_delivery_time)
35
    t_order.customer_id = order.customer_id
36
    t_order.customer_name = order.customer_name
37
    t_order.customer_mobilenumber = order.customer_mobilenumber
38
    t_order.customer_pincode = order.customer_pincode
738 chandransh 39
    t_order.customer_address1 = order.customer_address1
40
    t_order.customer_address2 = order.customer_address2
669 chandransh 41
    t_order.customer_city = order.customer_city
42
    t_order.customer_state = order.customer_state
483 rajveer 43
    t_order.customer_email = order.customer_email    
699 chandransh 44
    t_order.status = order.status 
483 rajveer 45
    t_order.statusDescription = order.statusDescription
46
    t_order.total_amount = order.total_amount
1976 varun.gupt 47
    t_order.discounted_amount = order.discounted_amount
483 rajveer 48
    t_order.total_weight = order.total_weight
49
    t_order.created_timestamp = to_java_date(order.created_timestamp)
50
    t_order.invoice_number = order.invoice_number
51
    t_order.billed_by = order.billed_by
986 chandransh 52
    t_order.accepted_timestamp = to_java_date(order.accepted_timestamp)
53
    t_order.billing_timestamp = to_java_date(order.billing_timestamp)
54
    t_order.shipping_timestamp = to_java_date(order.shipping_timestamp)
55
    t_order.delivery_timestamp = to_java_date(order.delivery_timestamp)
1208 chandransh 56
    t_order.outofstock_timestamp = to_java_date(order.outofstock_timestamp)
642 chandransh 57
    t_order.jacket_number = order.jacket_number
1220 chandransh 58
    t_order.receiver = order.receiver
59
    t_order.batchNo = order.batchNo
60
    t_order.serialNo = order.serialNo
483 rajveer 61
    t_order.lineitems = []
62
    for lineitem in order.lineitems:
63
        t_lineitem = to_t_lineitem(lineitem)
64
        t_order.lineitems.append(t_lineitem)
65
 
66
    return t_order
67
 
68
def to_t_lineitem(lineitem):
69
    t_lineitem = T_LineItem()
70
    t_lineitem.id = lineitem.id
699 chandransh 71
    t_lineitem.item_id = lineitem.item_id
970 chandransh 72
    t_lineitem.productGroup = lineitem.productGroup
73
    t_lineitem.brand = lineitem.brand
74
    t_lineitem.model_number = lineitem.model_number
75
    t_lineitem.color = lineitem.color
76
    t_lineitem.model_name = lineitem.model_name
77
    t_lineitem.extra_info = lineitem.extra_info
483 rajveer 78
    t_lineitem.unit_weight = lineitem.unit_weight
79
    t_lineitem.unit_price = lineitem.unit_price
80
    t_lineitem.total_price = lineitem.total_price
1976 varun.gupt 81
    t_lineitem.discounted_price = lineitem.discounted_price
996 varun.gupt 82
    t_lineitem.transfer_price = lineitem.transfer_price
483 rajveer 83
    t_lineitem.total_weight = lineitem.total_weight 
669 chandransh 84
    t_lineitem.quantity = lineitem.quantity
483 rajveer 85
    return t_lineitem
86
 
87
def to_t_alert(alert):
88
    t_alert = T_Alert()
89
    t_alert.id = alert.id
90
    t_alert.comment = alert.comment
91
    try:
92
        t_alert.time_set = to_java_date(alert.time_set)
93
    except:
94
        pass
95
    try:
96
        t_alert.time_unset = to_java_date(alert.time_unset)
97
    except:
98
        pass
99
    t_alert.order_id = alert.order_id
100
    t_alert.type = alert.type
738 chandransh 101
    return t_alert