def transaction_contribution_delete(obj_response, uuid): if delete_contribution := Contribution.query.filter_by( uuid=uuid).first(): if delete_contribution.is_approved: flash(u'This is an approved contribution! Delete not allowed', 'danger') SijaxHandler.sijax_transaction_contribution_update( obj_response, uuid) return else: # delete the record db.session.delete(delete_contribution) db.session.commit() flash(u'Transaction Contribution has been deleted!', 'success')
def transaction_loan_update_save(obj_response, transaction_loan_update_form): # save updates # amount_update_to = float(transaction_loan_update_form['amount']) if transaction_loan_update_form['date_start'] != '': transaction_loan_update_form['date_start'] = datetime.strptime( transaction_loan_update_form['date_start'], '%Y-%m-%d') # obj_response.alert(str((transaction_loan_update_form))) form = TransactionLoanForm(data=transaction_loan_update_form) if update_loan := Loan.query.filter_by( uuid=transaction_loan_update_form['uuid']).first(): ''' Let WTForm perform the form validations ''' # validate the form form.validate() get_loan_detail = LoanDetail.query.filter_by( loan_code=update_loan.code).all() # run action to perform if not form.errors.items(): if check_borrower := Borrower.query.filter_by( code=form.borrower_code.data).first(): save_loan_code = update_loan.code form.populate_obj(update_loan) # update_loan.interest_amount = float(update_loan.amount) * (float(update_loan.interest_rate) * float(.01)) update_loan.code = save_loan_code # save the header values db.session.commit() # recompute the detail lines recompute_loan_details(update_loan) flash(u'Transaction Loan has been updated!', 'success') SijaxHandler.sijax_transaction_loan_update( obj_response, transaction_loan_update_form['uuid']) return else: flash(u'Borrower not found!', 'danger')
# run the render template and place it in string variable then render-thru-sijax html_string = str(render_template('/maintenance/member/member_main_content.html', form=form, content_to_load='Update')) obj_response.html('#render-thru-sijax', html_string) # sijax function def member_delete(obj_response, uuid): if delete_member := Member.query.filter_by(uuid=uuid).first(): # delete the record db.session.delete(delete_member) db.session.commit() flash(u'Member has been deleted!', 'success') else: flash(u'Record is already deleted!', 'danger') # back to member list SijaxHandler.sijax_maintenance_member(obj_response) # check if its sijax request if g.sijax.is_sijax_request: g.sijax.register_callback('sijax_maintenance_member_update_save', member_update_save) g.sijax.register_callback('sijax_maintenance_member_delete', member_delete) g.sijax.register_object(SijaxHandler) return g.sijax.process_request() else: get_member = Member.query.filter_by(uuid=uuid).first() form = MemberMaintenanceForm(obj=get_member) if get_member: content_to_load = 'Update' else:
uuid=uuid).first(): if delete_contribution.is_approved: flash(u'This is an approved contribution! Delete not allowed', 'danger') SijaxHandler.sijax_transaction_contribution_update( obj_response, uuid) return else: # delete the record db.session.delete(delete_contribution) db.session.commit() flash(u'Transaction Contribution has been deleted!', 'success') else: flash(u'Record is already deleted!', 'danger') # back to member list SijaxHandler.sijax_transaction_contribution(obj_response) # sijax function def transaction_contribution_approve(obj_response, uuid): if approve_contribution := Contribution.query.filter_by( uuid=uuid).first(): # approve the record approve_contribution.is_approved = True db.session.commit() # update the company if update_company := Company.query.first(): update_company.total_fund += approve_contribution.amount update_company.available_fund += approve_contribution.amount db.session.commit() flash(u'Transaction Contribution has been approved!', 'success')
# delete the detail record all_details = LoanDetail.query.filter_by( loan_code=delete_loan.code).all() for detail in all_details: db.session.delete(detail) db.session.commit() # delete the header record db.session.delete(delete_loan) db.session.commit() flash(u'Transaction Loan has been deleted!', 'success') else: flash(u'Record is already deleted!', 'danger') # back to list SijaxHandler.sijax_transaction_loan(obj_response) # sijax function def transaction_loan_approve(obj_response, uuid): # obj_response.alert(uuid) if approve_loan := Loan.query.filter_by(uuid=uuid).first(): if not approve_loan.is_approved: # mark the loan as approved approve_loan.type_loan = 'Loan' approve_loan.is_approved = True db.session.commit() # update the company fund if update_company := Company.query.first(): update_company.available_fund -= approve_loan.amount
html_string = str( render_template('/setup/sequence/setup_sequence_content.html', form=form, content_to_load='Update')) obj_response.html('#render-thru-sijax', html_string) # sijax function def setup_sequence_delete(obj_response, uuid): if delete_sequence := Sequence.query.filter_by(uuid=uuid).first(): db.session.delete(delete_sequence) db.session.commit() flash(u'Sequence has been deleted!', 'success') else: flash(u'Record is already deleted!', 'danger') SijaxHandler.sijax_setup_sequence(obj_response) # check if its sijax request if g.sijax.is_sijax_request: g.sijax.register_callback('sijax_setup_sequence_update_save', setup_sequence_update_save) g.sijax.register_callback('sijax_setup_sequence_delete', setup_sequence_delete) g.sijax.register_object(SijaxHandler) return g.sijax.process_request() else: get_sequence = Sequence.query.filter_by(uuid=uuid).first() form = SetupSequenceForm(obj=get_sequence) if get_sequence: content_to_load = 'Update'