Subversion Repositories SmartDukaan

Rev

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

Rev 7167 Rev 7175
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
from shop2020.utils.EmailAttachmentSender import mail, mail_html
17
 
17
 
18
 
18
 
19
 
19
 
20
if __name__ == '__main__' and __package__ is None:
20
if __name__ == '__main__' and __package__ is None:
21
    import os
21
    import os
Line 176... Line 176...
176
            data[1] -= int(txn[3]) - int(txn[4])
176
            data[1] -= int(txn[3]) - int(txn[4])
177
        data[2] -= int(txn[3])
177
        data[2] -= int(txn[3])
178
        data[3] -= int(txn[4])
178
        data[3] -= int(txn[4])
179
        data[4] -= int(txn[3]) - int(txn[4])
179
        data[4] -= int(txn[3]) - int(txn[4])
180
    print storeData
180
    print storeData
181
        
-
 
182
    push_recharge_collection_to_ocr(storeData, todate)
-
 
183
    
181
    
184
    dt = session.query(func.sum(RechargeTransaction.amount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL])).filter(RechargeTransaction.transactionTime >= todate).filter(RechargeTransaction.transactionTime < tomorrow).one()
182
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 1).one()    
185
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 1).one()
183
    push_recharge_collection_to_ocr(storeData, todate, wallet.amount)
-
 
184
    
-
 
185
    dt = session.query(func.sum(RechargeTransaction.amount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL])).one()
-
 
186
    
186
    if int(dt[0]) != wallet.amount:
187
    if int(dt[0]) != wallet.amount:
187
        mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in"], "Wallet amount: " + str(wallet.amount) + " does not match with transaction amount: " + str(int(dt[0])) , "", [], [], [])    
188
        mail("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in"], "Wallet amount: " + str(wallet.amount) + " does not match with transaction amount: " + str(int(dt[0])) , "", [], [], [])    
188
             
189
             
189
def push_recharge_collection_to_ocr(storeData, todate):
190
def push_recharge_collection_to_ocr(storeData, todate, wamount):
-
 
191
    maildata = "<html><body><table border='1'><thead><th>StoreId</th><th>Gross</th><th>Discount</th><th>Net</th></thead><tbody>"
-
 
192
    trecharge = 0
190
    
193
        
191
    for storeId in storeData.keys():
194
    for storeId in storeData.keys():
192
        store = HotspotStore.get_by(id = storeId)
195
        store = HotspotStore.get_by(id = storeId)
193
        store.collectedAmount = 0
196
        store.collectedAmount = 0
194
        store.availableLimit = store.creditLimit
197
        store.availableLimit = store.creditLimit
195
        session.commit()
198
        session.commit()
Line 202... Line 205...
202
        cash_string = "<Cash>" + str(data[0]) + "</Cash>"
205
        cash_string = "<Cash>" + str(data[0]) + "</Cash>"
203
        card_string = "<Hdfc>" + str(data[1]) + "</Hdfc>"
206
        card_string = "<Hdfc>" + str(data[1]) + "</Hdfc>"
204
        type_string = "<Type>RechargeSale</Type>"
207
        type_string = "<Type>RechargeSale</Type>"
205
        amount_string = "<GrossRechargeAmount>" + str(data[2]) + "</GrossRechargeAmount><Discount>" + str(data[3]) +  "</Discount><NetCollection>" + str(data[4]) + "</NetCollection>";
208
        amount_string = "<GrossRechargeAmount>" + str(data[2]) + "</GrossRechargeAmount><Discount>" + str(data[3]) +  "</Discount><NetCollection>" + str(data[4]) + "</NetCollection>";
206
        
209
        
-
 
210
        maildata += "<tr><td>" + store.hotspotId + "</td><td>" + str(data[2]) + "</td><td>" + str(data[3]) + "</td><td>" + str(data[4]) + "</td></tr>"
-
 
211
        trecharge +=  data[2]
-
 
212
        
207
        #SaholicRechargeSaleTransfer(string Store, int ReconDate, decimal Cash, decimal Hdfc, string Type, decimal GrossRechargeAmount, decimal Discount, decimal NetCollection)
213
        #SaholicRechargeSaleTransfer(string Store, int ReconDate, decimal Cash, decimal Hdfc, string Type, decimal GrossRechargeAmount, decimal Discount, decimal NetCollection)
208
        
214
        
209
        conn = httplib.HTTPConnection("182.71.104.182")
215
        conn = httplib.HTTPConnection("182.71.104.182")
210
        XML="""
216
        XML="""
211
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
217
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Line 231... Line 237...
231
        print response.status, response.reason
237
        print response.status, response.reason
232
        resp = response.read()
238
        resp = response.read()
233
        conn.close()
239
        conn.close()
234
        print resp
240
        print resp
235
 
241
 
-
 
242
    maildata += "</tbody></table></body></html>"
-
 
243
    mail_html("cnc.center@shop2020.in", "5h0p2o2o", ["rajveer.singh@shop2020.in", "anupam.singh@shop2020.in"], "MIS   (Date - " + todate.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wamount) + ")    (Total Recharge - " + str(trecharge) + ")", maildata, [], [], [])
-
 
244
 
236
def topup_company_wallet(companyId, amount):
245
def topup_company_wallet(companyId, amount):
237
    wallet = WalletForCompany.query.filter(WalletForCompany.id == companyId).with_lockmode("update").one()
246
    wallet = WalletForCompany.query.filter(WalletForCompany.id == companyId).with_lockmode("update").one()
238
 
247
 
239
    wh = WalletHistoryForCompany()
248
    wh = WalletHistoryForCompany()
240
    wh.walletId = wallet.id
249
    wh.walletId = wallet.id