Subversion Repositories SmartDukaan

Rev

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

Rev 1248 Rev 1504
Line 102... Line 102...
102
         - destination_pin
102
         - destination_pin
103
        """
103
        """
104
        try:
104
        try:
105
            if not destination_pin:
105
            if not destination_pin:
106
                destination_pin = self.default_pincode
106
                destination_pin = self.default_pincode
-
 
107
            try:
-
 
108
                client = InventoryClient().get_client()
-
 
109
                item = client.getItem(itemId)
-
 
110
            except Exception as ex:
-
 
111
                raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
107
            delivery_estimate = get_logistics_estimation(destination_pin)
112
            delivery_estimate = get_logistics_estimation(destination_pin, item.sellingPrice)
108
            if delivery_estimate is None:
113
            if delivery_estimate is None:
109
                raise LogisticsServiceException(103, "Unable to fetch delivery estimate for this pincode.")
114
                raise LogisticsServiceException(103, "Unable to fetch delivery estimate for this pincode.")
110
            delivery_time = 24*delivery_estimate.delivery_time
115
            delivery_time = 24*delivery_estimate.delivery_time
111
            if self.cutoff_time <= datetime.datetime.now().hour:
116
            if self.cutoff_time <= datetime.datetime.now().hour:
112
                delivery_time = delivery_time + 24
117
                delivery_time = delivery_time + 24
113
            warehouse_loc = delivery_estimate.warehouse_location
118
            warehouse_loc = delivery_estimate.warehouse_location
114
            try:
119
            try:
115
                client = InventoryClient().get_client()
-
 
116
                warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(warehouse_loc, itemId)
120
                warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(warehouse_loc, itemId)
117
            except:
121
            except Exception as ex:
118
                raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.") 
122
                raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.") 
119
            if items_in_inventory < self.stock_threshold :
123
            if items_in_inventory < self.stock_threshold :
120
                delivery_time = delivery_time + self.time_to_producre
124
                delivery_time = delivery_time + self.time_to_producre
121
            delivery_time = int(math.ceil(delivery_time/24.0))
125
            delivery_time = int(math.ceil(delivery_time/24.0))
122
            
126