Subversion Repositories SmartDukaan

Rev

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

Rev 23213 Rev 23217
Line 114... Line 114...
114
    awbs  = [str(awb) for awb in json.loads(the_page)['awb']]
114
    awbs  = [str(awb) for awb in json.loads(the_page)['awb']]
115
    return awbs
115
    return awbs
116
 
116
 
117
#All orders awbwise
117
#All orders awbwise
118
#{'awb':[o1, o2, o3]}
118
#{'awb':[o1, o2, o3]}
119
def forward_request(airwaybill_no, logisticsTxnId):
119
def forward_request(logisticsTxnId):
120
    try:
120
    try:
121
        client = TransactionClient().get_client()
121
        client = TransactionClient().get_client()
122
        orders = client.getGroupOrdersByLogisticsTxnId(logisticsTxnId)
122
        orders = client.getGroupOrdersByLogisticsTxnId(logisticsTxnId)
123
        values = {'username' : username,
123
        values = {'username' : username,
124
                  'password' : password,
124
                  'password' : password,
125
                  'json_input' : _forwardMap(airwaybill_no, orders),
125
                  'json_input' : _forwardMap(orders[0].airwaybill_no, orders),
126
                  }
126
                  }
127
        print "values - ", values 
127
        print "values - ", values 
128
        data = urllib.urlencode(values)
128
        data = urllib.urlencode(values)
-
 
129
        print "------ data start ------"
129
        print "data - ", data 
130
        print  data
-
 
131
        print "------- date end ------ " 
130
        req = urllib2.Request(forwardApi, data)
132
        req = urllib2.Request(forwardApi, data)
131
        response = urllib2.urlopen(req)
133
        response = urllib2.urlopen(req)
132
        the_page = response.read()
134
        the_page = response.read()
133
        jsonResponse = json.loads(the_page)
135
        jsonResponse = json.loads(the_page)
134
        return jsonResponse[0]['success']
136
        return jsonResponse[0]['success']
Line 196... Line 198...
196
    shipment[F_ADDITIONAL_INFORMATION] = {"MULTI_SELLER_INFORMATION": _getMultiSellerInfo(orders, sellerInfo, warehouseAddressObj)}
198
    shipment[F_ADDITIONAL_INFORMATION] = {"MULTI_SELLER_INFORMATION": _getMultiSellerInfo(orders, sellerInfo, warehouseAddressObj)}
197
    return shipment 
199
    return shipment 
198
    
200
    
199
def _getMultiSellerInfo(orders, sellerInfo, warehouseAddressObj):
201
def _getMultiSellerInfo(orders, sellerInfo, warehouseAddressObj):
200
    itemIds = []
202
    itemIds = []
201
    
-
 
202
    for order in orders:
-
 
203
        lineitem = order.lineitems[0]
-
 
204
        itemIds.append(lineitem.item_id)
-
 
205
    
-
 
206
    
-
 
207
    inventory_client = InventoryClient().get_client()
203
    inventory_client = InventoryClient().get_client()
208
    warehouse = inventory_client.getWarehouse(orders[0].warehouse_id)
204
    warehouse = inventory_client.getWarehouse(orders[0].warehouse_id)
209
    whState = fetchStateMaster().get(warehouse.stateId)
-
 
210
    
205
    
211
    cc = CatalogClient().get_client()
-
 
212
    if whState == orders[0].customer_state:
206
    if sellerInfo.stateId == warehouse.stateId:
213
        taxRateMap = cc.getStateTaxRate(itemIds, sellerInfo.stateId)
207
        taxRate = cc.getStateTaxRate(itemIds, sellerInfo.stateId)
214
    else:
208
    else:
215
        taxRateMap = cc.getStateTaxRate(itemIds, -1)
209
        taxRate = cc.getStateTaxRate(itemIds, -1)
216
 
210
 
217
    for order in orders:
211
    for order in orders:
218
        lineitem = order.lineitems[0]
212
        lineitem = order.lineitems[0]
-
 
213
    for order in orders:
219
        taxRate = taxRateMap.get(lineitem.item_id) 
214
        lineitem = order.lineitems[0]
-
 
215
        cc = CatalogClient().get_client()
220
        totalTaxRate = taxRate.sgstRate + taxRate.cgstRate + taxRate.igstRate
216
        totalTaxRate = lineitem.sgstRate + lineitem.cgstRate + lineitem.igstRate
221
        stateMaster = fetchStateMaster()
217
        stateMaster = fetchStateMaster()
222
        return {
218
        return {
223
            "ITEM_DESCRIPTION": " ".join(filter(None, [lineitem.brand, lineitem.model_name,  lineitem.model_number])),
219
            "ITEM_DESCRIPTION": " ".join(filter(None, [lineitem.brand, lineitem.model_name,  lineitem.model_number])),
224
            "ITEM_VALUE": lineitem.unit_price,
220
            "ITEM_VALUE": lineitem.unit_price,
225
            "ITEM_CATEGORY": "Mobile/Mobile Accessory",
221
            "ITEM_CATEGORY": "Mobile/Mobile Accessory",