Subversion Repositories SmartDukaan

Rev

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

Rev 22452 Rev 22461
Line 26... Line 26...
26
import json
26
import json
27
import math
27
import math
28
import traceback
28
import traceback
29
 
29
 
30
 
30
 
31
#user_item_pricing_map = {175115644: {
-
 
32
#                                     26868:4495
-
 
33
#                                     }
-
 
34
#                         }
-
 
35
 
31
 
36
user_item_pricing_map = {}
-
 
37
 
32
 
38
def get_cart(userId):
33
def get_cart(userId):
39
    user = User.get_by(id=userId)
34
    user = User.get_by(id=userId)
40
    return user.active_cart
35
    return user.active_cart
41
 
36
 
Line 920... Line 915...
920
    
915
    
921
    for line in cart_lines:
916
    for line in cart_lines:
922
        itemQuantityChanged=False
917
        itemQuantityChanged=False
923
        cartItem={}
918
        cartItem={}
924
        tempBulkItemList = []
919
        tempBulkItemList = []
925
        user_item_pricing = user_item_pricing_map.get(user.id)
-
 
926
        
920
        
927
        old_estimate = line.estimate
921
        old_estimate = line.estimate
928
        item_id = line.item_id
922
        item_id = line.item_id
929
        item = itemsMap.get(item_id)
923
        item = itemsMap.get(item_id)
930
        #in case item is missing remove that line
924
        #in case item is missing remove that line
Line 946... Line 940...
946
        item_shipping_info = catalog_client.isActive(item_id) 
940
        item_shipping_info = catalog_client.isActive(item_id) 
947
        if item_shipping_info.isActive:
941
        if item_shipping_info.isActive:
948
            if item_shipping_info.isRisky and item_shipping_info.quantity < line.quantity:
942
            if item_shipping_info.isRisky and item_shipping_info.quantity < line.quantity:
949
                line.quantity = item_shipping_info.quantity
943
                line.quantity = item_shipping_info.quantity
950
                itemQuantityChanged=True
944
                itemQuantityChanged=True
951
            if user_item_pricing and user_item_pricing.has_key(item_id):
-
 
952
                cartItem['maxQuantity'] = min(250,item_shipping_info.quantity)
-
 
953
            else:
-
 
954
                cartItem['maxQuantity'] = min(item_shipping_info.quantity,100)
945
            cartItem['maxQuantity'] = min(item_shipping_info.quantity,100)
955
                if item.maximumBuyQuantity is not None and item.maximumBuyQuantity >0:
946
            if item.maximumBuyQuantity is not None and item.maximumBuyQuantity >0:
956
                    cartItem['maxQuantity'] = min(item_shipping_info.quantity, item.maximumBuyQuantity)
947
                cartItem['maxQuantity'] = min(item_shipping_info.quantity, item.maximumBuyQuantity)
957
        else:
948
        else:
958
            cartItem['maxQuantity'] =0
949
            cartItem['maxQuantity'] =0
959
            
950
            
960
        
951
        
961
        if item_shipping_info.quantity < cartItem['minBuyQuantity']:
952
        if item_shipping_info.quantity < cartItem['minBuyQuantity']:
Line 971... Line 962...
971
        
962
        
972
        cartItem['quantity'] = line.quantity
963
        cartItem['quantity'] = line.quantity
973
        
964
        
974
        bulkPrice = None
965
        bulkPrice = None
975
        singleUnitPricing = False
966
        singleUnitPricing = False
976
        if item_id in bulkPricingItems and not (user_item_pricing and user_item_pricing.has_key(item_id)):
967
        if item_id in bulkPricingItems:
977
            #Check quantity qualifies or not
968
            #Check quantity qualifies or not
978
            bulkPricingList = bulkPricingMap.get(item_id)
969
            bulkPricingList = bulkPricingMap.get(item_id)
979
            bulkPricingList = sorted(bulkPricingList, key=lambda x: x.quantity, reverse=False)
970
            bulkPricingList = sorted(bulkPricingList, key=lambda x: x.quantity, reverse=False)
980
            for pricingItems in bulkPricingList:
971
            for pricingItems in bulkPricingList:
981
                if pricingItems.quantity ==1:
972
                if pricingItems.quantity ==1:
Line 983... Line 974...
983
                if pricingItems.quantity <= line.quantity:
974
                if pricingItems.quantity <= line.quantity:
984
                    bulkPrice = pricingItems
975
                    bulkPrice = pricingItems
985
                tempBulkItemList.append({'quantity':pricingItems.quantity,'price':pricingItems.price})
976
                tempBulkItemList.append({'quantity':pricingItems.quantity,'price':pricingItems.price})
986
            
977
            
987
        if item_id in dealItems:
978
        if item_id in dealItems:
988
            if not singleUnitPricing and item_id in bulkPricingItems and not (user_item_pricing and user_item_pricing.has_key(item_id)):
979
            if not singleUnitPricing and item_id in bulkPricingItems:
989
                tempBulkItemList.append({'quantity':1,'price':deals[item_id].dealPrice})
980
                tempBulkItemList.append({'quantity':1,'price':deals[item_id].dealPrice})
990
            if bulkPrice is None:
981
            if bulkPrice is None:
991
                line.actual_price = deals[item_id].dealPrice
982
                line.actual_price = deals[item_id].dealPrice
992
                if user_item_pricing and user_item_pricing.has_key(item_id):
-
 
993
                    line.actual_price = user_item_pricing.get(item_id)
-
 
994
 
-
 
995
            else:
983
            else:
996
                line.actual_price = bulkPrice.price
984
                line.actual_price = bulkPrice.price
997
            if deals[item_id].dealTextOption==0:
985
            if deals[item_id].dealTextOption==0:
998
                line.dealText = ''
986
                line.dealText = ''
999
            if deals[item_id].dealTextOption==2:
987
            if deals[item_id].dealTextOption==2: