Merge branch 'development' into feature/item_por_tipo_factura
This commit is contained in:
@@ -95,7 +95,7 @@ def calculate_values(
|
||||
|
||||
Traduce el CALCULOS ROUTINE de Clarion:
|
||||
- Busca la factura de importación por fa_data.search_invoice (TEM → DEF como fallback)
|
||||
- Copia clase, unidad de medida, fracción (si fa_data.download), país, tipo fracción,
|
||||
- Copia clase, unidad de medida, fracción (si fa_data.discharge), país, tipo fracción,
|
||||
bultos y descripción inglés desde la línea de importación encontrada
|
||||
- Calcula valores en moneda (USD/MXN/MC) según la moneda de la factura
|
||||
"""
|
||||
@@ -168,8 +168,8 @@ def calculate_values(
|
||||
line.class_id = import_line.class_id
|
||||
line.unit_of_measure = import_line.unit_of_measure
|
||||
|
||||
# Fracción: copiar solo si fa_data.download == True (≡ ColumnaV != '')
|
||||
if fa_data and fa_data.download and import_line.customs:
|
||||
# Fracción: copiar solo si fa_data.discharge == True (≡ ColumnaV != '')
|
||||
if fa_data and fa_data.discharge and import_line.customs:
|
||||
line.customs.fraction = import_line.customs.fraction
|
||||
|
||||
if import_line.customs:
|
||||
|
||||
@@ -16,7 +16,7 @@ from api.v1.modules.a76.general_catalogs.units_of_measure.models import UnitOfMe
|
||||
from api.v1.modules.a76.general_catalogs.packages.models import Package
|
||||
from api.v1.modules.a24.fa.fa_item_lines.models import FaLineItem
|
||||
from api.v1.modules.public.reference_data.countries.models import Country
|
||||
from api.v1.modules.public.reference_data.sectors.models import Sector
|
||||
from api.v1.modules.a76.general_catalogs.sectors.models import Sector
|
||||
from api.v1.modules.public.reference_data.valuation_methods.models import (
|
||||
ValuationMethod,
|
||||
)
|
||||
@@ -222,7 +222,7 @@ def validate_common(
|
||||
)
|
||||
elif (
|
||||
# Col. H: valida unidad de medida sólo cuando hay descarga
|
||||
fa_data.download is True
|
||||
fa_data.discharge is True
|
||||
and line.unit_of_measure
|
||||
and import_line.unit_of_measure
|
||||
and line.unit_of_measure != import_line.unit_of_measure
|
||||
@@ -314,7 +314,11 @@ def validate_common(
|
||||
)
|
||||
elif fraction_type.strip().upper() == FractionType.PROSEC and sector:
|
||||
sector_db: Sector = (
|
||||
db.query(Sector).filter(Sector.key == sector).scalar()
|
||||
db.query(Sector).filter(
|
||||
Sector.key == sector,
|
||||
Sector.tenant_id == tenant_id,
|
||||
Sector.company_id == company_id,
|
||||
).scalar()
|
||||
)
|
||||
if sector_db:
|
||||
errors.add_error(
|
||||
|
||||
@@ -83,11 +83,11 @@ def validate_create(
|
||||
errors.add_required_error(field=f"line[{line_number}].fa_data.movement_type_import")
|
||||
|
||||
# Col. F: ¿Descarga la línea? (DescargaPartida) — obligatorio
|
||||
if fa_data.download is None:
|
||||
errors.add_required_error(field=f"line[{line_number}].fa_data.download")
|
||||
if fa_data.discharge is None:
|
||||
errors.add_required_error(field=f"line[{line_number}].fa_data.discharge")
|
||||
|
||||
# Col. D / E: Factura y Línea de Impo — obligatorios sólo si hay descarga
|
||||
if fa_data.download is True:
|
||||
if fa_data.discharge is True:
|
||||
if not fa_data.search_invoice:
|
||||
errors.add_required_error(field=f"line[{line_number}].fa_data.search_invoice")
|
||||
if not fa_data.search_line:
|
||||
|
||||
@@ -207,8 +207,8 @@ def validate_update(
|
||||
fa_data.movement_type_import = existing_fa_data.movement_type_import
|
||||
|
||||
# Col. F: ¿Descarga la línea? (Descarga)
|
||||
if fa_data.download is None:
|
||||
fa_data.download = existing_fa_data.download
|
||||
if fa_data.discharge is None:
|
||||
fa_data.discharge = existing_fa_data.discharge
|
||||
|
||||
# Col. D: Factura de Importación — obligatoria sólo si hay descarga
|
||||
if not fa_data.search_invoice:
|
||||
|
||||
@@ -15,7 +15,7 @@ from api.v1.modules.a76.classes.models import Class
|
||||
from api.v1.modules.a76.general_catalogs.units_of_measure.models import UnitOfMeasure
|
||||
from api.v1.modules.a76.general_catalogs.packages.models import Package
|
||||
from api.v1.modules.public.reference_data.countries.models import Country
|
||||
from api.v1.modules.public.reference_data.sectors.models import Sector
|
||||
from api.v1.modules.a76.general_catalogs.sectors.models import Sector
|
||||
from api.v1.modules.public.reference_data.valuation_methods.models import (
|
||||
ValuationMethod,
|
||||
)
|
||||
@@ -239,7 +239,11 @@ def validate_common(
|
||||
)
|
||||
elif fraction_type.strip().upper() == FractionType.PROSEC and sector:
|
||||
sector_db: Sector = (
|
||||
db.query(Sector).filter(Sector.key == sector).scalar()
|
||||
db.query(Sector).filter(
|
||||
Sector.key == sector,
|
||||
Sector.tenant_id == tenant_id,
|
||||
Sector.company_id == company_id,
|
||||
).scalar()
|
||||
)
|
||||
if sector_db:
|
||||
errors.add_error(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Optional
|
||||
from sqlalchemy import ForeignKey, Integer, String
|
||||
from sqlalchemy import Boolean, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
|
||||
from core.database import Base
|
||||
@@ -16,11 +16,10 @@ class Serie(Base, TenantScopedMixin, TimestampMixin):
|
||||
serial_numbers: Mapped[Optional[str]] = mapped_column(String(50)) # SERIEEXPO
|
||||
model: Mapped[Optional[str]] = mapped_column(String(50)) # MODELOEXPO
|
||||
sub_model: Mapped[Optional[str]] = mapped_column(String(50)) # SUBMODELOEXPO
|
||||
brand: Mapped[Optional[str]] = mapped_column(String(50)) # MARCA
|
||||
expo_brad: Mapped[Optional[str]] = mapped_column(String(50)) # MARCAEXPO
|
||||
brand: Mapped[Optional[str]] = mapped_column(String(50)) # MARCAEXPO
|
||||
number_id: Mapped[Optional[str]] = mapped_column(String(25)) # NUMIDEXPO
|
||||
import_invoice: Mapped[Optional[str]] = mapped_column(String(15)) # FACTURAIMPO
|
||||
import_line: Mapped[Optional[int]] = mapped_column(Integer) # LINEAIMPO
|
||||
discharge: Mapped[Optional[bool]] = mapped_column(Boolean) # MARCA
|
||||
serie_row: Mapped[Optional[int]] = mapped_column(Integer) # LINEASERIEIMPO <-- IN CASE OF EXPO
|
||||
image_path: Mapped[Optional[str]] = mapped_column(String(255)) # PATH DE IMAGEN (MEX)
|
||||
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class ItemService:
|
||||
# FA data uses line.id as primary key
|
||||
if line_data.fa_data:
|
||||
fa_dict = line_data.fa_data.model_dump(
|
||||
exclude_unset=True, exclude={"line_item_id"}
|
||||
exclude_unset=True, exclude={"line_item_id", "includes_subitems"}
|
||||
)
|
||||
fa_dict.update(
|
||||
{"id": line.id, "tenant_id": tenant_id, "company_id": company_id}
|
||||
|
||||
Reference in New Issue
Block a user