Exemple #1
0
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))
Exemple #2
0
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))