Fixed employee_code references to employee_id in Fingerprint and related functions.

Updated windows install guide.
This commit is contained in:
Tanshu 2013-04-17 14:08:09 +05:30
parent ddd6883172
commit bff0ef7ff9
3 changed files with 12 additions and 11 deletions

View File

@ -1,16 +1,15 @@
from datetime import datetime
from sqlalchemy.ext.hybrid import hybrid_property
import uuid
from brewman.models.guidtype import GUID
from sqlalchemy import Column, Integer, Boolean, Unicode, DateTime, Numeric, ForeignKey, func
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy import Column, Integer, Boolean, Unicode, DateTime, Numeric, ForeignKey
from sqlalchemy.orm import relationship, synonym, backref
from brewman.models.guidtype import GUID
from brewman.models import Base, DBSession
from brewman.models.master import Product
class VoucherType:
def __init__(self, id, name):
self.id = id
@ -304,7 +303,7 @@ class Fingerprint(Base):
employee_id = Column('EmployeeID', GUID(), ForeignKey('entities_employees.LedgerID'))
date = Column('Date', DateTime)
def __init__(self, id=None, employee_id=None, date=None):
def __init__(self, id=None, employee_id=None,date=None):
self.id = id
self.employee_id = employee_id
self.date = date

View File

@ -57,7 +57,7 @@ def attendance_date_report(date):
Attendance.date == date).filter(Attendance.is_valid == True).first()
att = 0 if att is None else att.attendance_type
prints, hours, worked = get_prints(item.code, date)
prints, hours, worked = get_prints(item.id, date)
report['Body'].append({'id': item.id, 'Code': item.code, 'Name': item.name, 'Designation': item.designation,
'Department': item.costcenter.name, 'AttendanceTypeID': att, 'Prints': prints,
'Hours': hours, 'Worked': worked})
@ -118,7 +118,7 @@ def employee_attendance(employee, start_date, finish_date):
.filter(Attendance.is_valid == True)\
.first()
att = 0 if att is None else att.attendance_type
prints, hours, worked = get_prints(employee.code, item)
prints, hours, worked = get_prints(employee.id, item)
list.append({'Date': item.strftime('%d-%b-%Y'), 'AttendanceTypeID': att, 'Prints': prints, 'Hours': hours,
'Worked': worked})
return list

View File

@ -4,6 +4,7 @@ from io import StringIO
from pyramid.view import view_config
import transaction
from brewman.models import DBSession
from brewman.models.master import Employee
from brewman.models.validation_exception import TryCatchFunction
from brewman.models.voucher import Fingerprint
@ -38,13 +39,14 @@ def add_fingerprint(row):
date = datetime.datetime.strptime(row[3] + ' ' + row[4], '%m/%d/%Y %H:%M')
except ValueError:
return
Fingerprint(employee_code=employee_code, date=date).create()
employee_id = Employee.by_code(employee_code).id
Fingerprint(employee_id=employee_id, date=date).create()
def get_prints(employee_code, date):
def get_prints(employee_id, date):
start_fp = date + datetime.timedelta(hours=7)
finish_fp = date + datetime.timedelta(hours=7, days=1)
prints = DBSession.query(Fingerprint).filter(Fingerprint.employee_code == employee_code)\
prints = DBSession.query(Fingerprint).filter(Fingerprint.employee_id == employee_id)\
.filter(Fingerprint.date >= start_fp).filter(Fingerprint.date < finish_fp).order_by(Fingerprint.date).all()
last = None