| Line 103... |
Line 103... |
| 103 |
continue
|
103 |
continue
|
| 104 |
if amount != refundAmount:
|
104 |
if amount != refundAmount:
|
| 105 |
print "Refund amount is not same as transaction amount"
|
105 |
print "Refund amount is not same as transaction amount"
|
| 106 |
continue
|
106 |
continue
|
| 107 |
if isStoreOrder:
|
107 |
if isStoreOrder:
|
| 108 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, refundDate)
|
108 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)
|
| 109 |
else:
|
109 |
else:
|
| 110 |
update_recharge_order_status(order.id, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, refundDate)
|
110 |
update_recharge_order_status(order.id, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, refundDate)
|
| 111 |
|
111 |
|
| 112 |
def processUnknownTransactions():
|
112 |
def processUnknownTransactions():
|
| 113 |
orders = get_recharge_orders_for_status(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
113 |
orders = get_recharge_orders_for_status(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
| Line 131... |
Line 131... |
| 131 |
status, description = checkTransactionStatus('', str(order.id))
|
131 |
status, description = checkTransactionStatus('', str(order.id))
|
| 132 |
print status, description
|
132 |
print status, description
|
| 133 |
if status:
|
133 |
if status:
|
| 134 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_SUCCESSFUL)
|
134 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_SUCCESSFUL)
|
| 135 |
else:
|
135 |
else:
|
| 136 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_FAILED)
|
136 |
update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)
|
| 137 |
except:
|
137 |
except:
|
| 138 |
print "Do Nothing"
|
138 |
print "Do Nothing"
|
| 139 |
|
139 |
|
| 140 |
|
140 |
|
| 141 |
def processAuthorizedTransactions(txn_id):
|
141 |
def processAuthorizedTransactions(txn_id):
|
| Line 143... |
Line 143... |
| 143 |
|
143 |
|
| 144 |
|
144 |
|
| 145 |
def compute_recharge_collection(cdate):
|
145 |
def compute_recharge_collection(cdate):
|
| 146 |
todate = datetime.datetime(cdate.year, cdate.month, cdate.day)
|
146 |
todate = datetime.datetime(cdate.year, cdate.month, cdate.day)
|
| 147 |
tomorrow = todate + timedelta(days=1)
|
147 |
tomorrow = todate + timedelta(days=1)
|
| 148 |
txns = session.query(RechargeTransaction.storeId, RechargeTransaction.payMethod, RechargeTransaction.status, func.sum(RechargeTransaction.amount), func.sum(RechargeTransaction.discount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED])).filter(RechargeTransaction.transactionTime >= todate).filter(RechargeTransaction.transactionTime < tomorrow).group_by(RechargeTransaction.storeId, RechargeTransaction.payMethod, RechargeTransaction.status).order_by(RechargeTransaction.storeId).all()
|
148 |
txns = session.query(RechargeTransaction.storeId, RechargeTransaction.payMethod, RechargeTransaction.status, func.sum(RechargeTransaction.amount), func.sum(RechargeTransaction.discount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.RECHARGE_UNKNOWN])).filter(RechargeTransaction.transactionTime >= todate).filter(RechargeTransaction.transactionTime < tomorrow).group_by(RechargeTransaction.storeId, RechargeTransaction.payMethod, RechargeTransaction.status).order_by(RechargeTransaction.storeId).all()
|
| 149 |
storeData = {}
|
149 |
storeData = {}
|
| 150 |
for txn in txns:
|
150 |
for txn in txns:
|
| 151 |
print txn
|
151 |
print txn
|
| 152 |
if not storeData.has_key(txn[0]):
|
152 |
if not storeData.has_key(txn[0]):
|
| 153 |
data = [0,0,0,0,0]
|
153 |
data = [0,0,0,0,0]
|
| Line 156... |
Line 156... |
| 156 |
data = storeData[txn[0]]
|
156 |
data = storeData[txn[0]]
|
| 157 |
if txn[1] == 1:
|
157 |
if txn[1] == 1:
|
| 158 |
data[0] += int(txn[3]) - int(txn[4])
|
158 |
data[0] += int(txn[3]) - int(txn[4])
|
| 159 |
if txn[1] == 2:
|
159 |
if txn[1] == 2:
|
| 160 |
data[1] += int(txn[3]) - int(txn[4])
|
160 |
data[1] += int(txn[3]) - int(txn[4])
|
| 161 |
if txn[2] in (RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED):
|
161 |
if txn[2] in (RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.RECHARGE_UNKNOWN):
|
| 162 |
data[2] += int(txn[3])
|
162 |
data[2] += int(txn[3])
|
| 163 |
data[3] += int(txn[4])
|
163 |
data[3] += int(txn[4])
|
| 164 |
data[4] += int(txn[3]) - int(txn[4])
|
164 |
data[4] += int(txn[3]) - int(txn[4])
|
| 165 |
storeData[txn[0]] = data
|
165 |
storeData[txn[0]] = data
|
| 166 |
|
166 |
|