Subversion Repositories SmartDukaan

Rev

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

Rev 7245 Rev 7250
Line 25... Line 25...
25
    OrderType
25
    OrderType
26
from shop2020.model.v1.order.impl.DataAccessors import get_recharge_orders_for_status, update_recharge_order_status,\
26
from shop2020.model.v1.order.impl.DataAccessors import get_recharge_orders_for_status, update_recharge_order_status,\
27
    update_recharge_transaction_status, get_next_invoice_number
27
    update_recharge_transaction_status, get_next_invoice_number
28
from shop2020.model.v1.order.impl import DataService
28
from shop2020.model.v1.order.impl import DataService
29
from shop2020.model.v1.order.impl.DataService import RechargeTransaction, HotspotStore,\
29
from shop2020.model.v1.order.impl.DataService import RechargeTransaction, HotspotStore,\
30
    WalletForCompany, WalletHistoryForCompany
30
    WalletForCompany, WalletHistoryForCompany, RechargeCollection
31
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
31
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
32
from shop2020.model.v1.order.impl.RechargeService import checkTransactionStatus, getRefunds
32
from shop2020.model.v1.order.impl.RechargeService import checkTransactionStatus, getRefunds
33
 
33
 
34
 
34
 
35
def main():
35
def main():
Line 182... Line 182...
182
        data[3] -= int(txn[4])
182
        data[3] -= int(txn[4])
183
        data[4] -= int(txn[3]) - int(txn[4])
183
        data[4] -= int(txn[3]) - int(txn[4])
184
    print storeData
184
    print storeData
185
    
185
    
186
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 1).one()    
186
    wallet = WalletForCompany.query.filter(WalletForCompany.id == 1).one()    
187
    push_recharge_collection_to_ocr(storeData, todate, wallet.amount)
-
 
188
    
187
    
189
    dt = session.query(func.sum(RechargeTransaction.amount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL])).one()
188
    dt = session.query(func.sum(RechargeTransaction.amount)).filter(RechargeTransaction.status.in_([RechargeOrderStatus.RECHARGE_SUCCESSFUL])).one()
190
    
189
    
191
    if int(dt[0]) != wallet.amount:
190
    if int(dt[0]) != wallet.amount:
192
        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])) , "", [], [], [])    
191
        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])) , "", [], [], [])    
193
             
192
 
194
def push_recharge_collection_to_ocr(storeData, todate, wamount):
-
 
195
    maildata = "<html><body><table border='1'><thead><th>StoreId</th><th>Gross</th><th>Discount</th><th>Net</th></thead><tbody>"
193
    maildata = "<html><body><table border='1'><thead><th>StoreId</th><th>Gross</th><th>Discount</th><th>Net</th></thead><tbody>"
196
    trecharge = 0
194
    trecharge = 0
197
        
-
 
198
    for storeId in storeData.keys():
195
    for storeId in storeData.keys():
199
        store = HotspotStore.get_by(id = storeId)
196
        store = HotspotStore.get_by(id = storeId)
200
        store.collectedAmount = 0
197
        store.collectedAmount = 0
201
        store.availableLimit = store.creditLimit
198
        store.availableLimit = store.creditLimit
202
        session.commit()
199
        session.commit()
203
        
200
        
204
        data = storeData.get(storeId)
201
        data = storeData.get(storeId)
205
        
-
 
206
        
202
        rc = RechargeCollection()
207
        store_string = "<Store>" + store.hotspotId + "</Store>"
203
        rc.hotspotId = store.hotspotId
208
        date_string = "<ReconDate>" + todate.strftime("%Y%m%d") + "</ReconDate>"
204
        rc.reconDate = int(todate.strftime("%Y%m%d"))
209
        cash_string = "<Cash>" + str(data[0]) + "</Cash>"
205
        rc.cash = data[0]
210
        card_string = "<Hdfc>" + str(data[1]) + "</Hdfc>"
206
        rc.hdfc = data[1]
-
 
207
        rc.grossAmount = data[2]
211
        type_string = "<Type>RechargeSale</Type>"
208
        rc.discount = data[3]
-
 
209
        rc.netCollection = data[4]
