Subversion Repositories SmartDukaan

Rev

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

Rev 19891 Rev 19912
Line 9980... Line 9980...
9980
            userCounterMap = user_client.getCounterName(userIds)
9980
            userCounterMap = user_client.getCounterName(userIds)
9981
        return userCounterMap, credit_os_result 
9981
        return userCounterMap, credit_os_result 
9982
    except Exception as e:
9982
    except Exception as e:
9983
        print e
9983
        print e
9984
 
9984
 
-
 
9985
def mark_payment_settled(userId,paymentId,totalAmount,repaymentDate):
-
 
9986
    try:
-
 
9987
        pendingSettlements = session.query(LoanHistory).filter_by(user_id=userId,payment_id=paymentId).all()
-
 
9988
        if pendingSettlements is not None:
-
 
9989
            amount=0
-
 
9990
            for pendingSettlement in pendingSettlements:
-
 
9991
                amount += pendingSettlement.amount
-
 
9992
            if amount!=totalAmount:
-
 
9993
                return False,"Amount mismatch for the particular payment id"
-
 
9994
            else:
-
 
9995
                loanObjs = []
-
 
9996
                for pendingSettlement in pendingSettlements:
-
 
9997
                    loanObj = __loanHistoryObj(pendingSettlement.user_id, 1, pendingSettlement.payment_id, pendingSettlement.amount, CreditTxnType.PAID, pendingSettlement.loan_id,datetime.datetime.strptime(repaymentDate, '%Y-%m-%d'), pendingSettlement.invoiceNumber)
-
 
9998
                    loanObjs.append(loanObj)
-
 
9999
                if process_loan_transaction(paymentId, userId, 1, loanObjs):
-
 
10000
                    return True,"Successfully settled payment"
-
 
10001
        else:
-
 
10002
            return False,"No payment to be settled."    
-
 
10003
    except:
-
 
10004
        print traceback.print_exc()
-
 
10005
        return False,"Some exception at the backend"
-
 
10006
        
-
 
10007
        
-
 
10008
def mark_payment_settled_partial(userId,paymentId,totalAmount,repaymentDate):
-
 
10009
    try:
-
 
10010
        pendingSettlements = session.query(LoanHistory).filter_by(user_id=userId,payment_id=paymentId).all()
-
 
10011
        if pendingSettlements is not None:
-
 
10012
            amount=0
-
 
10013
            for pendingSettlement in pendingSettlements:
-
 
10014
                amount += pendingSettlement.amount
-
 
10015
            if amount!=totalAmount:
-
 
10016
                return False,"Amount mismatch for the particular payment id"
-
 
10017
            else:
-
 
10018
                loanObjs = []
-
 
10019
                for pendingSettlement in pendingSettlements:
-
 
10020
                    loanObj = __loanHistoryObj(pendingSettlement.user_id, 1, pendingSettlement.payment_id, pendingSettlement.amount, CreditTxnType.PAID, pendingSettlement.loan_id,datetime.datetime.strptime(repaymentDate, '%Y-%m-%d'), pendingSettlement.invoiceNumber)
-
 
10021
                    loanObjs.append(loanObj)
-
 
10022
                process_loan_transaction(paymentId, userId, 1, loanObjs)
-
 
10023
        else:
-
 
10024
            return False,"No payment to be settled."    
-
 
10025
    except:
-
 
10026
        print traceback.print_exc()
-
 
10027
        
9985
def set_order_attribute_for_master_order_id(logisticsTransactionId, attributes):
10028
def set_order_attribute_for_master_order_id(logisticsTransactionId, attributes):
9986
    orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
10029
    orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
9987
    for order in orders:
10030
    for order in orders:
9988
        for attribute in attributes :
10031
        for attribute in attributes :
9989
            existingAttribute = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == attribute.name).first()
10032
            existingAttribute = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == attribute.name).first()
Line 10914... Line 10957...
10914
    returnOrder = ReturnOrderInfo.get_by(id=returnOrderId)
10957
    returnOrder = ReturnOrderInfo.get_by(id=returnOrderId)
10915
    if returnOrder is None:
10958
    if returnOrder is None:
10916
        raise TransactionServiceException(101, "No Return Order is there with this Order Id")
10959
        raise TransactionServiceException(101, "No Return Order is there with this Order Id")
10917
    
10960
    
10918
if __name__ == '__main__':
10961
if __name__ == '__main__':
10919
    print get_orders_by_mobile_number("9650889334")
10962
    print get_orders_by_mobile_number("9650889334")
10920
10963