Exemple #1
0
def trasferAccount(idx=None):

    if not (session.get('login') and session.get('login') == 'Cashier/Teller'):
        flash("Please Login as Cashier/Teller To Perform This Operation",
              'danger')
        return redirect(url_for('login'))

    if idx == None:
        return redirect(url_for('view_all_customers'))
    form = TransferWithin()
    if form.validate_on_submit():
        AccountStatus.objects(acc_cust_id=form.cust_id.data).update(
            acc_message="Money Tranfer within accounts",
            acc_last_update=datetime.now())
        source = AccountStatus.objects.filter(acc_cust_id=form.cust_id.data,
                                              acc_type=form.source.data)
        target = AccountStatus.objects.filter(acc_cust_id=form.cust_id.data,
                                              acc_type=form.target.data)
        trasfer = form.transfer_amount.data
        s_acc = source.first()['acc_deposit'] - trasfer
        t_acc = target.first()['acc_deposit'] + trasfer
        source.update(acc_deposit=s_acc)
        target.update(acc_deposit=t_acc)

        flash("Transfer successfull", "success")
        return redirect(url_for('view_all_customers'))

    cust = CustomerStatus.objects(customer_id=idx).first()
    if not cust:
        flash(f"No Customer of id {idx} Found", "danger")
        return redirect(url_for('view_all_customers'))
    return render_template('trasferAccount.html', c=cust, form=form)
Exemple #2
0
def searchCustomer():

    if not session.get('login'):
        return redirect(url_for('login'))

    cust_id = request.form.get("customer_id")
    ssn_id = request.form.get("ssn_id")
    if cust_id:
        cust = CustomerStatus.objects(customer_id=cust_id).first()
        if cust:
            flash("Customer of ID " + str(cust_id), 'success')
            return render_template('viewAllCustomers.html',
                                   cust=[cust],
                                   view_all_customers=True)
    if ssn_id:
        cust = CustomerStatus.objects(ssn_id=ssn_id).first()
        if cust:
            flash("Customer of SSN " + str(ssn_id), 'success')
            return render_template('viewAllCustomers.html',
                                   cust=[cust],
                                   view_all_customers=True)
    flash("No customer found", "danger")
    return redirect(url_for('view_all_customers'))
Exemple #3
0
def deleteCustomer():

    if not (session.get('login')
            and session.get('login') == 'Account Executive'):
        flash("Please Login as Account Executive To Perform This Operation",
              'danger')
        return redirect(url_for('indix'))

    cust_id = request.form.get("customer_id")
    cust = CustomerStatus.objects(customer_id=cust_id).first()
    AccountStatus.objects(acc_cust_id=cust_id).update(acc_status="Inactive")
    if cust:
        cust.delete()
        flash("Customer Successfully deleted", "danger")
    else:
        flash("Costomer already deleted", "danger")
    return redirect(url_for('view_all_customers'))
Exemple #4
0
def customerViewEdit(idx=None):
    # return redirect(url_for('index'))

    if not (session.get('login')
            and session.get('login') == 'Account Executive'):
        flash("Please Login as Account Executive To Perform This Operation",
              'danger')
        return redirect(url_for('index'))

    if idx == None:
        return redirect(url_for('view_all_customers'))

    form = UpdateCustomer()
    if form.validate_on_submit():
        message = ""
        if form.cust_name.data:
            CustomerStatus.objects(customer_id=form.cust_id.data).update(
                customer_name=form.cust_name.data)
            message += "Name, "
        if form.cust_age.data:
            CustomerStatus.objects(customer_id=form.cust_id.data).update(
                cust_age=form.cust_age.data)
            message += "Age, "
        if form.cust_address.data:
            CustomerStatus.objects(customer_id=form.cust_id.data).update(
                customer_address=form.cust_address.data)
            message += "Address, "
        if message == "":
            message = "Nothing, "

        else:
            CustomerStatus.objects(customer_id=form.cust_id.data).update(
                message="Customer Updated Successfully")
            CustomerStatus.objects(customer_id=form.cust_id.data).update(
                last_update=datetime.now())
        flash(message + "Updated", "danger")
        return redirect(url_for('view_all_customers'))
        #   CustomerStatus.objects(customer_id=form.cust_id.data).update(title='Example Post')
        # CustomerStatus.objects(customer_id=form.cust_id.data).update(title='Example Post')

    cust = CustomerStatus.objects(customer_id=idx).first()
    if not cust:
        flash(f"No Customer of id {idx} Found", "danger")
        return redirect(url_for('view_all_customers'))
    return render_template('customerViewEdit.html',
                           form=form,
                           create_customer=True,
                           c=cust)
Exemple #5
0
 def validate_acc_cust_id(form, field):
     if not CustomerStatus.objects(customer_id=field.data).first():
         raise ValidationError("customer of this ID does not exists")
Exemple #6
0
 def validate_cust_ssn(form, field):
     if len(str(field.data)) != 9:
         raise ValidationError("SSN number must be of 9 digits")
     elif CustomerStatus.objects(ssn_id=field.data).first():
         raise ValidationError("SSN number Already exists")