212
        amount_string = "<GrossRechargeAmount>" + str(data[2]) + "</GrossRechargeAmount><Discount>" + str(data[3]) +  "</Discount><NetCollection>" + str(data[4]) + "</NetCollection>";
210
        rc.addedAt = datetime.datetime.now()
-
 
211
        rc.pushedToOcr = False
213
        
212
        session.commit()
-
 
213
 
214
        maildata += "<tr><td>" + store.hotspotId + "</td><td>" + str(data[2]) + "</td><td>" + str(data[3]) + "</td><td>" + str(data[4]) + "</td></tr>"
214
        maildata += "<tr><td>" + store.hotspotId + "</td><td>" + str(data[2]) + "</td><td>" + str(data[3]) + "</td><td>" + str(data[4]) + "</td></tr>"
215
        trecharge +=  data[2]
215
        trecharge +=  data[2]
-
 
216
 
-
 
217
    maildata += "</tbody></table></body></html>"
-
 
218
    mail_html("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"], "MIS   (Date - " + todate.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wallet.amount) + ")    (Total Recharge - " + str(trecharge) + ")", maildata, [])
-
 
219
    
-
 
220
    push_recharge_collection_to_ocr()
216
        
221
         
-
 
222
def push_recharge_collection_to_ocr():
-
 
223
    rcs = RechargeCollection.query.filter(RechargeCollection.pushedToOcr == False).all()
-
 
224
    
-
 
225
    for rc in rcs:
-
 
226
        store_string = "<Store>" + rc.hotspotId + "</Store>"
-
 
227
        date_string = "<ReconDate>" + str(rc.reconDate) + "</ReconDate>"
-
 
228
        cash_string = "<Cash>" + str(rc.cash) + "</Cash>"
-
 
229
        card_string = "<Hdfc>" + str(rc.hdfc) + "</Hdfc>"
-
 
230
        type_string = "<Type>RechargeSale</Type>"
-
 
231
        amount_string = "<GrossRechargeAmount>" + str(rc.grossAmount) + "</GrossRechargeAmount><Discount>" + str(rc.discount) +  "</Discount><NetCollection>" + str(rc.netCollection) + "</NetCollection>";
-
 
232
                
217
        #SaholicRechargeSaleTransfer(string Store, int ReconDate, decimal Cash, decimal Hdfc, string Type, decimal GrossRechargeAmount, decimal Discount, decimal NetCollection)
233
        #SaholicRechargeSaleTransfer(string Store, int ReconDate, decimal Cash, decimal Hdfc, string Type, decimal GrossRechargeAmount, decimal Discount, decimal NetCollection)
218
        
234
        
219
        conn = httplib.HTTPConnection("182.71.104.182")
235
        conn = httplib.HTTPConnection("182.71.104.182")
220
        XML="""
236
        XML="""
221
        <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/">
237
        <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 240... Line 256...
240
        response = conn.getresponse()
256
        response = conn.getresponse()
241
        print response.status, response.reason
257
        print response.status, response.reason
242
        resp = response.read()
258
        resp = response.read()
243
        conn.close()
259
        conn.close()
244
        print resp
260
        print resp
-
 
261
        if "Saved Successfully" in resp:
-
 
262
            rc.pushedAt = datetime.datetime.now()
-
 
263
            rc.pushedToOcr = True
-
 
264
            session.commit()
-
 
265
        elif "Error in Saving Data" in resp:
-
 
266
            print "Send Alert to someone"
-
 
267
        else: 
-
 
268
            print "Send Alert to someone"
-
 
269
        
245
 
270
 
246
    maildata += "</tbody></table></body></html>"
-
 
247
    mail_html("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"], "MIS   (Date - " + todate.strftime("%d-%m-%Y") + ")   (Wallet Amount - " + str(wamount) + ")    (Total Recharge - " + str(trecharge) + ")", maildata, [])
-
 
248
 
271
 
249
def topup_company_wallet(companyId, amount):
272
def topup_company_wallet(companyId, amount):
250
    wallet = WalletForCompany.query.filter(WalletForCompany.id == companyId).with_lockmode("update").one()
273
    wallet = WalletForCompany.query.filter(WalletForCompany.id == companyId).with_lockmode("update").one()
251
 
274
 
252
    wh = WalletHistoryForCompany()
275
    wh = WalletHistoryForCompany()