Beispiel #1
0
 def deleteBankAccount(self, bid):
     dao = BankAccountDAO()
     if not dao.getBankAccountById(bid):
         return jsonify(Error="Bank Account not found."), 404
     else:
         dao.deleteBankAccount(bid)
         return jsonify(DeleteStatus="OK"), 200
Beispiel #2
0
 def getBankAccountById(self, bank_account_id):
     dao = BankAccountDAO()
     row = dao.getBankAccountById(bank_account_id)
     if not row:
         return jsonify(Error="Bank Account Not Found"), 404
     else:
         bank_account = self.build__bank_account_dict(row)
         return jsonify(BankAccount=bank_account)
Beispiel #3
0
 def getAllBankAccounts(self):
     dao = BankAccountDAO()
     bank_accounts_list = dao.getAllBankAccount()
     result_list = []
     for row in bank_accounts_list:
         result = self.build__bank_account_dict(row)
         result_list.append(result)
     return jsonify(BankAccounts=result_list)
Beispiel #4
0
 def getSuppliersByBankAccountId(self, bank_account_id):
     dao = BankAccountDAO()
     if not dao.getBankAccountById(bank_account_id):
         return jsonify(Error="Bank Account Not Found"), 404
     suppliers_list = dao.getSupplierByBankAccountId(bank_account_id)
     result_list = []
     for row in suppliers_list:
         result = self.build_supplier_dict(row)
         result_list.append(result)
     return jsonify(Supplier=result_list)
Beispiel #5
0
    def searchBankAccounts(self, args):
        dao = BankAccountDAO()

        routing = args.get('routing')
        accountNumber = args.get('accountNumber')
        BankName = args.get('BankName')

        bank_accounts_list = []

        if (len(args) == 3) and routing and accountNumber and BankName:
            bank_accounts_list = dao.getBankAccountByRoutingAccountNumberBankName(
                routing, accountNumber, BankName)
        elif (len(args) == 2) and routing and accountNumber:
            bank_accounts_list = dao.getBankAccountByRoutingAccountNumber(
                routing, accountNumber)
        elif (len(args) == 2) and routing and BankName:
            bank_accounts_list = dao.getBankAccountByRoutingBankName(
                routing, BankName)
        elif (len(args) == 2) and accountNumber and BankName:
            bank_accounts_list = dao.getBankAccountByAccountNumberBankName(
                accountNumber, BankName)
        elif (len(args) == 1) and routing:
            bank_accounts_list = dao.getBankAccountByRouting(routing)
        elif (len(args) == 1) and accountNumber:
            bank_accounts_list = dao.getBankAccountByAccountNumber(
                accountNumber)
        elif (len(args) == 1) and BankName:
            bank_accounts_list = dao.getBankAccountByBankNamet(BankName)
        else:
            return jsonify(Error="Malformed query string"), 400
        results_list = []
        for row in bank_accounts_list:
            result = self.build_bank_account_dict(row)
            results_list.append(result)
        return jsonify(Bank_Account=results_list)
Beispiel #6
0
    def searchSupplierOfThisBankAccount(self, bid, args):

        daoBank = BankAccountDAO()
        dao = SupplierDAO()

        if not daoBank.getBankAccountById(bid):
            return jsonify(Error = 'Bank Account Not Found'), 404

        afirst = args.get('afirst')
        alast = args.get('alast')
        email = args.get('email')
        phone = args.get('phone')

        suppliers_list = []

        if(len(args) == 4) and afirst and alast and email and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstAlastEmailPhone(bid, afirst, alast, email, phone)
        elif(len(args) == 3) and afirst and alast and email:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstAlastEmail(bid, afirst, alast, email)
        elif(len(args) == 3) and afirst and alast and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstAlastPhone(bid, afirst, alast, phone)
        elif(len(args) == 3) and afirst and phone and email:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstPhoneEmail(bid, afirst, phone, email)
        elif(len(args) == 3) and alast and email and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByAlastEmailPhone(bid, alast, email, phone)
        elif(len(args) == 2) and afirst and alast:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstAlast(bid, afirst, alast)
        elif(len(args) == 2) and afirst and email:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstEmail(bid, afirst, email)
        elif(len(args) == 2) and afirst and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirstPhone(bid, afirst, phone)
        elif(len(args) == 2) and alast and email:
            suppliers_list = dao.getSupplierOfThisBankAccountByAlastEmail(bid, alast, email)
        elif(len(args) == 2) and alast and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByAlastPhone(bid, alast, phone)
        elif(len(args) == 2) and email and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByEmailPhone(bid, email, phone)
        elif(len(args) == 1) and afirst:
            suppliers_list = dao.getSupplierOfThisBankAccountByAfirst(bid, afirst)
        elif(len(args) == 1) and alast:
            suppliers_list = dao.getSupplierOfThisBankAccountByAlast(bid, alast)
        elif(len(args) == 1) and email:
            suppliers_list = dao.getSupplierOfThisBankAccountByEmail(bid, email)
        elif(len(args) == 1) and phone:
            suppliers_list = dao.getSupplierOfThisBankAccountByPhone(bid, phone)
        else:
            return jsonify(Error = "Malformed query string"), 400
        result_list = []
        for row in suppliers_list:
            result = self.build_supplier_dict(row)
            result_list.append(result)
        return jsonify(Suppliers = result_list)
