Пример #1
0
def external_transfer():
    if request.method == 'POST':
        from_acc = request.form['from_acc']
        to_bank = request.form['to_bank']
        swift = session.query(Banks).filter_by(name=to_bank).first()
        swift_code = swift.swift_code
        to_ext_acc = request.form['to_ext_acc']
        remark = request.form['remark']
        remark += " " + str(swift_code)
        amount = float(request.form['amount'])
        if amount > Getters.getCustomerAccountDetails(from_acc).working_bal:
            flash('Account Balance is Less than Required')
            return redirect(url_for('banking.external_transfer'))
        else:
            TransactionUpdate.externalTransferTransactionUpdate(
                from_acc, to_ext_acc, amount, remark,
                Getters.getSysDate().date)

            # TransactionUpdate.accChargeUpdate('RTGS', from_acc, Getters.getSysDate().date)
            ChargeTransaction(Getters.getSysDate().date,
                              from_acc).charges(TransactionType.RTGS)
            flash('RTGS Successful')
            return redirect(url_for('banking.external_transfer'))
    else:
        record = []
        # fad = From Account Details
        # tad = To Account Details
        fad = None
        tad = None
        return render_template('banking/external_transfer.html',
                               fad=fad,
                               tad=tad,
                               record=record,
                               user=Profile().user_details(),
                               banks=Getters.getBanks())
Пример #2
0
def transfer():
    if request.method == 'POST':
        from_acc = request.form['from_acc']
        to_acc = request.form['to_acc']
        remark = request.form['remark']
        amount = float(request.form['amount'])
        if amount > Getters.getCustomerAccountDetails(from_acc).working_bal:
            flash('The Account ' + from_acc + ' has no overdraft facility ')
            return redirect(url_for('banking.transfer'))
        else:
            TransactionUpdate.transferTransactionUpdate(
                from_acc, to_acc, amount, remark,
                Getters.getSysDate().date)
            # TransactionUpdate.accChargeUpdate('TR', from_acc, Getters.getSysDate().date)
            ChargeTransaction(Getters.getSysDate().date,
                              from_acc).charges(TransactionType.TRANSFER)

            flash('Transfer Successful')
            return redirect(url_for('banking.transfer'))
    else:
        record = []
        fad = None
        tad = None
        return render_template('banking/transfer.html',
                               user=Profile().user_details(),
                               record=record,
                               fad=fad,
                               tad=tad)
Пример #3
0
def deposits():
    record = None
    if request.method == 'POST':
        if Verify.till_is_linked(login_session['username']):
            cr_account_number = int(request.form['client_account'])
            if Verify.account_exists(cr_account_number):
                system_date = Getters.getSysDate(
                ).date  # use system date for transactions
                dep_ref = request.form['deposit_ref']
                amount = float(request.form['deposit_amount'])

                AccountTransaction(
                    date=system_date,
                    amount=amount,
                    cr_account=cr_account_number).deposit(dep_ref)

                TransactionUpdate.ttUpdate(TransactionType.DEBIT, amount,
                                           system_date, dep_ref,
                                           cr_account_number)
                flash('Account Credited')
                return redirect(
                    url_for('banking.deposits', user=Profile().user_details()))
            else:
                flash('Account Cannot be found: Search again')
                return redirect(
                    url_for('banking.deposits', user=Profile().user_details()))
        else:
            flash('User is NOT linked to Any Till. Please Open a Till First')
            return redirect(url_for('banking.deposits'))
    else:
        return render_template('banking/deposits.html',
                               record=record,
                               user=Profile().user_details())
Пример #4
0
def amend_cus():
    record = None
    if request.method == 'POST':
        acc_num = int(request.form['acc_number'])
        if Verify.account_exists(acc_num):

            a_record = session.query(Customer).filter_by(
                acc_number=acc_num).one()
            if request.form['first_name'] == a_record.first_name:
                pass
            else:
                a_record.first_name = request.form['first_name']
            if request.form['last_name'] == a_record.last_name:
                pass
            else:
                a_record.last_name = request.form['last_name']
            if request.form['dob'] == a_record.dob:
                pass
            else:
                a_record.dob = request.form['dob']
            if request.form['gender'] == a_record.gender:
                pass
            else:
                a_record.gender = request.form['gender']
            if request.form['contact_number'] == a_record.contact_number:
                pass
            else:
                a_record.contact_number = int(request.form['contact_number'])
            if request.form['email'] == a_record.email:
                pass
            else:
                a_record.email = request.form['email']
            if request.form['address'] == a_record.address:
                pass
            else:
                a_record.address = request.form['address']
            if request.form['country'] == a_record.country:
                pass
            else:
                a_record.country = request.form['country']
            if request.form['account_type'] == a_record.account_type:
                pass
            else:
                a_record.account_type = request.form['account_type']
            a_record.create_date = a_record.create_date

            session.add(a_record)
            session.commit()
            return redirect(
                url_for('customer.my_cus', user=Profile().user_details()))
        else:
            flash('Account Cannot be modified, Search Again')
            record = None
            return redirect(url_for('customer.amend_cus'))
    else:
        return render_template('customer/amend_cus.html',
                               record=record,
                               user=Profile().user_details(),
                               account=Getters.getAccountType())
