def RequestNewCard(id): form = RequestCards() cust = B_Customer.query.filter_by(C_id=id).first() # If the form is valid on submission (we'll talk about validation next) if form.validate_on_submit(): Cardn = CardRequests(C_id=id, Card_Type=form.CardType.data, Card_Status_Type=form.CardStatusType.data, Usagetype=form.Usagetype.data, Request_Status="Processing") db.session.add(Cardn) db.session.commit() sub = "New Card Request Generated" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>A request for new card is generated from your account <br><b>Reference Id</b> :{Cardn.id}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Your Request is submitted succesfully soon your staff will review your Request.Please check your email for futher Information" return render_template('CreateAlert.html', id=id, msg=msg, Atype="customer") return render_template('CustomerRequestNewCard.html', id=id, form=form)
def CreateCustomer(id, Acctype): form = createcustomer() if form.validate_on_submit(): print("entered validate") cuslast = B_Customer.query.all()[-1] cusid = "C" + str(int(cuslast.C_id[1:]) + 1) cus1 = B_Customer(C_id=cusid, firstname=form.firstname.data, lastname=form.lastname.data, gender=form.gender.data, age=form.age.data, email=form.email.data, address=form.address.data, number=form.phone.data, C_pass="******", balance=form.balance.data) db.session.add(cus1) db.session.commit() cardno = B_Customer_Card_Details.query.all()[-1] cardid = cardno.Card_No + 1 card1 = B_Customer_Card_Details(C_id=cusid, Card_Type="MasterCard", Card_No=cardid, Card_Activate=True, Usagetype="Domestic", Card_Status_Type="Debit", ExpiryDate="02/23") db.session.add(card1) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Created a New customer", OtherId=cusid, ActionTime=dt_string) db.session.add(log) db.session.commit() msg1 = "Customer Successfully Created" sub = "Account Created" htmlbody = f"Hello <b>{form.firstname.data}</b>,<br><br>Your Account has been Created<br><b>Username</b> : {cusid}<br><b>Password</b> : password<br><br>please login to portal to find more<br>if not done by you please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[form.email.data]) msg.html = htmlbody mail.send(msg) return render_template('CreateAlert.html', id=id, msg=msg1, Atype=Acctype) else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('CreateNewCustomer.html', id=id, form=form, Acctype=Acctype)
def EditEmployeeDeatils(id, cid, Acctype): form = EditEmployee() custm = B_Employee.query.filter_by(E_id=cid).first() if form.validate_on_submit(): custm = B_Employee.query.filter_by(E_id=cid).first() if (form.firstname.data): custm.E_firstname = form.firstname.data if (form.lastname.data): custm.E_lastname = form.lastname.data if (form.gender.data): custm.E_gender = form.gender.data if (form.age.data): custm.E_age = form.age.data if (form.address.data): custm.E_address = form.address.data if (form.phone.data): custm.E_number = form.phone.data db.session.add(custm) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Edited Employee Details", OtherId=cid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Account Details Edited" htmlbody = f"Hello <b>{custm.E_firstname}</b>,<br><br>Your Account Account Details has been edited <br><b>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[custm.E_email]) msg.html = htmlbody mail.send(msg) msg = "Employee Details Successfully Edited" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('EditEmployeeDetails.html', id=id, form=form, custm=custm, Acctype=Acctype)
def CustomerCardDeavtivateRequest(id): cust = B_Customer.query.filter_by(C_id=id).first() cards = B_Customer_Card_Details.query.filter_by(C_id=id).all() a = [] for card in cards: print(card.Card_No) print( str(id) + "--" + str(card.Card_No) + "--" + str(card.Card_Type) + "--" + str(card.Card_Status_Type) + "--" + str(card.Usagetype)) a.append( (card.Card_No, str(id) + "--" + str(card.Card_No) + "--" + str(card.Card_Type) + "--" + str(card.Card_Status_Type) + "--" + str(card.Usagetype))) class AmountTransferForm(FlaskForm): card1 = SelectField('Select the card', choices=a, validators=[DataRequired()]) reason = StringField('Reason for Deactivation', validators=[DataRequired()]) submit = SubmitField("Request") form = AmountTransferForm() if form.validate_on_submit(): req = CardDeActLogs(C_id=id, CardNo=str(form.card1.data), DeActReason=form.reason.data) cust = B_Customer.query.filter_by(C_id=id).first() db.session.add(req) db.session.commit() sub = f"A request for card Deactivation is rised from your Account " htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>A request for card Deactivation is rised from your Account <br><b>Reference Id</b> :{req.id}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Your Request is submitted succesfully soon your staff will review your Request.Please check your email for futher Information" return render_template('CreateAlert.html', id=id, msg=msg, Atype="customer") else: flash(form.errors) return render_template('CustomerCardDeavtivateRequest.html', id=id, form=form)
def CreateEmployee(id): form = createemloyee() if form.validate_on_submit(): print("entered validate") emplast = B_Employee.query.all()[-1] empid = "E" + str(int(emplast.E_id[1:]) + 1) print(empid) Emp1 = B_Employee(E_id=empid, firstname=form.firstname.data, lastname=form.lastname.data, gender=form.gender.data, age=form.age.data, email=form.email.data, address=form.address.data, number=form.phone.data, E_pass="******") db.session.add(Emp1) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Created a New Employee ", OtherId=empid, ActionTime=dt_string) db.session.add(log) db.session.commit() msg1 = "Employee Successfully Created" sub = "Account Created" htmlbody = f"Hello <b>{form.firstname.data}</b>,<br><br>welcome to the Organization.we are glad that ypu are joining us<br>Your Account has been Created<br><b>Username</b> : {empid}<br><b>Password</b> : password<br><br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[form.email.data]) msg.html = htmlbody mail.send(msg) return render_template('CreateAlert.html', id=id, msg=msg1, Atype="Admin") else: err = form.errors for i in err: flash(i + "-" + str(err[i])) return render_template('CreateNewEmployee.html', id=id, form=form)
def AddAmounttoCustomerAccount1(id, cid, Acctype): form = AmountTransferForm() cust = B_Customer.query.filter_by(C_id=cid).first() if form.validate_on_submit(): cust = B_Customer.query.filter_by(C_id=cid).first() cust.C_balance = cust.C_balance + int(form.Amount.data) db.session.add(cust) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type=Acctype, ActionDone="Added Amount to customer Account ", OtherId=cid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = f"Amount Rs.{form.Amount.data} Credited into your Account" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br> An Amount of Rs.{form.Amount.data} credited into your Account <br><br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Succesfully Added Amount to the Customer Account" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: print(form.errors) return render_template('AddAmounttoCustomerAccount1.html', id=id, form=form, cust=cust, Acctype=Acctype)
def CustomerTransferFunds1(id, cid): form = AmountTransferForm() cust = B_Customer.query.filter_by(C_id=cid).first() cust1 = B_Customer.query.filter_by(C_id=id).first() # If the form is valid on submission (we'll talk about validation next) if form.validate_on_submit(): if (cust1.C_balance < int(form.Amount.data)): flash("The amount exceeded the current balance in your account") else: cust.C_balance = cust.C_balance + int(form.Amount.data) cust1.C_balance = cust1.C_balance - int(form.Amount.data) # datetime object containing current date and time now = datetime.now() # dd/mm/YY H:M:S dt_string = now.strftime("%B %d %Y-- %H:%M:%S") ts = B_Customer_transactions.query.all()[-1].T_id print(ts) tid = str(ts[0:3]) + str(int(ts[3:]) + 1) tarns = B_Customer_transactions(T_id=tid, C_id=id, R_id=cid, Card_Number=0, T_amount=form.Amount.data, T_Type="Debited", T_balance=cust1.C_balance, T_Time=str(dt_string)) tarns1 = B_Customer_transactions(T_id=tid, C_id=cid, R_id=id, Card_Number=0, T_amount=form.Amount.data, T_Type="Credited", T_balance=cust.C_balance, T_Time=str(dt_string)) db.session.add(cust) db.session.add(cust1) db.session.add(tarns) db.session.add(tarns1) db.session.commit() sub = f"Amount of {form.Amount.data} is Dredited from your Account " htmlbody = f"Hello <b>{cust1.C_firstname}</b>,<br><br>An Amount of Rs.{form.Amount.data} is Debited from your account <br><b>Reference Id</b> :{tid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust1.C_email]) msg.html = htmlbody mail.send(msg) sub = f"Amount of {form.Amount.data} is Credited into your Account " htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Amount{form.Amount.data} is Credited into your Account <br><b>Reference Id</b> :{tid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Your Request is submitted succesfully .Please refer to your email for futher Details " return render_template('CreateAlert.html', id=id, msg=msg, Atype="customer") return render_template('CustomerTransferFunds1.html', id=id, cust=cust, form=form)
def EvaluateDeactivateCardRequest(id, rid, Acctype): reqs = CardDeActLogs.query.filter_by(id=rid).first() cust = B_Customer.query.filter_by(C_id=reqs.C_id).first() form = EvaluationForm() if form.validate_on_submit(): if form.Approve.data: card = B_Customer_Card_Details.query.filter_by( Card_No=reqs.CardNo).first() card.Card_Activate = False db.session.add(card) db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs( Actor_id=id, Actor_Type=Acctype, ActionDone="Accepted Customer Request for card Deactivation ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Deactivation Request Approved" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for Card Deactivation is Approved <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Accepted Customer Request for card Deactivation" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs( Actor_id=id, Actor_Type=Acctype, ActionDone="Declined Customer Request for card Deactivation ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Deactivation Request Declined" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for Card Deactivation is Declined <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Declined Customer Request for card Deactivation" return render_template('CreateAlert.html', id=id, msg=msg, Atype=Acctype) else: flash(form.errors) return render_template('EvaluateDeactivateCardRequest.html', id=id, reqs=reqs, cust=cust, form=form, Acctype=Acctype)
def EvaluateIssueCardRequest(id, rid): reqs = CardRequests.query.filter_by(id=rid).first() cust = B_Customer.query.filter_by(C_id=reqs.C_id).first() form = EvaluationForm() if form.validate_on_submit(): if form.Approve.data: cardno = B_Customer_Card_Details.query.all()[-1] cardid = cardno.Card_No + 1 card1 = B_Customer_Card_Details( C_id=reqs.C_id, Card_Type=reqs.Card_Type, Card_No=cardid, Card_Activate=True, Usagetype=reqs.Usagetype, Card_Status_Type=reqs.Card_Status_Type, ExpiryDate="02/28") db.session.add(card1) db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Issue a new card for an customer ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Approved" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for new Card is Approved <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg1 = "Issued a new card succesfully" return render_template('CreateAlert.html', id=id, msg=msg1, Atype="Admin") else: db.session.delete(reqs) now = datetime.now() dt_string = now.strftime("%B %d %Y-- %H:%M:%S") log = logs(Actor_id=id, Actor_Type="Admin", ActionDone="Declined a Customer Request for new card ", OtherId=rid, ActionTime=dt_string) db.session.add(log) db.session.commit() sub = "Card Declined" htmlbody = f"Hello <b>{cust.C_firstname}</b>,<br><br>Your Request for new Card is Declined <br><b>Reference Id</b> :{rid}<br>please login to portal to find more<br>if not done on your request, please report us<br><b>Best Wishes,</b><br><br>Team Bank Application" msg = Message(sub, sender='*****@*****.**', recipients=[cust.C_email]) msg.html = htmlbody mail.send(msg) msg = "Declined a Customer Request for new card" return render_template('CreateAlert.html', id=id, msg=msg, Atype="Admin") else: flash(form.errors) return render_template('EvaluateIssueCardRequest.html', id=id, reqs=reqs, cust=cust, form=form)