Subversion Repositories SmartDukaan

Rev

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

Rev 19486 Rev 19493
Line 291... Line 291...
291
    if total_count > skip:
291
    if total_count > skip:
292
        cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
292
        cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
293
        refunds = []
293
        refunds = []
294
        for refund in cursor:
294
        for refund in cursor:
295
            del(refund["_id"])
295
            del(refund["_id"])
-
 
296
            if (refund["type"]) == utils.CREDIT_TYPE_REFUND:
-
 
297
                batchDetails = fetchCrmRefundByBatchId(refund["batch"])
-
 
298
                referenceNumber = batchDetails.get('reference_no')                
-
 
299
                refund["description"] = "Refunded against Saholic order # %s"%(referenceNumber)
-
 
300
            elif (refund["type"]) == utils.CREDIT_TYPE_ADJUSTMENT:
-
 
301
                batchDetails = fetchCrmRefundByBatchId(refund["batch"])
-
 
302
                referenceNumber = batchDetails.get('reference_no')
-
 
303
                referenceStore = batchDetails.get('store')
-
 
304
                refund["description"] = "Adjusted against %s order # %s"%(referenceStore,referenceNumber)                
-
 
305
            else:
-
 
306
                refund["description"] = ""
296
            refunds.append(refund)
307
            refunds.append(refund)
297
        result['credited'] = credited
308
        result['credited'] = credited
298
        result['data'] = refunds
309
        result['data'] = refunds
299
        result['window'] = window
310
        result['window'] = window
300
        result['totalCount'] = total_count 
311
        result['totalCount'] = total_count 
Line 3232... Line 3243...
3232
def fetchCrmRefundUsers(status,offset,limit):
3243
def fetchCrmRefundUsers(status,offset,limit):
3233
    cursor = list(get_mongo_connection().Dtr.crmrefundwallet.find({"status":status}).skip(offset).limit(limit).sort("created_timestamp",-1))
3244
    cursor = list(get_mongo_connection().Dtr.crmrefundwallet.find({"status":status}).skip(offset).limit(limit).sort("created_timestamp",-1))
3234
    return cursor
3245
    return cursor
3235
 
3246
 
3236
def fetchCrmRefundByBatchId(batchId):
3247
def fetchCrmRefundByBatchId(batchId):
3237
    cursor = list(get_mongo_connection().Dtr.crmrefundwallet.find({"batchId":int(batchId)}))
3248
    cursor = get_mongo_connection().Dtr.crmrefundwallet.find_one({"batchId":int(batchId)})
3238
    return cursor
3249
    return cursor
3239
 
3250
 
3240
def todict(obj, classkey=None):
3251
def todict(obj, classkey=None):
3241
    if isinstance(obj, dict):
3252
    if isinstance(obj, dict):
3242
        data = {}
3253
        data = {}