Пример #5
0
def bulk_salaries():
    record = []
    if request.method == 'POST':
        file_name = secure_filename(request.files['salary_file'].filename)
        # load the file from the form
        file = request.files['salary_file']

        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            # Upload the file in the in the folder
            file.save(os.path.join(UPLOAD_FOLDER, filename))
            location_and_name = os.path.join(UPLOAD_FOLDER, filename)

            with open('Uploads\\' + filename, 'r') as f:
                # f_contents = f.readline()
                for line in f:
                    record_line = line.split(',')
                    from_acc = int(record_line[0])
                    to_acc = int(record_line[1])
                    amount = float(record_line[2])
                    remark = record_line[3]

                    print(record_line)

                    TransactionUpdate.transferTransactionUpdate(
                        from_acc, to_acc, amount, remark,
                        Getters.getSysDate().date)
                    ChargeTransaction(Getters.getSysDate().date,
                                      from_acc).charges(
                                          TransactionType.TRANSFER)

                    # print(line, end='')
                flash("uploaded and posted")
        else:
            flash("Please Check file extension")
            return redirect(url_for('bulk.bulk_salaries'))
        return render_template('bulk/bulk_salaries.html',
                               record=record,
                               user=Profile().user_details())
    else:
        return render_template('bulk/bulk_salaries.html',
                               record=record,
                               user=Profile().user_details())
Пример #6
0
def external_transfer_search():
    if request.method == 'POST':
        acc_num = int(request.form['from_account'])
        if session.query(Customer).filter_by(acc_number=acc_num).first():
            record = session.query(Customer).filter_by(
                acc_number=acc_num).first()
            return render_template(
                'banking/external_transfer.html',
                record=Getters.getCustomerAccountDetails(acc_num),
                user=Profile().user_details(),
                banks=Getters.getBanks(),
                fad=Getters.getCustomerAccountDetails(acc_num))
        else:
            flash('The Account Number Provided Is NOT In The System')
            record = None
            return render_template('banking/deposits.html',
                                   record=record,
                                   user=Profile().user_details(),
                                   banks=Getters.getBanks())
    else:
        return redirect(url_for('banking.deposits'))
Пример #7
0
 def _generate_transaction_reference(self):
     sys_date = datetime.datetime.strptime(Getters.getSysDate().date,
                                           '%Y-%m-%d')
     time_component = sys_date.strftime("%y%m%d")
     alphabet = [
         'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
         'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
     ]
     random.shuffle(alphabet)
     rand_string = random.sample(alphabet, 5)
     alp = "".join(rand_string)
     ref_str = "FT" + str(time_component) + alp.upper()
     return ref_str
Пример #8
0
def add_cus():
    new_account = Auto().account_number_generator()
    # name = request.form['first_name']

    if request.method == 'POST':

        first_name = request.form['first_name']
        last_name = request.form['last_name']
        dob = request.form['dob']
        gender = request.form['gender']
        contact_number = request.form['contact_number']
        email = request.form['email']
        address = request.form['address']
        country = request.form['country']
        acc_number = request.form['acc_number']
        initial_deposit = request.form['working_bal']
        if initial_deposit == "":
            working_bal = float(0)
        else:
            working_bal = float(initial_deposit)
        account_type = request.form['account_type']

        CustomerController(
            first_name=first_name,
            last_name=last_name,
            dob=dob,
            gender=gender,
            contact_number=contact_number,
            email=email,
            address=address,
            country=country,
            new_account=new_account,
            working_bal=working_bal,
            account_type=account_type,
            inputter_id=Profile().user_details().uid).create_customer()

        result = AccountTransaction(date=time.strftime('%Y-%m-%d'),
                                    amount=working_bal,
                                    cr_account=new_account).create_account()
        if result == 0:
            flash("account Creation Failed")
        else:
            flash("Account Created Successfully")

        return redirect(url_for('customer.my_cus'))
    else:
        return render_template('customer/add_cus.html',
                               new_account=new_account,
                               user=Profile().user_details(),
                               account=Getters.getAccountType())
Пример #9
0
def transfer_search():
    if request.method == 'POST':
        from_account = request.form['from_account']
        to_account = request.form['to_account']
        if from_account == to_account:
            flash('The Accounts submitted are the same')
            return redirect(url_for('banking.transfer'))

        if Verify.account_exists(from_account):
            if Verify.account_exists(to_account):
                record = [from_account, to_account]
                return render_template(
                    'banking/transfer.html',
                    user=Profile().user_details(),
                    record=record,
                    fad=Getters.getCustomerAccountDetails(from_account),
                    tad=Getters.getCustomerAccountDetails(to_account))
            else:
                flash('To Account number is not valid')
                return redirect(url_for('banking.transfer'))
        else:
            flash('from account is not valid')
            return redirect(url_for('banking.transfer'))
