Subversion Repositories SmartDukaan

Rev

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

Rev 483 Rev 494
Line 8... Line 8...
8
    get_provider, get_shipment_info, get_shipments, get_todays_shipments, initialize,\
8
    get_provider, get_shipment_info, get_shipments, get_todays_shipments, initialize,\
9
    get_providers, create_shipment, update_shipment_status, get_logistics_estimation, add_delivery_estimate,\
9
    get_providers, create_shipment, update_shipment_status, get_logistics_estimation, add_delivery_estimate,\
10
    add_pincode_warehouse_mapping, get_logistics_info
10
    add_pincode_warehouse_mapping, get_logistics_info
11
from shop2020.logistics.service.impl.Converters import to_t_provider,\
11
from shop2020.logistics.service.impl.Converters import to_t_provider,\
12
    to_t_shipment, to_t_shipmentstatusinfo, to_t_shipmentupdate, to_t_itemLogistics
12
    to_t_shipment, to_t_shipmentstatusinfo, to_t_shipmentupdate, to_t_itemLogistics
13
 
-
 
-
 
13
from shop2020.clients.InventoryClient import InventoryClient
-
 
14
from shop2020.config.client.ConfigClient import ConfigClient
14
from shop2020.utils.Utils import log_entry, to_py_date
15
from shop2020.utils.Utils import log_entry, to_py_date
-
 
16
import datetime
-
 
17
import time
-
 
18
 
15
 
19
 
16
class LogisticsServiceHandler:
20
class LogisticsServiceHandler:
17
    
21
    
18
    def __init__(self):
22
    def __init__(self):
19
        initialize()
23
        initialize()
Line 117... Line 121...
117
        Parameters:
121
        Parameters:
118
         - itemId
122
         - itemId
119
         - destination_pin
123
         - destination_pin
120
        """
124
        """
121
        
125
        
-
 
126
        inventory_client = InventoryClient()
-
 
127
        inventory_client.__start__()
-
 
128
        client = inventory_client.get_client()
-
 
129
        config_client = ConfigClient()
-
 
130
        
-
 
131
        cutoff_time = int(config_client.get_property('delivery_cutoff_time'))
-
 
132
        stock_threshold = int(config_client.get_property('inventory_stock_threshold'))
-
 
133
        
-
 
134
        
122
        delivery_estimate, warehouse_id = get_logistics_estimation(itemId, destination_pin, provider_id)
135
        delivery_estimate, warehouse_id = get_logistics_estimation(itemId, destination_pin, provider_id)
-
 
136
        delivery_time = delivery_estimate.delivery_time
-
 
137
        
-
 
138
        items_in_inventory = client.getItemAvailibilityAtWarehouse(warehouse_id, itemId)
-
 
139
        now = datetime.datetime.now()
-
 
140
        print now.hour
-
 
141
        if cutoff_time < now.hour:
-
 
142
            delivery_time = delivery_time + 24
123
        items_in_inventory = 100
143
        if items_in_inventory < stock_threshold :
-
 
144
            time_to_procure = int(config_client.get_property('inventory_time_to_procure'))
-
 
145
            delivery_time = delivery_time + time_to_procure
-
 
146
 
124
        return to_t_itemLogistics(delivery_estimate, items_in_inventory, warehouse_id)
147
        return to_t_itemLogistics(delivery_time, items_in_inventory, warehouse_id)
125
 
148
 
126
    def addDeliveryEstimate(self, warahouse_id, destination_pin, provider_id, delivery_time, reliability):
149
    def addDeliveryEstimate(self, warahouse_id, destination_pin, provider_id, delivery_time, reliability):
127
        """
150
        """
128
        Parameters:
151
        Parameters:
129
         - warahouse_id
152
         - warahouse_id