| Line 9592... |
Line 9592... |
| 9592 |
if userId:
|
9592 |
if userId:
|
| 9593 |
us_query = us_query.filter(UserSanction.user_id == userId)
|
9593 |
us_query = us_query.filter(UserSanction.user_id == userId)
|
| 9594 |
if creditorId:
|
9594 |
if creditorId:
|
| 9595 |
us_query = us_query.filter(UserSanction.creditor_id == creditorId)
|
9595 |
us_query = us_query.filter(UserSanction.creditor_id == creditorId)
|
| 9596 |
us_query = us_query.filter(UserSanction.active == True)
|
9596 |
us_query = us_query.filter(UserSanction.active == True)
|
| 9597 |
print sort
|
- |
|
| 9598 |
if sort == 'loan':
|
9597 |
if sort == 'loan':
|
| 9599 |
print 'Here'
|
- |
|
| 9600 |
us_query = us_query.order_by(desc(UserSanction.loan))
|
9598 |
us_query = us_query.order_by(desc(UserSanction.loan))
|
| 9601 |
if limit>0:
|
9599 |
if limit>0:
|
| 9602 |
us_query = us_query.limit(limit)
|
9600 |
us_query = us_query.limit(limit)
|
| 9603 |
if offset>0 and limit >0:
|
9601 |
if offset>0 and limit >0:
|
| 9604 |
us_query = us_query.offset(offset)
|
9602 |
us_query = us_query.offset(offset)
|
| Line 9940... |
Line 9938... |
| 9940 |
creditObj.amount = amount
|
9938 |
creditObj.amount = amount
|
| 9941 |
creditObj.credit_type = credit_type
|
9939 |
creditObj.credit_type = credit_type
|
| 9942 |
creditObj.shipping_id = shipping_id
|
9940 |
creditObj.shipping_id = shipping_id
|
| 9943 |
return creditObj
|
9941 |
return creditObj
|
| 9944 |
|
9942 |
|
| - |
|
9943 |
def get_outstanding_payments(fetchType,userId=0,limit=100):
|
| - |
|
9944 |
if fetchType =='loan':
|
| - |
|
9945 |
return fetch_outstanding_loans(userId,limit)
|
| - |
|
9946 |
elif fetchType =='credit':
|
| - |
|
9947 |
return fetch_outstanding_credits(userId,limit)
|
| - |
|
9948 |
else:
|
| - |
|
9949 |
return None
|
| - |
|
9950 |
|
| - |
|
9951 |
def fetch_outstanding_loans(userId,limit):
|
| - |
|
9952 |
userCounterMap={}
|
| - |
|
9953 |
try:
|
| - |
|
9954 |
loan_os_query = session.query(LoanHistory.user_id,LoanHistory.creditor_id,LoanHistory.payment_id,func.sum(LoanHistory.amount).label('totalAmount'),func.max(LoanHistory.due_date).label('createdDate'))
|
| - |
|
9955 |
user_client = UserClient().get_client()
|
| - |
|
9956 |
if userId>0:
|
| - |
|
9957 |
loan_os_query = loan_os_query.filter(LoanHistory.user_id==userId)
|
| - |
|
9958 |
loan_os_result = loan_os_query.group_by(LoanHistory.payment_id).having(func.sum(LoanHistory.amount)>0).order_by(func.max(LoanHistory.id)).all()
|
| - |
|
9959 |
if loan_os_result is not None or len(loan_os_result)>0:
|
| - |
|
9960 |
userIds=[]
|
| - |
|
9961 |
for r in loan_os_result:
|
| - |
|
9962 |
userIds.append(r.user_id)
|
| - |
|
9963 |
userCounterMap = user_client.getCounterName(userIds)
|
| - |
|
9964 |
return userCounterMap, loan_os_result
|
| - |
|
9965 |
except Exception as e:
|
| - |
|
9966 |
print e
|
| - |
|
9967 |
|
| - |
|
9968 |
def fetch_outstanding_credits(userId,limit):
|
| - |
|
9969 |
credit_hs_query = CreditHistory.query(CreditHistory.user_id,CreditHistory.creditor_id,CreditHistory.payment_id,CreditHistory.amount,CreditHistory.created)
|
| - |
|
9970 |
if userId>0:
|
| - |
|
9971 |
credit_hs_query = credit_hs_query.filter(CreditHistory.user_id==userId)
|
| - |
|
9972 |
credit_hs_query = credit_hs_query.group_by(CreditHistory.payment_id).having(func.sum(CreditHistory.amount)>0).order_by(func.max(CreditHistory.id)).all()
|
| - |
|
9973 |
|
| 9945 |
def set_order_attribute_for_master_order_id(logisticsTransactionId, attributes):
|
9974 |
def set_order_attribute_for_master_order_id(logisticsTransactionId, attributes):
|
| 9946 |
orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
|
9975 |
orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
|
| 9947 |
for order in orders:
|
9976 |
for order in orders:
|
| 9948 |
for attribute in attributes :
|
9977 |
for attribute in attributes :
|
| 9949 |
existingAttribute = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == attribute.name).first()
|
9978 |
existingAttribute = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == attribute.name).first()
|