def generate_payroll(uid): month = request.form['month'] year = request.form['year'] overtime = request.form['overtime'] month = month + str(year) employee = EmployeesModel.fetch_by_id(uid) basic = employee.basic_salary benefits = employee.benefits ya = Employee(basic, benefits) gross = ya.gross_salary payee = ya.calc_payee() nhif = ya.calc_NHIF() nssf = ya.nssf relief = 0 sacco = 0 pension = 0 netSalary = ya.calc_net_salary() emp_id = uid pay = PayrollsModel(month=month, gross_salary=gross, payee=payee, nhif=nhif, nssf=nssf, personal_relief=relief, sacco_distribution=sacco, pension=pension, net_salary=netSalary, employee_id=emp_id) # try: pay.insert_record() return redirect(url_for('payrolls', id=uid))
def generate_payroll(uid): month = request.form['month'] year = request.form['year'] overtime = request.form['overtime'] month = month + str(year) employee = EmployeesModel.fetch_by_id(uid) basic = employee.basic_salary benefits = employee.benefits mfanyikazi = Employee("bob",basic,benefits) gross = mfanyikazi.grossSalary payee = mfanyikazi.payeTax nhif = mfanyikazi.nhif nssf = mfanyikazi.nssf personal_relief = mfanyikazi.personal_relief sacco_contribution = 0 pension = 0 net = mfanyikazi.netSalary + int(overtime) emp_id = uid pay = PayrollsModel(month=month,gross_salary=gross,payee = payee,nhif=nhif, nssf=nssf,personal_relief=personal_relief, sacco_contribution=sacco_contribution, pension=pension,net_salary=net, employee_id=emp_id) try: pay.insert_record() return redirect(url_for('payrolls',id = uid)) except: flash("Error in saving to the database") return redirect(url_for('payrolls',id = uid))
def generate_payrolls(emp_id): this_employee = EmployeesModel.fetch_by_id(emp_id) payroll = Payroll(this_employee.full_name, this_employee.basic_salary, this_employee.benefits) payroll_month = request.form['month'] overtime = request.form['overtime'] advanced_pay = request.form['salary_advance'] loan_deductions = request.form['loan'] gross = payroll.gross_salary nhif = payroll.nhif_deductions nssf = round(payroll.nssf_deductions, 2) taxable_amount = payroll.taxable_income paye = round(payroll.payee, 2) personal_relief = payroll.personal_relief tax_off_relief = round(payroll.tax_off_relief, 2) net_salary = payroll.net_salary take_home_pay = net_salary - (float(loan_deductions) + float(advanced_pay)) payslip = PayrollsModel(payroll_month=payroll_month, overtime=overtime, advanced_pay=advanced_pay, loan_deductions=loan_deductions, gross_salary=gross, nhif_deductions=nhif, nssf_deductions=nssf, taxable_income=taxable_amount, PAYE=paye, personal_relief=personal_relief, tax_off_relief=tax_off_relief, net_salary=net_salary, take_home_pay=take_home_pay, employee_id=this_employee.id) payslip.insert_to_db() return redirect(url_for('payrolls', emp_id=this_employee.id))
def newPayroll(emp_id): this_employee = EmployeeModel.fetch_by_id(emp_id) payroll = Payroll(this_employee.first_name + this_employee.second_name, this_employee.basic_salary, this_employee.allowances) payroll_month = request.form['payroll_month'] gross_salary = payroll.gross_salary employee_id = emp_id dept_name = request.form['dept_name'] nssf_deductions = payroll.nssf_deductions nhif_deductions = payroll.nhif_deductions PAYE = payroll.payee taxable_income = payroll.taxable_income overtime = request.form['overtime'] salary_advance = request.form['salary_advance'] other_deductions = request.form['other_deductions'] net_salary = payroll.net_salary emp_payroll = PayrollsModel(employee_id=employee_id, dept_name=dept_name, payroll_month=payroll_month, gross_salary=gross_salary, nssf_deductions=nssf_deductions, nhif_deductions=nhif_deductions, taxable_income=taxable_income, PAYE=PAYE, overtime=overtime, salary_advance=salary_advance, other_deductions=other_deductions, net_salary=net_salary) emp_payroll.instert_into_database() return redirect(url_for('payrolls', emp_id=emp_id))
def generate_payroll(uid): month = request.form['month'] year = request.form['year'] overtime = request.form['overtime'] month = month + str(year) employee = EmployeesModel.fetch_by_id(uid) basic = employee.basic_salary benefits = employee.benefits mfanyikazi = Employees(basic, benefits) gross = mfanyikazi.get_gross_salary() nssf = mfanyikazi.get_nssf() nhif = mfanyikazi.get_nhif() net = mfanyikazi.get_net_salary() + float(overtime) payee = mfanyikazi.get_payee() personal_relief = mfanyikazi.personal_relief sacco_contribution = 0 pension = 0 emp_id = uid pay = PayrollsModel(month=month, gross_salary=gross, payee=payee, nhif=nhif, nssf=nssf, personal_relief=personal_relief, sacco_contribution=sacco_contribution, pension=pension, net_salary=net, employee_id=emp_id) # create a bar chart line_chart = pygal.Bar() line_chart.title = 'Payroll Summary in %' line_chart.x_labels = map(str, range(2019)) line_chart.add('Month', [month]) line_chart.add('Gross salary', [gross]) line_chart.add('PAYE', [payee]) line_chart.add('NHIF', [nhif]) line_chart.add('NSSF', [nssf]) line_chart.add('Relief', [personal_relief]) line_chart.add('Net Salary', [net]) bar = line_chart.render_data_uri() print(bar) try: pay.insert_records() return redirect(url_for('payrolls', id=uid)) except: flash("Error in saving to the database") return redirect(url_for('payrolls', id=uid))
def generate_payroll(id): #if request.method == 'POST': this_employee = EmployeeModel.fetch_by_id(id) payroll = Payroll(this_employee.basic_salary, this_employee.benefits) name_of_employee = request.form['name'] month = request.form['month'] overtime = request.form['overtime'] loan = request.form['loan'] salary_advance = request.form['salary_advance'] gross_salary = payroll.gross_salary taxable_income = payroll.taxable_income nssf = round(payroll.nssf_deductions, 2) paye = round(payroll.payee, 2) personal_relief = payroll.personal_relief #tax_net_off_relief = round(payroll.after_relief, 2) nhif = payroll.nhif_deductions net_salary = round(payroll.net_salary, 2) take_home_pay = net_salary - (float(loan) + float(salary_advance) + float(overtime)) payslip = PayrollsModel(full_name=name_of_employee, month=month, overtime=overtime, loan_deducted=loan, salary_advance=salary_advance, gross_salary=gross_salary, nssf=nssf, taxable_income=taxable_income, paye=paye, personal_relief=personal_relief, nhif=nhif, net_salary=net_salary, take_home_pay=take_home_pay, employee_id=this_employee.id) payslip.insert_to_db() #payslip.fetch_by_employee(id=id) #flash('Payslip for ' + this_employee.full_name + ' has been successfully generated', 'success') #return redirect(url_for('payrolls', emp_id=this_employee.id)),render_template('payroll.html') return redirect(url_for('hello_world'))
def generate_payroll(id): this_employee = EmployeesModel.fetch_by_id(id) payroll = Payroll(this_employee.name, this_employee.basicSalary, this_employee.benefits) NHIF = payroll.NHIF NSSF = payroll.NSSF PAYE = payroll.PAYE net_salary = payroll.net_salary gross_salary = payroll.gross_salary personal_relief = payroll.personal_relief taxable_income = payroll.taxable_income month = request.form['month'] payrolls = PayrollsModel(NHIF=NHIF, NSSF=NSSF, PAYE=PAYE, month=month, net_salary=net_salary, gross_salary=gross_salary, personal_relief=personal_relief, taxable_income=taxable_income, employee_id=id) payrolls.insert2DB() return redirect(url_for('hello_world'))