Subversion Repositories SmartDukaan

Rev

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

Rev 7155 Rev 7163
Line 11... Line 11...
11
from datetime import timedelta
11
from datetime import timedelta
12
from elixir import *
12
from elixir import *
13
from sqlalchemy.sql import func
13
from sqlalchemy.sql import func
14
import urllib
14
import urllib
15
import httplib
15
import httplib
-
 
16
from shop2020.utils.EmailAttachmentSender import mail
16
 
17
 
17
 
18
 
18
 
19
 
19
if __name__ == '__main__' and __package__ is None:
20
if __name__ == '__main__' and __package__ is None:
20
    import os
21
    import os
Line 117... Line 118...
117
                else:
118
                else:
118
                    update_recharge_order_status(order.id, RechargeOrderStatus.RECHARGE_FAILED)
119
                    update_recharge_order_status(order.id, RechargeOrderStatus.RECHARGE_FAILED)
119
        except:
120
        except:
120
            print "Do Nothing"
121
            print "Do Nothing"
121
 
122
 
-
 
123
    ## For store transactions
-
 
124
    orders = RechargeTransaction.get_by(status = RechargeOrderStatus.RECHARGE_UNKNOWN)
-
 
125
    for order in orders:
-
 
126
        try:
-
 
127
            if order.transactionTime + datetime.timedelta(minutes=10) < datetime.datetime.now():
-
 
128
                status, description = checkTransactionStatus('', str(order.id))
-
 
129
                print status, description
-
 
130
                if status:
-
 
131
                    update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_SUCCESSFUL)
-
 
132
                else:
-
 
133
                    update_recharge_transaction_status(order.id, RechargeOrderStatus.RECHARGE_FAILED)
-
 
134
        except:
-
 
135
            print "Do Nothing"
-
 
136
 
-
 
137
 
122
def processAuthorizedTransactions(txn_id):
138
def processAuthorizedTransactions(txn_id):
123
    update_recharge_order_status(txn_id, RechargeOrderStatus.PAYMENT_SUCCESSFUL)
139
    update_recharge_order_status(txn_id, RechargeOrderStatus.PAYMENT_SUCCESSFUL)
124
                
140
                
125
 
141
 
126
def compute_recharge_collection(cdate):
142
def compute_recharge_collection(cdate):
Line 161... Line 177...
161
        data[3] -= int(txn[4])
177
        data[3] -= int(txn[4])
162
        data[4] -= int(txn[3]) - int(txn[4])
178
        data[4] -= int(txn[3]) - int(txn[4])
163
    print storeData
179
    print storeData
164
        
180
        
165
    push_recharge_collection_to_ocr(storeData, todate)
181
    push_recharge_collection_to_ocr(storeData, todate)
-
 
182
    
166
        
183
    dt = session.query(func.sum(RechargeTransaction.amount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL])).filter(RechargeTransaction.transactionTime >= todate).filter(RechargeTransaction.transactionTime < tomorrow).one()
-
 
184
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 1).one()
-
 
185
    if int(dt[0]) != wallet.amount:
-
 
186
        mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in"], "Wallet amount: " + wallet.amount + " does not match with transaction amount: " + str(int(dt[0])) , "", [], [], [])    
-
 
187
             
167
def push_recharge_collection_to_ocr(storeData, todate):
188
def push_recharge_collection_to_ocr(storeData, todate):
168
    
189
    
169
    for storeId in storeData.keys():
190
    for storeId in storeData.keys():
170
        store = HotspotStore.get_by(id = storeId)
191
        store = HotspotStore.get_by(id = storeId)
171
        store.collectedAmount = 0
192
        store.collectedAmount = 0
Line 223... Line 244...
223
    wh.referenceNumber =  get_next_invoice_number(5)
244
    wh.referenceNumber =  get_next_invoice_number(5)
224
    wh.description = "Wallet Credited"
245
    wh.description = "Wallet Credited"
225
    
246
    
226
    wallet.amount += amount
247
    wallet.amount += amount
227
    session.commit()
248
    session.commit()
-
 
249
    mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "rajneesh.arora@shop2020.in"], "Wallet topped up by " +  amount + "rupees.", "", [], [], [])
228
    
250
    
229
if __name__ == '__main__':
251
if __name__ == '__main__':
230
    main()
252
    main()
231
253