feat: Implement general catalogs for ports, unit conversions, and units of measure
- Added models, DTOs, services, and routes for ports, including CRUD operations. - Introduced unit conversions with corresponding models, DTOs, services, and routes. - Developed units of measure with detailed models, DTOs, services, and routes for various types. - Ensured all new features are integrated with FastAPI and SQLAlchemy for seamless database interactions.
This commit is contained in:
@@ -20,6 +20,7 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.parts.models import Part
|
||||
from api.v1.modules.public.reference_data.material_types.models import MaterialType
|
||||
from api.v1.modules.a76.general_catalogs.units_of_measure.models import UnitOfMeasure
|
||||
|
||||
|
||||
class Class(Base, TenantScopedMixin, TimestampMixin):
|
||||
@@ -30,12 +31,6 @@ class Class(Base, TenantScopedMixin, TimestampMixin):
|
||||
__tablename__ = "classes"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint("id", name="classes_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_classes_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"], ["a76.company.id"], name="fk_classes_company"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["client_id"], ["a76.clients_and_providers.id"], name="fk_classes_client"
|
||||
),
|
||||
@@ -60,15 +55,17 @@ class Class(Base, TenantScopedMixin, TimestampMixin):
|
||||
class_code: Mapped[str] = mapped_column(String(8)) # CLASE
|
||||
|
||||
# Basic information
|
||||
description_es: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONE
|
||||
description_en: Mapped[Optional[str]] = mapped_column(String(500)) # DESCRIPCIONI
|
||||
description_es: Mapped[Optional[str]] = mapped_column(
|
||||
String(500)) # DESCRIPCIONE
|
||||
description_en: Mapped[Optional[str]] = mapped_column(
|
||||
String(500)) # DESCRIPCIONI
|
||||
|
||||
# Material and measurement
|
||||
material_key: Mapped[Optional[str]] = mapped_column(
|
||||
String(10), ForeignKey("public.material_types.key")
|
||||
) # CLAVEMAT - homologated from TIPOMAT/TIPOMATEQUIPO
|
||||
unit_of_measure: Mapped[Optional[str]] = mapped_column(
|
||||
String(5)
|
||||
String(5), ForeignKey("a76.units_of_measure.code")
|
||||
) # UNIMED - homologated from UNIMEDIDA
|
||||
|
||||
# Tariff fractions
|
||||
@@ -79,7 +76,8 @@ class Class(Base, TenantScopedMixin, TimestampMixin):
|
||||
|
||||
# Additional classification
|
||||
sub_key: Mapped[Optional[str]] = mapped_column(String(5)) # CLAVESUB
|
||||
physical_review: Mapped[Optional[int]] = mapped_column(SmallInteger) # REVFISICA
|
||||
physical_review: Mapped[Optional[int]] = mapped_column(
|
||||
SmallInteger) # REVFISICA
|
||||
iva_exempt_fraction: Mapped[Optional[str]] = mapped_column(
|
||||
String(4)
|
||||
) # FRACCIONEXENTAIVA
|
||||
@@ -88,6 +86,9 @@ class Class(Base, TenantScopedMixin, TimestampMixin):
|
||||
material_type: Mapped[Optional["MaterialType"]] = relationship(
|
||||
foreign_keys=[material_key]
|
||||
)
|
||||
unit_of_measure_info: Mapped[Optional["UnitOfMeasure"]] = relationship(
|
||||
foreign_keys=[unit_of_measure]
|
||||
)
|
||||
|
||||
# Inverse relationship with GParts that have this class
|
||||
parts: Mapped[list["Part"]] = relationship(
|
||||
|
||||
Reference in New Issue
Block a user