"$match": { "created_at": {'$gte': due_date_add_2,'$lte': endTodayTimeStamp}, "account_number": {'$in' : acc_arr}, "code" : '10' } },{ "$group": { "_id": 'null', "acc_arr" : {'$addToSet' : '$account_number'}, "total_amt": {'$sum': '$amt'}, } } ] ln3206fInfo = mongodb.aggregate_pipeline(MONGO_COLLECTION=ln3206_collection,aggregate_pipeline=aggregate_ln3206) if ln3206fInfo is not None: for ln3206 in ln3206fInfo: # temp['col'] = len(ln3206['acc_arr']) temp['amt'] = round(ln3206['total_amt']/1000) temp['col'] = temp['inci'] - col_today temp['col_prici'] = temp['inci_ob_principal'] - round(ob_principal_today/1000) temp['col_amt'] = temp['inci_amt'] - round(amt_today/1000) temp['rem'] = temp['inci'] - temp['col'] temp['rem_amt'] = temp['inci_amt'] - temp['col_amt'] temp['flow_rate'] = temp['rem'] / temp['inci'] if temp['inci'] != 0 else 0 temp['flow_rate_amt'] = temp['rem_amt'] / temp['inci_amt'] if temp['inci_amt'] != 0 else 0
}, { "$group": { "_id": 'null', "sum_balance": { '$sum': '$current_balance' }, "sum_principal": { '$sum': '$outstanding_principal' }, "count_data": { '$sum': 1 } } }] lnjc05Data = mongodb.aggregate_pipeline( MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_lnjc05) if lnjc05Data != None: for row in lnjc05Data: temp['start_os_bl'] = round(row['sum_balance'] / 1000000) temp['principal'] = round(row['sum_principal'] / 1000000) temp['start_no'] = row['count_data'] # Final No group = [] if duedate_type[0:1] == 'A': group.append('B' + duedate_type[1:3]) if duedate_type[0:1] == 'B': group.append('C' + duedate_type[1:3])
i = 1 # LNJC05 aggregate_pipeline = [ { "$match": { "starttime" : {'$gte' : todayTimeStamp,'$lte' : endTodayTimeStamp}, "direction" : 'outbound', # "userextension": '4022' } } ] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=cdr_collection,aggregate_pipeline=aggregate_pipeline) if data != None: for cdr in data: temp = {} temp['export_date'] = todayString temp['index'] = i temp['contacted'] = cdr['customernumber'] temp['disposition'] = cdr['disposition'] if 'disposition' in cdr.keys() else '' if 'dialtype' in cdr.keys() and cdr['dialtype'] == 'auto': temp['duration'] = cdr['callduration'] if 'callduration' in cdr.keys() else 0 else: temp['duration'] = cdr['totalduration'] if 'totalduration' in cdr.keys() else 0 temp['callduration'] = cdr['callduration'] if 'callduration' in cdr.keys() else 0
aggregate_ln3206 = [ { "$match": { "created_at": {'$gte': temp['due_date']}, "account_number": {'$in' : acc_arr} } },{ "$group": { "_id": 'null', "total_amt": {'$sum': '$amt'}, } } ] ln3206fInfo = mongodb.aggregate_pipeline(MONGO_COLLECTION=common.getSubUser(subUserType, 'LN3206F'),aggregate_pipeline=aggregate_ln3206) if ln3206fInfo is not None: for ln3206 in ln3206fInfo: temp['payment_amt'] = ln3206['total_amt'] if groupProduct['value'] == 'Card': yesterdayReportData = mongodb.getOne(MONGO_COLLECTION=collection, WHERE={'team_id': str(groupCell['_id']), 'created_at': {'$gte': (starttime - 86400), '$lte': (endtime - 86400)}}) listOfAccount = mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'List_of_account_in_collection'), WHERE={ 'account_number': {'$in': acc_arr}}) for account in listOfAccount: col_today += 1 col_amt_today += account['cur_bal'] aggregate_gl = [ { "$match":
aggregate_ln3206 = [ { "$match": { "created_at": {'$gte': temp['due_date'],'$lte': todayTimeStamp}, "account_number": {'$in' : acc_arr} } },{ "$group": { "_id": 'null', "total_amt": {'$sum': '$amt'}, } } ] ln3206fInfo = mongodb.aggregate_pipeline(MONGO_COLLECTION=common.getSubUser(subUserType, 'LN3206F'),aggregate_pipeline=aggregate_ln3206) if ln3206fInfo is not None: for ln3206 in ln3206fInfo: temp['amt'] = ln3206['total_amt'] temp['col'] = temp['inci'] - col_today temp['col_amt'] = temp['inci_amt'] - amt_today temp['col_prici'] = temp['inci_ob_principal'] - ob_principal_today temp['rem'] = temp['inci'] - temp['col'] temp['rem_amt'] = temp['inci_amt'] - temp['col_amt'] temp['flow_rate'] = temp['rem'] / temp['inci'] if temp['inci'] != 0 else 0 temp['flow_rate_amt'] = temp['rem_amt'] / temp['inci_amt'] if temp['inci_amt'] != 0 else 0 temp['col_rate'] = temp['col'] / temp['inci'] if temp['inci'] != 0 else 0 temp['actual_ratio'] = temp['amt'] / temp['inci_amt'] if temp['inci_amt'] != 0 else 0
"as": "detail" } },{ "$match": { "detail.group_number": '02', } },{ "$group": { "_id": 'null', "acc_arr": {'$push': '$account_number'}, } } ] data_acc = mongodb.aggregate_pipeline(MONGO_COLLECTION=account_collection,aggregate_pipeline=aggregate_acc) account_number_arr = [] for row in data_acc: account_number_arr = row['acc_arr'] accountInfo = mongodb.get(MONGO_COLLECTION=account_collection,WHERE={'account_number': {'$in' : account_number_arr}}) if accountInfo != None: i = 1 for acc_row in accountInfo: temp = { 'index' : i, 'account_number' : acc_row['account_number'], 'name' : acc_row['cus_name'], 'block' : 'true', 'accl' : '',
except Exception as SysArgvError: aggregate_acc = [{ "$match": { "createdAt": { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp }, } }, { "$project": { "_id": 0, } }] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=collection, aggregate_pipeline=aggregate_acc) dataReport = [] for row in data: temp = row # if 'loan_overdue_amount' in row.keys(): # temp['loan_overdue_amount'] = '{:,.2f}'.format(float(row['loan_overdue_amount'])) # if 'current_balance' in row.keys(): # temp['current_balance'] = '{:,.2f}'.format(float(row['current_balance'])) # if 'outstanding_principal' in row.keys(): # try: # temp['outstanding_principal'] = '{:,.2f}'.format(float(row['outstanding_principal'])) # except Exception as e: # temp['outstanding_principal'] = row['outstanding_principal']
"$match": { 'created_at': { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp }, 'code': '10' } }, { "$group": { "_id": 'null', "acc_arr": { '$addToSet': '$account_number' }, } }] accData = mongodb.aggregate_pipeline(MONGO_COLLECTION=ln3206_collection, aggregate_pipeline=aggregate_sibs) if accData != None: for row in accData: acc__sibs_arr = row['acc_arr'] for acc in acc__sibs_arr: aggregate_paid = [ { "$match": { "created_at": { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp }, "account_number": acc, "code": '10', }
}, { "$group": { "_id": 'null', "total_amt": { '$sum': '$cur_bal' }, "total_acc": { '$sum': 1 }, "acc_arr": { '$push': '$account_number' } } }] diallistDetail = mongodb.aggregate_pipeline( MONGO_COLLECTION=diallist_collection, aggregate_pipeline=aggregate_diallist) if diallistDetail is not None: for diallist in diallistDetail: temp['debt_acc_no'] = diallist['total_acc'] temp['current_balance_total'] = diallist[ 'total_amt'] # temp['debt_acc_301'] = diallist['total_acc'] # temp['current_balance_301'] = diallist['total_amt'] temp['acc_arr'] = diallist['acc_arr'] aggregate_sbv = [{ "$match": { "contract_no": { '$in': temp['acc_arr'] }
# Account aggregate_acc = [{ "$lookup": { "from": lnjc05_collection, "localField": "account_number", "foreignField": "account_number", "as": "detailLC05" } }, { "$match": { "detailLC05.account_number": { '$exists': 'true' }, } }] data_faccf = mongodb.aggregate_pipeline(MONGO_COLLECTION=zaccf_collection, aggregate_pipeline=aggregate_acc) account_number_arr = [] i = 1 if data_faccf != None: for row in data_faccf: for detail in row['detailLC05']: temp = { 'index': i, 'account_number': row['account_number'], 'name': row['name'], 'address': row['ADDR_1'], 'contract_date': row['CIF_CR8'], 'day': row['CIF_CR8'], 'group': '', 'createdBy': 'system',
# "$match": # { # "createdAt": {'$gte': temp['due_date'],'$lte' : todayTimeStamp}, # } # }, { "$group": { "_id": 'null', "acc_arr": { '$addToSet': '$account_number' } } } ] woPayment = mongodb.aggregate_pipeline( MONGO_COLLECTION=common.getSubUser(subUserType, 'Wo_payment'), aggregate_pipeline=aggregate_payment) acc_payment = [] for payment in woPayment: temp['col'] = len(payment['acc_arr']) acc_payment = payment['acc_arr'] count_wo = mongodb.count( MONGO_COLLECTION=common.getSubUser(subUserType, 'WO_monthly')) if count_wo != None or count_wo != 0: aggregate_payment_prod = [{ "$match": { 'ACCTNO': { '$in': acc_payment }, }
"$g" + product_value['code'], "t_g": "$t_g", "t_a": "$t_a", "a" + product_value['code']: "$a" + product_value['code'], # "g2" : { # "$divide" : [{"$cond":[{"$eq":["$group","02"]},],"$total"] # } } } ] total_report = list( mongodb.aggregate_pipeline(MONGO_COLLECTION=common.getSubUser( subUserType, 'List_of_all_customer_total_report_temp'), aggregate_pipeline=aggregate_sum)) if total_report not in [None, []] and total_report[0] is not None: temp['group'] = group temp["g" + product_value['code']] = total_report[0][ "g" + product_value['code']] temp["t_g"] = total_report[0]["t_g"] temp["t_a"] = total_report[0]["t_a"] temp["a" + product_value['code']] = total_report[0][ "a" + product_value['code']] temp['index'] = i temp['createdAt'] = time.time() insertData.append(temp) for gr in list_group_total: temp1 = {}
'$lte': endTodayTimeStamp }, } }, { "$project": { "group_id": 1, "account_number": 1, "cus_name": 1, "current_balance": 1, "due_date": 1, "address": 1, "officer_id": 1, "officer_name": 1, } }] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_pipeline) for row in data: if 'account_number' in row.keys(): row['APPROV_LMT'] = 0 row['RPY_PRD'] = 0 row['W_ORG'] = 0 zaccf = mongodb.getOne( MONGO_COLLECTION=zaccf_collection, WHERE={'account_number': str(row['account_number'])}, SELECT=[ 'cif_birth_date', 'CUS_ID', 'FRELD8', 'PRODGRP_ID', 'LIC_NO', 'APPROV_LMT', 'TERM_ID', 'RPY_PRD', 'F_PDT', 'DT_MAT', 'MOBILE_NO', 'WRK_REF', 'WRK_REF1', 'WRK_REF2', 'WRK_REF3', 'WRK_REF4', 'WRK_REF5', 'W_ORG', 'INT_RATE', 'OVER_DY' ])
'$in': list_prod_code, }, } zaccf_aggregate = [{ '$match': filter_cri }, { '$group': { '_id': '$INT_RATE', 'account_number': { '$push': '$account_number' } } }] zaccf_info = list( mongodb.aggregate_pipeline( MONGO_COLLECTION=common.getSubUser( subUserType, zaccf_collection), aggregate_pipeline=zaccf_aggregate)) pprint(len(zaccf_info)) for zaccf in zaccf_info: if ('a' + reportDate[str(todayTimeStamp)]['debt_group'] + '_' + zaccf['_id'].replace('.', '')) not in temp_column: temp_column.append(zaccf['_id']) mongodb.update_add_to_set( MONGO_COLLECTION=common.getSubUser( subUserType, 'First_time_payment_delinqunecy_columns'), WHERE={ 'for_year': str(reportDate[str(todayTimeStamp)] ['for_year']),
# SIBS aggregate_acc = [{ "$lookup": { "from": common.getSubUser(subUserType, 'ZACCF_report'), "localField": "account_number", "foreignField": "account_number", "as": "detail" } }, { "$match": { "detail.PRODGRP_ID": { '$in': ['103', '402', '502', '602', '702', '802', '902'] }, } }] data_acc = mongodb.aggregate_pipeline(MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_acc) if data_acc != None: for key, row in enumerate(data_acc): temp = {} if 'account_number' in row.keys(): temp['type'] = 'sibs' temp['stt'] = key temp['account_number'] = row['account_number'] temp['group'] = row['group_id'] temp['phone'] = row['mobile_num'] temp['name'] = row['cus_name'] temp['amount'] = float( row['overdue_amount_this_month']) - float( row['advance_balance']) temp['sending_date'] = now.strftime("%d/%m/%Y") temp['createdAt'] = time.time()
"name": 1, "ODIND_FG": 1, "CAR_ID": 1, "TERM_ID": 1, "W_ORG": 1, "PRODGRP_ID": 1, "PRODGRP_NAME": "$product.name", "LIC_NO": 1, "INT_RATE": 1, "WRK_BRN": 1, "STAT_CD": 1, "STAT_CD_NAME": "$province.name" } } ] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=zaccf_collection, aggregate_pipeline=aggregate_zaccf) for row in data: if 'account_number' in row.keys(): temp = {} temp['DT_TX'] = now.strftime("%d/%m/%Y") temp['ACC_ID'] = row['account_number'] temp['CUS_ID'] = row['CUS_ID'] temp['CUS_NM'] = row['name'] temp['Loan_Group'] = convert_group(row['ODIND_FG']) temp['CAR_ID'] = row['CAR_ID'] temp['TERM_ID'] = int(row['TERM_ID']) temp['W_ORG'] = int(float(row['W_ORG'])) temp['TOTAL_ACC'] = 1
"%d/%m/%Y %H:%M:%S"))) endTodayTimeStamp = int( time.mktime( time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) # LN2306f aggregate_pipeline = [{ "$match": { "created_at": { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp }, } }] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=ln3206_collection, aggregate_pipeline=aggregate_pipeline) if data != None: for row in data: lnjc05Data = mongodb.getOne( MONGO_COLLECTION=lnjc05_collection, WHERE={'account_number': str(row['account_number'])}) if lnjc05Data != None: accountYes.append(row['account_number']) else: accountNo.append(row['account_number']) print(len(accountYes)) temp['coNoHayKhong'] = 'Y' mongodb.batch_update(MONGO_COLLECTION=ln3206_collection, WHERE={
"name": 1, "ODIND_FG": 1, "CAR_ID": 1, "TERM_ID": 1, "W_ORG": 1, "PRODGRP_ID": 1, "PRODGRP_NAME": "$product.name", "LIC_NO": 1, "INT_RATE": 1, "WRK_BRN": 1, "STAT_CD": 1, "STAT_CD_NAME": "$province.name" } } ] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=zaccf_collection, aggregate_pipeline=aggregate_zaccf) for row in data: if 'account_number' in row.keys(): temp = {} temp['DT_TX'] = now.strftime("%d/%m/%Y") temp['ACC_ID'] = row['account_number'] temp['CUS_ID'] = row['CUS_ID'] temp['CUS_NM'] = row['name'] temp['Loan_Group'] = convert_group(row['ODIND_FG']) temp['CAR_ID'] = row['CAR_ID'] temp['TERM_ID'] = int(row['TERM_ID']) temp['W_ORG'] = int(float(row['W_ORG'])) temp['TOTAL_ACC'] = 1
'group_id': 1 # 'dateDifference' :{"$divide" : [{ "$subtract" : [todayTimeStamp,'$due_date']}, 86400]} } }, { "$match": { 'group_id': { '$regex': dept_group, '$nin': ['A' + dept_group] } # '$or' : [ {'dateDifference': {"$eq": 35} }, {'dateDifference': {"$eq": 65} }, {'dateDifference': {"$eq": 95} }, {'dateDifference': {"$eq": 185} }] } } ] dataLnjc05 = mongodb.aggregate_pipeline( MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_pipeline) if dataLnjc05 != None: for row in dataLnjc05: zaccf = mongodb.getOne( MONGO_COLLECTION=zaccf_collection, WHERE={'account_number': str(row['account_number'])}) if zaccf != None: temp = { 'index': i, 'account_number': row['account_number'], 'name':
}, 'group_three_plus_w_org_sibs' : { '$sum' : { '$cond' : [ { '$in' : ['$ODIND_FG', ['C', 'D', 'E']] }, '$W_ORG_1', 0 ] } }, } } ] zaccfInfo = list(mongodb.aggregate_pipeline(MONGO_COLLECTION=common.getSubUser(subUserType, 'ZACCF_report'),aggregate_pipeline=aggregate_zaccf)) temp['province_id'] = state_value['code'] temp['province_name'] = state_value['name'] if zaccfInfo not in [None, []] and zaccfInfo[0] is not None: temp['release_acc_no_sibs'] = zaccfInfo[0]['release_acc_no_sibs'] if zaccfInfo[0]['release_acc_no_sibs'] is not None else 0 temp['release_amt_sibs'] = zaccfInfo[0]['release_amt_sibs'] if zaccfInfo[0]['release_amt_sibs'] is not None else 0 temp['group_two_acc_sibs'] = zaccfInfo[0]['group_two_acc_sibs'] if zaccfInfo[0]['group_two_acc_sibs'] is not None else 0 temp['group_two_w_org_sibs'] = zaccfInfo[0]['group_two_w_org_sibs'] if zaccfInfo[0]['group_two_w_org_sibs'] is not None else 0 temp['group_two_plus_acc_sibs'] = zaccfInfo[0]['group_two_plus_acc_sibs'] if zaccfInfo[0]['group_two_plus_acc_sibs'] is not None else 0 temp['group_two_plus_w_org_sibs'] = zaccfInfo[0]['group_two_plus_w_org_sibs'] if zaccfInfo[0]['group_two_plus_w_org_sibs'] is not None else 0 temp['group_three_plus_acc_sibs'] = zaccfInfo[0]['group_three_plus_acc_sibs'] if zaccfInfo[0]['group_three_plus_acc_sibs'] is not None else 0 temp['group_three_plus_w_org_sibs'] = zaccfInfo[0]['group_three_plus_w_org_sibs'] if zaccfInfo[0]['group_three_plus_w_org_sibs'] is not None else 0 temp['total_acc_no_sibs'] = zaccfInfo[0]['total_acc_no_sibs'] if zaccfInfo[0]['total_acc_no_sibs'] is not None else 0 temp['total_amt_sibs'] = zaccfInfo[0]['total_amt_sibs'] if zaccfInfo[0]['total_amt_sibs'] is not None else 0 else: temp['release_acc_no_sibs'] = 0
temp_sibs_last_month = {} temp_card_last_month = {} if (report_day['due_date'] + 864000) == todayTimeStamp: # Update thong tin 10 ngay sau due date temp_sibs_10_days = {} temp_card_10_days = {} lnjc05_aggregate = [{ '$match': { 'group_id': 'A' + report_day['debt_group'], } }] lnjc05_info = list( mongodb.aggregate_pipeline( MONGO_COLLECTION=common.getSubUser(subUserType, lnjc05_today), aggregate_pipeline=lnjc05_aggregate)) temp_sibs_10_days['group_2_tran_no'] = len(lnjc05_info) mongodb.update(MONGO_COLLECTION=collection, WHERE={ 'for_month': str(report_day['for_month']), 'for_year': str(report_day['for_year']), 'debt_group': 'A' + report_day['debt_group'], 'prod_name': 'Bike/PL' }, VALUE=temp_sibs_10_days) list_acc_info_temp = list( mongodb.get(MONGO_COLLECTION=common.getSubUser( subUserType, list_of_acc_today), SELECT=['account_number']))
}, { "$group": { "_id": 'null', "total_amt": { '$sum': '$cur_bal' }, "total_acc": { '$sum': 1 }, "acc_arr": { '$push': '$account_number' } } }] diallistDetail = mongodb.aggregate_pipeline( MONGO_COLLECTION=common.getSubUser( subUserType, 'Diallist_detail'), aggregate_pipeline=aggregate_diallist) if diallistDetail is not None: for diallist in diallistDetail: temp['debt_acc_no'] = diallist['total_acc'] temp['current_balance_total'] = diallist[ 'total_amt'] temp['debt_acc_301'] = diallist[ 'total_acc'] temp['current_balance_301'] = diallist[ 'total_amt'] temp['acc_arr'] = diallist['acc_arr'] aggregate_sbv = [{ "$match": { "contract_no": {
"overdue_indicator": debtGroupCell[0:1], "kydue": debtGroupCell[1:3] } }, { "$group": { "_id": 'null', "total_acc": { '$sum': 1 }, "acc_arr": { '$push': '$contract_no' } } }] storedDetail = mongodb.aggregate_pipeline( MONGO_COLLECTION=store_collection, aggregate_pipeline=aggregate_stored) if storedDetail is not None: for store in storedDetail: temp['debt_acc_no'] = store['total_acc'] temp['acc_arr'] = store['acc_arr'] aggregate_account = [{ "$match": { "account_number": { '$in': temp['acc_arr'] } } }, { "$group": { "_id": 'null',
SELECT=['data'], WHERE={'name': 'Raa fields'}) users = _mongodb.get(MONGO_COLLECTION=user_collection, SELECT=['extension', 'agentname'], WHERE={'active': 'true'}) i = 1 # LNJC05 aggregate_pipeline = [{ "$lookup": { "from": action_code_collection, "localField": "account_number", "foreignField": "account_number", "as": "detail" } }] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_pipeline) for idx, row in enumerate(data): for detail in row['detail']: temp = {} temp['export_date'] = now.strftime("%d/%m/%Y") temp['index'] = i temp['account_number'] = row['account_number'] temp['phone'] = row['mobile_num'] temp['group_id'] = row['group_id'] temp['name'] = row['cus_name'] temp['overdue_date'] = row['due_date'] temp['loan_overdue_amount'] = row['loan_overdue_amount'] temp['current_balance'] = row['current_balance'] temp['outstanding_principal'] = row['outstanding_principal'] if 'assign' in detail.keys():
{ '$lookup' : { 'from' : collection_listofAccount, 'localField' : 'CONTRACTNR', 'foreignField' : 'account_number', 'as' : 'listofAccount' } }, { '$unwind' : { 'path' : '$listofAccount', 'preserveNullAndEmptyArrays' : True } } ] results_outsoucing = mongodb.aggregate_pipeline(MONGO_COLLECTION=collection,aggregate_pipeline=pipeline_outsoucing) if results_outsoucing != None: for idx,row_result in enumerate(results_outsoucing): count_account = 0 payment = 0 subdate = None os_balance = 0 if "lnjc05" in row_result: if row_result['lnjc05']['due_date'] != "": due_date = datetime.fromtimestamp(row_result['lnjc05']['due_date']) subdate = firstDayOfMonth - due_date os_balance = row_result['lnjc05']['current_balance'] # check_ln3206f = mongodb.count(MONGO_COLLECTION=collection_ln3206f, WHERE={'account_number':str(row_result['CONTRACTNR']), 'code':'10'}) check_ln3206f = mongodb.count(MONGO_COLLECTION=collection_ln3206f, WHERE={'account_number':str(row_result['CONTRACTNR']), 'code':'10', 'created_at': { '$gte' : startDayTimeStamp + 86400,'$lte' : endDayTimeStamp + 86400}}) if check_ln3206f > 0:
'group_3_over_acc_count': { '$sum': { '$cond': [{ '$and': [{ '$ne': ['$W_ORG', '.00'] }, { '$in': ['$ODIND_FG', ['C', 'D', 'E']] }] }, 1, 0] } } } }] zaccfInfo = zaccfInfo = list( mongodb.aggregate_pipeline(MONGO_COLLECTION=common.getSubUser( subUserType, 'ZACCF_report'), aggregate_pipeline=zaccf_pipeline)) if zaccfInfo != None: for zaccf in zaccfInfo: temp_detail = { 'group_code': product['group_code'], 'int_rate': zaccf['_id'], 'int_rate_name': float(zaccf['_id']), 'year': year, } temp_detail['total_w_org_' + str(report_month) + '_' + str(report_year)] = sum( map( lambda x: float(x), zaccf['total_w_org'] if 'total_w_org' in zaccf.keys() else 0))
}, 'group_id': debtGroupCell } }, { "$group": { "_id": 'null', "count_col": { '$sum': 1 }, "cur_bal_total": { '$sum': '$current_balance' } } }] lnjc05Data = mongodb.aggregate_pipeline( MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_lnjc05) if lnjc05Data != None: for row in lnjc05Data: col_today = row['count_col'] cur_bal_today = round(row['cur_bal_total'] / 1000) aggregate_ln3206 = [{ "$match": { "created_at": { '$gte': due_date_add_2, '$lte': endTodayTimeStamp }, "account_number": { '$in': acc_arr
{ "$project": { # col field "group_id": 1, "account_number": 1, "cus_name": 1, "overdue_amount_this_month": 1, 'installment_type': 1, 'advance_balance': 1, 'outstanding_principal': 1, } } ] price = mongodb.getOne(MONGO_COLLECTION=config_collection, SELECT=['conditionDonotCall']) data = mongodb.aggregate_pipeline(MONGO_COLLECTION=lnjc05_collection,aggregate_pipeline=aggregate_pipeline) count = 0 for row in data: if 'account_number' in row.keys(): condition = row['overdue_amount_this_month'] - row['advance_balance'] if condition <= price['conditionDonotCall']: zaccf = mongodb.getOne(MONGO_COLLECTION=zaccf_collection, WHERE={'account_number': str(row['account_number'])}, SELECT=['PRODGRP_ID']) if zaccf != None: if zaccf['PRODGRP_ID'] != "103" and zaccf['PRODGRP_ID'] != "402" and zaccf['PRODGRP_ID'] != "502" and zaccf['PRODGRP_ID'] != "602" and zaccf['PRODGRP_ID'] != "702" and zaccf['PRODGRP_ID'] != "802" and zaccf['PRODGRP_ID'] != "902": count +=1 temp = {} if row['installment_type'] =='n' and row['outstanding_principal'] == 0: temp['No'] = count temp['Account_No'] = row['account_number']
WHERE={ 'createdAt': { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp } }) aggregate_blockcard = [{ "$group": { "_id": 'null', "acc_blook_card": { '$push': '$account_number' }, } }] blook_acc = mongodb.aggregate_pipeline( MONGO_COLLECTION=collection, aggregate_pipeline=aggregate_blockcard) blockCard_arr = [] for row in blook_acc: blockCard_arr = row['acc_blook_card'] i = 1 # Account aggregate_acc = [{ "$lookup": { "from": common.getSubUser(subUserType, 'SBV_Stored'), "localField": "account_number", "foreignField": "contract_no", "as": "detail" } }, {
else: aggregate_pipeline = [{ "$match": { "diallist_id": ObjectId(diallist['_id']), } }, { "$group": { "_id": 'null', "total_amt": { '$sum': '$cur_bal' }, } }] diallist_detail = mongodb.aggregate_pipeline( MONGO_COLLECTION=common.getSubUser( subUserType, 'Diallist_detail'), aggregate_pipeline=aggregate_pipeline) for detail in diallist_detail: temp['tar_amt'] = (diallist['target'] * detail['total_amt']) / 100 # oldReport oldYesterdayReportData = mongodb.get( MONGO_COLLECTION=collection, WHERE={ 'team_id': str(groupCell['_id']), 'due_date_code': debtGroupCell[1:3], 'month': str(oldMonth) }, SORT=[('createdAt', -1)], SKIP=0,