def go(): weekly_pay = queries.weekly_pay(printmode = 1) for rec in weekly_pay: open_tab = total_staff_tab(rec['first_name'], rec['last_name']) rec['open_tab'] = open_tab rec['payout'] = rec['net_wage'] if open_tab is not None: if open_tab <= rec['net_wage']: close_staff_tab(rec['first_name'], rec['last_name']) rec['open_tab'] = str(open_tab) + ' CLOSED' rec['payout'] = round(float(rec['net_wage']) - float(open_tab)) else: rec['open_tab'] = str(open_tab) + ' STILL OPEN' slip_text = get_slip_text(rec) slipfile = tempfile.NamedTemporaryFile(delete=False) slipfile.write(slip_text) filename = slipfile.name slipfile.close() #testfile = '-p/var/www/slips/%s.ps'%rec['last_name'] #subprocess.call(['enscript', testfile, '--font=Courier-Bold@11/16', '-B', '-MEnv10', filename]) subprocess.call(['enscript', '--font=Courier-Bold@11/16', '-B', '-MEnv10', filename]) #print slip_text os.remove(filename)
def go(): weekly_pay = queries.weekly_pay(printmode = 1) for rec in weekly_pay: open_tab = total_staff_tab(rec['first_name'], rec['last_name']) rec['open_tab'] = open_tab rec['payout'] = rec['net_wage'] if open_tab is not None: if open_tab <= rec['net_wage']: close_staff_tab(rec['first_name'], rec['last_name']) rec['open_tab'] = str(open_tab) + ' CLOSED' rec['payout'] = round(float(rec['net_wage']) - float(open_tab)) else: rec['open_tab'] = str(open_tab) + ' STILL OPEN' slip_text = get_slip_text(rec) utils.print_slip(slip_text)
def index(req, doprint=0): if doprint: print_pay() print_message="<p> PRINTED.<br>" else: print_message = "" cursor = utils.get_cursor() populate_response = populate_pay_stub.populate_pay_stub(temp = True, incursor = cursor) weekly = queries.weekly_pay(incursor=cursor) payroll_sql = ''' SELECT week_of, round(sum(hours_worked)) as hours_worked, round(avg(hours_worked)) as avg_hours_worked, count(person_id) as num_employees, round(sum(weekly_pay - nys_withholding - fed_withholding - social_security_tax - medicare_tax)) as payroll from %(table_name)s where yearweek(week_of) > yearweek(now() - interval '5' week) and last_name not in ('Kobrin', 'Labossier', 'Kanarova') group by yearweek(week_of) order by yearweek(week_of) desc ''' new_payroll = utils.select( payroll_sql%{ 'table_name' : 'PAY_STUB_TEMP'}, incursor=cursor, label=False ) past_payroll = utils.select( payroll_sql%{ 'table_name' : 'PAY_STUB'}, incursor=cursor, label=False ) detail = utils.select(''' SELECT concat(yearweek(intime),' ',dayname(intime),' ',date), last_name, first_name, time_in, time_out, hours_worked from hours_worked where yearweek(intime) > yearweek(now() - interval '5' week) order by yearweek(intime) desc, last_name, date(intime)''', incursor=None, label=False ) html = ( ''' <html> <body> ''' ) if populate_response: html += '<h1>' + populate_response + '</h1>' else: html +=''' <form action="time.py?doprint=1" method="POST"> <input type="submit" value="print pay slips"> </form> ''' + print_message html += ( utils.tohtml( 'Hours worked per week by person', ('week of', 'last name', 'first_name', 'hours_worked', 'rate', 'tax', 'net weekly wage', 'tips', 'total hourly'), weekly, breakonfirst = True ) + utils.tohtml( 'New Payroll', ('yearweek', 'hours_worked', 'avg_hrs', '# employees', 'payroll'), new_payroll, breakonfirst = True ) + utils.tohtml( 'Past Payroll', ('yearweek', 'hours_worked', 'avg_hrs', '# employees', 'payroll'), past_payroll, breakonfirst = True ) + utils.tohtml( "detail hours", ('date', 'last_name', 'first_name', 'time_in', 'time_out', 'hours_worked'), detail ) + '''</body></html>''' ) return html