| Line 77... |
Line 77... |
| 77 |
return {0:'This coupon has expired'}
|
77 |
return {0:'This coupon has expired'}
|
| 78 |
|
78 |
|
| 79 |
if 'minDiscountableVal' in args and total_amount < int(args['minDiscountableVal']):
|
79 |
if 'minDiscountableVal' in args and total_amount < int(args['minDiscountableVal']):
|
| 80 |
return {0:'This coupon is valid for purchases equal to or more than Rs.' + (args['minDiscountableVal'])}
|
80 |
return {0:'This coupon is valid for purchases equal to or more than Rs.' + (args['minDiscountableVal'])}
|
| 81 |
|
81 |
|
| 82 |
if 'couponType' not in args or args['couponType'] != 'recharge' or args['couponType'] != 'both':
|
82 |
if 'couponType' not in args or args['couponType'] not in ('recharge','both'):
|
| 83 |
return {0:'Invalid Coupon'}
|
83 |
return {0:'Invalid Coupon'}
|
| 84 |
|
84 |
|
| 85 |
if args['emails'] != '*':
|
85 |
if args['emails'] != '*':
|
| 86 |
user_client = UserClient().get_client()
|
86 |
user_client = UserClient().get_client()
|
| 87 |
user = user_client.getUserById(user_id)
|
87 |
user = user_client.getUserById(user_id)
|
| 88 |
if not (user.email in args['emails']):
|
88 |
if user.email not in args['emails']:
|
| 89 |
return {0:'Invalid coupon'}
|
89 |
return {0:'Invalid coupon'}
|
| 90 |
|
90 |
|
| 91 |
if 'startHour' in args and 'startMinute' in args and 'endHour' in args and 'endMinute' in args :
|
91 |
if 'startHour' in args and 'startMinute' in args and 'endHour' in args and 'endMinute' in args :
|
| 92 |
startHour = int(args['startHour'])
|
92 |
startHour = int(args['startHour'])
|
| 93 |
startMinute = int(args['startMinute'])
|
93 |
startMinute = int(args['startMinute'])
|
| Line 116... |
Line 116... |
| 116 |
return {0:'This promotion is over.'}
|
116 |
return {0:'This promotion is over.'}
|
| 117 |
|
117 |
|
| 118 |
if 'discountType' in args:
|
118 |
if 'discountType' in args:
|
| 119 |
discountType = args['discountType']
|
119 |
discountType = args['discountType']
|
| 120 |
if discountType == 'percent' :
|
120 |
if discountType == 'percent' :
|
| 121 |
discount = round(total_amount * (args['discount']/100))
|
121 |
discount = round(total_amount * (args['discount']/float(100)))
|
| 122 |
if discountType == 'absolute' :
|
122 |
elif discountType == 'absolute' :
|
| 123 |
discount = min(args['discount'], total_amount)
|
123 |
discount = min(args['discount'], total_amount)
|
| 124 |
else :
|
124 |
else :
|
| 125 |
return {0 : 'Invalid coupon'}
|
125 |
return {0 : 'Invalid coupon'}
|
| 126 |
|
126 |
|
| 127 |
if 'maxDiscount' in args and discount > int(args['maxDiscount']):
|
127 |
if 'maxDiscount' in args and discount > int(args['maxDiscount']):
|