| Line 1... |
Line 1... |
| 1 |
from datetime import datetime
|
1 |
from datetime import datetime, timedelta
|
| 2 |
from dtr.storage.DataService import user_app_cashbacks
|
2 |
from dtr.storage.DataService import user_app_cashbacks
|
| 3 |
import sys
|
3 |
import sys
|
| 4 |
import traceback
|
4 |
import traceback
|
| 5 |
import getopt
|
5 |
import getopt
|
| 6 |
from dtr.main import tprint, refundToWallet
|
6 |
from dtr.main import tprint, refundToWallet
|
| Line 29... |
Line 29... |
| 29 |
print 'Live Run:- Amount will be credited in the specific users'
|
29 |
print 'Live Run:- Amount will be credited in the specific users'
|
| 30 |
currentTimestamp = datetime.today()
|
30 |
currentTimestamp = datetime.today()
|
| 31 |
currentMonth = currentTimestamp.month
|
31 |
currentMonth = currentTimestamp.month
|
| 32 |
currentDay = currentTimestamp.day
|
32 |
currentDay = currentTimestamp.day
|
| 33 |
currentYear = currentTimestamp.year
|
33 |
currentYear = currentTimestamp.year
|
| - |
|
34 |
sevenDaysBeforeTimestamp = datetime.today() - timedelta(days=7)
|
| - |
|
35 |
sevenDaysBeforeYear = sevenDaysBeforeTimestamp.year
|
| - |
|
36 |
if currentYear > sevenDaysBeforeYear:
|
| - |
|
37 |
currentMonth = sevenDaysBeforeTimestamp.month
|
| - |
|
38 |
currentDay = sevenDaysBeforeTimestamp.day
|
| - |
|
39 |
currentYear = sevenDaysBeforeYear
|
| - |
|
40 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)+1
|
| - |
|
41 |
else:
|
| 34 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)
|
42 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)
|
| - |
|
43 |
|
| - |
|
44 |
print "FortNight: ", fortNight, "Year: ", currentYear
|
| 35 |
|
45 |
|
| 36 |
userCashbacksToBeCredited = user_app_cashbacks.query.filter(user_app_cashbacks.user_id>0).filter(user_app_cashbacks.status=='Approved').filter(user_app_cashbacks.fortnightOfYear<fortNight).filter(user_app_cashbacks.yearVal==currentYear).all()
|
46 |
userCashbacksToBeCredited = user_app_cashbacks.query.filter(user_app_cashbacks.user_id>0).filter(user_app_cashbacks.status=='Approved').filter(user_app_cashbacks.fortnightOfYear<fortNight).filter(user_app_cashbacks.yearVal==currentYear).all()
|
| 37 |
userCashbacksMap = {}
|
47 |
userCashbacksMap = {}
|
| 38 |
for userCashback in userCashbacksToBeCredited:
|
48 |
for userCashback in userCashbacksToBeCredited:
|
| 39 |
if userCashback.user_id >0:
|
49 |
if userCashback.user_id >0:
|
| Line 61... |
Line 71... |
| 61 |
print 'Dry Run:- Only showing user map for which cashback have been updated'
|
71 |
print 'Dry Run:- Only showing user map for which cashback have been updated'
|
| 62 |
currentTimestamp = datetime.today()
|
72 |
currentTimestamp = datetime.today()
|
| 63 |
currentMonth = currentTimestamp.month
|
73 |
currentMonth = currentTimestamp.month
|
| 64 |
currentDay = currentTimestamp.day
|
74 |
currentDay = currentTimestamp.day
|
| 65 |
currentYear = currentTimestamp.year
|
75 |
currentYear = currentTimestamp.year
|
| - |
|
76 |
sevenDaysBeforeTimestamp = datetime.today() - timedelta(days=7)
|
| - |
|
77 |
sevenDaysBeforeYear = sevenDaysBeforeTimestamp.year
|
| - |
|
78 |
if currentYear > sevenDaysBeforeYear:
|
| - |
|
79 |
currentMonth = sevenDaysBeforeTimestamp.month
|
| - |
|
80 |
currentDay = sevenDaysBeforeTimestamp.day
|
| - |
|
81 |
currentYear = sevenDaysBeforeYear
|
| - |
|
82 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)+1
|
| - |
|
83 |
else:
|
| 66 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)
|
84 |
fortNight = (currentMonth - 1)*2 + (currentDay/15)
|
| - |
|
85 |
|
| - |
|
86 |
print "FortNight: ", fortNight, "Year: ", currentYear
|
| 67 |
|
87 |
|
| 68 |
userCashbacksToBeCredited = user_app_cashbacks.query.filter(user_app_cashbacks.user_id>0).filter(user_app_cashbacks.status=='Approved').filter(user_app_cashbacks.fortnightOfYear<fortNight).filter(user_app_cashbacks.yearVal==currentYear).all()
|
88 |
userCashbacksToBeCredited = user_app_cashbacks.query.filter(user_app_cashbacks.user_id>0).filter(user_app_cashbacks.status=='Approved').filter(user_app_cashbacks.fortnightOfYear<fortNight).filter(user_app_cashbacks.yearVal==currentYear).all()
|
| 69 |
userCashbacksMap = {}
|
89 |
userCashbacksMap = {}
|
| 70 |
for userCashback in userCashbacksToBeCredited:
|
90 |
for userCashback in userCashbacksToBeCredited:
|
| 71 |
if userCashback.user_id >0:
|
91 |
if userCashback.user_id >0:
|