Subversion Repositories SmartDukaan

Rev

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

Rev 20745 Rev 20768
Line 15... Line 15...
15
LICENCE_KEY="5f1740fdfb8196e7980faea7fe52dd0d"
15
LICENCE_KEY="5f1740fdfb8196e7980faea7fe52dd0d"
16
API_VERSION="1.7"
16
API_VERSION="1.7"
17
API_TYPE="S"
17
API_TYPE="S"
18
AREA="ALL"
18
AREA="ALL"
19
 
19
 
-
 
20
xstr = lambda s: s or ""
-
 
21
 
20
class __BluedartAWBResponse:
22
class __BluedartAWBResponse:
21
    def __init__(self, awbNo, destArea, destLocation):
23
    def __init__(self, awbNo, destArea, destLocation):
22
        self.awbNo = awbNo
24
        self.awbNo = awbNo
23
        self.destArea = destArea
25
        self.destArea = destArea
24
        self.destLocation = destLocation
26
        self.destLocation = destLocation
Line 59... Line 61...
59
        ship.Sender = "ADONIS MOBITRADE"
61
        ship.Sender = "ADONIS MOBITRADE"
60
        ship.CustomerTelephone="9311608716"
62
        ship.CustomerTelephone="9311608716"
61
        shipper = ship
63
        shipper = ship
62
    return shipper
64
    return shipper
63
 
65
 
-
 
66
def clean_address(order, consignee):
-
 
67
    address_string = xstr(order.customer_address1)+" "+xstr(order.customer_address2)
-
 
68
    address_string = re.sub(",",' ',address_string)
-
 
69
    add_string = re.sub(' +',' ',address_string)
-
 
70
    c_1, idx = sub_address(address_string, 0, 30)
-
 
71
    c_2, idx = sub_address(address_string, idx, idx+30)
-
 
72
    c_3, idx = sub_address(address_string, idx, len(add_string))
-
 
73
    consignee.ConsigneeAddress1 = c_1
-
 
74
    consignee.ConsigneeAddress2 = c_2
-
 
75
    consignee.ConsigneeAddress3 = c_3 +" "+order.customer_city
-
 
76
    return consignee
-
 
77
 
-
 
78
def sub_address(add_str, previous_loc, final_loc):
-
 
79
    sub = add_str[previous_loc:final_loc]
-
 
80
    max_idx = sub.rfind(" ")
-
 
81
    if max_idx==-1:
-
 
82
        return sub, len(sub)
-
 
83
    if max_idx == (final_loc-1):
-
 
84
        return sub
-
 
85
    return sub[: max_idx], max_idx+previous_loc
-
 
86
    
-
 
87
 
64
def generate_awb(orders_list):
88
def generate_awb(orders_list):
65
    try:
89
    try:
66
        if not isinstance(orders_list, list) or not orders_list:
90
        if not isinstance(orders_list, list) or not orders_list:
67
            raise ValueError("Expecting list of orders")
91
            raise ValueError("Expecting list of orders")
68
        consignee = get_client().factory.create('ns2:Consignee')
92
        consignee = get_client().factory.create('ns2:Consignee')
69
        consignee.ConsigneeAddress1 = orders_list[0].customer_address1
93
        consignee = clean_address(orders_list[0], consignee)
70
        if orders_list[0].customer_address2:
-
 
71
            consignee.ConsigneeAddress2 = orders_list[0].customer_address2 
-
 
72
            consignee.ConsigneeAddress3 = orders_list[0].customer_city+" "+orders_list[0].customer_state
-
 
73
        else:
-
 
74
            consignee.ConsigneeAddress2 = orders_list[0].customer_city
-
 
75
        consignee.ConsigneeAttention = orders_list[0].customer_name
94
        consignee.ConsigneeAttention = orders_list[0].customer_name
76
        consignee.ConsigneeMobile = orders_list[0].customer_mobilenumber
95
        consignee.ConsigneeMobile = orders_list[0].customer_mobilenumber
77
        consignee.ConsigneeName = orders_list[0].customer_name
96
        consignee.ConsigneeName = orders_list[0].customer_name
78
        consignee.ConsigneePincode = orders_list[0].customer_pincode
97
        consignee.ConsigneePincode = orders_list[0].customer_pincode
79
        consignee.ConsigneeTelephone = orders_list[0].customer_mobilenumber
98
        consignee.ConsigneeTelephone = orders_list[0].customer_mobilenumber