Subversion Repositories SmartDukaan

Rev

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

Rev 23218 Rev 23446
Line 75... Line 75...
75
        try:
75
        try:
76
            return [to_t_provider(provider) for provider in get_providers()]
76
            return [to_t_provider(provider) for provider in get_providers()]
77
        finally:
77
        finally:
78
            close_session()
78
            close_session()
79
            
79
            
80
    def getLogisticsInfo(self, destination_pincode, itemId, type, pickUp):
80
    def getLogisticsInfo(self, destination_pincode, itemId, type, pickUp, stateId):
81
        """
81
        """
82
        Parameters:
82
        Parameters:
83
         - destination_pincode
83
         - destination_pincode
84
         - item_id
84
         - item_id
85
         - type
85
         - type
86
        """
86
        """
87
        try:
87
        try:
88
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pincode, type, pickUp)
88
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pincode, type, pickUp, stateId)
89
            #logistics_info.airway_billno = get_empty_AWB(logistics_info.providerId, type)
89
            #logistics_info.airway_billno = get_empty_AWB(logistics_info.providerId, type)
90
            return logistics_info
90
            return logistics_info
91
        finally:
91
        finally:
92
            close_session()
92
            close_session()
93
            
93
            
Line 134... Line 134...
134
         - itemId
134
         - itemId
135
         - destination_pin
135
         - destination_pin
136
         - type
136
         - type
137
        """
137
        """
138
        try:
138
        try:
139
            return self.get_logistics_estimation_with_type(itemId, destination_pin, type)
139
            return self.get_logistics_estimation_with_type(itemId, destination_pin, type, -1)
140
        finally:
140
        finally:
141
            close_session()
141
            close_session()
142
    
142
    
143
 
143
 
144
    def getLogisticsEstimationForStore(self, itemId, destination_pin, type):
144
    def getLogisticsEstimationForStore(self, itemId, destination_pin, type):
Line 148... Line 148...
148
         - destination_pin
148
         - destination_pin
149
         - type
149
         - type
150
        """
150
        """
151
        try:
151
        try:
152
            todate = datetime.datetime.now()
152
            todate = datetime.datetime.now()
153
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pin, type)
153
            logistics_info = self.get_logistics_estimation_with_type(itemId, destination_pin, type, -1)
154
            logistics_info.deliveryTime = to_java_date(todate +  datetime.timedelta(days = adjust_delivery_time(todate, logistics_info.deliveryTime)))
154
            logistics_info.deliveryTime = to_java_date(todate +  datetime.timedelta(days = adjust_delivery_time(todate, logistics_info.deliveryTime)))
155
            logistics_info.shippingTime = to_java_date(todate +  datetime.timedelta(days = adjust_delivery_time(todate, logistics_info.shippingTime)))
155
            logistics_info.shippingTime = to_java_date(todate +  datetime.timedelta(days = adjust_delivery_time(todate, logistics_info.shippingTime)))
156
            minAdvanceAmount, logistics_info.codAllowed = get_min_advance_amount(itemId, destination_pin, logistics_info.providerId, logistics_info.codAllowed)
156
            minAdvanceAmount, logistics_info.codAllowed = get_min_advance_amount(itemId, destination_pin, logistics_info.providerId, logistics_info.codAllowed)
157
            ## Send minadvanceamount in providerId field 
157
            ## Send minadvanceamount in providerId field 
158
            logistics_info.providerId = int(minAdvanceAmount)
158
            logistics_info.providerId = int(minAdvanceAmount)
159
            return logistics_info
159
            return logistics_info
160
        finally:
160
        finally:
161
            close_session()
161
            close_session()
162
            
162
            
163
    def get_logistics_estimation_with_type(self, itemId, destination_pin, type, pickUp=PickUpType.COURIER):
163
    def get_logistics_estimation_with_type(self, itemId, destination_pin, type, pickUp=PickUpType.COURIER, stateId):
164
        try:
164
        try:
165
            #Get the id and location of actual warehouse that'll be used to fulfil this order.
165
            #Get the id and location of actual warehouse that'll be used to fulfil this order.
166
            client = InventoryClient().get_client()
166
            client = InventoryClient().get_client()
167
            fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = client.getItemAvailabilityAtLocation(itemId, self.sourceId)
167
            fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = client.getItemAvailabilityAtLocation(itemId, self.sourceId, stateId)
168
            #We assume that if totalAvailability 0 then its the case of hotspot billing where itemAvailabilityCache is sort of bypassed
168
            #We assume that if totalAvailability 0 then its the case of hotspot billing where itemAvailabilityCache is sort of bypassed
169
            if totalAvailability <= 0:
169
            if totalAvailability <= 0:
170
                expected_delay = 0
170
                expected_delay = 0
171
                
171
                
172
        except Exception as ex:
172
        except Exception as ex:
Line 329... Line 329...
329
        
329
        
330
        estimateList = []
330
        estimateList = []
331
 
331
 
332
        for item in items:
332
        for item in items:
333
            try:
333
            try:
334
                estimationInfo = self.get_logistics_estimation_with_type(item.id, destination_pin, type)
334
                estimationInfo = self.get_logistics_estimation_with_type(item.id, destination_pin, type, -1)
335
            except Exception as ex:
335
            except Exception as ex:
336
                estimationInfo = LogisticsInfo()
336
                estimationInfo = LogisticsInfo()
337
                estimationInfo.deliveryTime = 0
337
                estimationInfo.deliveryTime = 0
338
            if item.itemStatus == status.ACTIVE:
338
            if item.itemStatus == status.ACTIVE:
339
                estimateList.append((0, estimationInfo.deliveryTime, "BUY NOW", item.id))
339
                estimateList.append((0, estimationInfo.deliveryTime, "BUY NOW", item.id))