Subversion Repositories SmartDukaan

Rev

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

Rev 4829 Rev 4866
Line 6... Line 6...
6
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo,\
6
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo,\
7
    LogisticsServiceException, DeliveryType
7
    LogisticsServiceException, DeliveryType
8
from shop2020.logistics.service.impl.DataAccessor import get_empty_AWB,\
8
from shop2020.logistics.service.impl.DataAccessor import get_empty_AWB,\
9
    get_shipment_info, initialize, get_logistics_estimation, get_provider,\
9
    get_shipment_info, initialize, get_logistics_estimation, get_provider,\
10
    get_providers, close_session, get_free_awb_count, get_holidays,\
10
    get_providers, close_session, get_free_awb_count, get_holidays,\
11
    is_cod_allowed, is_alive
11
    is_alive
12
from shop2020.logistics.service.impl.Converters import to_t_awbupdate,\
12
from shop2020.logistics.service.impl.Converters import to_t_awbupdate,\
13
    to_t_provider
13
    to_t_provider
14
from shop2020.clients.CatalogClient import CatalogClient
14
from shop2020.clients.CatalogClient import CatalogClient
15
from shop2020.config.client.ConfigClient import ConfigClient
15
from shop2020.config.client.ConfigClient import ConfigClient
16
import datetime
16
import datetime
Line 33... Line 33...
33
            print "[ERROR] Unexpected config error:", sys.exc_info()[0]
33
            print "[ERROR] Unexpected config error:", sys.exc_info()[0]
34
            self.cutoff_time = 15
34
            self.cutoff_time = 15
35
            self.cod_cutoff_time = 0
35
            self.cod_cutoff_time = 0
36
            self.stock_threshold = 2
36
            self.stock_threshold = 2
37
            self.time_to_procure = 48
37
            self.time_to_procure = 48
38
            self.default_pincode = "110001" 
38
            self.default_pincode = "110001"
39
        
-
 
40
        ##FIXME
-
 
41
        '''
-
 
42
        self.kanwaar_effected_pins_by_two_days = ['244713', '247667', '248001', '248002', '248003', '248005', '248006', 
-
 
43
                                             '248008', '248009', '248110', '248146', '248171', '248179', '249201', 
-
 
44
                                             '249401', '249403', '249404', '249407', '249408', '249409', '249410', 
-
 
45
                                             '249411', '262405', '263139', '263153']
-
 
46
        self.kanwaar_effected_pins_by_one_day = ['201001', '201002', '201003', '201004', '201005', '201007', '201009', 
-
 
47
                                            '201010', '201011', '201012', '201014', '201204', '202001', '202002', 
-
 
48
                                            '203001', '203131', '204101']
-
 
49
        '''
-
 
50
         
39
         
51
    def getProvider(self, providerId):
40
    def getProvider(self, providerId):
52
        """
41
        """
53
        Returns a provider for a given provider ID. Throws an exception if none found.
42
        Returns a provider for a given provider ID. Throws an exception if none found.
54
        
43
        
Line 182... Line 171...
182
        delivery_time = delivery_time + shipping_delay
171
        delivery_time = delivery_time + shipping_delay
183
        
172
        
184
        shipping_delay = int(math.ceil(shipping_delay/24.0))
173
        shipping_delay = int(math.ceil(shipping_delay/24.0))
185
        delivery_time = int(math.ceil(delivery_time/24.0))
174
        delivery_time = int(math.ceil(delivery_time/24.0))
186
        
175
        
187
        '''
-
 
188
        Delays such as the following are delivery delays and are to only affect the
-
 
189
        delivery time and not the shipping time.
-
 
190
        '''
-
 
191
        '''
-
 
192
        ## 
-
 
193
        ## FIXME Due to Kanwaar on the Delhi-Dehradun route, deliveries to the following
-
 
194
        pin codes will be affected:
-
 
195
        ## Changing as per ticket number #462
-
 
196
        if destination_pin in self.kanwaar_effected_pins_by_two_days:
-
 
197
            delivery_time += 2
-
 
198
        elif destination_pin in self.kanwaar_effected_pins_by_one_day:
-
 
199
            delivery_time += 1
-
 
200
        ## FIXME Remove the above code once Kanwaar season is over
-
 
201
        '''
-
 
202
        
-
 
203
        logistics_info = LogisticsInfo()
176
        logistics_info = LogisticsInfo()
204
        logistics_info.deliveryTime = delivery_time
177
        logistics_info.deliveryTime = delivery_time
205
        logistics_info.providerId = delivery_estimate.provider_id
178
        logistics_info.providerId = delivery_estimate.provider_id
206
        logistics_info.warehouseId = warehouse_id
179
        logistics_info.warehouseId = warehouse_id
207
        logistics_info.shippingTime = shipping_delay
180
        logistics_info.shippingTime = shipping_delay
-
 
181
        logistics_info.codAllowed = codAllowed 
208
        
182
        
209
        return logistics_info
183
        return logistics_info
210
        
184
        
211
    def getDestinationCode(self, providerId, pinCode):
185
    def getDestinationCode(self, providerId, pinCode):
212
        """
186
        """
Line 253... Line 227...
253
        try:
227
        try:
254
            return get_holidays(fromDate, toDate)
228
            return get_holidays(fromDate, toDate)
255
        finally:
229
        finally:
256
            close_session()
230
            close_session()
257
    
231
    
258
    def isCodAllowed(self, destination_pincode):
-
 
259
        """
-
 
260
        Returns true if COD is allowed for this destination pincode
-
 
261
        
-
 
262
        Parameters:
-
 
263
         - destination_pincode
-
 
264
        """
-
 
265
        try:
-
 
266
            return is_cod_allowed(destination_pincode)
-
 
267
        finally:
-
 
268
            close_session()
-
 
269
            
-
 
270
    def closeSession(self, ):
232
    def closeSession(self, ):
271
        close_session()
233
        close_session()
272
 
234
 
273
    def isAlive(self, ):
235
    def isAlive(self, ):
274
        """
236
        """