| Line 5874... |
Line 5874... |
| 5874 |
wallet.amount = 0
|
5874 |
wallet.amount = 0
|
| 5875 |
wallet.userId = userId
|
5875 |
wallet.userId = userId
|
| 5876 |
wallet.refundable_amount = 0
|
5876 |
wallet.refundable_amount = 0
|
| 5877 |
return wallet
|
5877 |
return wallet
|
| 5878 |
|
5878 |
|
| 5879 |
def get_user_wallet_history(userId):
|
5879 |
def get_user_wallet_history(userId, offset=0, limit=50):
|
| 5880 |
wallet = get_user_wallet(userId)
|
5880 |
wallet = get_user_wallet(userId)
|
| 5881 |
if wallet.id:
|
5881 |
if wallet.id:
|
| 5882 |
return UserWalletHistory.query.filter_by(wallet = wallet).all()
|
5882 |
return UserWalletHistory.query.filter_by(wallet = wallet).offset(offset).limit(limit).order_by(desc(UserWalletHistory.id)).all()
|
| 5883 |
else:
|
5883 |
else:
|
| 5884 |
return []
|
5884 |
return []
|
| 5885 |
|
5885 |
|
| 5886 |
def get_provider(providerId):
|
5886 |
def get_provider(providerId):
|
| 5887 |
return ServiceProvider.query.filter_by(id = providerId).one()
|
5887 |
return ServiceProvider.query.filter_by(id = providerId).one()
|
| Line 11552... |
Line 11552... |
| 11552 |
l3 = session.query(PMSA.id).filter(PMSA.l1_id == a.id).filter(PMSA.level == "L3").count()
|
11552 |
l3 = session.query(PMSA.id).filter(PMSA.l1_id == a.id).filter(PMSA.level == "L3").count()
|
| 11553 |
not_activated = session.query(PMSA.id).filter(PMSA.l1_id == a.id).filter(PMSA.activated == False).count()
|
11553 |
not_activated = session.query(PMSA.id).filter(PMSA.l1_id == a.id).filter(PMSA.activated == False).count()
|
| 11554 |
total = session.query(PMSA.id).filter(PMSA.l1_id == a.id).count()
|
11554 |
total = session.query(PMSA.id).filter(PMSA.l1_id == a.id).count()
|
| 11555 |
return [l2,l3,total,not_activated,total-not_activated]
|
11555 |
return [l2,l3,total,not_activated,total-not_activated]
|
| 11556 |
|
11556 |
|
| 11557 |
def credit_user_wallet(userId, amount, cash_back):
|
11557 |
def credit_user_wallet(userId, amount, cash_back, shortDesc):
|
| 11558 |
user_client = UserClient().get_client()
|
11558 |
user_client = UserClient().get_client()
|
| 11559 |
t_user = user_client.getUserById(userId)
|
11559 |
t_user = user_client.getUserById(userId)
|
| 11560 |
if t_user.userId == -1 or amount <=0:
|
11560 |
if t_user.userId == -1 or amount <=0:
|
| 11561 |
raise
|
11561 |
raise
|
| 11562 |
ap = AdvancePayments()
|
11562 |
ap = AdvancePayments()
|
| Line 11564... |
Line 11564... |
| 11564 |
ap.amount = amount
|
11564 |
ap.amount = amount
|
| 11565 |
ap.cash_back = cash_back
|
11565 |
ap.cash_back = cash_back
|
| 11566 |
ap.cash_back_type = "PERCENTAGE"
|
11566 |
ap.cash_back_type = "PERCENTAGE"
|
| 11567 |
ap.cash_back_amount = int(math.floor(amount * (cash_back/100)))
|
11567 |
ap.cash_back_amount = int(math.floor(amount * (cash_back/100)))
|
| 11568 |
session.commit()
|
11568 |
session.commit()
|
| 11569 |
if cash_back:
|
11569 |
if not shortDesc:
|
| 11570 |
description = "Paid in advance Rs.{0} + {1}% advance cashback".format(amount, cash_back)
|
- |
|
| 11571 |
else:
|
- |
|
| 11572 |
description = "Paid in advance"
|
11570 |
shortDesc = "Paid in advance"
|
| 11573 |
add_amount_in_wallet(userId, ap.amount + ap.cash_back_amount, ap.id, WalletReferenceType.ADVANCE_AMOUNT, description, True, commit_session=True)
|
11571 |
add_amount_in_wallet(userId, ap.amount + ap.cash_back_amount, ap.id, WalletReferenceType.ADVANCE_AMOUNT, shortDesc, True, commit_session=True)
|
| 11574 |
return True
|
11572 |
return True
|
| 11575 |
|
11573 |
|
| 11576 |
#refund complete shipping if type is list else as per map
|
11574 |
#refund complete shipping if type is list else as per map
|
| 11577 |
def __refund_shipping(orders, commit=True):
|
11575 |
def __refund_shipping(orders, commit=True):
|
| 11578 |
if type(orders) is list:
|
11576 |
if type(orders) is list:
|