| Line 61... |
Line 61... |
| 61 |
ship.Sender = "ADONIS MOBITRADE"
|
61 |
ship.Sender = "ADONIS MOBITRADE"
|
| 62 |
ship.CustomerTelephone="9311608716"
|
62 |
ship.CustomerTelephone="9311608716"
|
| 63 |
shipper = ship
|
63 |
shipper = ship
|
| 64 |
return shipper
|
64 |
return shipper
|
| 65 |
|
65 |
|
| - |
|
66 |
def create_commodity_obj(orders_list, cd, ser):
|
| - |
|
67 |
SpecialInstruction = ""
|
| - |
|
68 |
for order in orders_list:
|
| - |
|
69 |
temp = xstr(order.lineitems[0].brand)+" "+xstr(order.lineitems[0].model_name)+" "+xstr(order.lineitems[0].model_number)+" "+xstr(order.lineitems[0].color)+"-"+str(order.lineitems[0].quantity)
|
| - |
|
70 |
SpecialInstruction+=temp
|
| - |
|
71 |
SpecialInstruction = re.sub(' +',' ',SpecialInstruction)
|
| - |
|
72 |
ser.SpecialInstruction = SpecialInstruction
|
| - |
|
73 |
cd.CommodityDetail1 = SpecialInstruction[:30]
|
| - |
|
74 |
cd.CommodityDetail2 = SpecialInstruction[30:60]
|
| - |
|
75 |
cd.CommodityDetail3 = SpecialInstruction[60:]
|
| - |
|
76 |
ser.CommodityDetail = cd
|
| - |
|
77 |
return ser
|
| - |
|
78 |
|
| 66 |
def clean_address(order, consignee):
|
79 |
def clean_address(order, consignee):
|
| 67 |
address_string = xstr(order.customer_address1)+" "+xstr(order.customer_address2)
|
80 |
address_string = xstr(order.customer_address1)+" "+xstr(order.customer_address2)
|
| 68 |
address_string = re.sub(",",' ',address_string)
|
81 |
address_string = re.sub(",",' ',address_string)
|
| 69 |
add_string = re.sub(' +',' ',address_string)
|
82 |
add_string = re.sub(' +',' ',address_string)
|
| 70 |
c_1, idx = sub_address(address_string, 0, 30)
|
83 |
c_1, idx = sub_address(address_string, 0, 30)
|
| Line 129... |
Line 142... |
| 129 |
ser.RegisterPickup = False
|
142 |
ser.RegisterPickup = False
|
| 130 |
if isCod:
|
143 |
if isCod:
|
| 131 |
ser.CollectableAmount = collectable_amount
|
144 |
ser.CollectableAmount = collectable_amount
|
| 132 |
ser.SubProductCode = "C"
|
145 |
ser.SubProductCode = "C"
|
| 133 |
wbg = get_client().factory.create('ns2:WayBillGenerationRequest')
|
146 |
wbg = get_client().factory.create('ns2:WayBillGenerationRequest')
|
| 134 |
wbg.Consignee = consignee
|
- |
|
| 135 |
wbg.Services = ser
|
- |
|
| 136 |
wbg.Shipper = get_shipper_object()
|
- |
|
| 137 |
|
147 |
|
| 138 |
d= get_client().factory.create('ns2:Dimension')
|
148 |
d= get_client().factory.create('ns2:Dimension')
|
| 139 |
shipment_cost = get_shipment_details(orders_list[0].logisticsTransactionId)
|
149 |
shipment_cost = get_shipment_details(orders_list[0].logisticsTransactionId)
|
| 140 |
if shipment_cost is None or shipment_cost.packageDimensions is None:
|
150 |
if shipment_cost is None or shipment_cost.packageDimensions is None:
|
| 141 |
raise RuntimeError("Package dim. is none")
|
151 |
raise RuntimeError("Package dim. is none")
|
| 142 |
t_dimensions = shipment_cost.packageDimensions.split("X")
|
152 |
t_dimensions = shipment_cost.packageDimensions.split("X")
|
| 143 |
if len(t_dimensions!=3):
|
153 |
if len(t_dimensions!=3):
|
| 144 |
raise RuntimeError("Package dim. is not valid")
|
154 |
raise RuntimeError("Package dim. is not valid")
|
| 145 |
d.Count=1
|
155 |
d.Count=1
|
| 146 |
d.Length = t_dimensions[0]
|
156 |
d.Length = float(t_dimensions[0].strip())
|
| 147 |
d.Breadth = t_dimensions[1]
|
157 |
d.Breadth = float(t_dimensions[1].strip())
|
| 148 |
d.Height = t_dimensions[2]
|
158 |
d.Height = float(t_dimensions[2].strip())
|
| 149 |
ser.Dimensions=[d]
|
159 |
ser.Dimensions=[d]
|
| - |
|
160 |
|
| - |
|
161 |
cd = get_client().factory.create('ns2:CommodityDetail')
|
| - |
|
162 |
|
| - |
|
163 |
ser = create_commodity_obj(orders_list, cd, ser)
|
| - |
|
164 |
|
| - |
|
165 |
wbg.Consignee = consignee
|
| - |
|
166 |
wbg.Services = ser
|
| - |
|
167 |
wbg.Shipper = get_shipper_object()
|
| - |
|
168 |
|
| 150 |
response = get_client().service.GenerateWayBill(wbg, get_profile())
|
169 |
response = get_client().service.GenerateWayBill(wbg, get_profile())
|
| 151 |
if response.AWBNo is None:
|
170 |
if response.AWBNo is None:
|
| 152 |
raise RuntimeError("AWB generated is empty")
|
171 |
raise RuntimeError("AWB generated is empty")
|
| 153 |
else:
|
172 |
else:
|
| 154 |
bluedartResponse = __BluedartAWBResponse(str(response.AWBNo),str(response.DestinationArea),str(response.DestinationLocation))
|
173 |
bluedartResponse = __BluedartAWBResponse(str(response.AWBNo),str(response.DestinationArea),str(response.DestinationLocation))
|