Subversion Repositories SmartDukaan

Rev

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

Rev 20928 Rev 20931
Line 6010... Line 6010...
6010
    
6010
    
6011
def consume_wallet(userId, amount, reference, reference_type):
6011
def consume_wallet(userId, amount, reference, reference_type):
6012
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6012
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6013
        return
6013
        return
6014
    wallet = get_user_wallet(userId)
6014
    wallet = get_user_wallet(userId)
6015
    if wallet.amount < amount:
-
 
6016
        return
-
 
6017
    refundable_amount = wallet.refundable_amount
6015
    refundable_amount = wallet.refundable_amount
6018
    promotional_amount = wallet.amount - wallet.refundable_amount
6016
    promotional_amount = wallet.amount - wallet.refundable_amount
6019
    refundable_amount_used = 0
6017
    refundable_amount_used = 0
6020
    
6018
    
6021
    if promotional_amount < amount:
6019
    if promotional_amount < amount:
Line 6038... Line 6036...
6038
 
6036
 
6039
def refund_amount_from_wallet(userId, amount, reference, reference_type):
6037
def refund_amount_from_wallet(userId, amount, reference, reference_type):
6040
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6038
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6041
        return
6039
        return
6042
    wallet = get_user_wallet(userId)
6040
    wallet = get_user_wallet(userId)
6043
    if wallet.refundable_amount < amount or wallet.amount < amount:
-
 
6044
        return
-
 
6045
    
6041
    
6046
    wallet.amount = wallet.amount - amount
6042
    wallet.amount = wallet.amount - amount
6047
    wallet.refundable_amount = wallet.refundable_amount - amount
6043
    wallet.refundable_amount = wallet.refundable_amount - amount
6048
    history = UserWalletHistory()
6044
    history = UserWalletHistory()
6049
    history.amount = -amount
6045
    history.amount = -amount