Fix: Employee was not saving because of isStarred, added that functionality to employee
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
from datetime import date
|
||||
import uuid
|
||||
from datetime import date
|
||||
|
||||
from sqlalchemy import (
|
||||
UniqueConstraint,
|
||||
@ -16,8 +16,8 @@ from sqlalchemy import (
|
||||
)
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from .meta import Base
|
||||
from brewman.models.guidtype import GUID
|
||||
from .meta import Base
|
||||
|
||||
|
||||
class Product(Base):
|
||||
@ -332,15 +332,15 @@ class Employee(AccountBase):
|
||||
attendances = relationship('Attendance', backref='employee', cascade=None, cascade_backrefs=False)
|
||||
fingerprints = relationship('Fingerprint', backref='employee', cascade=None, cascade_backrefs=False)
|
||||
|
||||
def __init__(self, code=None, name=None, is_active=None, cost_centre_id=None, designation=None, salary=None,
|
||||
service_points=None, joining_date=None, leaving_date=None):
|
||||
def __init__(self, code=None, name=None, is_starred=None, is_active=None, cost_centre_id=None, designation=None,
|
||||
salary=None, service_points=None, joining_date=None, leaving_date=None):
|
||||
self.designation = designation
|
||||
self.salary = salary
|
||||
self.service_points = service_points
|
||||
self.joining_date = joining_date
|
||||
self.leaving_date = leaving_date
|
||||
super().__init__(code=code, name=name, type=10, is_active=is_active, is_reconcilable=False,
|
||||
cost_centre_id=cost_centre_id)
|
||||
super().__init__(code=code, name=name, type=10, is_starred=is_starred, is_active=is_active,
|
||||
is_reconcilable=False, cost_centre_id=cost_centre_id)
|
||||
|
||||
def create(self, dbsession):
|
||||
code = dbsession.query(func.max(AccountBase.code)).filter(AccountBase.type == self.type).one()[0]
|
||||
|
||||
@ -53,6 +53,7 @@ def save(request):
|
||||
except (ValueError, KeyError, TypeError):
|
||||
raise ValidationError("Joining Date is not a valid date")
|
||||
|
||||
is_starred = request.json_body['isStarred']
|
||||
is_active = request.json_body['isActive']
|
||||
try:
|
||||
if is_active:
|
||||
@ -64,7 +65,7 @@ def save(request):
|
||||
except (ValueError, KeyError, TypeError):
|
||||
raise ValidationError("Leaving Date is not a valid date")
|
||||
|
||||
item = Employee(0, name, is_active, cost_centre_id, designation, salary, service_points, joining_date,
|
||||
item = Employee(0, name, is_starred, is_active, cost_centre_id, designation, salary, service_points, joining_date,
|
||||
leaving_date).create(request.dbsession)
|
||||
transaction.commit()
|
||||
return employee_info(item.id, request.dbsession)
|
||||
@ -102,6 +103,7 @@ def update(request):
|
||||
except (ValueError, KeyError, TypeError):
|
||||
raise ValidationError("Joining Date is not a valid date")
|
||||
|
||||
item.is_starred = request.json_body['isStarred']
|
||||
item.is_active = request.json_body['isActive']
|
||||
try:
|
||||
if item.is_active:
|
||||
|
||||
Reference in New Issue
Block a user