Subversion Repositories SmartDukaan

Rev

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

Rev 8795 Rev 8815
Line 96... Line 96...
96
def processRecon():
96
def processRecon():
97
    cdate = datetime.datetime.now() + timedelta(days = -1)
97
    cdate = datetime.datetime.now() + timedelta(days = -1)
98
    startTime = datetime.datetime(cdate.year, cdate.month, cdate.day)
98
    startTime = datetime.datetime(cdate.year, cdate.month, cdate.day)
99
    endTime = startTime + timedelta(days=1)
99
    endTime = startTime + timedelta(days=1)
100
 
100
 
101
    startTime = datetime.datetime.strptime('2012-10-10 00:00:00', "%Y-%m-%d %H:%M:%S");
-
 
102
    endTime = datetime.datetime.strptime('2013-11-13 17:43:43', "%Y-%m-%d %H:%M:%S");
-
 
103
 
101
 
104
    '''
102
    '''
105
    A - All such orders for which we have attempted the recharge and recharge is either successful or unknown.
103
    A - All such orders for which we have attempted the recharge and recharge is either successful or unknown.
106
    B - All such orders for which we have attempted the recharge and we received the refund after this time window.
104
    B - All such orders for which we have attempted the recharge and we received the refund after this time window.
107
    C - All such orders for which we have received the refund in this time window, although the recharge was attempted before this window.
105
    C - All such orders for which we have received the refund in this time window, although the recharge was attempted before this window.
Line 444... Line 442...
444
    wallet.amount += amount
442
    wallet.amount += amount
445
    session.commit()
443
    session.commit()
446
    mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "Ashwani.Kumar@spiceretail.co.in","parveen.mittal@spiceretail.co.in","pardeep.panwar@spiceretail.co.in","gagan.sharma@spiceretail.co.in","j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in", "amit.tyagi@spiceretail.co.in"] , company.name + " wallet topped up by " +  str(amount) + " rupees.", "", [], [], [])
444
    mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "Ashwani.Kumar@spiceretail.co.in","parveen.mittal@spiceretail.co.in","pardeep.panwar@spiceretail.co.in","gagan.sharma@spiceretail.co.in","j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in", "amit.tyagi@spiceretail.co.in"] , company.name + " wallet topped up by " +  str(amount) + " rupees.", "", [], [], [])
447
 
445
 
448
def compute_website_recharge_collection(cdate, oldBalance, newBalance):
446
def compute_website_recharge_collection(cdate, oldBalance, newBalance):
449
    todate = datetime.datetime(cdate.year, cdate.month, cdate.day)
447
    startTime = datetime.datetime(cdate.year, cdate.month, cdate.day)
450
    tomorrow = todate + timedelta(days=1)
-
 
451
    
-
 
452
    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()
448
    endTime = startTime + timedelta(days=1)
453
    
-
 
454
    tamount = 0
449
    tamount = 0
-
 
450
    
455
    for txn in txns:
451
    txns = session.query(func.sum(RechargeOrder.totalAmount), func.sum(RechargeOrder.couponAmount)).filter(RechargeOrder.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL, RechargeOrderStatus.PAYMENT_SUCCESSFUL])).filter(RechargeOrder.creationTimestamp.between(startTime,endTime)).first()    
-
 
452
    if txns and txns[0]:
456
        tamount += int(txn[1])
453
        tamount += int(txns[0])
457
        
454
    
458
  
455
    otxns = session.query(func.sum(RechargeOrder.totalAmount), func.sum(RechargeOrder.couponAmount)).filter(RechargeOrder.status.in_([RechargeOrderStatus.RECHARGE_FAILED, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.REFUNDED, RechargeOrderStatus.PARTIALLY_REFUNDED])).filter(RechargeOrder.creationTimestamp.between(startTime,endTime)).filter(not_(RechargeOrder.responseTimestamp.between(startTime,endTime))).first()
-
 
456
    if otxns and otxns[0]:
-
 
457
        tamount += int(otxns[0])
459
    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()  
458
    
460
    for txn in reftxns:
459
    reftxns = session.query(func.sum(RechargeOrder.totalAmount), func.sum(RechargeOrder.couponAmount)).filter(RechargeOrder.status.in_([RechargeOrderStatus.RECHARGE_FAILED, RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, RechargeOrderStatus.REFUNDED, RechargeOrderStatus.PARTIALLY_REFUNDED])).filter(RechargeOrder.responseTimestamp.between(startTime,endTime)).filter(not_(RechargeOrder.creationTimestamp.between(startTime,endTime))).first()
