Example #1
0
    def getTransactions(accounttype, accountno, startdate, enddate):
        try:
            # print(accounttype)
            transactionDict = {}
            transactions = Dbase.getTransactionDetails(accounttype, accountno)
            if accounttype == "debitcard":
                debit_accountno = Dbase.getDebitCardAccountno(accountno)
                transactions += Dbase.getTransactionDetails(
                    accounttype, debit_accountno)
                # print(transactions)
            tranxList = []
            # print(transactions)
            transactions.sort(
                key=lambda r: time.strptime(r[8], '%m:%d:%Y %H:%M:%S'),
                reverse=True)
            for trans in transactions:
                tranxDict = {}
                tranxDict['tranxdate'] = trans[8].split(' ')[0].replace(
                    ':', '/')
                if time.strptime(tranxDict['tranxdate'],
                                 '%m/%d/%Y') >= startdate and time.strptime(
                                     tranxDict['tranxdate'],
                                     '%m/%d/%Y') <= enddate:

                    tranxDict['tranxid'] = trans[0]
                    tranxDict['account1type'] = trans[2]
                    tranxDict['account2'] = trans[3]
                    tranxDict['account2type'] = trans[4]
                    tranxDict['amount'] = trans[5]
                    tranxDict['tranxtype'] = trans[6]
                    tranxDict['tranxdate'] = trans[8].split(' ')[0].replace(
                        ':', '/')
                    tranxDict['tranxtime'] = trans[8].split(' ')[1]
                    tranxDict['status'] = trans[9]
                    tranxList.append(tranxDict)

            transactionDict['transactions'] = tranxList
            return transactionDict
        except Exception as e:
            raise e
Example #2
0
 def getAccountDetails(accounttype, accountno):
     try:
         detailsDict = {}
         account = Dbase.getAccountDetails(accounttype, accountno)
         print(account)
         detailsDict['accounttype'] = accounttype
         detailsDict['id'] = accountno
         print(account)
         if accounttype == 'loanaccount':
             detailsDict['loannumber'] = account[0]
             detailsDict['customername'] = account[1]
             detailsDict['password'] = account[2]
             detailsDict['loantype'] = account[4]
             detailsDict['loanamount'] = str(amount[5])
         elif accounttype == 'insurance':
             detailsDict['number'] = account[0]
             detailsDict['customername'] = account[1]
             detailsDict['password'] = account[2]
             detailsDict['insurancetype'] = account[4]
             detailsDict['premium'] = account[5]
             detailsDict['duedate'] = time.strftime(
                 '%m\%d\%Y', time.strptime(account[6], '%m-%d-%Y'))
             detailsDict['insuranceamount'] = account[7]
         elif accounttype == 'creditcard':
             detailsDict['cardnumber'] = account[0]
             detailsDict['cardholder'] = account[1]
             detailsDict['pin'] = account[2]
             detailsDict['creditlimit'] = str(account[4])
             detailsDict['amountdue'] = str(account[5])
         else:
             detailsDict['cardnumber'] = account[0]
             detailsDict['cardholder'] = account[2]
             detailsDict['pin'] = account[3]
             detailsDict['accountnumber'] = account[1]
             detailsDict['accountbalance'] = str(account[5])
             detailsDict['debitaccounttype'] = account[6]
         transactions = Dbase.getTransactionDetails(accounttype, accountno)
         if accounttype == "debitcard":
             debit_accountno = Dbase.getDebitCardAccountno(accountno)
             transactions += Dbase.getTransactionDetails(
                 accounttype, debit_accountno)
         tranxList = []
         transactions.sort(
             key=lambda r: time.strptime(r[8], '%m:%d:%Y %H:%M:%S'),
             reverse=True)
         count = 0
         for trans in transactions:
             tranxDict = {}
             tranxDict['tranxid'] = trans[0]
             tranxDict['account1type'] = trans[2]
             tranxDict['account2'] = trans[3]
             tranxDict['account2type'] = trans[4]
             tranxDict['amount'] = trans[5]
             tranxDict['tranxtype'] = trans[6]
             tranxDict['tranxdate'] = trans[8].split(' ')[0].replace(
                 ':', '/')
             tranxDict['tranxtime'] = trans[8].split(' ')[1]
             tranxDict['status'] = trans[9]
             tranxList.append(tranxDict)
             count += 1
             if count == 10:
                 break
         detailsDict['transactions'] = tranxList
         return detailsDict
     except Exception as e:
         raise e