pedimentos UI
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
"""change_config_parameters_to_boolean
|
||||
|
||||
Revision ID: 7c4a2cee214d
|
||||
Revises: 8de9bb2a4c1b
|
||||
Create Date: 2025-12-26 23:15:47.125136
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7c4a2cee214d'
|
||||
down_revision: Union[str, Sequence[str], None] = '8de9bb2a4c1b'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Change SmallInteger columns to Boolean with default False
|
||||
op.alter_column('pedimento_config_parameters', 'is_embassy',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'rule_3121_section_ii',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_previous_tariff',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_payment_date_fi',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'add_state_supplier_record_505',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_calculation',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'two_decimals_unit_value',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_per_item',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_national_supplier',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_consolidated',
|
||||
type_=sa.Boolean(),
|
||||
server_default='false',
|
||||
schema='a76')
|
||||
|
||||
# Change embassy_dta to have default value
|
||||
op.alter_column('pedimento_config_parameters', 'embassy_dta',
|
||||
server_default='0.00',
|
||||
schema='a76')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Revert to SmallInteger
|
||||
op.alter_column('pedimento_config_parameters', 'is_embassy',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'rule_3121_section_ii',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_previous_tariff',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'use_payment_date_fi',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'add_state_supplier_record_505',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_calculation',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'two_decimals_unit_value',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'customs_value_per_item',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_national_supplier',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
op.alter_column('pedimento_config_parameters', 'is_consolidated',
|
||||
type_=sa.SmallInteger(),
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
|
||||
# Remove default from embassy_dta
|
||||
op.alter_column('pedimento_config_parameters', 'embassy_dta',
|
||||
server_default=None,
|
||||
schema='a76')
|
||||
@@ -0,0 +1,34 @@
|
||||
"""make_status_nullable
|
||||
|
||||
Revision ID: 8de9bb2a4c1b
|
||||
Revises: e34fc441c57f
|
||||
Create Date: 2025-12-26 22:48:03.475946
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '8de9bb2a4c1b'
|
||||
down_revision: Union[str, Sequence[str], None] = 'e34fc441c57f'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.alter_column('pedimentos', 'status',
|
||||
existing_type=sa.String(30),
|
||||
nullable=True,
|
||||
schema='a76')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.alter_column('pedimentos', 'status',
|
||||
existing_type=sa.String(30),
|
||||
nullable=False,
|
||||
schema='a76')
|
||||
@@ -0,0 +1,113 @@
|
||||
"""update_config_calculations_types
|
||||
|
||||
Revision ID: b83a80ad1cb8
|
||||
Revises: 7c4a2cee214d
|
||||
Create Date: 2025-12-26 23:52:00.464690
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b83a80ad1cb8'
|
||||
down_revision: Union[str, Sequence[str], None] = '7c4a2cee214d'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# Make dta_type nullable
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_type DROP NOT NULL')
|
||||
|
||||
# Change SmallInteger to Boolean with defaults using USING clause
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_operation TYPE boolean USING (dta_operation::boolean),
|
||||
ALTER COLUMN dta_operation SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_vehicle_count SET DEFAULT 0')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_mixed_rate_8permil TYPE boolean USING (dta_mixed_rate_8permil::boolean),
|
||||
ALTER COLUMN dta_mixed_rate_8permil SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_vat TYPE boolean USING (pays_vat::boolean),
|
||||
ALTER COLUMN pays_vat SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_prevalidation TYPE boolean USING (pays_prevalidation::boolean),
|
||||
ALTER COLUMN pays_prevalidation SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN include_sagar_certificate_fee TYPE boolean USING (include_sagar_certificate_fee::boolean),
|
||||
ALTER COLUMN include_sagar_certificate_fee SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN fixed_vehicle_dta_fee TYPE boolean USING (fixed_vehicle_dta_fee::boolean),
|
||||
ALTER COLUMN fixed_vehicle_dta_fee SET DEFAULT false
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee SET DEFAULT 0')
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee_payment_method DROP NOT NULL')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# Revert changes
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_type SET NOT NULL')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_operation TYPE smallint USING (dta_operation::int::smallint),
|
||||
ALTER COLUMN dta_operation DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN dta_vehicle_count DROP DEFAULT')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN dta_mixed_rate_8permil TYPE smallint USING (dta_mixed_rate_8permil::int::smallint),
|
||||
ALTER COLUMN dta_mixed_rate_8permil DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_vat TYPE smallint USING (pays_vat::int::smallint),
|
||||
ALTER COLUMN pays_vat DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN pays_prevalidation TYPE smallint USING (pays_prevalidation::int::smallint),
|
||||
ALTER COLUMN pays_prevalidation DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN include_sagar_certificate_fee TYPE smallint USING (include_sagar_certificate_fee::int::smallint),
|
||||
ALTER COLUMN include_sagar_certificate_fee DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('''
|
||||
ALTER TABLE a76.pedimento_config_calculations
|
||||
ALTER COLUMN fixed_vehicle_dta_fee TYPE smallint USING (fixed_vehicle_dta_fee::int::smallint),
|
||||
ALTER COLUMN fixed_vehicle_dta_fee DROP DEFAULT
|
||||
''')
|
||||
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee DROP DEFAULT')
|
||||
op.execute('ALTER TABLE a76.pedimento_config_calculations ALTER COLUMN additional_fixed_fee_payment_method SET NOT NULL')
|
||||
@@ -0,0 +1,31 @@
|
||||
"""add_observations_to_pedimentos
|
||||
|
||||
Revision ID: e34fc441c57f
|
||||
Revises: 3a012dff0274
|
||||
Create Date: 2025-12-26 20:26:46.308358
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'e34fc441c57f'
|
||||
down_revision: Union[str, Sequence[str], None] = '3a012dff0274'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.add_column('pedimentos',
|
||||
sa.Column('observations', sa.Text(), nullable=True),
|
||||
schema='a76'
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_column('pedimentos', 'observations', schema='a76')
|
||||
@@ -301,8 +301,15 @@ class TenantCRUDRoutes(
|
||||
db, company_id, current_user)
|
||||
|
||||
# For child resources, parent_id validation would go here
|
||||
resource = self.service.create(db, data, tenant_id, company_id)
|
||||
return resource
|
||||
try:
|
||||
resource = self.service.create(db, data, tenant_id, company_id)
|
||||
return resource
|
||||
except ValueError as e:
|
||||
# Capturar errores de validación (como duplicados)
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
# Re-lanzar otros errores
|
||||
raise
|
||||
else:
|
||||
# Parent resource - no parent_id needed
|
||||
|
||||
@@ -324,8 +331,15 @@ class TenantCRUDRoutes(
|
||||
):
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user)
|
||||
resource = self.service.create(db, data, tenant_id, company_id)
|
||||
return resource
|
||||
try:
|
||||
resource = self.service.create(db, data, tenant_id, company_id)
|
||||
return resource
|
||||
except ValueError as e:
|
||||
# Capturar errores de validación (como duplicados)
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
# Re-lanzar otros errores
|
||||
raise
|
||||
|
||||
# PUT route
|
||||
# For parent resources: PUT /{id}
|
||||
@@ -353,9 +367,13 @@ class TenantCRUDRoutes(
|
||||
db, company_id, current_user)
|
||||
parent_id = path_params.get(self.parent_id_name)
|
||||
|
||||
resource = self.service.update(
|
||||
db, parent_id, tenant_id, data, company_id
|
||||
)
|
||||
try:
|
||||
resource = self.service.update(
|
||||
db, parent_id, tenant_id, data, company_id
|
||||
)
|
||||
except ValueError as e:
|
||||
# Capturar errores de validación (como duplicados)
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
if not resource:
|
||||
raise HTTPException(
|
||||
@@ -388,9 +406,13 @@ class TenantCRUDRoutes(
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user)
|
||||
|
||||
resource = self.service.update(
|
||||
db, resource_id, tenant_id, data, company_id
|
||||
)
|
||||
try:
|
||||
resource = self.service.update(
|
||||
db, resource_id, tenant_id, data, company_id
|
||||
)
|
||||
except ValueError as e:
|
||||
# Capturar errores de validación (como duplicados)
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
if not resource:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoConfigAdditionalBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Additional"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
add_po_identifier: Optional[int] = Field(None, description="Add PO identifier")
|
||||
do_not_exempt_norms_complement_x: Optional[int] = Field(
|
||||
None, description="Do not exempt norms complement X"
|
||||
|
||||
@@ -7,24 +7,24 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoConfigCalculationsBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Calculations"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
dta_type: Optional[str] = Field(None, max_length=1, description="DTA type")
|
||||
dta_operation: Optional[int] = Field(None, description="DTA operation")
|
||||
dta_vehicle_count: Optional[int] = Field(None, description="DTA vehicle count")
|
||||
dta_mixed_rate_8permil: Optional[int] = Field(
|
||||
None, description="DTA mixed rate 8 per mil"
|
||||
dta_operation: Optional[bool] = Field(False, description="DTA operation")
|
||||
dta_vehicle_count: Optional[int] = Field(0, description="DTA vehicle count")
|
||||
dta_mixed_rate_8permil: Optional[bool] = Field(
|
||||
False, description="DTA mixed rate 8 per mil"
|
||||
)
|
||||
pays_vat: Optional[int] = Field(None, description="Pays VAT")
|
||||
pays_prevalidation: Optional[int] = Field(None, description="Pays prevalidation")
|
||||
include_sagar_certificate_fee: Optional[int] = Field(
|
||||
None, description="Include SAGAR certificate fee"
|
||||
pays_vat: Optional[bool] = Field(False, description="Pays VAT")
|
||||
pays_prevalidation: Optional[bool] = Field(False, description="Pays prevalidation")
|
||||
include_sagar_certificate_fee: Optional[bool] = Field(
|
||||
False, description="Include SAGAR certificate fee"
|
||||
)
|
||||
fixed_vehicle_dta_fee: Optional[int] = Field(
|
||||
None, description="Fixed vehicle DTA fee"
|
||||
fixed_vehicle_dta_fee: Optional[bool] = Field(
|
||||
False, description="Fixed vehicle DTA fee"
|
||||
)
|
||||
additional_fixed_fee: Optional[int] = Field(
|
||||
None, description="Additional fixed fee"
|
||||
0, description="Additional fixed fee"
|
||||
)
|
||||
additional_fixed_fee_payment_method: Optional[int] = Field(
|
||||
None, description="Additional fixed fee payment method"
|
||||
@@ -41,13 +41,13 @@ class PedimentoConfigCalculationsUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Calculations"""
|
||||
|
||||
dta_type: Optional[str] = Field(None, max_length=1)
|
||||
dta_operation: Optional[int] = None
|
||||
dta_operation: Optional[bool] = None
|
||||
dta_vehicle_count: Optional[int] = None
|
||||
dta_mixed_rate_8permil: Optional[int] = None
|
||||
pays_vat: Optional[int] = None
|
||||
pays_prevalidation: Optional[int] = None
|
||||
include_sagar_certificate_fee: Optional[int] = None
|
||||
fixed_vehicle_dta_fee: Optional[int] = None
|
||||
dta_mixed_rate_8permil: Optional[bool] = None
|
||||
pays_vat: Optional[bool] = None
|
||||
pays_prevalidation: Optional[bool] = None
|
||||
include_sagar_certificate_fee: Optional[bool] = None
|
||||
fixed_vehicle_dta_fee: Optional[bool] = None
|
||||
additional_fixed_fee: Optional[int] = None
|
||||
additional_fixed_fee_payment_method: Optional[int] = None
|
||||
|
||||
|
||||
@@ -8,31 +8,31 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoConfigParametersBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Parameters"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
is_embassy: Optional[int] = Field(None, description="Is embassy")
|
||||
embassy_dta: Optional[Decimal] = Field(None, description="Embassy DTA")
|
||||
rule_3121_section_ii: Optional[int] = Field(
|
||||
None, description="Rule 3.1.21 Section II"
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
is_embassy: Optional[bool] = Field(False, description="Is embassy")
|
||||
embassy_dta: Optional[Decimal] = Field(Decimal('0.00'), description="Embassy DTA")
|
||||
rule_3121_section_ii: Optional[bool] = Field(
|
||||
False, description="Rule 3.1.21 Section II"
|
||||
)
|
||||
use_previous_tariff: Optional[int] = Field(None, description="Use previous tariff")
|
||||
use_payment_date_fi: Optional[int] = Field(None, description="Use payment date FI")
|
||||
add_state_supplier_record_505: Optional[int] = Field(
|
||||
None, description="Add state supplier record 505"
|
||||
use_previous_tariff: Optional[bool] = Field(False, description="Use previous tariff")
|
||||
use_payment_date_fi: Optional[bool] = Field(False, description="Use payment date FI")
|
||||
add_state_supplier_record_505: Optional[bool] = Field(
|
||||
False, description="Add state supplier record 505"
|
||||
)
|
||||
customs_value_calculation: Optional[int] = Field(
|
||||
None, description="Customs value calculation"
|
||||
customs_value_calculation: Optional[bool] = Field(
|
||||
False, description="Customs value calculation"
|
||||
)
|
||||
two_decimals_unit_value: Optional[int] = Field(
|
||||
None, description="Two decimals unit value"
|
||||
two_decimals_unit_value: Optional[bool] = Field(
|
||||
False, description="Two decimals unit value"
|
||||
)
|
||||
customs_value_per_item: Optional[int] = Field(
|
||||
None, description="Customs value per item"
|
||||
customs_value_per_item: Optional[bool] = Field(
|
||||
False, description="Customs value per item"
|
||||
)
|
||||
is_national_supplier: Optional[int] = Field(
|
||||
None, description="Is national supplier"
|
||||
is_national_supplier: Optional[bool] = Field(
|
||||
False, description="Is national supplier"
|
||||
)
|
||||
is_consolidated: Optional[int] = Field(None, description="Is consolidated")
|
||||
is_consolidated: Optional[bool] = Field(False, description="Is consolidated")
|
||||
|
||||
|
||||
class PedimentoConfigParametersCreate(PedimentoConfigParametersBase):
|
||||
@@ -44,17 +44,17 @@ class PedimentoConfigParametersCreate(PedimentoConfigParametersBase):
|
||||
class PedimentoConfigParametersUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Parameters"""
|
||||
|
||||
is_embassy: Optional[int] = None
|
||||
is_embassy: Optional[bool] = None
|
||||
embassy_dta: Optional[Decimal] = None
|
||||
rule_3121_section_ii: Optional[int] = None
|
||||
use_previous_tariff: Optional[int] = None
|
||||
use_payment_date_fi: Optional[int] = None
|
||||
add_state_supplier_record_505: Optional[int] = None
|
||||
customs_value_calculation: Optional[int] = None
|
||||
two_decimals_unit_value: Optional[int] = None
|
||||
customs_value_per_item: Optional[int] = None
|
||||
is_national_supplier: Optional[int] = None
|
||||
is_consolidated: Optional[int] = None
|
||||
rule_3121_section_ii: Optional[bool] = None
|
||||
use_previous_tariff: Optional[bool] = None
|
||||
use_payment_date_fi: Optional[bool] = None
|
||||
add_state_supplier_record_505: Optional[bool] = None
|
||||
customs_value_calculation: Optional[bool] = None
|
||||
two_decimals_unit_value: Optional[bool] = None
|
||||
customs_value_per_item: Optional[bool] = None
|
||||
is_national_supplier: Optional[bool] = None
|
||||
is_consolidated: Optional[bool] = None
|
||||
|
||||
|
||||
class PedimentoConfigParametersResponse(PedimentoConfigParametersBase):
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoConfigSurchargesBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Surcharges"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
surcharge_igi: Optional[int] = Field(None, description="Surcharge IGI")
|
||||
surcharge_dta: Optional[int] = Field(None, description="Surcharge DTA")
|
||||
surcharge_vat: Optional[int] = Field(None, description="Surcharge VAT")
|
||||
|
||||
@@ -9,8 +9,8 @@ from api.v1.common.dto_mixins import UpdateFlagsMixin
|
||||
class PedimentoConfigUpdateRectificationBase(BaseModel, UpdateFlagsMixin):
|
||||
"""Base schema for Pedimento Config Update Rectification"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
calculate_surcharge: Optional[int] = Field(None, description="Calculate surcharge")
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ from api.v1.common.dto_mixins import UpdateFlagsMixin
|
||||
class PedimentoConfigUpdatesBase(BaseModel, UpdateFlagsMixin):
|
||||
"""Base schema for Pedimento Config Updates"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
|
||||
class PedimentoConfigUpdatesCreate(PedimentoConfigUpdatesBase):
|
||||
"""Schema for creating a new Pedimento Config Updates"""
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoCustomsOfficesBase(BaseModel):
|
||||
"""Base schema for Pedimento Customs Offices"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
dispatch_customs: Optional[str] = Field(
|
||||
None, max_length=3, description="Dispatch customs"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoDatesBase(BaseModel):
|
||||
"""Base schema for Pedimento Dates"""
|
||||
|
||||
entry_date: Optional[datetime] = Field(None, description="Entry date")
|
||||
entry_date: Optional[datetime] = Field(None, description="Entry date")
|
||||
pedimento_date: Optional[datetime] = Field(None, description="Pedimento date")
|
||||
payment_date: datetime = Field(..., description="Payment date")
|
||||
rectification_payment_date: Optional[datetime] = Field(
|
||||
None, description="Rectification payment date"
|
||||
@@ -23,7 +24,8 @@ class PedimentoDatesBase(BaseModel):
|
||||
class PedimentoDatesCreate(BaseModel):
|
||||
"""Schema for creating a new Pedimento Dates - pedimento_id and tenant_id are set by backend"""
|
||||
|
||||
entry_date: Optional[datetime] = Field(None, description="Entry date")
|
||||
entry_date: Optional[datetime] = Field(None, description="Entry date")
|
||||
pedimento_date: Optional[datetime] = Field(None, description="Pedimento date")
|
||||
payment_date: datetime = Field(..., description="Payment date")
|
||||
rectification_payment_date: Optional[datetime] = Field(None, description="Rectification payment date")
|
||||
extraction_date: Optional[datetime] = Field(None, description="Extraction date")
|
||||
@@ -37,7 +39,8 @@ class PedimentoDatesCreate(BaseModel):
|
||||
class PedimentoDatesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Dates"""
|
||||
|
||||
entry_date: Optional[datetime] = None
|
||||
entry_date: Optional[datetime] = None
|
||||
pedimento_date: Optional[datetime] = None
|
||||
payment_date: Optional[datetime] = None
|
||||
rectification_payment_date: Optional[datetime] = None
|
||||
extraction_date: Optional[datetime] = None
|
||||
|
||||
@@ -8,8 +8,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoDecrementablesBase(BaseModel):
|
||||
"""Base schema for Pedimento Decrementables"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
freight: Optional[Decimal] = Field(None, description="Freight")
|
||||
insurance: Optional[Decimal] = Field(None, description="Insurance")
|
||||
loading: Optional[Decimal] = Field(None, description="Loading")
|
||||
|
||||
@@ -8,8 +8,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoIncrementablesBase(BaseModel):
|
||||
"""Base schema for Pedimento Incrementables"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
insured_value: Optional[Decimal] = Field(None, description="Insured value")
|
||||
freight: Optional[Decimal] = Field(None, description="Freight")
|
||||
insurance: Optional[Decimal] = Field(None, description="Insurance")
|
||||
|
||||
@@ -8,8 +8,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoIndexesBase(BaseModel):
|
||||
"""Base schema for Pedimento Indexes"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
update_factor_type: Optional[int] = Field(None, description="Update factor type")
|
||||
update_factor: Optional[Decimal] = Field(None, description="Update factor")
|
||||
manual_update_factor: Optional[int] = Field(
|
||||
|
||||
@@ -9,8 +9,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoPaymentsBase(BaseModel):
|
||||
"""Base schema for Pedimento Payments"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
acknowledgment: Optional[str] = Field(
|
||||
None, max_length=20, description="Acknowledgment"
|
||||
)
|
||||
|
||||
@@ -6,8 +6,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoRectificationDestinationBase(BaseModel):
|
||||
"""Base schema for Pedimento Rectification Destination"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
destination_pedimento_year: Optional[str] = Field(
|
||||
None, max_length=2, description="Destination pedimento year"
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoRectificationOriginBase(BaseModel):
|
||||
"""Base schema for Pedimento Rectification Origin"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
original_pedimento_year: Optional[str] = Field(
|
||||
None, max_length=2, description="Original pedimento year"
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoTransportMeansBase(BaseModel):
|
||||
"""Base schema for Pedimento Transport Means"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
destination: Optional[int] = Field(None, description="Destination")
|
||||
entry_exit: Optional[str] = Field(None, max_length=2, description="Entry/exit")
|
||||
arrival: str = Field(..., max_length=2, description="Arrival")
|
||||
|
||||
@@ -7,8 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
||||
class PedimentoValidationBase(BaseModel):
|
||||
"""Base schema for Pedimento Validation"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
pedimento_id: Optional[int] = Field(None, description="Pedimento ID")
|
||||
tenant_id: Optional[int] = Field(None, description="Tenant ID")
|
||||
validator: Optional[str] = Field(None, max_length=3, description="Validator")
|
||||
validation_ack: Optional[str] = Field(
|
||||
None, max_length=8, description="Validation acknowledgment"
|
||||
|
||||
@@ -50,7 +50,8 @@ class PedimentosBase(BaseModel):
|
||||
usd_value: Optional[Decimal] = Field(None, description="USD value")
|
||||
paid_price: Optional[Decimal] = Field(None, description="Paid price")
|
||||
gross_weight: Optional[Decimal] = Field(None, description="Gross weight")
|
||||
exchange_rate: Optional[Decimal] = Field(None, description="Exchange rate")
|
||||
exchange_rate: Optional[Decimal] = Field(None, description="Exchange rate")
|
||||
observations: Optional[str] = Field(None, description="Observations")
|
||||
|
||||
class PedimentosCreate(PedimentosBase):
|
||||
"""Schema for creating a new Pedimento"""
|
||||
@@ -61,13 +62,11 @@ class PedimentosCreate(PedimentosBase):
|
||||
license: str = Field(..., max_length=4, description="License")
|
||||
pedimento_number: str = Field(..., max_length=7, description="Pedimento number")
|
||||
client_id: int = Field(..., description="Client ID")
|
||||
operation_type: int = Field(..., description="Operation type")
|
||||
pedimento_type: str = Field(..., max_length=20, description="Pedimento type")
|
||||
# operation_type, pedimento_type, status son opcionales - se pueden llenar después
|
||||
pedimento_code: str = Field(
|
||||
..., max_length=2, description="Pedimento key"
|
||||
)
|
||||
regime: str = Field(..., max_length=3, description="Regime")
|
||||
status: str = Field(..., max_length=30, description="Status")
|
||||
regime: str = Field(..., max_length=3, description="Regime")
|
||||
|
||||
pedimento_dates: Optional[PedimentoDatesCreate] = None
|
||||
pedimento_decrementables: Optional[PedimentoDecrementablesCreate] = None
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
|
||||
from core.database import Base
|
||||
from sqlalchemy import (
|
||||
Boolean,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
@@ -38,16 +39,16 @@ class PedimentoConfigCalculations(Base, TenantScopedMixin, TimestampMixin):
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
dta_type: Mapped[str] = mapped_column(String(1))
|
||||
dta_operation: Mapped[int] = mapped_column(SmallInteger)
|
||||
dta_vehicle_count: Mapped[int] = mapped_column(SmallInteger)
|
||||
dta_mixed_rate_8permil: Mapped[int] = mapped_column(SmallInteger)
|
||||
pays_vat: Mapped[int] = mapped_column(SmallInteger)
|
||||
pays_prevalidation: Mapped[int] = mapped_column(SmallInteger)
|
||||
include_sagar_certificate_fee: Mapped[int] = mapped_column(SmallInteger)
|
||||
fixed_vehicle_dta_fee: Mapped[int] = mapped_column(SmallInteger)
|
||||
additional_fixed_fee: Mapped[int] = mapped_column(SmallInteger)
|
||||
additional_fixed_fee_payment_method: Mapped[int] = mapped_column(SmallInteger)
|
||||
dta_type: Mapped[Optional[str]] = mapped_column(String(1), nullable=True)
|
||||
dta_operation: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
dta_vehicle_count: Mapped[int] = mapped_column(SmallInteger, default=0, server_default='0')
|
||||
dta_mixed_rate_8permil: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
pays_vat: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
pays_prevalidation: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
include_sagar_certificate_fee: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
fixed_vehicle_dta_fee: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
additional_fixed_fee: Mapped[int] = mapped_column(SmallInteger, default=0, server_default='0')
|
||||
additional_fixed_fee_payment_method: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
||||
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_calculations"
|
||||
|
||||
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING
|
||||
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
|
||||
from core.database import Base
|
||||
from sqlalchemy import (
|
||||
Boolean,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
Numeric,
|
||||
@@ -39,17 +40,17 @@ class PedimentoConfigParameters(Base, TenantScopedMixin, TimestampMixin):
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
is_embassy: Mapped[int] = mapped_column(SmallInteger)
|
||||
embassy_dta: Mapped[Decimal] = mapped_column(Numeric(11, 2))
|
||||
rule_3121_section_ii: Mapped[int] = mapped_column(SmallInteger)
|
||||
use_previous_tariff: Mapped[int] = mapped_column(SmallInteger)
|
||||
use_payment_date_fi: Mapped[int] = mapped_column(SmallInteger)
|
||||
add_state_supplier_record_505: Mapped[int] = mapped_column(SmallInteger)
|
||||
customs_value_calculation: Mapped[int] = mapped_column(SmallInteger)
|
||||
two_decimals_unit_value: Mapped[int] = mapped_column(SmallInteger)
|
||||
customs_value_per_item: Mapped[int] = mapped_column(SmallInteger)
|
||||
is_national_supplier: Mapped[int] = mapped_column(SmallInteger)
|
||||
is_consolidated: Mapped[int] = mapped_column(SmallInteger)
|
||||
is_embassy: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
embassy_dta: Mapped[Decimal] = mapped_column(Numeric(11, 2), default=Decimal('0.00'), server_default='0.00')
|
||||
rule_3121_section_ii: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
use_previous_tariff: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
use_payment_date_fi: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
add_state_supplier_record_505: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
customs_value_calculation: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
two_decimals_unit_value: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
customs_value_per_item: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
is_national_supplier: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
is_consolidated: Mapped[bool] = mapped_column(Boolean, default=False, server_default='false')
|
||||
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_parameters"
|
||||
|
||||
@@ -10,6 +10,7 @@ from sqlalchemy import (
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
Text,
|
||||
UniqueConstraint,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
@@ -102,65 +103,67 @@ class Pedimentos(Base, TenantScopedMixin, TimestampMixin):
|
||||
pedimento_type: Mapped[str] = mapped_column(String(20))
|
||||
pedimento_code: Mapped[str] = mapped_column(String(2))
|
||||
regime: Mapped[str] = mapped_column(String(3))
|
||||
status: Mapped[str] = mapped_column(String(30))
|
||||
status: Mapped[Optional[str]] = mapped_column(String(30))
|
||||
usd_value: Mapped[Optional[Decimal]] = mapped_column(Numeric(17, 6))
|
||||
paid_price: Mapped[Optional[Decimal]] = mapped_column(Numeric(17, 6))
|
||||
gross_weight: Mapped[Optional[Decimal]] = mapped_column(Numeric(19, 3))
|
||||
exchange_rate: Mapped[Optional[Decimal]] = mapped_column(Numeric(9, 5))
|
||||
observations: Mapped[Optional[str]] = mapped_column(Text)
|
||||
|
||||
pedimento_config_additional: Mapped["PedimentoConfigAdditional"] = relationship(
|
||||
"PedimentoConfigAdditional", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigAdditional", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_config_calculations: Mapped["PedimentoConfigCalculations"] = relationship(
|
||||
"PedimentoConfigCalculations", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigCalculations", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_config_parameters: Mapped["PedimentoConfigParameters"] = relationship(
|
||||
"PedimentoConfigParameters", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigParameters", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_config_surcharges: Mapped["PedimentoConfigSurcharges"] = relationship(
|
||||
"PedimentoConfigSurcharges", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigSurcharges", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_config_update_rectification: Mapped[
|
||||
"PedimentoConfigUpdateRectification"
|
||||
] = relationship(
|
||||
"PedimentoConfigUpdateRectification", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigUpdateRectification", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_config_updates: Mapped["PedimentoConfigUpdates"] = relationship(
|
||||
"PedimentoConfigUpdates", uselist=False, back_populates="pedimento"
|
||||
"PedimentoConfigUpdates", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_customs_offices: Mapped["PedimentoCustomsOffices"] = relationship(
|
||||
"PedimentoCustomsOffices", uselist=False, back_populates="pedimento"
|
||||
"PedimentoCustomsOffices", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_dates: Mapped["PedimentoDates"] = relationship(
|
||||
"PedimentoDates", uselist=False, back_populates="pedimento"
|
||||
"PedimentoDates", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_decrementables: Mapped["PedimentoDecrementables"] = relationship(
|
||||
"PedimentoDecrementables", uselist=False, back_populates="pedimento"
|
||||
"PedimentoDecrementables", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_incrementables: Mapped["PedimentoIncrementables"] = relationship(
|
||||
"PedimentoIncrementables", uselist=False, back_populates="pedimento"
|
||||
"PedimentoIncrementables", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_indexes: Mapped["PedimentoIndexes"] = relationship(
|
||||
"PedimentoIndexes", uselist=False, back_populates="pedimento"
|
||||
"PedimentoIndexes", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_payments: Mapped["PedimentoPayments"] = relationship(
|
||||
"PedimentoPayments", uselist=False, back_populates="pedimento"
|
||||
"PedimentoPayments", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_rectification_destination: Mapped["PedimentoRectificationDestination"] = (
|
||||
relationship(
|
||||
"PedimentoRectificationDestination",
|
||||
uselist=False,
|
||||
back_populates="pedimento",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
)
|
||||
pedimento_rectification_origin: Mapped["PedimentoRectificationOrigin"] = (
|
||||
relationship(
|
||||
"PedimentoRectificationOrigin", uselist=False, back_populates="pedimento"
|
||||
"PedimentoRectificationOrigin", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
)
|
||||
pedimento_transport_means: Mapped["PedimentoTransportMeans"] = relationship(
|
||||
"PedimentoTransportMeans", uselist=False, back_populates="pedimento"
|
||||
"PedimentoTransportMeans", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
pedimento_validation: Mapped["PedimentoValidation"] = relationship(
|
||||
"PedimentoValidation", uselist=False, back_populates="pedimento"
|
||||
"PedimentoValidation", uselist=False, back_populates="pedimento", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoConfigParametersService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoConfigParameters]:
|
||||
"""Get config by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoConfigSurchargesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoConfigSurcharges]:
|
||||
"""Get config by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -20,7 +20,7 @@ class PedimentoConfigUpdateRectificationService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoConfigUpdateRectification]:
|
||||
"""Get config by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoConfigUpdatesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoConfigUpdates]:
|
||||
"""Get config by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoCustomsOfficesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoCustomsOffices]:
|
||||
"""Get customs offices by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoDatesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoDates]:
|
||||
"""Get dates by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoDecrementablesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoDecrementables]:
|
||||
"""Get decrementables by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoIncrementablesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoIncrementables]:
|
||||
"""Get incrementables by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -15,7 +15,7 @@ class PedimentoIndexesService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoIndexes]:
|
||||
"""Get indexes by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -15,7 +15,7 @@ class PedimentoPaymentsService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoPayments]:
|
||||
"""Get payments by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -20,7 +20,7 @@ class PedimentoRectificationDestinationService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoRectificationDestination]:
|
||||
"""Get rectification destination by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoRectificationOriginService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoRectificationOrigin]:
|
||||
"""Get rectification origin by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoTransportMeansService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoTransportMeans]:
|
||||
"""Get transport means by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -18,7 +18,7 @@ class PedimentoValidationService:
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int = None
|
||||
) -> Optional[PedimentoValidation]:
|
||||
"""Get validation by pedimento ID"""
|
||||
return (
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Any, Dict, List, Optional
|
||||
from sqlalchemy import desc
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
from sqlalchemy.orm import selectinload
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from datetime import datetime
|
||||
|
||||
from ..dtos.pedimentos import PedimentosCreate, PedimentosUpdate
|
||||
@@ -222,10 +223,15 @@ class PedimentosService:
|
||||
def create_related(model_class, data, extra_fields=None):
|
||||
if data or extra_fields:
|
||||
# Inicializar obj_dict desde data si existe, sino como dict vacío
|
||||
obj_dict = data.model_dump() if data else {}
|
||||
obj_dict = data.model_dump(exclude_none=True) if data else {}
|
||||
# Agregar campos extra si se proporcionan
|
||||
if extra_fields:
|
||||
obj_dict.update(extra_fields)
|
||||
# Solo crear si hay datos significativos (más que solo IDs)
|
||||
significant_fields = {k: v for k, v in obj_dict.items()
|
||||
if k not in ('pedimento_id', 'tenant_id', 'company_id') and v is not None}
|
||||
if not significant_fields and not extra_fields:
|
||||
return
|
||||
obj = model_class(**obj_dict)
|
||||
obj.pedimento_id = pedimento.id
|
||||
obj.tenant_id = tenant_id
|
||||
@@ -272,6 +278,15 @@ class PedimentosService:
|
||||
db.refresh(pedimento)
|
||||
return pedimento
|
||||
|
||||
except IntegrityError as e:
|
||||
db.rollback()
|
||||
# Detectar si es un error de pedimento duplicado
|
||||
error_msg = str(e.orig)
|
||||
if 'pedimentos_unique_key' in error_msg or 'duplicate key value violates unique constraint' in error_msg:
|
||||
logger.warning(f"Attempted to create duplicate pedimento: {e}")
|
||||
raise ValueError("Ya existe un pedimento con estos datos (Año, Aduana, Patente, Número)")
|
||||
logger.error(f"Integrity error creating pedimento: {e}")
|
||||
raise
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
logger.error(f"Error creating pedimento with related data: {e}")
|
||||
@@ -329,11 +344,11 @@ class PedimentosService:
|
||||
return
|
||||
|
||||
existing = service_class.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id)
|
||||
db, pedimento_id, tenant_id, company_id)
|
||||
if existing:
|
||||
# Actualizar existente
|
||||
# Actualizar existente (excluir pedimento_id, tenant_id, company_id)
|
||||
for field, value in data.items():
|
||||
if hasattr(existing, field):
|
||||
if hasattr(existing, field) and field not in ('pedimento_id', 'tenant_id', 'company_id'):
|
||||
setattr(existing, field, value)
|
||||
else:
|
||||
# Crear nuevo
|
||||
@@ -381,6 +396,15 @@ class PedimentosService:
|
||||
db.refresh(pedimento)
|
||||
return pedimento
|
||||
|
||||
except IntegrityError as e:
|
||||
db.rollback()
|
||||
# Detectar si es un error de pedimento duplicado
|
||||
error_msg = str(e.orig)
|
||||
if 'pedimentos_unique_key' in error_msg or 'duplicate key value violates unique constraint' in error_msg:
|
||||
logger.warning(f"Attempted to update to duplicate pedimento: {e}")
|
||||
raise ValueError("Ya existe otro pedimento con estos datos (Año, Aduana, Patente, Número)")
|
||||
logger.error(f"Integrity error updating pedimento: {e}")
|
||||
raise
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
logger.error(f"Error updating pedimento with related data: {e}")
|
||||
|
||||
@@ -162,7 +162,7 @@ services:
|
||||
- KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET:-dev-secret}
|
||||
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:5173,http://localhost:3000}
|
||||
ports:
|
||||
- "5050:8000"
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
postgres-a76:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"keycloak-js": "^26.2.1",
|
||||
"lucide-svelte": "^0.553.0"
|
||||
"lucide-svelte": "^0.553.0",
|
||||
"svelte-sonner": "^1.0.7"
|
||||
}
|
||||
}
|
||||
|
||||
23
frontend/pnpm-lock.yaml
generated
23
frontend/pnpm-lock.yaml
generated
@@ -14,6 +14,9 @@ importers:
|
||||
lucide-svelte:
|
||||
specifier: ^0.553.0
|
||||
version: 0.553.0(svelte@5.40.2)
|
||||
svelte-sonner:
|
||||
specifier: ^1.0.7
|
||||
version: 1.0.7(svelte@5.40.2)
|
||||
devDependencies:
|
||||
'@eslint/compat':
|
||||
specifier: ^1.4.0
|
||||
@@ -1675,6 +1678,11 @@ packages:
|
||||
run-parallel@1.2.0:
|
||||
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
|
||||
|
||||
runed@0.28.0:
|
||||
resolution: {integrity: sha512-k2xx7RuO9hWcdd9f+8JoBeqWtYrm5CALfgpkg2YDB80ds/QE4w0qqu34A7fqiAwiBBSBQOid7TLxwxVC27ymWQ==}
|
||||
peerDependencies:
|
||||
svelte: ^5.7.0
|
||||
|
||||
runed@0.35.1:
|
||||
resolution: {integrity: sha512-2F4Q/FZzbeJTFdIS/PuOoPRSm92sA2LhzTnv6FXhCoENb3huf5+fDuNOg1LNvGOouy3u/225qxmuJvcV3IZK5Q==}
|
||||
peerDependencies:
|
||||
@@ -1761,6 +1769,11 @@ packages:
|
||||
svelte:
|
||||
optional: true
|
||||
|
||||
svelte-sonner@1.0.7:
|
||||
resolution: {integrity: sha512-1EUFYmd7q/xfs2qCHwJzGPh9n5VJ3X6QjBN10fof2vxgy8fYE7kVfZ7uGnd7i6fQaWIr5KvXcwYXE/cmTEjk5A==}
|
||||
peerDependencies:
|
||||
svelte: ^5.0.0
|
||||
|
||||
svelte-toolbelt@0.10.6:
|
||||
resolution: {integrity: sha512-YWuX+RE+CnWYx09yseAe4ZVMM7e7GRFZM6OYWpBKOb++s+SQ8RBIMMe+Bs/CznBMc0QPLjr+vDBxTAkozXsFXQ==}
|
||||
engines: {node: '>=18', pnpm: '>=8.7.0'}
|
||||
@@ -3379,6 +3392,11 @@ snapshots:
|
||||
dependencies:
|
||||
queue-microtask: 1.2.3
|
||||
|
||||
runed@0.28.0(svelte@5.40.2):
|
||||
dependencies:
|
||||
esm-env: 1.2.2
|
||||
svelte: 5.40.2
|
||||
|
||||
runed@0.35.1(@sveltejs/kit@2.47.1(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.40.2)(vite@7.1.10(@types/node@20.19.22)(jiti@2.6.1)(lightningcss@1.30.1)))(svelte@5.40.2)(vite@7.1.10(@types/node@20.19.22)(jiti@2.6.1)(lightningcss@1.30.1)))(svelte@5.40.2):
|
||||
dependencies:
|
||||
dequal: 2.0.3
|
||||
@@ -3460,6 +3478,11 @@ snapshots:
|
||||
optionalDependencies:
|
||||
svelte: 5.40.2
|
||||
|
||||
svelte-sonner@1.0.7(svelte@5.40.2):
|
||||
dependencies:
|
||||
runed: 0.28.0(svelte@5.40.2)
|
||||
svelte: 5.40.2
|
||||
|
||||
svelte-toolbelt@0.10.6(@sveltejs/kit@2.47.1(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.40.2)(vite@7.1.10(@types/node@20.19.22)(jiti@2.6.1)(lightningcss@1.30.1)))(svelte@5.40.2)(vite@7.1.10(@types/node@20.19.22)(jiti@2.6.1)(lightningcss@1.30.1)))(svelte@5.40.2):
|
||||
dependencies:
|
||||
clsx: 2.1.1
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { deLocalizeUrl } from '$lib/paraglide/runtime';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export const reroute = (request) => deLocalizeUrl(request.url).pathname;
|
||||
export const reroute = (request: { url: string }) => deLocalizeUrl(request.url).pathname;
|
||||
|
||||
@@ -26,23 +26,32 @@ export interface ExchangeRateListResponse {
|
||||
*/
|
||||
export async function getExchangeRateByDate(date: string, companyId: number): Promise<ExchangeRate | null> {
|
||||
try {
|
||||
console.log('📡 [API] Solicitando tipos de cambio para company_id:', companyId);
|
||||
// Get all exchange rates and filter by date on client side
|
||||
const response = await api.get<ExchangeRateListResponse>(`/v1/a76/exchange-rate/?company_id=${companyId}`);
|
||||
|
||||
console.log('📡 [API] Respuesta recibida:', response.data?.total, 'tipos de cambio');
|
||||
|
||||
if (response.data && response.data.items && response.data.items.length > 0) {
|
||||
// Filter by date and find USD exchange rate
|
||||
const dateOnly = date.split('T')[0]; // Get YYYY-MM-DD part
|
||||
console.log('🔍 [API] Buscando fecha:', dateOnly, 'en', response.data.items.length, 'registros');
|
||||
|
||||
const matchingRates = response.data.items.filter(rate => {
|
||||
const rateDate = rate.date.split('T')[0];
|
||||
return rateDate === dateOnly && rate.foreign_currency === 'USD';
|
||||
const matches = rateDate === dateOnly && rate.foreign_currency === 'USD';
|
||||
console.log(' - Comparando:', rateDate, '===', dateOnly, '&& USD ===', rate.foreign_currency, '→', matches);
|
||||
return matches;
|
||||
});
|
||||
|
||||
console.log('✅ [API] Encontrados', matchingRates.length, 'tipos de cambio que coinciden');
|
||||
return matchingRates.length > 0 ? matchingRates[0] : null;
|
||||
}
|
||||
|
||||
console.log('⚠️ [API] No hay datos en la respuesta');
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error('Error fetching exchange rate:', error);
|
||||
console.error('❌ [API] Error fetching exchange rate:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,69 @@ export interface PedimentoConfigAdditional {
|
||||
add_remove_norms?: number | null;
|
||||
}
|
||||
|
||||
export interface PedimentoConfigCalculations {
|
||||
dta_type?: string | null;
|
||||
dta_operation?: number | null;
|
||||
dta_vehicle_count?: number | null;
|
||||
dta_mixed_rate_8permil?: number | null;
|
||||
pays_vat?: number | null;
|
||||
pays_prevalidation?: number | null;
|
||||
include_sagar_certificate_fee?: number | null;
|
||||
fixed_vehicle_dta_fee?: number | null;
|
||||
additional_fixed_fee?: number | null;
|
||||
additional_fixed_fee_payment_method?: number | null;
|
||||
}
|
||||
|
||||
export interface PedimentoConfigSurcharges {
|
||||
surcharge_igi?: number | null;
|
||||
surcharge_dta?: number | null;
|
||||
surcharge_vat?: number | null;
|
||||
surcharge_isan?: number | null;
|
||||
surcharge_ieps?: number | null;
|
||||
surcharge_cc?: number | null;
|
||||
}
|
||||
|
||||
export interface PedimentoConfigParameters {
|
||||
is_embassy?: number | null;
|
||||
embassy_dta?: string | null;
|
||||
rule_3121_section_ii?: number | null;
|
||||
use_previous_tariff?: number | null;
|
||||
use_payment_date_fi?: number | null;
|
||||
add_state_supplier_record_505?: number | null;
|
||||
customs_value_calculation?: number | null;
|
||||
two_decimals_unit_value?: number | null;
|
||||
customs_value_per_item?: number | null;
|
||||
is_national_supplier?: number | null;
|
||||
is_consolidated?: number | null;
|
||||
}
|
||||
|
||||
export interface PedimentoConfigUpdates {
|
||||
update_vat?: number | null;
|
||||
update_advalorem?: number | null;
|
||||
update_dta?: number | null;
|
||||
update_cc?: number | null;
|
||||
update_ieps?: number | null;
|
||||
}
|
||||
|
||||
export interface PedimentoConfigUpdateRectification {
|
||||
update_vat?: number | null;
|
||||
update_advalorem?: number | null;
|
||||
update_cc?: number | null;
|
||||
update_ieps?: number | null;
|
||||
calculate_surcharge?: number | null;
|
||||
}
|
||||
|
||||
export interface Identificador {
|
||||
id?: number;
|
||||
pedimento_id?: number;
|
||||
caso: string;
|
||||
complemento1: string;
|
||||
complemento2: string;
|
||||
complemento3: string;
|
||||
nodo: string;
|
||||
observaciones: string;
|
||||
}
|
||||
|
||||
export interface Pedimento {
|
||||
id: number;
|
||||
tenant_id: number;
|
||||
@@ -102,7 +165,7 @@ export interface Pedimento {
|
||||
paid_price?: number | null;
|
||||
gross_weight?: number | null;
|
||||
exchange_rate?: number | null;
|
||||
observaciones?: string | null;
|
||||
observations?: string | null;
|
||||
created_at: string;
|
||||
// Sub-resources
|
||||
pedimento_dates?: PedimentoDates | null;
|
||||
@@ -113,6 +176,12 @@ export interface Pedimento {
|
||||
pedimento_decrementables?: PedimentoDecrementables | null;
|
||||
pedimento_indexes?: PedimentoIndexes | null;
|
||||
pedimento_config_additional?: PedimentoConfigAdditional | null;
|
||||
pedimento_config_calculations?: PedimentoConfigCalculations | null;
|
||||
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
|
||||
pedimento_config_parameters?: PedimentoConfigParameters | null;
|
||||
pedimento_config_updates?: PedimentoConfigUpdates | null;
|
||||
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
|
||||
identificadores?: Identificador[] | null;
|
||||
}
|
||||
|
||||
export interface PedimentoListResponse {
|
||||
@@ -137,7 +206,7 @@ export interface CreatePedimentoData {
|
||||
paid_price?: number | null;
|
||||
gross_weight?: number | null;
|
||||
exchange_rate?: number | null;
|
||||
observaciones?: string | null;
|
||||
observations?: string | null;
|
||||
// Sub-resources
|
||||
pedimento_dates?: PedimentoDates | null;
|
||||
pedimento_payments?: PedimentoPayments | null;
|
||||
@@ -147,6 +216,12 @@ export interface CreatePedimentoData {
|
||||
pedimento_decrementables?: PedimentoDecrementables | null;
|
||||
pedimento_indexes?: PedimentoIndexes | null;
|
||||
pedimento_config_additional?: PedimentoConfigAdditional | null;
|
||||
pedimento_config_calculations?: PedimentoConfigCalculations | null;
|
||||
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
|
||||
pedimento_config_parameters?: PedimentoConfigParameters | null;
|
||||
pedimento_config_updates?: PedimentoConfigUpdates | null;
|
||||
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
|
||||
identificadores?: Identificador[] | null;
|
||||
}
|
||||
|
||||
export interface UpdatePedimentoData {
|
||||
@@ -164,7 +239,7 @@ export interface UpdatePedimentoData {
|
||||
paid_price?: number | null;
|
||||
gross_weight?: number | null;
|
||||
exchange_rate?: number | null;
|
||||
observaciones?: string | null;
|
||||
observations?: string | null;
|
||||
// Sub-resources
|
||||
pedimento_dates?: PedimentoDates | null;
|
||||
pedimento_payments?: PedimentoPayments | null;
|
||||
@@ -174,6 +249,12 @@ export interface UpdatePedimentoData {
|
||||
pedimento_decrementables?: PedimentoDecrementables | null;
|
||||
pedimento_indexes?: PedimentoIndexes | null;
|
||||
pedimento_config_additional?: PedimentoConfigAdditional | null;
|
||||
pedimento_config_calculations?: PedimentoConfigCalculations | null;
|
||||
pedimento_config_surcharges?: PedimentoConfigSurcharges | null;
|
||||
pedimento_config_parameters?: PedimentoConfigParameters | null;
|
||||
pedimento_config_updates?: PedimentoConfigUpdates | null;
|
||||
pedimento_config_update_rectification?: PedimentoConfigUpdateRectification | null;
|
||||
identificadores?: Identificador[] | null;
|
||||
}
|
||||
|
||||
export interface PedimentoFilters {
|
||||
|
||||
@@ -2,26 +2,7 @@ import type { ColumnDef } from "@tanstack/table-core";
|
||||
import { renderComponent, renderSnippet } from "$lib/components/ui/data-table/index.js";
|
||||
import { createRawSnippet } from "svelte";
|
||||
import DataTableActions from "./data-table-actions.svelte";
|
||||
|
||||
export type Pedimento = {
|
||||
id: number;
|
||||
tenant_id: number;
|
||||
year?: string | null;
|
||||
customs_office?: string | null;
|
||||
license?: string | null;
|
||||
pedimento_number?: string | null;
|
||||
client_id?: number | null;
|
||||
operation_type?: number | null;
|
||||
pedimento_type?: number | null;
|
||||
pedimento_code?: string | null;
|
||||
regime?: string | null;
|
||||
status?: string | null;
|
||||
usd_value?: number | null;
|
||||
paid_price?: number | null;
|
||||
gross_weight?: number | null;
|
||||
exchange_rate?: number | null;
|
||||
created_at: string;
|
||||
};
|
||||
import type { Pedimento } from "$lib/api/dashboard/a76/pedimentos";
|
||||
|
||||
/**
|
||||
* Formatea un número como moneda
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import * as DropdownMenu from "$lib/components/ui/dropdown-menu";
|
||||
import { pedimentosApi, type Pedimento } from "$lib/api/dashboard/a76/pedimentos";
|
||||
import { companyStore } from "$lib/stores/company.svelte";
|
||||
import { EllipsisVertical, Pencil, LoaderCircle, Trash2 } from 'lucide-svelte';
|
||||
|
||||
let {
|
||||
@@ -24,7 +25,8 @@
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const response = await pedimentosApi.delete(item.id);
|
||||
const companyId = companyStore.activeCompany?.id;
|
||||
const response = await pedimentosApi.delete(item.id, companyId);
|
||||
|
||||
if (response.error) {
|
||||
if (response.status === 401) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
DialogTitle,
|
||||
DialogFooter
|
||||
} from '$lib/components/ui/dialog';
|
||||
import Checkbox from '$lib/components/ui/checkbox/checkbox.svelte';
|
||||
import { Checkbox } from '$lib/components/ui/checkbox';
|
||||
import {
|
||||
Plus,
|
||||
Pencil,
|
||||
@@ -17,14 +17,18 @@
|
||||
pedimentoNumber?: string;
|
||||
} = $props();
|
||||
|
||||
// Inicializar formData
|
||||
if (!formData) {
|
||||
formData = {
|
||||
observaciones: pedimento?.observaciones || ''
|
||||
};
|
||||
}
|
||||
|
||||
exists = !!pedimento?.observaciones;
|
||||
// Asegurar que formData siempre tenga un valor por defecto
|
||||
formData = formData || { observaciones: '' };
|
||||
|
||||
// Actualizar formData cuando el pedimento cambie
|
||||
$effect(() => {
|
||||
if (pedimento?.observations !== undefined) {
|
||||
formData = {
|
||||
observaciones: pedimento.observations || ''
|
||||
};
|
||||
exists = !!pedimento.observations;
|
||||
}
|
||||
});
|
||||
|
||||
// Mapear el tipo de pedimento a un nombre legible
|
||||
const tipoPedimentoNombre = $derived.by(() => {
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
import type { CustomsBroker } from '$lib/api/dashboard/a76/customs-brokers';
|
||||
import type { ClientProvider } from '$lib/api/dashboard/a76/clients-providers';
|
||||
import type { CodePedimentoRegimen } from '$lib/api/dashboard/refrence_data/code_pedimento_regimens';
|
||||
import IdentificadoresTabForm from './identifiers-tab-form.svelte';
|
||||
|
||||
let {
|
||||
pedimento,
|
||||
formData = $bindable(),
|
||||
identificadoresFormData = $bindable(),
|
||||
pedimentoCodes = [],
|
||||
customsSections = [],
|
||||
customsBrokers = [],
|
||||
@@ -23,6 +25,7 @@
|
||||
}: {
|
||||
pedimento: Pedimento | null;
|
||||
formData?: any;
|
||||
identificadoresFormData?: any;
|
||||
pedimentoCodes?: PedimentoCode[];
|
||||
customsSections?: CustomsSection[];
|
||||
customsBrokers?: CustomsBroker[];
|
||||
@@ -249,19 +252,23 @@
|
||||
// Obtener automáticamente el tipo de cambio cuando cambie la fecha de entrada
|
||||
$effect(() => {
|
||||
if (formData && formData.entry_date && companyStore.activeCompany) {
|
||||
console.log('Buscando tipo de cambio para fecha:', formData.entry_date);
|
||||
console.log('🔍 [TIPO CAMBIO] Buscando para fecha:', formData.entry_date, 'Company ID:', companyStore.activeCompany.id);
|
||||
|
||||
getExchangeRateByDate(formData.entry_date, companyStore.activeCompany.id)
|
||||
.then(usdRate => {
|
||||
console.log('Tipo de cambio USD encontrado:', usdRate);
|
||||
console.log('✅ [TIPO CAMBIO] Respuesta recibida:', usdRate);
|
||||
if (usdRate && formData) {
|
||||
formData.exchange_rate = usdRate.value;
|
||||
console.log('Tipo de cambio actualizado a:', usdRate.value);
|
||||
console.log('✅ [TIPO CAMBIO] Actualizado a:', usdRate.value);
|
||||
} else {
|
||||
console.warn('No se encontró tipo de cambio USD para la fecha:', formData.entry_date);
|
||||
console.warn('⚠️ [TIPO CAMBIO] No encontrado para fecha:', formData.entry_date);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('Error al obtener tipo de cambio:', err));
|
||||
.catch(err => {
|
||||
console.error('❌ [TIPO CAMBIO] Error:', err);
|
||||
});
|
||||
} else {
|
||||
console.log('⏭️ [TIPO CAMBIO] Saltado - formData:', !!formData, 'entry_date:', formData?.entry_date, 'company:', !!companyStore.activeCompany);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -417,10 +424,9 @@
|
||||
<Label for="exchange_rate">Tipo de Cambio <span class="text-red-500">*</span></Label>
|
||||
<Input
|
||||
id="exchange_rate"
|
||||
type="number"
|
||||
step="0.0001"
|
||||
bind:value={formData.exchange_rate}
|
||||
placeholder="En fecha de entrada"
|
||||
type="text"
|
||||
value={formData.exchange_rate ? Number(formData.exchange_rate).toFixed(6) : ''}
|
||||
placeholder="Se obtiene automáticamente de la fecha de entrada"
|
||||
readonly
|
||||
disabled
|
||||
class="bg-muted cursor-not-allowed"
|
||||
@@ -898,9 +904,7 @@
|
||||
</div>
|
||||
{:else if activeSection === 'identificadores'}
|
||||
<!-- Identificadores -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<p class="text-muted-foreground col-span-full">Campos de Identificadores - Por configurar</p>
|
||||
</div>
|
||||
<IdentificadoresTabForm bind:formData={identificadoresFormData} />
|
||||
{:else if activeSection === 'indices'}
|
||||
<!-- Indices -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
<script lang="ts">
|
||||
import { Card } from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import { Textarea } from '$lib/components/ui/textarea';
|
||||
import * as Table from '$lib/components/ui/table';
|
||||
import * as Dialog from '$lib/components/ui/dialog';
|
||||
|
||||
interface Identificador {
|
||||
caso: string;
|
||||
complemento1: string;
|
||||
complemento2: string;
|
||||
complemento3: string;
|
||||
nodo: string;
|
||||
observaciones: string;
|
||||
}
|
||||
|
||||
let {
|
||||
formData = $bindable({
|
||||
identificadores: []
|
||||
})
|
||||
}: {
|
||||
formData: {
|
||||
identificadores: Identificador[];
|
||||
};
|
||||
} = $props();
|
||||
|
||||
let isIdentificadorDialogOpen = $state(false);
|
||||
let editingIdentificadorIndex = $state<number | null>(null);
|
||||
let currentIdentificador = $state<Identificador>({
|
||||
caso: '',
|
||||
complemento1: '',
|
||||
complemento2: '',
|
||||
complemento3: '',
|
||||
nodo: '',
|
||||
observaciones: ''
|
||||
});
|
||||
|
||||
function handleNuevoIdentificador() {
|
||||
currentIdentificador = {
|
||||
caso: '',
|
||||
complemento1: '',
|
||||
complemento2: '',
|
||||
complemento3: '',
|
||||
nodo: '',
|
||||
observaciones: ''
|
||||
};
|
||||
editingIdentificadorIndex = null;
|
||||
isIdentificadorDialogOpen = true;
|
||||
}
|
||||
|
||||
function handleEditarIdentificador(index: number) {
|
||||
currentIdentificador = { ...formData.identificadores[index] };
|
||||
editingIdentificadorIndex = index;
|
||||
isIdentificadorDialogOpen = true;
|
||||
}
|
||||
|
||||
function handleBorrarIdentificador(index: number) {
|
||||
formData.identificadores = formData.identificadores.filter((_, i) => i !== index);
|
||||
}
|
||||
|
||||
function saveIdentificador() {
|
||||
if (editingIdentificadorIndex !== null) {
|
||||
formData.identificadores[editingIdentificadorIndex] = { ...currentIdentificador };
|
||||
} else {
|
||||
formData.identificadores = [...formData.identificadores, { ...currentIdentificador }];
|
||||
}
|
||||
isIdentificadorDialogOpen = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Card class="p-6">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg font-semibold">Identificadores</h3>
|
||||
<Button size="sm" onclick={handleNuevoIdentificador}>
|
||||
Nuevo
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{#if formData.identificadores.length === 0}
|
||||
<p class="text-sm text-muted-foreground text-center py-8">
|
||||
No hay identificadores registrados
|
||||
</p>
|
||||
{:else}
|
||||
<Table.Root>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.Head>Caso</Table.Head>
|
||||
<Table.Head>Complemento 1</Table.Head>
|
||||
<Table.Head>Complemento 2</Table.Head>
|
||||
<Table.Head>Complemento 3</Table.Head>
|
||||
<Table.Head>Nodo</Table.Head>
|
||||
<Table.Head>Observaciones</Table.Head>
|
||||
<Table.Head class="text-right">Acciones</Table.Head>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each formData.identificadores as identificador, index}
|
||||
<Table.Row>
|
||||
<Table.Cell>{identificador.caso}</Table.Cell>
|
||||
<Table.Cell>{identificador.complemento1}</Table.Cell>
|
||||
<Table.Cell>{identificador.complemento2}</Table.Cell>
|
||||
<Table.Cell>{identificador.complemento3}</Table.Cell>
|
||||
<Table.Cell>{identificador.nodo}</Table.Cell>
|
||||
<Table.Cell class="max-w-xs truncate">{identificador.observaciones}</Table.Cell>
|
||||
<Table.Cell class="text-right">
|
||||
<div class="flex justify-end gap-2">
|
||||
<Button size="sm" variant="outline" onclick={() => handleEditarIdentificador(index)}>
|
||||
Editar
|
||||
</Button>
|
||||
<Button size="sm" variant="destructive" onclick={() => handleBorrarIdentificador(index)}>
|
||||
Borrar
|
||||
</Button>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
{/if}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<!-- Dialog para agregar/editar identificador -->
|
||||
<Dialog.Root bind:open={isIdentificadorDialogOpen}>
|
||||
<Dialog.Content class="max-w-2xl">
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>
|
||||
{editingIdentificadorIndex !== null ? 'Editar' : 'Nuevo'} Identificador
|
||||
</Dialog.Title>
|
||||
</Dialog.Header>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="space-y-2">
|
||||
<Label for="caso">Caso</Label>
|
||||
<Input id="caso" bind:value={currentIdentificador.caso} />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="complemento1">Complemento 1</Label>
|
||||
<Input id="complemento1" bind:value={currentIdentificador.complemento1} />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="complemento2">Complemento 2</Label>
|
||||
<Input id="complemento2" bind:value={currentIdentificador.complemento2} />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="complemento3">Complemento 3</Label>
|
||||
<Input id="complemento3" bind:value={currentIdentificador.complemento3} />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<Label for="nodo">Nodo</Label>
|
||||
<Input id="nodo" bind:value={currentIdentificador.nodo} />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2 col-span-2">
|
||||
<Label for="observaciones">Observaciones</Label>
|
||||
<Textarea id="observaciones" bind:value={currentIdentificador.observaciones} rows={3} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<Button variant="outline" onclick={() => (isIdentificadorDialogOpen = false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button onclick={saveIdentificador}>Aceptar</Button>
|
||||
</Dialog.Footer>
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import * as Select from '$lib/components/ui/select';
|
||||
import Checkbox from '$lib/components/ui/checkbox/checkbox.svelte';
|
||||
import { Checkbox } from '$lib/components/ui/checkbox';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -447,32 +447,7 @@
|
||||
currentPartesIIPage = totalPartesIIPages - 1;
|
||||
}
|
||||
|
||||
function goToNotasFirstPage() {
|
||||
currentNotasPage = 0;
|
||||
}
|
||||
|
||||
function goToNotasPreviousPage() {
|
||||
if (currentNotasPage > 0) currentNotasPage--;
|
||||
}
|
||||
|
||||
function goToNotasNextPage() {
|
||||
if (currentNotasPage < totalNotasPages - 1) currentNotasPage++;
|
||||
}
|
||||
|
||||
function goToNotasLastPage() {
|
||||
currentNotasPage = totalNotasPages - 1;
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (selectedEmbarques.length === embarquesParciales.length) {
|
||||
selectedEmbarques = [];
|
||||
} else {
|
||||
selectedEmbarques = embarquesParciales.map((_, i) => i);
|
||||
}
|
||||
}
|
||||
|
||||
function handleNuevoEmbarque() {
|
||||
editingEmbarqueIndex = null;
|
||||
currentEmbarque = {
|
||||
numero: '',
|
||||
peso: 0,
|
||||
@@ -495,6 +470,14 @@
|
||||
isEmbarqueDialogOpen = true;
|
||||
}
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (selectedEmbarques.length === embarquesParciales.length) {
|
||||
selectedEmbarques = [];
|
||||
} else {
|
||||
selectedEmbarques = embarquesParciales.map((_, i) => i);
|
||||
}
|
||||
}
|
||||
|
||||
function handleEditarEmbarque() {
|
||||
alert('Editar Embarque no implementado');
|
||||
}
|
||||
@@ -654,6 +637,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
function goToNotasFirstPage() {
|
||||
currentNotasPage = 0;
|
||||
}
|
||||
|
||||
function goToNotasPreviousPage() {
|
||||
if (currentNotasPage > 0) currentNotasPage--;
|
||||
}
|
||||
|
||||
function goToNotasNextPage() {
|
||||
if (currentNotasPage < totalNotasPages - 1) currentNotasPage++;
|
||||
}
|
||||
|
||||
function goToNotasLastPage() {
|
||||
currentNotasPage = totalNotasPages - 1;
|
||||
}
|
||||
|
||||
function handleSeleccionAutomatizada() {
|
||||
showBitacora = false;
|
||||
showPartesII = false;
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { goto, invalidateAll } from '$app/navigation';
|
||||
import * as Tabs from '$lib/components/ui/tabs';
|
||||
import * as Alert from '$lib/components/ui/alert';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
@@ -27,14 +27,14 @@
|
||||
// Importar los componentes de cada pestaña (ahora sin botones de guardar propios)
|
||||
import GeneralTabForm from '$lib/components/dashboard/pedimentos/edit/general-tab-form.svelte';
|
||||
import DatesTabForm from '$lib/components/dashboard/pedimentos/edit/dates-tab-form.svelte';
|
||||
import FacturasTabForm from '$lib/components/dashboard/pedimentos/edit/facturas-tab-form.svelte';
|
||||
import PartidasTabForm from '$lib/components/dashboard/pedimentos/edit/partidas-tab-form.svelte';
|
||||
import BultosTransportesTabForm from '$lib/components/dashboard/pedimentos/edit/bultos-transportes-tab-form.svelte';
|
||||
import DescargasTabForm from '$lib/components/dashboard/pedimentos/edit/descargas-tab-form.svelte';
|
||||
import ContribucionesTabForm from '$lib/components/dashboard/pedimentos/edit/contribuciones-tab-form.svelte';
|
||||
import CuentasCompensacionTabForm from '$lib/components/dashboard/pedimentos/edit/cuentas-compensacion-tab-form.svelte';
|
||||
import DigitalizacionTabForm from '$lib/components/dashboard/pedimentos/edit/digitalizacion-tab-form.svelte';
|
||||
import OtrosDatosTabForm from '$lib/components/dashboard/pedimentos/edit/otros-datos-tab-form.svelte';
|
||||
import FacturasTabForm from '$lib/components/dashboard/pedimentos/edit/invoices-tab-form.svelte';
|
||||
import PartidasTabForm from '$lib/components/dashboard/pedimentos/edit/items-tab-form.svelte';
|
||||
import BultosTransportesTabForm from '$lib/components/dashboard/pedimentos/edit/package-transportation-tab-form.svelte';
|
||||
import DescargasTabForm from '$lib/components/dashboard/pedimentos/edit/discharge-tab-form.svelte';
|
||||
import ContribucionesTabForm from '$lib/components/dashboard/pedimentos/edit/contributions-tab-form.svelte';
|
||||
import CuentasCompensacionTabForm from '$lib/components/dashboard/pedimentos/edit/accounts-compensation-tab-form.svelte';
|
||||
import DigitalizacionTabForm from '$lib/components/dashboard/pedimentos/edit/digitization-tab-form.svelte';
|
||||
import OtrosDatosTabForm from '$lib/components/dashboard/pedimentos/edit/other-data-tab-form.svelte';
|
||||
import PaymentsTabForm from '$lib/components/dashboard/pedimentos/edit/payments-tab-form.svelte';
|
||||
import TransportTabForm from '$lib/components/dashboard/pedimentos/edit/transport-tab-form.svelte';
|
||||
import ValidationTabForm from '$lib/components/dashboard/pedimentos/edit/validation-tab-form.svelte';
|
||||
@@ -104,6 +104,9 @@
|
||||
let digitalizacionFormData = $state({
|
||||
digitalizaciones: []
|
||||
});
|
||||
let identificadoresFormData = $state({
|
||||
identificadores: []
|
||||
});
|
||||
let otrosDatosFormData = $state({
|
||||
tipo_calculo: 'ninguno',
|
||||
dta_por_operacion_ag_facturas: false,
|
||||
@@ -187,11 +190,8 @@
|
||||
license: 'Patente',
|
||||
pedimento_number: 'Número de Pedimento',
|
||||
client_id: 'ID del Cliente',
|
||||
operation_type: 'Tipo de Operación',
|
||||
pedimento_type: 'Tipo de Pedimento',
|
||||
pedimento_code: 'Clave',
|
||||
regime: 'Régimen',
|
||||
status: 'Estado'
|
||||
regime: 'Régimen'
|
||||
};
|
||||
|
||||
const missingFields: string[] = [];
|
||||
@@ -226,13 +226,28 @@
|
||||
exchange_rate: generalFormData?.exchange_rate || undefined
|
||||
};
|
||||
|
||||
// Fechas - enviar si hay al menos un campo con valor
|
||||
if (generalFormData) {
|
||||
const hasDatesValue = generalFormData.entry_date || generalFormData.pedimento_date ||
|
||||
generalFormData.extraction_date || generalFormData.rectification_payment_date ||
|
||||
generalFormData.original_date || generalFormData.payment_date;
|
||||
if (hasDatesValue) {
|
||||
payload.pedimento_dates = {
|
||||
entry_date: generalFormData.entry_date || null,
|
||||
pedimento_date: generalFormData.pedimento_date || null,
|
||||
payment_date: generalFormData.payment_date || null,
|
||||
rectification_payment_date: generalFormData.rectification_payment_date || null,
|
||||
extraction_date: generalFormData.extraction_date || null,
|
||||
original_date: generalFormData.original_date || null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Solo agregar sub-recursos en modo UPDATE (no en CREATE)
|
||||
// Y solo si tienen valores reales (no enviar objetos vacíos/null)
|
||||
|
||||
// Observaciones - solo enviar si hay valor
|
||||
if (observacionesFormData?.observaciones) {
|
||||
payload.observaciones = observacionesFormData.observaciones;
|
||||
}
|
||||
// Observaciones - siempre enviar (puede ser string vacío para borrar)
|
||||
payload.observations = observacionesFormData?.observaciones || '';
|
||||
|
||||
// Incrementables - solo enviar si hay al menos un campo con valor
|
||||
if (generalFormData) {
|
||||
@@ -310,6 +325,133 @@
|
||||
}
|
||||
|
||||
|
||||
// Identificadores - enviar array de identificadores si existen
|
||||
if (identificadoresFormData?.identificadores && identificadoresFormData.identificadores.length > 0) {
|
||||
payload.identificadores = identificadoresFormData.identificadores;
|
||||
}
|
||||
|
||||
// Config Calculations - configuraciones de cálculo DTA, IVA, prevalidación
|
||||
if (otrosDatosFormData) {
|
||||
const hasCalculationsValue = otrosDatosFormData.tipo_calculo ||
|
||||
otrosDatosFormData.dta_por_operacion_ag_facturas !== undefined ||
|
||||
otrosDatosFormData.dta_por_numero_vehiculos !== undefined ||
|
||||
otrosDatosFormData.paga_iva !== undefined ||
|
||||
otrosDatosFormData.paga_prevalidacion !== undefined ||
|
||||
otrosDatosFormData.aplicar_dta_8_millar_partida !== undefined ||
|
||||
otrosDatosFormData.incluir_eci !== undefined ||
|
||||
otrosDatosFormData.cuota_fija_adicional_vehiculo !== undefined ||
|
||||
otrosDatosFormData.cuota_fija_adicional_fp;
|
||||
|
||||
if (hasCalculationsValue) {
|
||||
// Convertir tipo_calculo a 1 carácter para dta_type
|
||||
let dtaTypeValue = null;
|
||||
if (otrosDatosFormData.tipo_calculo === 'normal') {
|
||||
dtaTypeValue = '1';
|
||||
} else if (otrosDatosFormData.tipo_calculo === 'simplificado') {
|
||||
dtaTypeValue = '2';
|
||||
}
|
||||
|
||||
payload.pedimento_config_calculations = {
|
||||
dta_type: dtaTypeValue,
|
||||
dta_operation: otrosDatosFormData.dta_por_operacion_ag_facturas ? 1 : 0,
|
||||
dta_vehicle_count: otrosDatosFormData.dta_por_numero_vehiculos ? 1 : 0,
|
||||
dta_mixed_rate_8permil: otrosDatosFormData.aplicar_dta_8_millar_partida ? 1 : 0,
|
||||
pays_vat: otrosDatosFormData.paga_iva ? 1 : 0,
|
||||
pays_prevalidation: otrosDatosFormData.paga_prevalidacion ? 1 : 0,
|
||||
include_sagar_certificate_fee: otrosDatosFormData.incluir_eci ? 1 : 0,
|
||||
fixed_vehicle_dta_fee: otrosDatosFormData.cuota_fija_adicional_vehiculo ? 1 : 0,
|
||||
additional_fixed_fee: otrosDatosFormData.cuota_fija_adicional_fp ? parseInt(otrosDatosFormData.cuota_fija_adicional_fp) : 0,
|
||||
additional_fixed_fee_payment_method: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Config Surcharges - configuraciones de recargos
|
||||
if (otrosDatosFormData) {
|
||||
const hasSurchargesValue = otrosDatosFormData.recargo_igi !== undefined ||
|
||||
otrosDatosFormData.deducible_recargos !== undefined ||
|
||||
otrosDatosFormData.recargo_iva !== undefined ||
|
||||
otrosDatosFormData.recargo_ieps !== undefined ||
|
||||
otrosDatosFormData.recargo_isan !== undefined ||
|
||||
otrosDatosFormData.recargo_cc !== undefined;
|
||||
|
||||
if (hasSurchargesValue) {
|
||||
payload.pedimento_config_surcharges = {
|
||||
surcharge_igi: otrosDatosFormData.recargo_igi ? 1 : 0,
|
||||
surcharge_dta: otrosDatosFormData.deducible_recargos ? 1 : 0,
|
||||
surcharge_vat: otrosDatosFormData.recargo_iva ? 1 : 0,
|
||||
surcharge_ieps: otrosDatosFormData.recargo_ieps ? 1 : 0,
|
||||
surcharge_isan: otrosDatosFormData.recargo_isan ? 1 : 0,
|
||||
surcharge_cc: otrosDatosFormData.recargo_cc ? 1 : 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Config Parameters - parámetros de configuración del pedimento
|
||||
if (otrosDatosFormData) {
|
||||
const hasParametersValue = otrosDatosFormData.es_embajada !== undefined ||
|
||||
otrosDatosFormData.embajada_dta ||
|
||||
otrosDatosFormData.regla_3_1_21_factores !== undefined ||
|
||||
otrosDatosFormData.cambio_tarifa_anterior ||
|
||||
otrosDatosFormData.agregar_entidad_federativa_proveedor !== undefined ||
|
||||
otrosDatosFormData.calculo_valor_aduana_v2 !== undefined ||
|
||||
otrosDatosFormData.calculo_2_decimales_valor_unitario !== undefined ||
|
||||
otrosDatosFormData.calcular_valor_aduana_base_partidas !== undefined ||
|
||||
otrosDatosFormData.proveedor_nacional_modifico_dta !== undefined;
|
||||
|
||||
if (hasParametersValue) {
|
||||
payload.pedimento_config_parameters = {
|
||||
is_embassy: otrosDatosFormData.es_embajada ? 1 : 0,
|
||||
embassy_dta: otrosDatosFormData.embajada_dta || '0.00',
|
||||
rule_3121_section_ii: otrosDatosFormData.regla_3_1_21_factores ? 1 : 0,
|
||||
use_previous_tariff: otrosDatosFormData.cambio_tarifa_anterior ? 1 : 0,
|
||||
use_payment_date_fi: null,
|
||||
add_state_supplier_record_505: otrosDatosFormData.agregar_entidad_federativa_proveedor ? 1 : 0,
|
||||
customs_value_calculation: otrosDatosFormData.calculo_valor_aduana_v2 ? 1 : 0,
|
||||
two_decimals_unit_value: otrosDatosFormData.calculo_2_decimales_valor_unitario ? 1 : 0,
|
||||
customs_value_per_item: otrosDatosFormData.calcular_valor_aduana_base_partidas ? 1 : 0,
|
||||
is_national_supplier: otrosDatosFormData.proveedor_nacional_modifico_dta ? 1 : 0,
|
||||
is_consolidated: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Config Updates - configuraciones de actualización de valores
|
||||
if (otrosDatosFormData) {
|
||||
const hasUpdatesValue = otrosDatosFormData.actualizar_iva !== undefined ||
|
||||
otrosDatosFormData.actualizar_advalorem !== undefined ||
|
||||
otrosDatosFormData.actualizar_cc !== undefined ||
|
||||
otrosDatosFormData.actualizar_ieps !== undefined;
|
||||
|
||||
if (hasUpdatesValue) {
|
||||
payload.pedimento_config_updates = {
|
||||
update_vat: otrosDatosFormData.actualizar_iva ? 1 : 0,
|
||||
update_advalorem: otrosDatosFormData.actualizar_advalorem ? 1 : 0,
|
||||
update_cc: otrosDatosFormData.actualizar_cc ? 1 : 0,
|
||||
update_ieps: otrosDatosFormData.actualizar_ieps ? 1 : 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Config Update Rectification - configuraciones de actualización en rectificación
|
||||
if (otrosDatosFormData) {
|
||||
const hasUpdateRectValue = otrosDatosFormData.actualizar_iva_rect !== undefined ||
|
||||
otrosDatosFormData.actualizar_advalorem_rect !== undefined ||
|
||||
otrosDatosFormData.actualizar_cc_rect !== undefined ||
|
||||
otrosDatosFormData.actualizar_ieps_rect !== undefined ||
|
||||
otrosDatosFormData.calcular_recargos_diferencias !== undefined;
|
||||
|
||||
if (hasUpdateRectValue) {
|
||||
payload.pedimento_config_update_rectification = {
|
||||
update_vat: otrosDatosFormData.actualizar_iva_rect ? 1 : 0,
|
||||
update_advalorem: otrosDatosFormData.actualizar_advalorem_rect ? 1 : 0,
|
||||
update_cc: otrosDatosFormData.actualizar_cc_rect ? 1 : 0,
|
||||
update_ieps: otrosDatosFormData.actualizar_ieps_rect ? 1 : 0,
|
||||
calculate_surcharge: otrosDatosFormData.calcular_recargos_diferencias ? 1 : 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Eliminar campos undefined para no enviarlos
|
||||
Object.keys(payload).forEach(key => {
|
||||
if (payload[key as keyof typeof payload] === undefined) {
|
||||
@@ -319,7 +461,10 @@
|
||||
|
||||
let newPedimentoId = pedimentoId;
|
||||
|
||||
if (data.isCreate) {
|
||||
// Determinar si es creación o actualización basándose en si tenemos un ID
|
||||
const isCreating = !pedimentoId || data.isCreate;
|
||||
|
||||
if (isCreating) {
|
||||
// Crear nuevo pedimento con todos sus sub-recursos
|
||||
const response = await pedimentosApi.create(payload as CreatePedimentoData);
|
||||
if (response.error) {
|
||||
@@ -336,6 +481,9 @@
|
||||
// Actualizar pedimento existente con todos sus sub-recursos
|
||||
const response = await pedimentosApi.update(pedimentoId!, payload as UpdatePedimentoData);
|
||||
if (response.error) throw new Error(response.error);
|
||||
|
||||
// Recargar los datos del pedimento desde el servidor
|
||||
await invalidateAll();
|
||||
}
|
||||
|
||||
success = true;
|
||||
@@ -420,6 +568,7 @@
|
||||
<GeneralTabForm
|
||||
pedimento={data.pedimento}
|
||||
bind:formData={generalFormData}
|
||||
bind:identificadoresFormData={identificadoresFormData}
|
||||
pedimentoCodes={data.pedimentoCodes || []}
|
||||
customsSections={data.customsSections || []}
|
||||
customsBrokers={data.customsBrokers || []}
|
||||
@@ -461,29 +610,28 @@
|
||||
bind:formData={bultosTransportesFormData}
|
||||
/>
|
||||
</Tabs.Content>
|
||||
<!-- <Tabs.Content value="descargas">
|
||||
<!-- <Tabs.Content value="descargas">
|
||||
<DescargasTabForm
|
||||
bind:formData={descargasFormData}
|
||||
/>
|
||||
</Tabs.Content> -->
|
||||
<Tabs.Content value="contribuciones">
|
||||
<Tabs.Content value="contribuciones">
|
||||
<ContribucionesTabForm
|
||||
bind:formData={contribucionesFormData}
|
||||
/>
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value="cuentas-compensacion">
|
||||
<Tabs.Content value="cuentas-compensacion">
|
||||
<CuentasCompensacionTabForm
|
||||
bind:formData={cuentasCompensacionFormData}
|
||||
/>
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value="otros-datos">
|
||||
<OtrosDatosTabForm bind:formData={otrosDatosFormData} />
|
||||
</Tabs.Content>
|
||||
|
||||
<Tabs.Content value="digitalizacion">
|
||||
<DigitalizacionTabForm bind:formData={digitalizacionFormData} />
|
||||
</Tabs.Content>
|
||||
</Tabs.Root>
|
||||
<Tabs.Content value="otros-datos">
|
||||
<OtrosDatosTabForm bind:formData={otrosDatosFormData} />
|
||||
</Tabs.Content>
|
||||
<Tabs.Content value="digitalizacion">
|
||||
<DigitalizacionTabForm bind:formData={digitalizacionFormData} />
|
||||
</Tabs.Content>
|
||||
</Tabs.Root>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -528,8 +676,8 @@
|
||||
<Tabs.Trigger value="cuentas-compensacion" class="flex items-center gap-1.5 px-2.5 py-1.5 text-sm">
|
||||
<Wallet size={14} />
|
||||
<span>Cuentas/Comp.</span>
|
||||
</Tabs.Trigger>
|
||||
<Tabs.Trigger value="otros-datos" class="flex items-center gap-1.5 px-2.5 py-1.5 text-sm">
|
||||
</Tabs.Trigger>
|
||||
<Tabs.Trigger value="otros-datos" class="flex items-center gap-1.5 px-2.5 py-1.5 text-sm">
|
||||
<FileStack size={14} />
|
||||
<span>Otros</span>
|
||||
</Tabs.Trigger>
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
"moduleResolution": "bundler",
|
||||
"allowArbitraryExtensions": true
|
||||
}
|
||||
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
||||
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
||||
|
||||
Reference in New Issue
Block a user