Subversion Repositories SmartDukaan

Rev

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

Rev 7821 Rev 7823
Line 296... Line 296...
296
 
296
 
297
def compute_website_recharge_collection(cdate):
297
def compute_website_recharge_collection(cdate):
298
    todate = datetime.datetime(cdate.year, cdate.month, cdate.day)
298
    todate = datetime.datetime(cdate.year, cdate.month, cdate.day)
299
    tomorrow = todate + timedelta(days=1)
299
    tomorrow = todate + timedelta(days=1)
300
    
300
    
301
    txns = session.query(RechargeOrder.status, func.sum(RechargeOrder.totalAmount)).filter(RechargeOrder.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.PAYMENT_SUCCESSFUL])).filter(RechargeOrder.creationTimestamp >= todate).filter(RechargeOrder.creationTimestamp < tomorrow).group_by(RechargeTransaction.status).all()
301
    txns = session.query(RechargeOrder.status, func.sum(RechargeOrder.totalAmount)).filter(RechargeOrder.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.PAYMENT_SUCCESSFUL])).filter(RechargeOrder.creationTimestamp >= todate).filter(RechargeOrder.creationTimestamp < tomorrow).group_by(RechargeOrder.status).all()
302
    
302
    
303
    tamount = 0
303
    tamount = 0
304
    for txn in txns:
304
    for txn in txns:
305
        tamount += int(txn[1])
305
        tamount += int(txn[1])
306
        
306
        
307
  
307
  
308
    reftxns = session.query(RechargeOrder.status, func.sum(RechargeOrder.totalAmount)).filter(RechargeOrder.status == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED).filter(RechargeOrder.refundTimestamp >= todate).filter(RechargeOrder.refundTimestamp < tomorrow).group_by(RechargeTransaction.status).all()  
308
    reftxns = session.query(RechargeOrder.status, func.sum(RechargeOrder.totalAmount)).filter(RechargeOrder.status == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED).filter(RechargeOrder.responseTimestamp >= todate).filter(RechargeOrder.responseTimestamp < tomorrow).group_by(RechargeOrder.status).all()  
309
    for txn in reftxns:
309
    for txn in reftxns:
310
        tamount -= int(txn[1])
310
        tamount -= int(txn[1])
311
        
311
        
312
    dit2 = session.query(func.sum(WalletHistoryForCompany.amount)).filter(WalletHistoryForCompany.walletId == 2).filter(WalletHistoryForCompany.amount >= 50000).one()
-
 
313
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 2).with_lockmode("update").one()
312
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 2).with_lockmode("update").one()
-
 
313
 
-
 
314
    
-
 
315
    d = datetime.datetime.now()
-
 
316
    wh = WalletHistoryForCompany()
-
 
317
    wh.walletId = wallet.id
-
 
318
    wh.openingBal = wallet.amount
-
 
319
    wh.closingBal = wallet.amount - tamount
-
 
320
    wh.amount = tamount
-
 
321
    wh.transactionTime = d
-
 
322
    wh.referenceNumber =  int(d.strftime("%Y%m%d"))
-
 
323
    wh.description = "Wallet Credited"
314
    wallet.amount = int(dit2[0])- tamount 
324
    wallet.amount = wallet.amount - tamount
315
    session.commit()
325
    session.commit()
316
 
326
 
-
 
327
 
317
    maildata = ""
328
    maildata = ""
318
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in"], "MIS :- Saholic (Date - " + todate.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wallet.amount) + ")    (Total Recharge - " + str(tamount) + ")", maildata, []) 
329
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in"], "MIS :- Saholic (Date - " + todate.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wallet.amount) + ")    (Total Recharge - " + str(tamount) + ")", maildata, []) 
319
 
330
 
320
    
331
    
321
if __name__ == '__main__':
332
if __name__ == '__main__':
322
    main()
333
    main()
323
334