Rev 5501 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 27-June-2012@author: Varun GuptaSamsung Galaxy Ace S5830i Rs.401 offSamsung Galaxy Ace Duos S6802 Rs.401 offHTC One V T320e Rs.512 offHTC Desire C A320e Rs.762 off'''from shop2020.thriftpy.model.v1.user.ttypes import PromotionExceptionfrom shop2020.thriftpy.model.v1.user.ttypes import Discountdef execute(cart, coupon_code, args):discounts = []if cart.lines:total_selling_price = 0total_discounted_price = 0has_qualified_model = Falsefor line in cart.lines:line.discountedPrice = line.actualPricediscount_value = 0if line.itemId in (6829, 7243, 7298): #Samsung Galaxy Ace Duos S6802 & Galaxy Ace S5830ihas_qualified_model = Trueif line.actualPrice:line.discountedPrice = round(line.actualPrice - 401)discount_value = 401elif line.itemId == 4645: #HTC One V T320ehas_qualified_model = Trueif line.actualPrice:line.discountedPrice = round(line.actualPrice - 512)discount_value = 512elif line.itemId in (6747, 7127): #HTC Desire C A320ehas_qualified_model = Trueif line.actualPrice:line.discountedPrice = round(line.actualPrice - 762)discount_value = 762total_selling_price += line.actualPrice * line.quantitytotal_discounted_price += line.discountedPrice * line.quantityif discount_value > 0:discount = Discount()discount.cart_id = cart.iddiscount.item_id = line.itemIddiscount.discount = discount_valuediscount.quantity = line.quantitydiscounts.append(discount)if has_qualified_model is False:raise PromotionException(115, 'This coupon is applicable only for selective handsets.')cart.totalPrice = total_selling_pricecart.discountedPrice = total_discounted_pricereturn cart, discountsdef getDiscountOnItem(item):return None