Subversion Repositories SmartDukaan

Rev

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

Rev 22061 Rev 22210
Line 4014... Line 4014...
4014
            
4014
            
4015
            if order.status not in [OrderStatus.COD_VERIFICATION_FAILED,OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY]:
4015
            if order.status not in [OrderStatus.COD_VERIFICATION_FAILED,OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY]:
4016
                for line in order.lineitems:
4016
                for line in order.lineitems:
4017
                    totalCartVal = totalCartVal+line.total_price
4017
                    totalCartVal = totalCartVal+line.total_price
4018
                
4018
                
4019
        if totalCartVal < 500 and totalCartVal>0:
4019
        if totalCartVal<1000:
4020
            totalshippingCost = 100
-
 
4021
        elif totalCartVal >=500 and totalCartVal<1000:
-
 
4022
            totalshippingCost = 50
4020
            totalshippingCost = 50
4023
            
4021
            
4024
        shippingCostInOrders=0
4022
        shippingCostInOrders=0
4025
        shipUpdateOrder= None
4023
        shipUpdateOrder= None
4026
        if totalshippingCost > 0:
4024
        if totalshippingCost > 0:
Line 6046... Line 6044...
6046
    history.wallet = wallet
6044
    history.wallet = wallet
6047
    history.description = description
6045
    history.description = description
6048
    history.timestamp = datetime.datetime.now()
6046
    history.timestamp = datetime.datetime.now()
6049
    session.commit()
6047
    session.commit()
6050
 
6048
 
6051
def refund_amount_from_wallet(userId, amount, reference, reference_type, description=None):
6049
def refund_amount_from_wallet(userId, amount, reference, reference_type, description="Refunded to customer"):
6052
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6050
    if amount <= 0 or WalletReferenceType._VALUES_TO_NAMES.get(reference_type) is None:
6053
        return
6051
        return
6054
    wallet = get_user_wallet(userId)
6052
    wallet = get_user_wallet(userId)
6055
    
6053
    
6056
    wallet.amount = wallet.amount - amount
6054
    wallet.amount = wallet.amount - amount
6057
    wallet.refundable_amount = wallet.refundable_amount - amount
6055
    wallet.refundable_amount = wallet.refundable_amount - amount
-
 
6056
    if wallet.refundable_amount < 0:
-
 
6057
        return
6058
    history = UserWalletHistory()
6058
    history = UserWalletHistory()
6059
    history.amount = -amount
6059
    history.amount = -amount
6060
    history.refundable_amount = -amount
6060
    history.refundable_amount = -amount
6061
    history.reference = reference
6061
    history.reference = reference
6062
    history.reference_type = WalletReferenceType._VALUES_TO_NAMES.get(reference_type)
6062
    history.reference_type = WalletReferenceType._VALUES_TO_NAMES.get(reference_type)
6063
    history.wallet = wallet
6063
    history.wallet = wallet
6064
    history.description = "Refunded to customer"
6064
    history.description = description
6065
    history.timestamp = datetime.datetime.now()
6065
    history.timestamp = datetime.datetime.now()
6066
    session.commit()
6066
    session.commit()
6067
 
6067
 
6068
def reverse_money_to_wallet(userId, amount, reference, reference_type):
6068
def reverse_money_to_wallet(userId, amount, reference, reference_type):
6069
    
6069