From bff0ef7ff939c50f5b882621b976ee013a81f771 Mon Sep 17 00:00:00 2001 From: Tanshu Date: Wed, 17 Apr 2013 14:08:09 +0530 Subject: [PATCH] Fixed employee_code references to employee_id in Fingerprint and related functions. Updated windows install guide. --- brewman/brewman/models/voucher.py | 11 +++++------ brewman/brewman/views/attendance.py | 4 ++-- brewman/brewman/views/fingerprint.py | 8 +++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/brewman/brewman/models/voucher.py b/brewman/brewman/models/voucher.py index 4c2ba052..997fa601 100644 --- a/brewman/brewman/models/voucher.py +++ b/brewman/brewman/models/voucher.py @@ -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 diff --git a/brewman/brewman/views/attendance.py b/brewman/brewman/views/attendance.py index 878352c7..4b67e19d 100644 --- a/brewman/brewman/views/attendance.py +++ b/brewman/brewman/views/attendance.py @@ -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 diff --git a/brewman/brewman/views/fingerprint.py b/brewman/brewman/views/fingerprint.py index 14c98e10..62a4329a 100644 --- a/brewman/brewman/views/fingerprint.py +++ b/brewman/brewman/views/fingerprint.py @@ -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