File Cabinet MVP: case detail with inline Ledger CRUD

- Extend Transaction with ledger fields (item_no, employee_number, t_code, t_type_l, quantity, rate, billed)
- Startup SQLite migration to add missing columns on transactions
- Ledger create/update/delete endpoints with validations and auto-compute Amount = Quantity × Rate
- Uniqueness: ensure (transaction_date, item_no) per case by auto-incrementing
- Compute case totals (billed/unbilled/overall) and display in case view
- Update case.html for master-detail ledger UI; add client-side auto-compute JS
- Enhance import_ledger_data to populate extended fields
- Close/Reopen actions retained; case detail sorting by date/item
- Auth: switch to pbkdf2_sha256 default (bcrypt fallback) and seed admin robustness

Tested in Docker: health OK, login OK, import ROLODEX/FILES OK, ledger create persisted and totals displayed.
This commit is contained in:
HotSwapp
2025-10-07 09:26:58 -05:00
parent f9c3b3cc9c
commit 950d261eb4
13 changed files with 496 additions and 19 deletions

View File

@@ -123,10 +123,20 @@ class Transaction(Base):
id = Column(Integer, primary_key=True, index=True)
case_id = Column(Integer, ForeignKey("cases.id"), nullable=False)
transaction_date = Column(DateTime(timezone=True))
transaction_type = Column(String(20))
# Legacy/basic fields
transaction_type = Column(String(20)) # Maps to legacy T_Type
amount = Column(Float)
description = Column(Text)
reference = Column(String(50))
description = Column(Text) # Maps to legacy Note
reference = Column(String(50)) # Previously used for Item_No
# Ledger-specific fields (added for File Cabinet MVP)
item_no = Column(Integer)
employee_number = Column(String(20)) # Empl_Num
t_code = Column(String(10)) # T_Code
t_type_l = Column(String(1)) # T_Type_L (Credit/Debit marker)
quantity = Column(Float)
rate = Column(Float)
billed = Column(String(1)) # 'Y' or 'N'
created_at = Column(DateTime(timezone=True), server_default=func.now())
# Relationships