55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import uuid
|
|
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
from sqlalchemy import Column, ForeignKey, Integer
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, relationship
|
|
|
|
from .meta import Base
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
# if the target of the relationship is in another module
|
|
# that cannot normally be imported at runtime
|
|
from .journal import Journal
|
|
|
|
|
|
class EmployeeBenefit(Base):
|
|
__tablename__ = "employee_benefit"
|
|
id: uuid.UUID = Column("id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
voucher_id: uuid.UUID = Column("voucher_id", UUID(as_uuid=True), ForeignKey("vouchers.id"), nullable=False)
|
|
journal_id: uuid.UUID = Column("journal_id", UUID(as_uuid=True), ForeignKey("journals.id"), nullable=False)
|
|
gross_salary: int = Column("gross_salary", Integer)
|
|
days_worked: int = Column("days_worked", Integer)
|
|
esi_ee: int = Column("esi_employee", Integer)
|
|
pf_ee: int = Column("pf_employee", Integer)
|
|
esi_er: int = Column("esi_employer", Integer)
|
|
pf_er: int = Column("pf_employer", Integer)
|
|
|
|
journal: Mapped["Journal"] = relationship("Journal", back_populates="employee_benefit")
|
|
|
|
def __init__(
|
|
self,
|
|
gross_salary: int,
|
|
days_worked: int,
|
|
esi_ee: int,
|
|
pf_ee: int,
|
|
esi_er: int,
|
|
pf_er: int,
|
|
journal: "Journal",
|
|
voucher_id: Optional[uuid.UUID] = None,
|
|
id_: Optional[uuid.UUID] = None,
|
|
) -> None:
|
|
if id_ is not None:
|
|
self.id = id_
|
|
if voucher_id is not None:
|
|
self.voucher_id = voucher_id
|
|
self.gross_salary = gross_salary
|
|
self.days_worked = days_worked
|
|
self.esi_ee = esi_ee
|
|
self.pf_ee = pf_ee
|
|
self.esi_er = esi_er
|
|
self.pf_er = pf_er
|
|
self.journal = journal
|