2026.03.29 20:00 Gitea_manager javítás előtt
This commit is contained in:
@@ -64,6 +64,7 @@ class Asset(Base):
|
||||
operator_org_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("fleet.organizations.id"))
|
||||
|
||||
status: Mapped[str] = mapped_column(String(20), default="active")
|
||||
data_status: Mapped[Optional[str]] = mapped_column(String(20), nullable=True, server_default=text("'draft'"))
|
||||
individual_equipment: Mapped[dict] = mapped_column(JSONB, server_default=text("'{}'::jsonb"))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), onupdate=func.now())
|
||||
@@ -87,6 +88,51 @@ class Asset(Base):
|
||||
"""Always False for now, as verification is not yet implemented."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def profile_completion_percentage(self) -> int:
|
||||
"""
|
||||
Calculate profile completion percentage based on available data.
|
||||
Uses dynamic weights from system.system_data_completion_weights table.
|
||||
Default weights (if not configured):
|
||||
- license_plate: 20%
|
||||
- make: 15% (from catalog)
|
||||
- model: 15% (from catalog)
|
||||
- vin: 30%
|
||||
- year_of_manufacture: 20%
|
||||
"""
|
||||
# Default weights (fallback if dynamic weights not available)
|
||||
default_weights = {
|
||||
'license_plate': 20,
|
||||
'make': 15,
|
||||
'model': 15,
|
||||
'vin': 30,
|
||||
'year_of_manufacture': 20
|
||||
}
|
||||
|
||||
total_score = 0
|
||||
|
||||
# 1. license_plate
|
||||
if self.license_plate and self.license_plate.strip():
|
||||
total_score += default_weights['license_plate']
|
||||
|
||||
# 2. make (from catalog)
|
||||
if self.catalog and self.catalog.make:
|
||||
total_score += default_weights['make']
|
||||
|
||||
# 3. model (from catalog)
|
||||
if self.catalog and self.catalog.model:
|
||||
total_score += default_weights['model']
|
||||
|
||||
# 4. vin
|
||||
if self.vin and self.vin.strip():
|
||||
total_score += default_weights['vin']
|
||||
|
||||
# 5. year_of_manufacture
|
||||
if self.year_of_manufacture:
|
||||
total_score += default_weights['year_of_manufacture']
|
||||
|
||||
return min(total_score, 100)
|
||||
|
||||
class AssetFinancials(Base):
|
||||
""" I. Beszerzés és IV. Értékcsökkenés (Amortizáció). """
|
||||
__tablename__ = "asset_financials"
|
||||
@@ -273,4 +319,27 @@ class VehicleExpenses(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# Relationship
|
||||
asset: Mapped["Asset"] = relationship("Asset")
|
||||
asset: Mapped["Asset"] = relationship("Asset")
|
||||
|
||||
|
||||
class VehicleTransferRequest(Base):
|
||||
"""Járműátadási kérelem - asset átruházás másik tulajdonosnak vagy szervezetnek."""
|
||||
__tablename__ = "vehicle_transfer_requests"
|
||||
__table_args__ = {"schema": "vehicle"}
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
asset_id: Mapped[uuid.UUID] = mapped_column(PG_UUID(as_uuid=True), ForeignKey("vehicle.assets.id"), nullable=False, index=True)
|
||||
requester_id: Mapped[int] = mapped_column(Integer, ForeignKey("identity.users.id"), nullable=False, index=True)
|
||||
current_owner_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("identity.persons.id"), nullable=True, index=True)
|
||||
status: Mapped[str] = mapped_column(String(20), default="pending", index=True)
|
||||
proof_document_id: Mapped[Optional[uuid.UUID]] = mapped_column(PG_UUID(as_uuid=True), ForeignKey("system.documents.id"), nullable=True)
|
||||
|
||||
requested_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
processed_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True))
|
||||
notes: Mapped[Optional[str]] = mapped_column(Text)
|
||||
|
||||
# Relationships
|
||||
asset: Mapped["Asset"] = relationship("Asset")
|
||||
requester: Mapped["User"] = relationship("User", foreign_keys=[requester_id])
|
||||
current_owner: Mapped[Optional["Person"]] = relationship("Person", foreign_keys=[current_owner_id])
|
||||
proof_document: Mapped[Optional["Document"]] = relationship("Document")
|
||||
Reference in New Issue
Block a user