Пример #10
0
def stmt_print(account, start_date, end_date):
    dt = Getters.getSysDate().date  # time.strftime('%Y-%m-%d')
    acc_num = int(account)
    start_date = start_date
    end_date = end_date
    # record = session.query(Customer).filter_by(acc_number=acc_num).first()
    record, statement_records = Search.search_stmt_transactions(
        acc_num, start_date, end_date)
    return render_template('banking/stmt_printed.html',
                           record=record,
                           stmt=statement_records,
                           dt=dt,
                           sd=start_date,
                           ed=end_date,
                           user=Profile().user_details())
Пример #11
0
def id_search():
    if request.method == 'POST':
        id_num = int(request.form['customer_id'])
        if session.query(Customer).filter_by(custid=id_num).first():
            record = session.query(Customer).filter_by(custid=id_num).first()
            return render_template('customer/amend_cus.html',
                                   record=record,
                                   user=Profile().user_details(),
                                   account=Getters.getAccountType())
        else:
            flash('The Customer System ID Provided Is NOT Valid')
            record = None
            return render_template('customer/amend_cus.html',
                                   record=record,
                                   user=Profile().user_details())
    else:
        flash('Failed to go through the IF STMT')
        return redirect(
            url_for('customer.amend_cus', user=Profile().user_details()))
Пример #12
0
def account_search():
    if request.method == 'POST':
        acc_num = int(request.form['account_number'])
        if session.query(Customer).filter_by(acc_number=acc_num).first():
            record = session.query(Customer).filter_by(
                acc_number=acc_num).first()
            return render_template('customer/amend_cus.html',
                                   record=record,
                                   user=Profile().user_details(),
                                   account=Getters.getAccountType())
        else:
            flash('The Account Number Provided Is NOT In The System')
            record = None
            return render_template('customer/amend_cus.html',
                                   record=record,
                                   user=Profile().user_details())
    else:
        return redirect(
            url_for('customer.amend_cus', user=Profile().user_details()))
Пример #13
0
def stmt_search():
    dt = Getters.getSysDate().date  # time.strftime('%Y-%m-%d')
    start_date = ''
    end_date = ''
    if request.method == 'POST':
        acc_num = int(request.form['account_number'])
        start_date = request.form['start_date']
        end_date = request.form['end_date']

        record, statement_records = Search.search_stmt_transactions(
            acc_num, start_date, end_date)

        if record is not None and statement_records:
            return render_template('banking/statement.html',
                                   record=record,
                                   stmt=statement_records,
                                   dt=dt,
                                   sd=start_date,
                                   ed=end_date,
                                   user=Profile().user_details())
        else:
            flash('The Account Number Provided Is NOT In The System')
            return render_template('banking/statement.html',
                                   record=record,
                                   stmt=statement_records,
                                   dt=dt,
                                   sd=start_date,
                                   ed=end_date,
                                   user=Profile().user_details())
    else:
        return redirect(
            url_for('banking.statement',
                    dt=dt,
                    sd=start_date,
                    ed=end_date,
                    user=Profile().user_details()))
Пример #14
0
def withdrawal():
    record = None
    if request.method == 'POST':
        if Verify.till_is_linked(login_session['username']):

            acc_num = int(request.form['client_account'])
            if Verify.account_exists(acc_num):
                date = Getters.getSysDate().date  # time.strftime('%Y-%m-%d')
                dep_ref = request.form['withdrawal_ref']
                ref = Auto.reference_string_generator()
                amount = float(request.form['withdrawal_amount'])

                # TransactionUpdate.withdrawalTransactionUpdate(date, acc_num, amount, ref)
                AccountTransaction(date, amount, acc_num).withdrawal(ref)

                # TransactionUpdate.accChargeUpdate(TransactionType.CREDIT, acc_num, date)
                ChargeTransaction(date,
                                  acc_num).charges(TransactionType.CREDIT)

                TransactionUpdate.ttUpdate(TransactionType.CREDIT, amount,
                                           date, dep_ref, acc_num)
                flash('Account Debited')
                return redirect(
                    url_for('banking.withdrawal', user=Profile.user_details()))
            else:
                flash('Account Cannot be found: Search again')
                return redirect(
                    url_for('banking.withdrawal', user=Profile.user_details()))
        else:
            flash('User is not linked to Any Till. Please Open a Till First')
            return redirect(
                url_for('banking.withdrawal', user=Profile().user_details()))
    else:
        return render_template('banking/withdrawal.html',
                               record=record,
                               user=Profile().user_details())
Пример #15
0
 def till_is_linked(cls, email):
     cls._v_logging("Till account Linked to :  " + email)
     record = session.query(User).filter_by(email=email).first()
     till_list = [i.user_id for i in Getters.getAllTellers()]
     if record.uid in till_list:
         return True
Пример #16
0
def stmt_drill_down(ft_reference):
    # record = []
    record = Getters.getTransactionDetails(ft_reference)
    return render_template('enquiry/stmt_drilldown.html', record=record, user=Profile().user_details())
Пример #17
0
def teller_transactions():
    record = None
    return render_template('reconciliation/teller_transactions.html',
                           my_tt=Getters.getAllTts(),
                           record=record,
                           user=Profile().user_details())