-
 
460
    if reftxns and reftxns[0]:
461
        tamount -= int(txn[1])
461
        tamount -= int(reftxns[0])
462
        
462
        
463
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 2).with_lockmode("update").one()
463
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 2).with_lockmode("update").one()
464
 
464
 
465
    
465
    
466
    d = datetime.datetime.now()
466
    d = datetime.datetime.now()
Line 475... Line 475...
475
    wallet.amount = wallet.amount - tamount
475
    wallet.amount = wallet.amount - tamount
476
    session.commit()
476
    session.commit()
477
 
477
 
478
 
478
 
479
    maildata = ""
479
    maildata = ""
480
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["pardeep.panwar@spiceretail.co.in>", "amit.tyagi@spiceretail.co.in", "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, []) 
480
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["pardeep.panwar@spiceretail.co.in>", "amit.tyagi@spiceretail.co.in", "rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in"], "MIS :- Saholic (Date - " + startTime.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wallet.amount) + ")    (Total Recharge - " + str(tamount) + ")", maildata, []) 
481
 
481
 
482
    rAmount = 0
482
    rAmount = 0
483
    ramount = session.query(func.sum(WalletHistoryForCompany.amount)).filter(WalletHistoryForCompany.transactionTime >= todate).filter(WalletHistoryForCompany.amount >= 100000).one()
483
    ramount = session.query(func.sum(WalletHistoryForCompany.amount)).filter(WalletHistoryForCompany.transactionTime >= startTime).filter(WalletHistoryForCompany.amount >= 100000).one()
484
    if ramount[0]:
484
    if ramount[0]:
485
        rAmount = int(ramount[0])
485
        rAmount = int(ramount[0])
486
    rcs = session.query(func.sum(RechargeCollection.grossAmount)).filter(RechargeCollection.reconDate == int(todate.strftime("%Y%m%d"))).one()
486
    rcs = session.query(func.sum(RechargeCollection.grossAmount)).filter(RechargeCollection.reconDate == int(startTime.strftime("%Y%m%d"))).one()
487
    hamount = int(rcs[0])
487
    hamount = int(rcs[0])
488
    
488
    
489
    maildata = "(A) Old Wallet Amount is : " + str(oldBalance) + "<br>(B) New Wallet Amount is : " + str(newBalance) + "<br>(C) Recharge Amount is : " + str(rAmount) + "<br>---------------------------<br>(D) Total Debit Amount for Recharge(A-B+C) is : " + str(oldBalance - newBalance + rAmount) + "<br><br><br>(E) Saholic Recharge Amount is :" + str(tamount) + "<br>(F) Hotspot Recharge Amount is :" + str(hamount) + "<br>---------------------------<br>(G) Total Recharge Amount (E+F) is : " + str(tamount + hamount)
489
    maildata = "(A) Old Wallet Amount is : " + str(oldBalance) + "<br>(B) New Wallet Amount is : " + str(newBalance) + "<br>(C) Recharge Amount is : " + str(rAmount) + "<br>---------------------------<br>(D) Total Debit Amount for Recharge(A-B+C) is : " + str(oldBalance - newBalance + rAmount) + "<br><br><br>(E) Saholic Recharge Amount is :" + str(tamount) + "<br>(F) Hotspot Recharge Amount is :" + str(hamount) + "<br>---------------------------<br>(G) Total Recharge Amount (E+F) is : " + str(tamount + hamount)
490
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["pardeep.panwar@spiceretail.co.in>", "amit.tyagi@spiceretail.co.in", "rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in"], "MIS :- Wallet and Recharge (Date - " + todate.strftime("%d-%m-%Y") + ")", maildata, [])
490
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["pardeep.panwar@spiceretail.co.in>", "amit.tyagi@spiceretail.co.in", "rajveer.singh@shop2020.in", "anupam.singh@shop2020.in", "j.p.gupta@shop2020.in", "rajneesh.arora@shop2020.in"], "MIS :- Wallet and Recharge (Date - " + startTime.strftime("%d-%m-%Y") + ")", maildata, [])
491
    
491
    
492
    
492
    
493
if __name__ == '__main__':
493
if __name__ == '__main__':
494
    main()
494
    main()
495
            
495
            
496
496