def payroll2(): benefits = request.form["form_other_benefits"] Date = request.form["form_date"] overtime = request.form["form_overtime"] employee_id = request.form['form_empdata_id'] empdata = Employee.select().where(Employee.id == employee_id).get() calc = Payrollcalculator(empdata.basic_salary, overtime, empdata.house_allowance, benefits) Payroll.create(benefits=benefits, payroll_date=Date, overtime=overtime, nhif=calc.nhif, nssf=calc.nssf, payee=calc.payee, employee_id=employee_id) return redirect(url_for('payroll2'))
def main(): manager = r.Manager(1, 'Mary Poppins', 3000) secretary = r.Secretary(2, 'John Smith', 1500) sales_guy = r.SalesPerson(3, 'Kevin Bacon', 1000, 250) factory_worker = r.FactoryWorker(2, 'Jane Doe', 40, 15) employees = [ manager, secretary, sales_guy, factory_worker, ] productivity = Productivity() productivity.track(employees, 40) payroll = Payroll() payroll.calculate_payroll(employees)
def addPayroll(): overtime = request.form['form_overtime'] otherbenefits = request.form['form_otherbenefits'] payrolldate = request.form['form_date'] id = request.form['form_emp_id'] emp = Employee.select().where(Employee.id == id).get() calc = Payrollcalc(emp.basicsalary, emp.houseallowance, overtime, otherbenefits) # calc2 = Payrollcalc.getBenefits (emp.houseallowance, overtime, otherbenefits) Payroll.create(benefits=calc.benefits, overtime=overtime, otherbenefits=otherbenefits, payrolldate=payrolldate, nhif=calc.nhif, nssf=calc.nssf, paye=calc.paye, employeeid=id) return redirect(url_for("payroll", a=id))
def printDetails(emp_name, KRA_PIN, id_number, basic_salary, allowances, other_deductions): # basic_salary = int(basic_salary) empl1 = Payroll(emp_name, KRA_PIN, id_number, int(basic_salary), int(allowances), int(other_deductions)) # empl2 = Payroll("Aaron Mwanzia", "A0123456789W", 29094964, 220000, 0, 0) # print("Name is: ", empl1.emp_name) # print("KRA PIN is: ", empl1.KRA_PIN) # print("ID number is: ", empl1.id_number) # print("Basic salary: ", empl1.basic_salary) # print("Allowances: ", empl1.allowances) # print("Other deductions: ", empl1.other_deductions) # # print("Pension: ", empl1.pension) # print("Gross Salary: ", empl1.gross_salary) # print("NSSF Deductions: ", empl1.nssf_deductions) # print("Taxable Income: {:.2f}".format(empl1.taxable_income)) # print("NHIF Deductions: ", empl1.nhif_deductions) # print("PAYE: {:.2f}".format(empl1.payee)) # print("Total deductions: {:.2f}".format(empl1.total_deductions)) # print("Net Salary: {:.2f}".format(empl1.net_salary)) return "Name: " + empl1.emp_name + "\n" \ + "Basic salary: {:.2f}".format(empl1.basic_salary)+ "\n" \ + "KRA PIN is: " + str(empl1.KRA_PIN) + "\n" \ + "ID number is: " + str(empl1.id_number) + "\n" \ + "Basic salary: {:.2f}".format(empl1.basic_salary) + "\n" \ + "Allowances: {:.2f}".format(empl1.allowances) + "\n" \ + "Other deductions: {:.2f}".format(empl1.other_deductions) + "\n" \ + "Pension: {:.2f}".format(empl1.pension) + "\n" \ + "Gross Salary: {:.2f}".format(empl1.gross_salary) + "\n" \ + "NSSF Deductions: {:.2f}".format(empl1.nssf_deductions) + "\n" \ + "Taxable Income: {:.2f}".format(empl1.taxable_income)+ "\n" \ + "NHIF Deductions: {:.2f}".format(empl1.nhif_deductions) + "\n" \ + "PAYE: {:.2f}".format(empl1.payee) + "\n" \ + "Total deductions: {:.2f}".format(empl1.total_deductions)+"\n"\ +"Net Salary: {:.2f}".format(empl1.net_salary)
from payroll import Payroll empl1 = Payroll("Aaron Mwanzia", "A0123456789W", 29094964, 220000, 0, 0) print("Name is: ", empl1.emp_name) print("KRA PIN is: ", empl1.KRA_PIN) print("ID number is: ", empl1.id_number) print("Basic salary: ", empl1.basic_salary) print("Allowances: ", empl1.allowances) print("Other deductions: ", empl1.other_deductions) # print("Pension: ", empl1.pension) print("Gross Salary: ", empl1.gross_salary) print("NSSF Deductions: ", empl1.nssf_deductions) print("Taxable Income: {:.2f}".format(empl1.taxable_income)) print("NHIF Deductions: ", empl1.nhif_deductions) print("PAYE: {:.2f}".format(empl1.payee)) print("Total deductions: {:.2f}".format(empl1.total_deductions)) print("Net Salary: {:.2f}".format(empl1.net_salary))
def payroll(a): allPayrolls = Payroll.select().join(Employee).where(Employee.id == int(a)) return render_template("payroll.html", myPayrolls=allPayrolls, id=a)
def main(data_csv, username, password, dry): """The script reads payroll data from the CSV input file and creates payments in the Justworks dashboard. CSV file must contain these columns: name, amount, type, note. """ utc_dt = datetime.utcnow().replace(microsecond=0).isoformat("_") request_id = "{}_{}".format(utc_dt, uuid.uuid4().hex[:4].upper()) click.secho("Start request, id: %s" % request_id, fg="bright_blue") api = API(username=username, password=password) # Get predefined values from Justworks website employees, payment_dates, fringe_benefits_subtypes = api.get_constants() click.secho("\nPersons found: %s" % len(employees), fg="bright_blue") click.secho("\nSupported payment dates:", fg="bright_blue") for pd_key, pd_value in payment_dates.items(): click.secho(pd_key, fg="bright_white") for day in pd_value: fg = "red" if day["disabled"] else None click.secho(" {value}, {description}".format(**day), fg=fg) click.secho("\nSupported payment types:", fg="bright_blue") for subtype in fringe_benefits_subtypes: click.secho("{value} — {description}".format(**subtype)) payroll = Payroll( employees=employees, payment_dates=payment_dates, fringe_benefits_subtypes=fringe_benefits_subtypes, request_id=request_id, ) click.secho("\nParse CSV file", fg="bright_blue") # Parse CSV, validate and match values all_good = payroll.load_from_csv(data_csv) click.secho("\nPayments to create:", fg="bright_blue") # Print payment list payroll.print_payments(sys.stdout) if not all_good: click.secho( "\nThere was some errors. Please fix it before continuing.", fg="bright_red") sys.exit() if not dry: click.secho("\nCreate payments", fg="bright_blue") # Create Justworks payments res = api.create_payments(payroll.payments) if res: click.secho("\nPayments creation error.", fg="bright_red") click.secho("status code: %s" % res.status_code, fg="bright_red") click.secho("response text: %s" % res.text, fg="bright_red") else: click.secho("DONE", fg="green")
from payroll import Payroll pay1 = Payroll(2000, 200) # pay1.gross_salary(2000,100) # print(pay1.benefits) # print(pay1.basic) print(pay1.gross)
def test_paycheck_whole(elf): paycheck = Paycheck(elf, 100, Payroll.JARS) assert paycheck.charity == 10 assert paycheck.retirement == 40 assert paycheck.candy == 50 def test_paycheck_fraction(elf): paycheck = Paycheck(elf, 3, Payroll.JARS) assert paycheck.charity == Decimal('0.3') assert paycheck.retirement == Decimal('1.2') assert paycheck.candy == Decimal('1.5') @pytest.mark.parametrize("total,jar_change,expected", [ ({}, {1: 1}, {1: 1}), ({1: 1}, {1: 1}, {1: 2}), ({1: 2}, {1: 2}, {1: 4}), ({1: 4}, {2: 2}, {1: 4, 2: 2}), ({1: 4, 2: 2}, {2: 2, 5: 1}, {1: 4, 2: 4, 5: 1}), ]) def test_change_update(total, jar_change, expected): change = Change(total) change.update_from_change(jar_change) assert change == expected if __name__ == "__main__": p = Payroll(payday(), [elf(), elf2()]) print(p)
def pay_of_not_born_elf(payday_before_elf_was_born, elf): return Payroll(payday_before_elf_was_born).pay(elf)
def pay(payday, elf): return Payroll(payday).pay(elf)
def test_pay_fraction_round_up(): elf = Elf(date.fromisoformat('2007-01-01')) payday = date.fromisoformat('2009-01-01') # (2 * 52) / 12 = 8.66 assert Payroll(payday).pay(elf) == 9
def test_pay_fraction_round_down(): elf = Elf(date.fromisoformat('2007-01-01')) payday = date.fromisoformat('2008-01-01') # (1 * 52) / 12 = 4.33 assert Payroll(payday).pay(elf) == 4
def test_payroll_output_no_elves(payday): payroll = Payroll(payday) payroll.run() assert str(payroll) == "\nTotal change: {}"
def test_payroll_output(payday, elf, elf2): payroll = Payroll(payday, [elf, elf2]) payroll.run() assert str(payroll) == report
def payroll(me): allpayrolls = Payroll.select().join(Employee).where(Employee.id == int(me)) return render_template('payroll2.html', mypayrolls=allpayrolls, employeeId=me)
from payroll import Payroll # emp1=input('enter name:') emp1=Payroll(100000,10000) print("NAME: Rosalia") print("GROSS SALARY : "+str(emp1.gross_salary)) print("NSSF : "+str(emp1.nssf_deductions)) print("TAXABLE INCOME: "+str(emp1.taxable_income)) print("PAYE : "+str(emp1.payee)) print("NHIF : "+str(emp1.nhif_deductions)) print("TOTAL DEDUCTIONS : "+str(emp1.total_deductions)) print("NET SALARY : "+str(emp1.net_salary))