Beispiel #7
0
    def getSupplierOfThisBankAccount(self, bid):

        daoBank = BankAccountDAO()
        dao = SupplierDAO()

        if not daoBank.getBankAccountById(bid):
            return jsonify(Error = 'Bank Account Not Found'), 404

        suppliers_list = dao.getSupplierOfThisBankAccount(bid)
        result_list = []
        for row in suppliers_list:
            result = self.build_supplier_dict(row)
            result_list.append(result)
        return jsonify(Supplier = result_list)
Beispiel #8
0
    def getBankAccountOfThisTransaction(self, tid):

        dao = BankAccountDAO()
        daoTran = TransactionDAO()

        if not daoTran.getTransactionById(tid):
            return jsonify(Error='Transaction Not Found'), 404

        bank_accounts_list = dao.getBankAccountOfThisTransaction(tid)
        result_list = []
        for row in bank_accounts_list:
            result = self.build_bank_account_dict(row)
            result_list.append(result)
        return jsonify(Bank_Account=result_list)
Beispiel #9
0
    def getBankAccountOfThisSupplier(self, sid):

        dao = BankAccountDAO()
        daoSup = SupplierDAO()

        if not daoSup.getSupplierById(sid):
            return jsonify(Error='Supplier Not Found'), 404

        bank_accounts_list = dao.getBankAccountOfThisSupplier(sid)
        results_list = []

        for row in bank_accounts_list:
            result = self.build_bank_account_dict(row)
            results_list.append(result)
        return jsonify(Bank_Account=results_list)
Beispiel #10
0
    def updateBankAccount(self, bid, form):
        dao = BankAccountDAO()
        if not dao.getBankAccountById(bid):
            return jsonify(Error='Bank Account not found'), 404
        else:
            if len(form) != 3:
                return jsonify(Error="Malformed update request"), 400

            routing = form['routing']
            accountNumber = form['accountNumber']
            BankName = form['BankName']

            if routing and accountNumber and BankName:
                dao.updateBankAccount(bid, routing, accountNumber, BankName)
                result = self.build_bank_account_attributes(
                    bid, routing, accountNumber, BankName)
                return jsonify(BankAccount=result)
            else:
                return jsonify(
                    Error="Unexpected attributes in update request"), 400
Beispiel #11
0
    def addNewBankAccount(self, form):
        if len(form) != 4:
            return jsonify(Error="Malformed post request"), 400
        else:

            routing = form['routing']
            accountNumber = form['accountNumber']
            BankName = form['BankName']
            sid = form['sid']

            if routing and accountNumber and BankName and sid:
                dao = BankAccountDAO()
                bid = dao.addNewBankAccount(routing, accountNumber, BankName,
                                            sid)
                result = self.build_bank_account_attributes(
                    bid, routing, accountNumber, BankName)
                return jsonify(BankAccount=result), 201
            else:
                return jsonify(
                    Error="Unexpected attributes in post request"), 400
Beispiel #12
0
    def seatchBankAccountOfThisTransaction(self, tid, args):

        dao = BankAccountDAO()
        daoTran = TransactionDAO()

        if not daoTran.getTransactionById(tid):
            return jsonify(Error='Transaction Not Found'), 404

        routing = args.get('routing')
        accountNumber = args.get('accountNumber')
        BankName = args.get('BankName')

        bank_accounts_list = []

        if (len(args) == 3) and routing and accountNumber and BankName:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByRoutingAccountNumberBankName(
                tid, routing, accountNumber, BankName)
        elif (len(args) == 2) and routing and accountNumber:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByRoutingAccountNumber(
                tid, routing, accountNumber)
        elif (len(args) == 2) and routing and BankName:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByRoutingBankName(
                tid, routing, BankName)
        elif (len(args) == 2) and accountNumber and BankName:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByAccountNumberBankName(
                tid, accountNumber, BankName)
        elif (len(args) == 1) and routing:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByRouting(
                tid, routing)
        elif (len(args) == 1) and accountNumber:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByAccountNumber(
                tid, accountNumber)
        elif (len(args) == 1) and BankName:
            bank_accounts_list = dao.getBankAccountOfThisTransactionByBankName(
                tid, BankName)
        else:
            return jsonify(Error="Malformed query string"), 400
        result_list = []

        for row in bank_accounts_list:
            result = self.build_bank_account_dict(row)
            result_list.append(result)
        return jsonify(Bank_Account=result_list)
Beispiel #13
0
    def searchBankAccounts(self, args):
        bank_account_no = args.get("bank_account_no")
        bank_account_type = args.get("bank_account_type")
        amount = args.get("amount")
        dao = BankAccountDAO()
        bank_accounts_list = []

        if (len(args) == 1) and bank_account_no:
            bank_accounts_list = dao.getBankAccountByBankAccountNo(
                bank_account_no)
        elif (len(args) == 1) and bank_account_type:
            bank_accounts_list = dao.getBankAccountByAccountType(
                bank_account_type)
        elif (len(args) == 1) and amount:
            bank_accounts_list = dao.getBankAccountByAmount(amount)
        else:
            return jsonify(Error="Malformed query string"), 400
        result_list = []

        for row in bank_accounts_list:
            result = self.build__bank_account_dict(row)
            result_list.append(result)
        return jsonify(Bankaccounts=result_list)