Subversion Repositories SmartDukaan

Rev

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

Rev 22392 Rev 22452
Line 27... Line 27...
27
import math
27
import math
28
import traceback
28
import traceback
29
 
29
 
30
 
30
 
31
#user_item_pricing_map = {175115644: {
31
#user_item_pricing_map = {175115644: {
32
#                                     26566:3003
32
#                                     26868:4495
33
#                                     }
33
#                                     }
34
#                         }
34
#                         }
35
 
35
 
36
user_item_pricing_map = {}
36
user_item_pricing_map = {}
37
 
37
 
Line 1185... Line 1185...
1185
        raise ShoppingCartException(102, "The specified cart couldn't be found")
1185
        raise ShoppingCartException(102, "The specified cart couldn't be found")
1186
    if wallet_amount < 0:
1186
    if wallet_amount < 0:
1187
        raise ShoppingCartException(103, "Wallet amount is negative")
1187
        raise ShoppingCartException(103, "Wallet amount is negative")
1188
    cart.wallet_amount = wallet_amount
1188
    cart.wallet_amount = wallet_amount
1189
    session.commit()
1189
    session.commit()
1190
    return True
-
 
1191
1190
    return True
-
 
1191
 
-
 
1192
 
-
 
1193
def add_item_pricing_to_cart(cartId, itemQtyPriceList):
-
 
1194
    try: 
-
 
1195
        found_cart = Cart.get_by(id=cartId)
-
 
1196
 
-
 
1197
        #Get prices to validate should not be less than mop
-
 
1198
        current_time = datetime.datetime.now()
-
 
1199
            
-
 
1200
        if found_cart.lines:
-
 
1201
            for line in found_cart.lines:
-
 
1202
                Discount.query.filter(Discount.line==line).delete()
-
 
1203
                line.delete()
-
 
1204
        for itemQtyPrice in itemQtyPriceList:
-
 
1205
            #This condition will ensure that cart is only persisted with non-zero quantities.
-
 
1206
            if itemQtyPrice.qty==0:
-
 
1207
                continue
-
 
1208
            line = Line()
-
 
1209
            line.cart = found_cart
-
 
1210
            print "itemQtyPrice.itemId-------", itemQtyPrice.itemId
-
 
1211
            line.item_id = itemQtyPrice.itemId
-
 
1212
            line.quantity = itemQtyPrice.qty
-
 
1213
            line.created_on = current_time
-
 
1214
            line.updated_on = current_time
-
 
1215
            line.line_status = LineStatus.LINE_ACTIVE
-
 
1216
            line.insurer = 0
-
 
1217
            line.insuranceAmount = 0
-
 
1218
            line.actual_price = itemQtyPrice.price
-
 
1219
        found_cart.coupon_code = None
-
 
1220
        session.commit()
-
 
1221
        return True
-
 
1222
    
-
 
1223
    except:
-
 
1224
        traceback.print_exc()
-
 
1225
        return False
-
 
1226
1192
1227