40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""
|
|
Ledger models based on legacy LEDGER.SC analysis
|
|
"""
|
|
from sqlalchemy import Column, Integer, String, Date, Float, Boolean, Text, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from app.models.base import BaseModel
|
|
|
|
|
|
class Ledger(BaseModel):
|
|
"""
|
|
Financial transactions per case
|
|
Corresponds to LEDGER table in legacy system
|
|
"""
|
|
__tablename__ = "ledger"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
file_no = Column(String(45), ForeignKey("files.file_no"), nullable=False)
|
|
item_no = Column(Integer, nullable=False, default=1) # Item number within file
|
|
|
|
# Transaction details
|
|
date = Column(Date, nullable=False) # Transaction date
|
|
t_code = Column(String(10), nullable=False) # Transaction code (PMT, FEE, etc.)
|
|
t_type = Column(String(1), nullable=False) # Transaction type (1-5)
|
|
t_type_l = Column(String(1)) # Transaction type letter (C=Credit, D=Debit, etc.)
|
|
|
|
# Employee and billing
|
|
empl_num = Column(String(10), nullable=False) # Employee number
|
|
quantity = Column(Float, default=0.0) # Number of billable units (hours)
|
|
rate = Column(Float, default=0.0) # Rate per unit
|
|
amount = Column(Float, nullable=False) # Dollar amount
|
|
billed = Column(String(1), default="N") # Y/N - has been billed
|
|
|
|
# Description
|
|
note = Column(Text) # Additional notes for transaction
|
|
|
|
# Relationships
|
|
file = relationship("File", back_populates="ledger_entries")
|
|
|
|
def __repr__(self):
|
|
return f"<Ledger(file_no='{self.file_no}', amount={self.amount}, date='{self.date}')>" |