feat: Implement multi-tenancy support in middleware and security layers
- Enhanced TenantMiddleware to validate tenant information from JWT tokens. - Added LicenseValidationMiddleware to check tenant licenses before processing requests. - Updated security utilities to extract tenant information from tokens and validate company access. - Introduced CompanyStore to manage active company state and handle company switching in the frontend. - Modified API routes to include company_id in requests for better resource management. - Improved logging and error handling throughout the middleware and API layers. - Updated frontend components to reflect changes in company management and selection. - Added new API route for fetching user's companies with proper authentication handling.
This commit is contained in:
@@ -5,23 +5,34 @@ from datetime import datetime
|
||||
|
||||
class PedimentoConfigAdditionalBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Additional"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., 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")
|
||||
manual_pedimento_year: Optional[str] = Field(None, max_length=2, description="Manual pedimento year")
|
||||
enable_import_invoice_recipient: Optional[int] = Field(None, description="Enable import invoice recipient")
|
||||
send_502_validation_file_for_consolidated: Optional[int] = Field(None, description="Send 502 validation file for consolidated")
|
||||
do_not_exempt_norms_complement_x: Optional[int] = Field(
|
||||
None, description="Do not exempt norms complement X"
|
||||
)
|
||||
manual_pedimento_year: Optional[str] = Field(
|
||||
None, max_length=2, description="Manual pedimento year"
|
||||
)
|
||||
enable_import_invoice_recipient: Optional[int] = Field(
|
||||
None, description="Enable import invoice recipient"
|
||||
)
|
||||
send_502_validation_file_for_consolidated: Optional[int] = Field(
|
||||
None, description="Send 502 validation file for consolidated"
|
||||
)
|
||||
add_remove_norms: Optional[int] = Field(None, description="Add/remove norms")
|
||||
|
||||
|
||||
class PedimentoConfigAdditionalCreate(PedimentoConfigAdditionalBase):
|
||||
"""Schema for creating a new Pedimento Config Additional"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoConfigAdditionalUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Additional"""
|
||||
|
||||
add_po_identifier: Optional[int] = None
|
||||
do_not_exempt_norms_complement_x: Optional[int] = None
|
||||
manual_pedimento_year: Optional[str] = Field(None, max_length=2)
|
||||
@@ -32,6 +43,7 @@ class PedimentoConfigAdditionalUpdate(BaseModel):
|
||||
|
||||
class PedimentoConfigAdditionalResponse(PedimentoConfigAdditionalBase):
|
||||
"""Schema for Pedimento Config Additional response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,27 +5,40 @@ from datetime import datetime
|
||||
|
||||
class PedimentoConfigCalculationsBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Calculations"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., 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_mixed_rate_8permil: Optional[int] = Field(
|
||||
None, 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")
|
||||
fixed_vehicle_dta_fee: Optional[int] = Field(None, description="Fixed vehicle DTA fee")
|
||||
additional_fixed_fee: Optional[int] = Field(None, description="Additional fixed fee")
|
||||
additional_fixed_fee_payment_method: Optional[int] = Field(None, description="Additional fixed fee payment method")
|
||||
include_sagar_certificate_fee: Optional[int] = Field(
|
||||
None, description="Include SAGAR certificate fee"
|
||||
)
|
||||
fixed_vehicle_dta_fee: Optional[int] = Field(
|
||||
None, description="Fixed vehicle DTA fee"
|
||||
)
|
||||
additional_fixed_fee: Optional[int] = Field(
|
||||
None, description="Additional fixed fee"
|
||||
)
|
||||
additional_fixed_fee_payment_method: Optional[int] = Field(
|
||||
None, description="Additional fixed fee payment method"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigCalculationsCreate(PedimentoConfigCalculationsBase):
|
||||
"""Schema for creating a new Pedimento Config Calculations"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
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_vehicle_count: Optional[int] = None
|
||||
@@ -40,6 +53,7 @@ class PedimentoConfigCalculationsUpdate(BaseModel):
|
||||
|
||||
class PedimentoConfigCalculationsResponse(PedimentoConfigCalculationsBase):
|
||||
"""Schema for Pedimento Config Calculations response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -6,28 +6,43 @@ from datetime import datetime
|
||||
|
||||
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")
|
||||
rule_3121_section_ii: Optional[int] = Field(
|
||||
None, 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")
|
||||
customs_value_calculation: Optional[int] = Field(None, description="Customs value calculation")
|
||||
two_decimals_unit_value: Optional[int] = Field(None, description="Two decimals unit value")
|
||||
customs_value_per_item: Optional[int] = Field(None, description="Customs value per item")
|
||||
is_national_supplier: Optional[int] = Field(None, description="Is national supplier")
|
||||
add_state_supplier_record_505: Optional[int] = Field(
|
||||
None, description="Add state supplier record 505"
|
||||
)
|
||||
customs_value_calculation: Optional[int] = Field(
|
||||
None, description="Customs value calculation"
|
||||
)
|
||||
two_decimals_unit_value: Optional[int] = Field(
|
||||
None, description="Two decimals unit value"
|
||||
)
|
||||
customs_value_per_item: Optional[int] = Field(
|
||||
None, description="Customs value per item"
|
||||
)
|
||||
is_national_supplier: Optional[int] = Field(
|
||||
None, description="Is national supplier"
|
||||
)
|
||||
is_consolidated: Optional[int] = Field(None, description="Is consolidated")
|
||||
|
||||
|
||||
class PedimentoConfigParametersCreate(PedimentoConfigParametersBase):
|
||||
"""Schema for creating a new Pedimento Config Parameters"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoConfigParametersUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Parameters"""
|
||||
|
||||
is_embassy: Optional[int] = None
|
||||
embassy_dta: Optional[Decimal] = None
|
||||
rule_3121_section_ii: Optional[int] = None
|
||||
@@ -43,6 +58,7 @@ class PedimentoConfigParametersUpdate(BaseModel):
|
||||
|
||||
class PedimentoConfigParametersResponse(PedimentoConfigParametersBase):
|
||||
"""Schema for Pedimento Config Parameters response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoConfigSurchargesBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Surcharges"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
surcharge_igi: Optional[int] = Field(None, description="Surcharge IGI")
|
||||
@@ -17,11 +18,13 @@ class PedimentoConfigSurchargesBase(BaseModel):
|
||||
|
||||
class PedimentoConfigSurchargesCreate(PedimentoConfigSurchargesBase):
|
||||
"""Schema for creating a new Pedimento Config Surcharges"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoConfigSurchargesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Surcharges"""
|
||||
|
||||
surcharge_igi: Optional[int] = None
|
||||
surcharge_dta: Optional[int] = None
|
||||
surcharge_vat: Optional[int] = None
|
||||
@@ -32,6 +35,7 @@ class PedimentoConfigSurchargesUpdate(BaseModel):
|
||||
|
||||
class PedimentoConfigSurchargesResponse(PedimentoConfigSurchargesBase):
|
||||
"""Schema for Pedimento Config Surcharges response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoConfigUpdateRectificationBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Update Rectification"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
update_vat: Optional[int] = Field(None, description="Update VAT")
|
||||
@@ -16,11 +17,13 @@ class PedimentoConfigUpdateRectificationBase(BaseModel):
|
||||
|
||||
class PedimentoConfigUpdateRectificationCreate(PedimentoConfigUpdateRectificationBase):
|
||||
"""Schema for creating a new Pedimento Config Update Rectification"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoConfigUpdateRectificationUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Update Rectification"""
|
||||
|
||||
update_vat: Optional[int] = None
|
||||
update_advalorem: Optional[int] = None
|
||||
update_cc: Optional[int] = None
|
||||
@@ -28,8 +31,11 @@ class PedimentoConfigUpdateRectificationUpdate(BaseModel):
|
||||
calculate_surcharge: Optional[int] = None
|
||||
|
||||
|
||||
class PedimentoConfigUpdateRectificationResponse(PedimentoConfigUpdateRectificationBase):
|
||||
class PedimentoConfigUpdateRectificationResponse(
|
||||
PedimentoConfigUpdateRectificationBase
|
||||
):
|
||||
"""Schema for Pedimento Config Update Rectification response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoConfigUpdatesBase(BaseModel):
|
||||
"""Base schema for Pedimento Config Updates"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
update_vat: Optional[int] = Field(None, description="Update VAT")
|
||||
@@ -15,11 +16,13 @@ class PedimentoConfigUpdatesBase(BaseModel):
|
||||
|
||||
class PedimentoConfigUpdatesCreate(PedimentoConfigUpdatesBase):
|
||||
"""Schema for creating a new Pedimento Config Updates"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoConfigUpdatesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Config Updates"""
|
||||
|
||||
update_vat: Optional[int] = None
|
||||
update_advalorem: Optional[int] = None
|
||||
update_cc: Optional[int] = None
|
||||
@@ -28,6 +31,7 @@ class PedimentoConfigUpdatesUpdate(BaseModel):
|
||||
|
||||
class PedimentoConfigUpdatesResponse(PedimentoConfigUpdatesBase):
|
||||
"""Schema for Pedimento Config Updates response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,25 +5,33 @@ from datetime import datetime
|
||||
|
||||
class PedimentoCustomsOfficesBase(BaseModel):
|
||||
"""Base schema for Pedimento Customs Offices"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
dispatch_customs: Optional[str] = Field(None, max_length=3, description="Dispatch customs")
|
||||
entry_exit_customs: Optional[str] = Field(None, max_length=3, description="Entry/exit customs")
|
||||
dispatch_customs: Optional[str] = Field(
|
||||
None, max_length=3, description="Dispatch customs"
|
||||
)
|
||||
entry_exit_customs: Optional[str] = Field(
|
||||
None, max_length=3, description="Entry/exit customs"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoCustomsOfficesCreate(PedimentoCustomsOfficesBase):
|
||||
"""Schema for creating a new Pedimento Customs Offices"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoCustomsOfficesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Customs Offices"""
|
||||
|
||||
dispatch_customs: Optional[str] = Field(None, max_length=3)
|
||||
entry_exit_customs: Optional[str] = Field(None, max_length=3)
|
||||
|
||||
|
||||
class PedimentoCustomsOfficesResponse(PedimentoCustomsOfficesBase):
|
||||
"""Schema for Pedimento Customs Offices response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,10 +5,13 @@ from datetime import datetime, time
|
||||
|
||||
class PedimentoDatesBase(BaseModel):
|
||||
"""Base schema for Pedimento Dates"""
|
||||
|
||||
entry_date: Optional[datetime] = Field(None, description="Entry date")
|
||||
pedimento_date: Optional[datetime] = Field(None, description="Pedimento date")
|
||||
payment_date: Optional[datetime] = Field(None, description="Payment date")
|
||||
rectification_payment_date: Optional[datetime] = Field(None, description="Rectification payment date")
|
||||
rectification_payment_date: Optional[datetime] = Field(
|
||||
None, description="Rectification payment date"
|
||||
)
|
||||
extraction_date: Optional[datetime] = Field(None, description="Extraction date")
|
||||
submission_date: Optional[datetime] = Field(None, description="Submission date")
|
||||
eucan_date: Optional[datetime] = Field(None, description="EUCAN date")
|
||||
@@ -21,11 +24,13 @@ class PedimentoDatesBase(BaseModel):
|
||||
|
||||
class PedimentoDatesCreate(PedimentoDatesBase):
|
||||
"""Schema for creating a new Pedimento Dates"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoDatesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Dates"""
|
||||
|
||||
entry_date: Optional[datetime] = None
|
||||
pedimento_date: Optional[datetime] = None
|
||||
payment_date: Optional[datetime] = None
|
||||
@@ -42,6 +47,7 @@ class PedimentoDatesUpdate(BaseModel):
|
||||
|
||||
class PedimentoDatesResponse(PedimentoDatesBase):
|
||||
"""Schema for Pedimento Dates response"""
|
||||
|
||||
id: int
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
|
||||
@@ -6,6 +6,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoDecrementablesBase(BaseModel):
|
||||
"""Base schema for Pedimento Decrementables"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
freight: Optional[Decimal] = Field(None, description="Freight")
|
||||
@@ -15,17 +16,23 @@ class PedimentoDecrementablesBase(BaseModel):
|
||||
others: Optional[Decimal] = Field(None, description="Others")
|
||||
currency: Optional[str] = Field(None, max_length=3, description="Currency")
|
||||
currency_factor: Optional[Decimal] = Field(None, description="Currency factor")
|
||||
not_affect_usd_value: Optional[int] = Field(None, description="Not affect USD value")
|
||||
not_affect_customs_value: Optional[int] = Field(None, description="Not affect customs value")
|
||||
not_affect_usd_value: Optional[int] = Field(
|
||||
None, description="Not affect USD value"
|
||||
)
|
||||
not_affect_customs_value: Optional[int] = Field(
|
||||
None, description="Not affect customs value"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoDecrementablesCreate(PedimentoDecrementablesBase):
|
||||
"""Schema for creating a new Pedimento Decrementables"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoDecrementablesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Decrementables"""
|
||||
|
||||
freight: Optional[Decimal] = None
|
||||
insurance: Optional[Decimal] = None
|
||||
loading: Optional[Decimal] = None
|
||||
@@ -39,6 +46,7 @@ class PedimentoDecrementablesUpdate(BaseModel):
|
||||
|
||||
class PedimentoDecrementablesResponse(PedimentoDecrementablesBase):
|
||||
"""Schema for Pedimento Decrementables response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoIncrementablesBase(BaseModel):
|
||||
"""Base schema for Pedimento Incrementables"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
insured_value: Optional[Decimal] = Field(None, description="Insured value")
|
||||
@@ -16,17 +17,23 @@ class PedimentoIncrementablesBase(BaseModel):
|
||||
deductibles: Optional[Decimal] = Field(None, description="Deductibles")
|
||||
currency: Optional[str] = Field(None, max_length=3, description="Currency")
|
||||
currency_factor: Optional[Decimal] = Field(None, description="Currency factor")
|
||||
not_affect_usd_value: Optional[int] = Field(None, description="Not affect USD value")
|
||||
not_affect_customs_value: Optional[int] = Field(None, description="Not affect customs value")
|
||||
not_affect_usd_value: Optional[int] = Field(
|
||||
None, description="Not affect USD value"
|
||||
)
|
||||
not_affect_customs_value: Optional[int] = Field(
|
||||
None, description="Not affect customs value"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoIncrementablesCreate(PedimentoIncrementablesBase):
|
||||
"""Schema for creating a new Pedimento Incrementables"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoIncrementablesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Incrementables"""
|
||||
|
||||
insured_value: Optional[Decimal] = None
|
||||
freight: Optional[Decimal] = None
|
||||
insurance: Optional[Decimal] = None
|
||||
@@ -41,6 +48,7 @@ class PedimentoIncrementablesUpdate(BaseModel):
|
||||
|
||||
class PedimentoIncrementablesResponse(PedimentoIncrementablesBase):
|
||||
"""Schema for Pedimento Incrementables response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -6,20 +6,25 @@ from datetime import datetime
|
||||
|
||||
class PedimentoIndexesBase(BaseModel):
|
||||
"""Base schema for Pedimento Indexes"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., 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(None, description="Manual update factor")
|
||||
manual_update_factor: Optional[int] = Field(
|
||||
None, description="Manual update factor"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoIndexesCreate(PedimentoIndexesBase):
|
||||
"""Schema for creating a new Pedimento Indexes"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoIndexesUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Indexes"""
|
||||
|
||||
update_factor_type: Optional[int] = None
|
||||
update_factor: Optional[Decimal] = None
|
||||
manual_update_factor: Optional[int] = None
|
||||
@@ -27,6 +32,7 @@ class PedimentoIndexesUpdate(BaseModel):
|
||||
|
||||
class PedimentoIndexesResponse(PedimentoIndexesBase):
|
||||
"""Schema for Pedimento Indexes response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,10 +5,15 @@ from datetime import datetime, date as Date, time as Time
|
||||
|
||||
class PedimentoPaymentsBase(BaseModel):
|
||||
"""Base schema for Pedimento Payments"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
acknowledgment: Optional[str] = Field(None, max_length=20, description="Acknowledgment")
|
||||
operation_number: Optional[str] = Field(None, max_length=14, description="Operation number")
|
||||
acknowledgment: Optional[str] = Field(
|
||||
None, max_length=20, description="Acknowledgment"
|
||||
)
|
||||
operation_number: Optional[str] = Field(
|
||||
None, max_length=14, description="Operation number"
|
||||
)
|
||||
bank_code: Optional[int] = Field(None, description="Bank code")
|
||||
cashier: Optional[str] = Field(None, max_length=2, description="Cashier")
|
||||
date: Optional[Date] = Field(None, description="Date")
|
||||
@@ -23,11 +28,13 @@ class PedimentoPaymentsBase(BaseModel):
|
||||
|
||||
class PedimentoPaymentsCreate(PedimentoPaymentsBase):
|
||||
"""Schema for creating a new Pedimento Payments"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoPaymentsUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Payments"""
|
||||
|
||||
acknowledgment: Optional[str] = Field(None, max_length=20)
|
||||
operation_number: Optional[str] = Field(None, max_length=14)
|
||||
bank_code: Optional[int] = None
|
||||
@@ -44,6 +51,7 @@ class PedimentoPaymentsUpdate(BaseModel):
|
||||
|
||||
class PedimentoPaymentsResponse(PedimentoPaymentsBase):
|
||||
"""Schema for Pedimento Payments response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -4,21 +4,32 @@ from typing import Optional
|
||||
|
||||
class PedimentoRectificationDestinationBase(BaseModel):
|
||||
"""Base schema for Pedimento Rectification Destination"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
destination_pedimento_year: Optional[str] = Field(None, max_length=2, description="Destination pedimento year")
|
||||
destination_customs_office: Optional[str] = Field(None, max_length=3, description="Destination customs office")
|
||||
destination_license: Optional[str] = Field(None, max_length=4, description="Destination license")
|
||||
destination_pedimento_number: Optional[str] = Field(None, max_length=7, description="Destination pedimento number")
|
||||
destination_pedimento_year: Optional[str] = Field(
|
||||
None, max_length=2, description="Destination pedimento year"
|
||||
)
|
||||
destination_customs_office: Optional[str] = Field(
|
||||
None, max_length=3, description="Destination customs office"
|
||||
)
|
||||
destination_license: Optional[str] = Field(
|
||||
None, max_length=4, description="Destination license"
|
||||
)
|
||||
destination_pedimento_number: Optional[str] = Field(
|
||||
None, max_length=7, description="Destination pedimento number"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoRectificationDestinationCreate(PedimentoRectificationDestinationBase):
|
||||
"""Schema for creating a new Pedimento Rectification Destination"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoRectificationDestinationUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Rectification Destination"""
|
||||
|
||||
destination_pedimento_year: Optional[str] = Field(None, max_length=2)
|
||||
destination_customs_office: Optional[str] = Field(None, max_length=3)
|
||||
destination_license: Optional[str] = Field(None, max_length=4)
|
||||
@@ -27,6 +38,7 @@ class PedimentoRectificationDestinationUpdate(BaseModel):
|
||||
|
||||
class PedimentoRectificationDestinationResponse(PedimentoRectificationDestinationBase):
|
||||
"""Schema for Pedimento Rectification Destination response"""
|
||||
|
||||
id: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
@@ -5,30 +5,49 @@ from datetime import datetime
|
||||
|
||||
class PedimentoRectificationOriginBase(BaseModel):
|
||||
"""Base schema for Pedimento Rectification Origin"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
original_pedimento_year: Optional[str] = Field(None, max_length=2, description="Original pedimento year")
|
||||
original_customs_office: Optional[str] = Field(None, max_length=3, description="Original customs office")
|
||||
original_license: Optional[str] = Field(None, max_length=4, description="Original license")
|
||||
original_pedimento_number: Optional[str] = Field(None, max_length=7, description="Original pedimento number")
|
||||
original_pedimento_code: Optional[str] = Field(None, max_length=2, description="Original pedimento key")
|
||||
original_payment_date: Optional[datetime] = Field(None, description="Original payment date")
|
||||
original_pedimento_year: Optional[str] = Field(
|
||||
None, max_length=2, description="Original pedimento year"
|
||||
)
|
||||
original_customs_office: Optional[str] = Field(
|
||||
None, max_length=3, description="Original customs office"
|
||||
)
|
||||
original_license: Optional[str] = Field(
|
||||
None, max_length=4, description="Original license"
|
||||
)
|
||||
original_pedimento_number: Optional[str] = Field(
|
||||
None, max_length=7, description="Original pedimento number"
|
||||
)
|
||||
original_pedimento_code: Optional[str] = Field(
|
||||
None, max_length=2, description="Original pedimento key"
|
||||
)
|
||||
original_payment_date: Optional[datetime] = Field(
|
||||
None, description="Original payment date"
|
||||
)
|
||||
total_cash: Optional[int] = Field(None, description="Total cash")
|
||||
total_others: Optional[int] = Field(None, description="Total others")
|
||||
reason: Optional[str] = Field(None, max_length=255, description="Reason")
|
||||
charge_to_client: Optional[int] = Field(None, description="Charge to client")
|
||||
use_original_payment_date_for_interest_calc: Optional[int] = Field(None, description="Use original payment date for interest calculation")
|
||||
use_original_payment_date_for_interest_calc: Optional[int] = Field(
|
||||
None, description="Use original payment date for interest calculation"
|
||||
)
|
||||
manual_calculation: Optional[int] = Field(None, description="Manual calculation")
|
||||
original_pedimento_norms: Optional[int] = Field(None, description="Original pedimento norms")
|
||||
original_pedimento_norms: Optional[int] = Field(
|
||||
None, description="Original pedimento norms"
|
||||
)
|
||||
|
||||
|
||||
class PedimentoRectificationOriginCreate(PedimentoRectificationOriginBase):
|
||||
"""Schema for creating a new Pedimento Rectification Origin"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoRectificationOriginUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Rectification Origin"""
|
||||
|
||||
original_pedimento_year: Optional[str] = Field(None, max_length=2)
|
||||
original_customs_office: Optional[str] = Field(None, max_length=3)
|
||||
original_license: Optional[str] = Field(None, max_length=4)
|
||||
@@ -46,6 +65,7 @@ class PedimentoRectificationOriginUpdate(BaseModel):
|
||||
|
||||
class PedimentoRectificationOriginResponse(PedimentoRectificationOriginBase):
|
||||
"""Schema for Pedimento Rectification Origin response"""
|
||||
|
||||
id: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
|
||||
class PedimentoTransportMeansBase(BaseModel):
|
||||
"""Base schema for Pedimento Transport Means"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., description="Tenant ID")
|
||||
destination: Optional[int] = Field(None, description="Destination")
|
||||
@@ -15,11 +16,13 @@ class PedimentoTransportMeansBase(BaseModel):
|
||||
|
||||
class PedimentoTransportMeansCreate(PedimentoTransportMeansBase):
|
||||
"""Schema for creating a new Pedimento Transport Means"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoTransportMeansUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Transport Means"""
|
||||
|
||||
destination: Optional[int] = None
|
||||
entry_exit: Optional[str] = Field(None, max_length=2)
|
||||
arrival: Optional[str] = Field(None, max_length=2)
|
||||
@@ -28,6 +31,7 @@ class PedimentoTransportMeansUpdate(BaseModel):
|
||||
|
||||
class PedimentoTransportMeansResponse(PedimentoTransportMeansBase):
|
||||
"""Schema for Pedimento Transport Means response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -5,25 +5,36 @@ from datetime import datetime
|
||||
|
||||
class PedimentoValidationBase(BaseModel):
|
||||
"""Base schema for Pedimento Validation"""
|
||||
|
||||
pedimento_id: int = Field(..., description="Pedimento ID")
|
||||
tenant_id: int = Field(..., 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")
|
||||
validation_ack: Optional[str] = Field(
|
||||
None, max_length=8, description="Validation acknowledgment"
|
||||
)
|
||||
pre_ack: Optional[str] = Field(None, max_length=8, description="Pre-acknowledgment")
|
||||
line_signature: Optional[str] = Field(None, max_length=50, description="Line signature")
|
||||
electronic_signature: Optional[str] = Field(None, max_length=999, description="Electronic signature")
|
||||
certificate_number: Optional[str] = Field(None, max_length=99, description="Certificate number")
|
||||
line_signature: Optional[str] = Field(
|
||||
None, max_length=50, description="Line signature"
|
||||
)
|
||||
electronic_signature: Optional[str] = Field(
|
||||
None, max_length=999, description="Electronic signature"
|
||||
)
|
||||
certificate_number: Optional[str] = Field(
|
||||
None, max_length=99, description="Certificate number"
|
||||
)
|
||||
validator_id: Optional[int] = Field(None, description="Validator ID")
|
||||
responsible_id: Optional[int] = Field(None, description="Responsible ID")
|
||||
|
||||
|
||||
class PedimentoValidationCreate(PedimentoValidationBase):
|
||||
"""Schema for creating a new Pedimento Validation"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentoValidationUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento Validation"""
|
||||
|
||||
validator: Optional[str] = Field(None, max_length=3)
|
||||
validation_ack: Optional[str] = Field(None, max_length=8)
|
||||
pre_ack: Optional[str] = Field(None, max_length=8)
|
||||
@@ -36,6 +47,7 @@ class PedimentoValidationUpdate(BaseModel):
|
||||
|
||||
class PedimentoValidationResponse(PedimentoValidationBase):
|
||||
"""Schema for Pedimento Validation response"""
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
@@ -4,20 +4,29 @@ from typing import Optional
|
||||
from decimal import Decimal
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class OperationType(IntEnum):
|
||||
EXPORTACION = 1
|
||||
IMPORTACION = 2
|
||||
|
||||
|
||||
class PedimentosBase(BaseModel):
|
||||
"""Base schema for Pedimentos"""
|
||||
|
||||
year: Optional[str] = Field(None, max_length=2, description="Year")
|
||||
customs_office: Optional[str] = Field(None, max_length=2, description="Customs office")
|
||||
customs_office: Optional[str] = Field(
|
||||
None, max_length=2, description="Customs office"
|
||||
)
|
||||
license: Optional[str] = Field(None, max_length=4, description="License")
|
||||
pedimento_number: Optional[str] = Field(None, max_length=7, description="Pedimento number")
|
||||
pedimento_number: Optional[str] = Field(
|
||||
None, max_length=7, description="Pedimento number"
|
||||
)
|
||||
client_id: Optional[int] = Field(None, description="Client ID")
|
||||
operation_type: Optional[int] = Field(None, description="Operation type")
|
||||
pedimento_type: Optional[int] = Field(None, description="Pedimento type")
|
||||
pedimento_code: Optional[str] = Field(None, max_length=2, description="Pedimento key")
|
||||
pedimento_code: Optional[str] = Field(
|
||||
None, max_length=2, description="Pedimento key"
|
||||
)
|
||||
regime: Optional[str] = Field(None, max_length=3, description="Regime")
|
||||
status: Optional[str] = Field(None, max_length=30, description="Status")
|
||||
usd_value: Optional[Decimal] = Field(None, description="USD value")
|
||||
@@ -28,11 +37,13 @@ class PedimentosBase(BaseModel):
|
||||
|
||||
class PedimentosCreate(PedimentosBase):
|
||||
"""Schema for creating a new Pedimento"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class PedimentosUpdate(BaseModel):
|
||||
"""Schema for updating a Pedimento"""
|
||||
|
||||
year: Optional[str] = Field(..., max_length=2)
|
||||
customs_office: Optional[str] = Field(..., max_length=2)
|
||||
license: Optional[str] = Field(..., max_length=4)
|
||||
@@ -51,6 +62,7 @@ class PedimentosUpdate(BaseModel):
|
||||
|
||||
class PedimentosResponse(PedimentosBase):
|
||||
"""Schema for Pedimento response"""
|
||||
|
||||
id: int
|
||||
tenant_id: int
|
||||
created_at: datetime
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, func, text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from datetime import datetime
|
||||
from core.database import Base
|
||||
|
||||
@@ -9,31 +19,55 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class PedimentoConfigAdditional(Base):
|
||||
__tablename__ = 'pedimento_config_additional'
|
||||
__tablename__ = "pedimento_config_additional"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_additional_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_config_additional_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_config_additional_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_additional'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_additional_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_additional_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_config_additional_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_config_additional_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_additional",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_additional_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped [int] = mapped_column(Integer)
|
||||
tenant_id: Mapped [int] = mapped_column(Integer, nullable=False, index=True)
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped [int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
add_po_identifier: Mapped [int] = mapped_column(SmallInteger)
|
||||
do_not_exempt_norms_complement_x: Mapped [int] = mapped_column(SmallInteger)
|
||||
manual_pedimento_year: Mapped [str] = mapped_column(String(2))
|
||||
enable_import_invoice_recipient: Mapped [int] = mapped_column(SmallInteger)
|
||||
send_502_validation_file_for_consolidated: Mapped [int] = mapped_column(SmallInteger)
|
||||
add_remove_norms: Mapped [int] = mapped_column(SmallInteger)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
add_po_identifier: Mapped[int] = mapped_column(SmallInteger)
|
||||
do_not_exempt_norms_complement_x: Mapped[int] = mapped_column(SmallInteger)
|
||||
manual_pedimento_year: Mapped[str] = mapped_column(String(2))
|
||||
enable_import_invoice_recipient: Mapped[int] = mapped_column(SmallInteger)
|
||||
send_502_validation_file_for_consolidated: Mapped[int] = mapped_column(SmallInteger)
|
||||
add_remove_norms: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_additional')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_additional"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from datetime import datetime
|
||||
from core.database import Base
|
||||
@@ -7,22 +17,33 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoConfigCalculations(Base):
|
||||
__tablename__ = 'pedimento_config_calculations'
|
||||
__tablename__ = "pedimento_config_calculations"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_calculations_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id']),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id']),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_calculations'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_calculations_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_calculations_pkey"),
|
||||
ForeignKeyConstraint(["tenant_id"], ["a76.tenants.id"]),
|
||||
ForeignKeyConstraint(["company_id"], ["a76.company.id"]),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_calculations",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_calculations_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
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)
|
||||
@@ -33,10 +54,16 @@ class PedimentoConfigCalculations(Base):
|
||||
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)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_calculations')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_calculations"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, Numeric, PrimaryKeyConstraint, SmallInteger, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -11,21 +21,39 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class PedimentoConfigParameters(Base):
|
||||
__tablename__ = 'pedimento_config_parameters'
|
||||
__tablename__ = "pedimento_config_parameters"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_parameters_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_config_parameters_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_config_parameters_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_parameters'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_parameters_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_parameters_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_config_parameters_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_config_parameters_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_parameters",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_parameters_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
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)
|
||||
@@ -37,10 +65,16 @@ class PedimentoConfigParameters(Base):
|
||||
customs_value_per_item: Mapped[int] = mapped_column(SmallInteger)
|
||||
is_national_supplier: Mapped[int] = mapped_column(SmallInteger)
|
||||
is_consolidated: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_parameters')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_parameters"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -8,32 +17,57 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoConfigSurcharges(Base):
|
||||
__tablename__ = 'pedimento_config_surcharges'
|
||||
__tablename__ = "pedimento_config_surcharges"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_surcharges_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_config_surcharges_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_config_surcharges_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_surcharges'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_surcharges_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_surcharges_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_config_surcharges_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_config_surcharges_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_surcharges",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_surcharges_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
surcharge_igi: Mapped[int] = mapped_column(SmallInteger)
|
||||
surcharge_dta: Mapped[int] = mapped_column(SmallInteger)
|
||||
surcharge_vat: Mapped[int] = mapped_column(SmallInteger)
|
||||
surcharge_isan: Mapped[int] = mapped_column(SmallInteger)
|
||||
surcharge_ieps: Mapped[int] = mapped_column(SmallInteger)
|
||||
surcharge_cc: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_surcharges')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_surcharges"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -8,31 +17,56 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoConfigUpdateRectification(Base):
|
||||
__tablename__ = 'pedimento_config_update_rectification'
|
||||
__tablename__ = "pedimento_config_update_rectification"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_update_rectification_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_config_update_rectification_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_config_update_rectification_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_update_rectification'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_update_rectification_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_update_rectification_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_config_update_rectification_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_config_update_rectification_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_update_rectification",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_update_rectification_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
|
||||
update_vat: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_advalorem: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_cc: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_ieps: Mapped[int] = mapped_column(SmallInteger)
|
||||
calculate_surcharge: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_update_rectification')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_update_rectification"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -8,30 +17,53 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoConfigUpdates(Base):
|
||||
__tablename__ = 'pedimento_config_updates'
|
||||
__tablename__ = "pedimento_config_updates"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_config_updates_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_config_updates_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_config_updates_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_config_updates'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_config_updates_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_config_updates_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_config_updates_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_config_updates_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_config_updates",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_config_updates_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
update_vat: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_advalorem: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_cc: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_ieps: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_config_updates')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_config_updates"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -8,28 +17,53 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoCustomsOffices(Base):
|
||||
__tablename__ = 'pedimento_customs_offices'
|
||||
__tablename__ = "pedimento_customs_offices"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_customs_offices_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_customs_offices_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_customs_offices_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_customs_offices'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_customs_offices_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_customs_offices_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_customs_offices_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_customs_offices_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_customs_offices",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_customs_offices_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
dispatch_customs: Mapped[str] = mapped_column(String(3))
|
||||
entry_exit_customs: Mapped[str] = mapped_column(String(3))
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_customs_offices')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_customs_offices"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Index, Integer, PrimaryKeyConstraint, Time, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Index,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
Time,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime, time as datetime_time
|
||||
@@ -8,23 +18,38 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoDates(Base):
|
||||
__tablename__ = 'pedimento_dates'
|
||||
__tablename__ = "pedimento_dates"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_dates_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_dates_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_dates_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_dates'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_dates_pedimento_id_key'),
|
||||
Index('idx_pedimento_dates_pedimento_id', 'pedimento_id'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_dates_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_dates_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"], ["a76.company.id"], name="fk_pedimento_dates_company"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_dates",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_dates_pedimento_id_key",
|
||||
),
|
||||
Index("idx_pedimento_dates_pedimento_id", "pedimento_id"),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
entry_date: Mapped[datetime] = mapped_column(DateTime)
|
||||
pedimento_date: Mapped[datetime] = mapped_column(DateTime)
|
||||
payment_date: Mapped[datetime] = mapped_column(DateTime)
|
||||
@@ -37,10 +62,16 @@ class PedimentoDates(Base):
|
||||
end_date: Mapped[datetime] = mapped_column(DateTime)
|
||||
capture_date: Mapped[datetime] = mapped_column(DateTime)
|
||||
capture_time: Mapped[datetime_time] = mapped_column(Time)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_dates')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_dates"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, Numeric, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -9,22 +20,39 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoDecrementables(Base):
|
||||
__tablename__ = 'pedimento_decrementables'
|
||||
__tablename__ = "pedimento_decrementables"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_decrementables_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_decrementables_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_decrementables_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_decrementables'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_decrementables_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_decrementables_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_decrementables_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_decrementables_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_decrementables",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_decrementables_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
freight: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
insurance: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
loading: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
@@ -34,10 +62,16 @@ class PedimentoDecrementables(Base):
|
||||
currency_factor: Mapped[Decimal] = mapped_column(Numeric(15, 8))
|
||||
not_affect_usd_value: Mapped[int] = mapped_column(SmallInteger)
|
||||
not_affect_customs_value: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_decrementables')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_decrementables"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, Numeric, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -9,22 +20,39 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoIncrementables(Base):
|
||||
__tablename__ = 'pedimento_incrementables'
|
||||
__tablename__ = "pedimento_incrementables"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_incrementables_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_incrementables_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_incrementables_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_incrementables'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_incrementables_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_incrementables_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_incrementables_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_incrementables_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_incrementables",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_incrementables_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
insured_value: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
freight: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
insurance: Mapped[Decimal] = mapped_column(Numeric(13, 2))
|
||||
@@ -35,10 +63,16 @@ class PedimentoIncrementables(Base):
|
||||
currency_factor: Mapped[Decimal] = mapped_column(Numeric(15, 8))
|
||||
not_affect_usd_value: Mapped[int] = mapped_column(SmallInteger)
|
||||
not_affect_customs_value: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_incrementables')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_incrementables"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, Numeric, PrimaryKeyConstraint, SmallInteger, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -9,29 +19,50 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoIndexes(Base):
|
||||
__tablename__ = 'pedimento_indexes'
|
||||
__tablename__ = "pedimento_indexes"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_indexes_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_indexes_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_indexes_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_indexes'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_indexes_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_indexes_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_indexes_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"], ["a76.company.id"], name="fk_pedimento_indexes_company"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_indexes",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_indexes_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
update_factor_type: Mapped[int] = mapped_column(SmallInteger)
|
||||
update_factor: Mapped[Decimal] = mapped_column(Numeric(7, 4))
|
||||
manual_update_factor: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_indexes')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_indexes"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import Date, DateTime, ForeignKeyConstraint, Index, Integer, PrimaryKeyConstraint, SmallInteger, String, Time, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
Date,
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Index,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
Time,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime, time as Time2, date as Date2
|
||||
@@ -8,24 +21,39 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoPayments(Base):
|
||||
__tablename__ = 'pedimento_payments'
|
||||
__tablename__ = "pedimento_payments"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_payments_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_payments_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_payments_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_payments'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_payments_pedimento_id_key'),
|
||||
Index('idx_pedimento_payments_pedimento_id', 'pedimento_id'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_payments_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimento_payments_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"], ["a76.company.id"], name="fk_pedimento_payments_company"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_payments",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_payments_pedimento_id_key",
|
||||
),
|
||||
Index("idx_pedimento_payments_pedimento_id", "pedimento_id"),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
payment_id: Mapped[int] = mapped_column(Integer)
|
||||
|
||||
|
||||
acknowledgment: Mapped[str] = mapped_column(String(20))
|
||||
operation_number: Mapped[str] = mapped_column(String(14))
|
||||
bank_code: Mapped[int] = mapped_column(Integer)
|
||||
@@ -36,11 +64,17 @@ class PedimentoPayments(Base):
|
||||
total_cash_paid: Mapped[int] = mapped_column(Integer)
|
||||
total_contributions: Mapped[int] = mapped_column(Integer)
|
||||
counter_payment: Mapped[int] = mapped_column(SmallInteger)
|
||||
pece_code: Mapped[str] = mapped_column(String(5))
|
||||
|
||||
pece_code: Mapped[str] = mapped_column(String(5))
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_payments')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_payments"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, String, UniqueConstraint, func
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from core.database import Base
|
||||
@@ -8,30 +16,55 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoRectificationDestination(Base):
|
||||
__tablename__ = 'pedimento_rectification_destination'
|
||||
__tablename__ = "pedimento_rectification_destination"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_rectification_destination_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_rectification_destination_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_rectification_destination_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_rectification_destination'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_destination_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_rectification_destination_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_rectification_destination_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_rectification_destination_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_rectification_destination",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_rectification_destination_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
destination_pedimento_year: Mapped[str] = mapped_column(String(2))
|
||||
destination_customs_office: Mapped[str] = mapped_column(String(3))
|
||||
destination_license: Mapped[str] = mapped_column(String(4))
|
||||
destination_pedimento_number: Mapped[str] = mapped_column(String(7))
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_rectification_destination')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_rectification_destination"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, func
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from core.database import Base
|
||||
@@ -8,22 +17,41 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoRectificationOrigin(Base):
|
||||
__tablename__ = 'pedimento_rectification_origin'
|
||||
__tablename__ = "pedimento_rectification_origin"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_rectification_origin_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_rectification_origin_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_rectification_origin_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_rectification_origin'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_rectification_origin_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_rectification_origin_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_rectification_origin_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_rectification_origin_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_rectification_origin",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_rectification_origin_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
original_pedimento_year: Mapped[str] = mapped_column(String(2))
|
||||
original_customs_office: Mapped[str] = mapped_column(String(3))
|
||||
original_license: Mapped[str] = mapped_column(String(4))
|
||||
@@ -34,13 +62,21 @@ class PedimentoRectificationOrigin(Base):
|
||||
total_others: Mapped[int] = mapped_column(Integer)
|
||||
reason: Mapped[str] = mapped_column(String(255))
|
||||
charge_to_client: Mapped[int] = mapped_column(SmallInteger)
|
||||
use_original_payment_date_for_interest_calc: Mapped[int] = mapped_column(SmallInteger)
|
||||
use_original_payment_date_for_interest_calc: Mapped[int] = mapped_column(
|
||||
SmallInteger
|
||||
)
|
||||
manual_calculation: Mapped[int] = mapped_column(SmallInteger)
|
||||
original_pedimento_norms: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_rectification_origin')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_rectification_origin"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, SmallInteger, String, UniqueConstraint, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
SmallInteger,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from core.database import Base
|
||||
@@ -8,26 +17,49 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoTransportMeans(Base):
|
||||
__tablename__ = 'pedimento_transport_means'
|
||||
__tablename__ = "pedimento_transport_means"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_transport_means_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_transport_means_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_transport_means_company'),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_transport_means'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_transport_means_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_transport_means_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"],
|
||||
["a76.tenants.id"],
|
||||
name="fk_pedimento_transport_means_tenant",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"],
|
||||
["a76.company.id"],
|
||||
name="fk_pedimento_transport_means_company",
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_transport_means",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_transport_means_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
|
||||
destination: Mapped[int] = mapped_column(SmallInteger)
|
||||
entry_exit: Mapped[str] = mapped_column(String(2))
|
||||
arrival: Mapped[str] = mapped_column(String(2))
|
||||
departure: Mapped[str] = mapped_column(String(2))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=text('CURRENT_TIMESTAMP'))
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, server_default=text("CURRENT_TIMESTAMP")
|
||||
)
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_transport_means')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_transport_means"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
@@ -8,35 +17,50 @@ from core.database import Base
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
||||
|
||||
|
||||
class PedimentoValidation(Base):
|
||||
__tablename__ = 'pedimento_validation' #PedimentoValidacion
|
||||
__tablename__ = "pedimento_validation" # PedimentoValidacion
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimento_validation_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id']),
|
||||
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_validation'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_validation_pedimento_id_key'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimento_validation_pkey"),
|
||||
ForeignKeyConstraint(["tenant_id"], ["a76.tenants.id"]),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_id"],
|
||||
["a76.pedimentos.id"],
|
||||
ondelete="CASCADE",
|
||||
name="fk_pedimento_validation",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"pedimento_id",
|
||||
name="pedimento_validation_pedimento_id_key",
|
||||
),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
validator: Mapped[str] = mapped_column(String(3)) #validador
|
||||
validation_ack: Mapped[str] = mapped_column(String(8)) #acuse_validacion
|
||||
pre_ack: Mapped[str] = mapped_column(String(8)) #acuse_previo
|
||||
line_signature: Mapped[str] = mapped_column(String(50)) #firma_linea_captura
|
||||
electronic_signature: Mapped[str] = mapped_column(String(999)) #firma_electronica
|
||||
certificate_number: Mapped[str] = mapped_column(String(99)) #numero_certificado
|
||||
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
validator: Mapped[str] = mapped_column(String(3)) # validador
|
||||
validation_ack: Mapped[str] = mapped_column(String(8)) # acuse_validacion
|
||||
pre_ack: Mapped[str] = mapped_column(String(8)) # acuse_previo
|
||||
line_signature: Mapped[str] = mapped_column(String(50)) # firma_linea_captura
|
||||
electronic_signature: Mapped[str] = mapped_column(String(999)) # firma_electronica
|
||||
certificate_number: Mapped[str] = mapped_column(String(99)) # numero_certificado
|
||||
validator_id: Mapped[int] = mapped_column(Integer)
|
||||
responsible_id: Mapped[int] = mapped_column(Integer)
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
|
||||
|
||||
pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_validation')
|
||||
pedimento: Mapped["Pedimentos"] = relationship(
|
||||
"Pedimentos", back_populates="pedimento_validation"
|
||||
)
|
||||
|
||||
@@ -1,50 +1,110 @@
|
||||
from decimal import Decimal
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from sqlalchemy import DateTime, ForeignKeyConstraint, Index, Integer, Numeric, PrimaryKeyConstraint, String, UniqueConstraint, func, text
|
||||
from sqlalchemy import (
|
||||
DateTime,
|
||||
ForeignKeyConstraint,
|
||||
Index,
|
||||
Integer,
|
||||
Numeric,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
func,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.orm.base import Mapped
|
||||
from datetime import datetime
|
||||
from enum import IntEnum
|
||||
from core.database import Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_additional import PedimentoConfigAdditional
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_calculations import PedimentoConfigCalculations
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_parameters import PedimentoConfigParameters
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_surcharges import PedimentoConfigSurcharges
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_update_rectification import PedimentoConfigUpdateRectification
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_updates import PedimentoConfigUpdates
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_customs_offices import PedimentoCustomsOffices
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_additional import (
|
||||
PedimentoConfigAdditional,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_calculations import (
|
||||
PedimentoConfigCalculations,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_parameters import (
|
||||
PedimentoConfigParameters,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_surcharges import (
|
||||
PedimentoConfigSurcharges,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_update_rectification import (
|
||||
PedimentoConfigUpdateRectification,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_config_updates import (
|
||||
PedimentoConfigUpdates,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_customs_offices import (
|
||||
PedimentoCustomsOffices,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_dates import PedimentoDates
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_decrementables import PedimentoDecrementables
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_incrementables import PedimentoIncrementables
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_decrementables import (
|
||||
PedimentoDecrementables,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_incrementables import (
|
||||
PedimentoIncrementables,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_indexes import PedimentoIndexes
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_payments import PedimentoPayments
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_rectification_destination import PedimentoRectificationDestination
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_rectification_origin import PedimentoRectificationOrigin
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_transport_means import PedimentoTransportMeans
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_validation import PedimentoValidation
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_payments import (
|
||||
PedimentoPayments,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_rectification_destination import (
|
||||
PedimentoRectificationDestination,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_rectification_origin import (
|
||||
PedimentoRectificationOrigin,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_transport_means import (
|
||||
PedimentoTransportMeans,
|
||||
)
|
||||
from api.v1.modules.a76.pedmientos.models.pedimento_validation import (
|
||||
PedimentoValidation,
|
||||
)
|
||||
|
||||
|
||||
class Pedimentos(Base):
|
||||
__tablename__ = 'pedimentos'
|
||||
__tablename__ = "pedimentos"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint('id', name='pedimentos_pkey'),
|
||||
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimentos_tenant'),
|
||||
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimentos_company'),
|
||||
ForeignKeyConstraint(['client_id'], ['a76.client_provider.id'], name='fk_pedimentos_client'),
|
||||
ForeignKeyConstraint(['regime'], ['public.pedimento_regimens.code'], name='fk_pedimentos_regime'),
|
||||
ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_pedimentos_code'),
|
||||
UniqueConstraint('tenant_id', 'company_id', 'year', 'customs_office', 'license', 'pedimento_number', name='pedimentos_unique_key'),
|
||||
Index('idx_pedimentos_client_id', 'client_id'),
|
||||
Index('idx_pedimentos_created_at', 'created_at'),
|
||||
Index('idx_pedimentos_status', 'status'),
|
||||
{'schema': 'a76'}
|
||||
PrimaryKeyConstraint("id", name="pedimentos_pkey"),
|
||||
ForeignKeyConstraint(
|
||||
["tenant_id"], ["a76.tenants.id"], name="fk_pedimentos_tenant"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["company_id"], ["a76.company.id"], name="fk_pedimentos_company"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["client_id"], ["a76.client_provider.id"], name="fk_pedimentos_client"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["regime"], ["public.pedimento_regimens.code"], name="fk_pedimentos_regime"
|
||||
),
|
||||
ForeignKeyConstraint(
|
||||
["pedimento_code"],
|
||||
["public.pedimento_codes.code"],
|
||||
name="fk_pedimentos_code",
|
||||
),
|
||||
UniqueConstraint(
|
||||
"tenant_id",
|
||||
"company_id",
|
||||
"year",
|
||||
"customs_office",
|
||||
"license",
|
||||
"pedimento_number",
|
||||
name="pedimentos_unique_key",
|
||||
),
|
||||
Index("idx_pedimentos_client_id", "client_id"),
|
||||
Index("idx_pedimentos_created_at", "created_at"),
|
||||
Index("idx_pedimentos_status", "status"),
|
||||
{"schema": "a76"},
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer)
|
||||
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
||||
|
||||
|
||||
year: Mapped[str] = mapped_column(String(2))
|
||||
customs_office: Mapped[str] = mapped_column(String(2))
|
||||
license: Mapped[str] = mapped_column(String(4))
|
||||
@@ -59,26 +119,69 @@ class Pedimentos(Base):
|
||||
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))
|
||||
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now()
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
||||
)
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
pedimento_config_additional: Mapped['PedimentoConfigAdditional'] = relationship('PedimentoConfigAdditional', uselist=False, back_populates='pedimento')
|
||||
pedimento_config_calculations: Mapped['PedimentoConfigCalculations'] = relationship('PedimentoConfigCalculations', uselist=False, back_populates='pedimento')
|
||||
pedimento_config_parameters: Mapped['PedimentoConfigParameters'] = relationship('PedimentoConfigParameters', uselist=False, back_populates='pedimento')
|
||||
pedimento_config_surcharges: Mapped['PedimentoConfigSurcharges'] = relationship('PedimentoConfigSurcharges', uselist=False, back_populates='pedimento')
|
||||
pedimento_config_update_rectification: Mapped['PedimentoConfigUpdateRectification'] = relationship('PedimentoConfigUpdateRectification', uselist=False, back_populates='pedimento')
|
||||
pedimento_config_updates: Mapped['PedimentoConfigUpdates'] = relationship('PedimentoConfigUpdates', uselist=False, back_populates='pedimento')
|
||||
pedimento_customs_offices: Mapped['PedimentoCustomsOffices'] = relationship('PedimentoCustomsOffices', uselist=False, back_populates='pedimento')
|
||||
pedimento_dates: Mapped['PedimentoDates'] = relationship('PedimentoDates', uselist=False, back_populates='pedimento')
|
||||
pedimento_decrementables: Mapped['PedimentoDecrementables'] = relationship('PedimentoDecrementables', uselist=False, back_populates='pedimento')
|
||||
pedimento_incrementables: Mapped['PedimentoIncrementables'] = relationship('PedimentoIncrementables', uselist=False, back_populates='pedimento')
|
||||
pedimento_indexes: Mapped['PedimentoIndexes'] = relationship('PedimentoIndexes', uselist=False, back_populates='pedimento')
|
||||
pedimento_payments: Mapped['PedimentoPayments'] = relationship('PedimentoPayments', uselist=False, back_populates='pedimento')
|
||||
pedimento_rectification_destination: Mapped['PedimentoRectificationDestination'] = relationship('PedimentoRectificationDestination', uselist=False, back_populates='pedimento')
|
||||
pedimento_rectification_origin: Mapped['PedimentoRectificationOrigin'] = relationship('PedimentoRectificationOrigin', uselist=False, back_populates='pedimento')
|
||||
pedimento_transport_means: Mapped['PedimentoTransportMeans'] = relationship('PedimentoTransportMeans', uselist=False, back_populates='pedimento')
|
||||
pedimento_validation: Mapped['PedimentoValidation'] = relationship('PedimentoValidation', uselist=False, back_populates='pedimento')
|
||||
|
||||
pedimento_config_additional: Mapped["PedimentoConfigAdditional"] = relationship(
|
||||
"PedimentoConfigAdditional", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_config_calculations: Mapped["PedimentoConfigCalculations"] = relationship(
|
||||
"PedimentoConfigCalculations", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_config_parameters: Mapped["PedimentoConfigParameters"] = relationship(
|
||||
"PedimentoConfigParameters", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_config_surcharges: Mapped["PedimentoConfigSurcharges"] = relationship(
|
||||
"PedimentoConfigSurcharges", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_config_update_rectification: Mapped[
|
||||
"PedimentoConfigUpdateRectification"
|
||||
] = relationship(
|
||||
"PedimentoConfigUpdateRectification", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_config_updates: Mapped["PedimentoConfigUpdates"] = relationship(
|
||||
"PedimentoConfigUpdates", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_customs_offices: Mapped["PedimentoCustomsOffices"] = relationship(
|
||||
"PedimentoCustomsOffices", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_dates: Mapped["PedimentoDates"] = relationship(
|
||||
"PedimentoDates", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_decrementables: Mapped["PedimentoDecrementables"] = relationship(
|
||||
"PedimentoDecrementables", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_incrementables: Mapped["PedimentoIncrementables"] = relationship(
|
||||
"PedimentoIncrementables", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_indexes: Mapped["PedimentoIndexes"] = relationship(
|
||||
"PedimentoIndexes", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_payments: Mapped["PedimentoPayments"] = relationship(
|
||||
"PedimentoPayments", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_rectification_destination: Mapped["PedimentoRectificationDestination"] = (
|
||||
relationship(
|
||||
"PedimentoRectificationDestination",
|
||||
uselist=False,
|
||||
back_populates="pedimento",
|
||||
)
|
||||
)
|
||||
pedimento_rectification_origin: Mapped["PedimentoRectificationOrigin"] = (
|
||||
relationship(
|
||||
"PedimentoRectificationOrigin", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
)
|
||||
pedimento_transport_means: Mapped["PedimentoTransportMeans"] = relationship(
|
||||
"PedimentoTransportMeans", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
pedimento_validation: Mapped["PedimentoValidation"] = relationship(
|
||||
"PedimentoValidation", uselist=False, back_populates="pedimento"
|
||||
)
|
||||
|
||||
@@ -1,39 +1,119 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from .routes.pedimento_config_additional import router as pedimento_config_additional_router
|
||||
from .routes.pedimento_config_calculations import router as pedimento_config_calculations_router
|
||||
from .routes.pedimento_config_parameters import router as pedimento_config_parameters_router
|
||||
from .routes.pedimento_config_surcharges import router as pedimento_config_surcharges_router
|
||||
from .routes.pedimento_config_update_rectification import router as pedimento_config_update_rectification_router
|
||||
from .routes.pedimento_config_additional import (
|
||||
router as pedimento_config_additional_router,
|
||||
)
|
||||
from .routes.pedimento_config_calculations import (
|
||||
router as pedimento_config_calculations_router,
|
||||
)
|
||||
from .routes.pedimento_config_parameters import (
|
||||
router as pedimento_config_parameters_router,
|
||||
)
|
||||
from .routes.pedimento_config_surcharges import (
|
||||
router as pedimento_config_surcharges_router,
|
||||
)
|
||||
from .routes.pedimento_config_update_rectification import (
|
||||
router as pedimento_config_update_rectification_router,
|
||||
)
|
||||
from .routes.pedimento_config_updates import router as pedimento_config_updates_router
|
||||
from .routes.pedimento_customs_offices import router as pedimento_customs_offices_router
|
||||
from .routes.pedimento_dates import router as pedimento_dates_router
|
||||
from .routes.pedimento_decrementables import router as pedimento_decrementables_router
|
||||
from .routes.pedimento_incrementables import router as pedimento_incrementables_router
|
||||
from .routes.pedimento_incrementables import router as pedimento_incrementables_router
|
||||
from .routes.pedimento_indexes import router as pedimento_indexes_router
|
||||
from .routes.pedimento_payments import router as pedimento_payments_router
|
||||
from .routes.pedimento_rectification_destination import router as pedimento_rectification_destination_router
|
||||
from .routes.pedimento_rectification_origin import router as pedimento_rectification_origin_router
|
||||
from .routes.pedimento_rectification_destination import (
|
||||
router as pedimento_rectification_destination_router,
|
||||
)
|
||||
from .routes.pedimento_rectification_origin import (
|
||||
router as pedimento_rectification_origin_router,
|
||||
)
|
||||
from .routes.pedimento_transport_means import router as pedimento_transport_means_router
|
||||
from .routes.pedimento_validation import router as pedimento_validation_router
|
||||
from .routes.pedimentos import router as pedimentos_router
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
router.include_router(pedimento_config_additional_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_additional"])
|
||||
router.include_router(pedimento_config_calculations_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_calculations"])
|
||||
router.include_router(pedimento_config_parameters_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_parameters"])
|
||||
router.include_router(pedimento_config_surcharges_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_surcharges"])
|
||||
router.include_router(pedimento_config_update_rectification_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_update_rectification"])
|
||||
router.include_router(pedimento_config_updates_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_config_updates"])
|
||||
router.include_router(pedimento_customs_offices_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_customs_offices"])
|
||||
router.include_router(pedimento_dates_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_dates"])
|
||||
router.include_router(pedimento_decrementables_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_decrementables"])
|
||||
router.include_router(pedimento_incrementables_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_incrementables"])
|
||||
router.include_router(pedimento_indexes_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_indexes"])
|
||||
router.include_router(pedimento_payments_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_payments"])
|
||||
router.include_router(pedimento_rectification_destination_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_rectification_destination"])
|
||||
router.include_router(pedimento_rectification_origin_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_rectification_origin"])
|
||||
router.include_router(pedimento_transport_means_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_transport_means"])
|
||||
router.include_router(pedimento_validation_router, prefix="/pedimentos", tags=["a76 / pedimentos / pedimento_validation"])
|
||||
router.include_router(pedimentos_router, prefix="/pedimentos", tags=["a76 / pedimentos"])
|
||||
router.include_router(
|
||||
pedimento_config_additional_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_additional"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_config_calculations_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_calculations"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_config_parameters_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_parameters"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_config_surcharges_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_surcharges"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_config_update_rectification_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_update_rectification"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_config_updates_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_config_updates"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_customs_offices_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_customs_offices"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_dates_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_dates"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_decrementables_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_decrementables"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_incrementables_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_incrementables"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_indexes_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_indexes"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_payments_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_payments"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_rectification_destination_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_rectification_destination"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_rectification_origin_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_rectification_origin"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_transport_means_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_transport_means"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimento_validation_router,
|
||||
prefix="/pedimentos",
|
||||
tags=["a76 / pedimentos / pedimento_validation"],
|
||||
)
|
||||
router.include_router(
|
||||
pedimentos_router, prefix="/pedimentos", tags=["a76 / pedimentos"]
|
||||
)
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoConfigAdditional CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_additional import PedimentoConfigAdditionalService
|
||||
from ..dtos.pedimento_config_additional import (
|
||||
PedimentoConfigAdditionalCreate,
|
||||
PedimentoConfigAdditionalUpdate,
|
||||
PedimentoConfigAdditionalResponse
|
||||
PedimentoConfigAdditionalResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_config_additional(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config additional by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config additional not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_config_additional(
|
||||
data: PedimentoConfigAdditionalCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config additional"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id and company_id match
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
config = PedimentoConfigAdditionalService.create(db, data, tenant_id, company_id)
|
||||
return config
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_config_additional(
|
||||
data: PedimentoConfigAdditionalUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config additional"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigAdditionalService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigAdditionalService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config additional not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +82,15 @@ async def delete_config_additional(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config additional"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoConfigAdditionalService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigAdditionalService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config additional not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoConfigCalculations CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_calculations import PedimentoConfigCalculationsService
|
||||
from ..dtos.pedimento_config_calculations import (
|
||||
PedimentoConfigCalculationsCreate,
|
||||
PedimentoConfigCalculationsUpdate,
|
||||
PedimentoConfigCalculationsResponse
|
||||
PedimentoConfigCalculationsResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_config_calculations(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config calculations by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config calculations not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_config_calculations(
|
||||
data: PedimentoConfigCalculationsCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config calculations"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
config = PedimentoConfigCalculationsService.create(db, data, tenant_id, company_id)
|
||||
return config
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_config_calculations(
|
||||
data: PedimentoConfigCalculationsUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config calculations"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigCalculationsService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigCalculationsService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config calculations not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +82,13 @@ async def delete_config_calculations(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config calculations"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigCalculationsService.delete(db, pedimento_id, company_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config calculations not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoConfigParameters CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_parameters import PedimentoConfigParametersService
|
||||
from ..dtos.pedimento_config_parameters import (
|
||||
PedimentoConfigParametersCreate,
|
||||
PedimentoConfigParametersUpdate,
|
||||
PedimentoConfigParametersResponse
|
||||
PedimentoConfigParametersResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_config_parameters(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config parameters by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config parameters not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_config_parameters(
|
||||
data: PedimentoConfigParametersCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config parameters"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
config = PedimentoConfigParametersService.create(db, data, tenant_id, company_id)
|
||||
return config
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_config_parameters(
|
||||
data: PedimentoConfigParametersUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config parameters"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigParametersService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigParametersService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config parameters not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +82,15 @@ async def delete_config_parameters(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config parameters"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoConfigParametersService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigParametersService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config parameters not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoConfigSurcharges CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_surcharges import PedimentoConfigSurchargesService
|
||||
from ..dtos.pedimento_config_surcharges import (
|
||||
PedimentoConfigSurchargesCreate,
|
||||
PedimentoConfigSurchargesUpdate,
|
||||
PedimentoConfigSurchargesResponse
|
||||
PedimentoConfigSurchargesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_config_surcharges(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config surcharges by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config surcharges not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_config_surcharges(
|
||||
data: PedimentoConfigSurchargesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config surcharges"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
config = PedimentoConfigSurchargesService.create(db, data, tenant_id, company_id)
|
||||
return config
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_config_surcharges(
|
||||
data: PedimentoConfigSurchargesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config surcharges"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigSurchargesService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigSurchargesService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config surcharges not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +82,15 @@ async def delete_config_surcharges(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config surcharges"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoConfigSurchargesService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigSurchargesService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config surcharges not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
"""
|
||||
Routes for PedimentoConfigUpdateRectification CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_update_rectification import PedimentoConfigUpdateRectificationService
|
||||
from ..services.pedimento_config_update_rectification import (
|
||||
PedimentoConfigUpdateRectificationService,
|
||||
)
|
||||
from ..dtos.pedimento_config_update_rectification import (
|
||||
PedimentoConfigUpdateRectificationCreate,
|
||||
PedimentoConfigUpdateRectificationUpdate,
|
||||
PedimentoConfigUpdateRectificationResponse
|
||||
PedimentoConfigUpdateRectificationResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,32 +26,42 @@ async def get_config_update_rectification(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config update rectification by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config update rectification not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Config update rectification not found"
|
||||
)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@router.post("/", response_model=PedimentoConfigUpdateRectificationResponse, status_code=201)
|
||||
@router.post(
|
||||
"/", response_model=PedimentoConfigUpdateRectificationResponse, status_code=201
|
||||
)
|
||||
async def create_config_update_rectification(
|
||||
pedimento_id: int,
|
||||
data: PedimentoConfigUpdateRectificationCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config update rectification"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.create(db, data, tenant_id, company_id)
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return config
|
||||
|
||||
|
||||
@@ -57,14 +71,19 @@ async def update_config_update_rectification(
|
||||
data: PedimentoConfigUpdateRectificationUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config update rectification"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigUpdateRectificationService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config update rectification not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Config update rectification not found"
|
||||
)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +92,17 @@ async def delete_config_update_rectification(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config update rectification"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoConfigUpdateRectificationService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigUpdateRectificationService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config update rectification not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Config update rectification not found"
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoConfigUpdates CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_config_updates import PedimentoConfigUpdatesService
|
||||
from ..dtos.pedimento_config_updates import (
|
||||
PedimentoConfigUpdatesCreate,
|
||||
PedimentoConfigUpdatesUpdate,
|
||||
PedimentoConfigUpdatesResponse
|
||||
PedimentoConfigUpdatesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_config_updates(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get config updates by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config updates not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -38,15 +43,16 @@ async def create_config_updates(
|
||||
pedimento_id: int,
|
||||
data: PedimentoConfigUpdatesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db)
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create config updates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
config = PedimentoConfigUpdatesService.create(db, data, tenant_id, company_id)
|
||||
return config
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_config_updates(
|
||||
data: PedimentoConfigUpdatesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update config updates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
config = PedimentoConfigUpdatesService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
config = PedimentoConfigUpdatesService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail="Config updates not found")
|
||||
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@@ -73,12 +82,15 @@ async def delete_config_updates(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete config updates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoConfigUpdatesService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoConfigUpdatesService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Config updates not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"""
|
||||
Routes for PedimentoCustomsOffices CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from typing import Dict, Any, List
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
from ..services.pedimento_customs_offices import PedimentoCustomsOfficesService
|
||||
from ..dtos.pedimento_customs_offices import (
|
||||
PedimentoCustomsOfficesCreate,
|
||||
PedimentoCustomsOfficesUpdate,
|
||||
PedimentoCustomsOfficesResponse
|
||||
PedimentoCustomsOfficesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,11 +23,14 @@ async def list_customs_offices(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all customs offices for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
return offices
|
||||
|
||||
|
||||
@@ -36,14 +40,17 @@ async def get_customs_office(
|
||||
office_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific customs office by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
office = PedimentoCustomsOfficesService.get_by_id(db, office_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
office = PedimentoCustomsOfficesService.get_by_id(
|
||||
db, office_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not office:
|
||||
raise HTTPException(status_code=404, detail="Customs office not found")
|
||||
|
||||
|
||||
return office
|
||||
|
||||
|
||||
@@ -53,14 +60,15 @@ async def create_customs_office(
|
||||
data: PedimentoCustomsOfficesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new customs office"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
office = PedimentoCustomsOfficesService.create(db, data, tenant_id, company_id)
|
||||
return office
|
||||
|
||||
@@ -72,14 +80,17 @@ async def update_customs_office(
|
||||
data: PedimentoCustomsOfficesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a customs office"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
office = PedimentoCustomsOfficesService.update(db, office_id, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
office = PedimentoCustomsOfficesService.update(
|
||||
db, office_id, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not office:
|
||||
raise HTTPException(status_code=404, detail="Customs office not found")
|
||||
|
||||
|
||||
return office
|
||||
|
||||
|
||||
@@ -89,12 +100,15 @@ async def delete_customs_office(
|
||||
office_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a customs office"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoCustomsOfficesService.delete(db, office_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoCustomsOfficesService.delete(
|
||||
db, office_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Customs office not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,48 +1,55 @@
|
||||
"""
|
||||
Routes for PedimentoDates CRUD operations
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_dates import PedimentoDatesService
|
||||
from ..dtos.pedimento_dates import (
|
||||
PedimentoDatesCreate,
|
||||
PedimentoDatesUpdate,
|
||||
PedimentoDatesResponse
|
||||
PedimentoDatesResponse,
|
||||
)
|
||||
|
||||
|
||||
router = APIRouter(prefix="/{pedimento_id}/dates")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@router.get("/", response_model=PedimentoDatesResponse)
|
||||
async def get_dates(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get dates by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
dates = PedimentoDatesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
dates = PedimentoDatesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not dates:
|
||||
raise HTTPException(status_code=404, detail="Pedimento dates not found")
|
||||
|
||||
|
||||
return dates
|
||||
|
||||
|
||||
@router.post("/", response_model=PedimentoDatesResponse, status_code=201)
|
||||
async def create_dates(
|
||||
async def create_dates(
|
||||
data: PedimentoDatesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create pedimento dates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
dates = PedimentoDatesService.create(db, data, tenant_id, company_id)
|
||||
return dates
|
||||
|
||||
@@ -53,14 +60,15 @@ async def update_dates(
|
||||
data: PedimentoDatesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update pedimento dates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
dates = PedimentoDatesService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
if not dates:
|
||||
raise HTTPException(status_code=404, detail="Pedimento dates not found")
|
||||
|
||||
|
||||
return dates
|
||||
|
||||
|
||||
@@ -69,12 +77,13 @@ async def delete_dates(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete pedimento dates"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoDatesService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Pedimento dates not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoDecrementables CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from typing import Dict, Any, List
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_decrementables import PedimentoDecrementablesService
|
||||
from ..dtos.pedimento_decrementables import (
|
||||
PedimentoDecrementablesCreate,
|
||||
PedimentoDecrementablesUpdate,
|
||||
PedimentoDecrementablesResponse
|
||||
PedimentoDecrementablesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -23,11 +24,14 @@ async def list_decrementables(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all decrementables for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
return decrementables
|
||||
|
||||
|
||||
@@ -37,14 +41,17 @@ async def get_decrementable(
|
||||
decrementable_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific decrementable by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.get_by_id(db, decrementable_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.get_by_id(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not decrementable:
|
||||
raise HTTPException(status_code=404, detail="Decrementable not found")
|
||||
|
||||
|
||||
return decrementable
|
||||
|
||||
|
||||
@@ -54,15 +61,18 @@ async def create_decrementable(
|
||||
data: PedimentoDecrementablesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new decrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
decrementable = PedimentoDecrementablesService.create(db, data, tenant_id, company_id)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return decrementable
|
||||
|
||||
|
||||
@@ -73,14 +83,17 @@ async def update_decrementable(
|
||||
data: PedimentoDecrementablesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a decrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.update(db, decrementable_id, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.update(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not decrementable:
|
||||
raise HTTPException(status_code=404, detail="Decrementable not found")
|
||||
|
||||
|
||||
return decrementable
|
||||
|
||||
|
||||
@@ -90,12 +103,15 @@ async def delete_decrementable(
|
||||
decrementable_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a decrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoDecrementablesService.delete(db, decrementable_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoDecrementablesService.delete(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Decrementable not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoIncrementables CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from typing import Dict, Any, List
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_incrementables import PedimentoIncrementablesService
|
||||
from ..dtos.pedimento_incrementables import (
|
||||
PedimentoIncrementablesCreate,
|
||||
PedimentoIncrementablesUpdate,
|
||||
PedimentoIncrementablesResponse
|
||||
PedimentoIncrementablesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -23,11 +24,14 @@ async def list_incrementables(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all incrementables for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
return incrementables
|
||||
|
||||
|
||||
@@ -37,14 +41,17 @@ async def get_incrementable(
|
||||
incrementable_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific incrementable by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.get_by_id(db, incrementable_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.get_by_id(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not incrementable:
|
||||
raise HTTPException(status_code=404, detail="Incrementable not found")
|
||||
|
||||
|
||||
return incrementable
|
||||
|
||||
|
||||
@@ -54,15 +61,18 @@ async def create_incrementable(
|
||||
data: PedimentoIncrementablesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new incrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
incrementable = PedimentoIncrementablesService.create(db, data, tenant_id, company_id)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return incrementable
|
||||
|
||||
|
||||
@@ -73,14 +83,17 @@ async def update_incrementable(
|
||||
data: PedimentoIncrementablesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update an incrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.update(db, incrementable_id, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.update(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not incrementable:
|
||||
raise HTTPException(status_code=404, detail="Incrementable not found")
|
||||
|
||||
|
||||
return incrementable
|
||||
|
||||
|
||||
@@ -90,12 +103,15 @@ async def delete_incrementable(
|
||||
incrementable_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete an incrementable"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoIncrementablesService.delete(db, incrementable_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoIncrementablesService.delete(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Incrementable not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoIndexes CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_indexes import PedimentoIndexesService
|
||||
from ..dtos.pedimento_indexes import (
|
||||
PedimentoIndexesCreate,
|
||||
PedimentoIndexesUpdate,
|
||||
PedimentoIndexesResponse
|
||||
PedimentoIndexesResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_indexes(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get indexes by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not indexes:
|
||||
raise HTTPException(status_code=404, detail="Pedimento indexes not found")
|
||||
|
||||
|
||||
return indexes
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_indexes(
|
||||
data: PedimentoIndexesCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create pedimento indexes"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
indexes = PedimentoIndexesService.create(db, data, tenant_id, company_id)
|
||||
return indexes
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_indexes(
|
||||
data: PedimentoIndexesUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update pedimento indexes"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
indexes = PedimentoIndexesService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
indexes = PedimentoIndexesService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not indexes:
|
||||
raise HTTPException(status_code=404, detail="Pedimento indexes not found")
|
||||
|
||||
|
||||
return indexes
|
||||
|
||||
|
||||
@@ -73,12 +82,13 @@ async def delete_indexes(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete pedimento indexes"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoIndexesService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Pedimento indexes not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoPayments CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from typing import Dict, Any, List
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_payments import PedimentoPaymentsService
|
||||
from ..dtos.pedimento_payments import (
|
||||
PedimentoPaymentsCreate,
|
||||
PedimentoPaymentsUpdate,
|
||||
PedimentoPaymentsResponse
|
||||
PedimentoPaymentsResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -23,11 +24,14 @@ async def list_payments(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all payments for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
return payments
|
||||
|
||||
|
||||
@@ -37,14 +41,17 @@ async def get_payment(
|
||||
payment_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific payment by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
payment = PedimentoPaymentsService.get_by_id(db, payment_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
payment = PedimentoPaymentsService.get_by_id(
|
||||
db, payment_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not payment:
|
||||
raise HTTPException(status_code=404, detail="Payment not found")
|
||||
|
||||
|
||||
return payment
|
||||
|
||||
|
||||
@@ -54,14 +61,15 @@ async def create_payment(
|
||||
data: PedimentoPaymentsCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new payment"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
payment = PedimentoPaymentsService.create(db, data, tenant_id, company_id)
|
||||
return payment
|
||||
|
||||
@@ -73,14 +81,17 @@ async def update_payment(
|
||||
data: PedimentoPaymentsUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a payment"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
payment = PedimentoPaymentsService.update(db, payment_id, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
payment = PedimentoPaymentsService.update(
|
||||
db, payment_id, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not payment:
|
||||
raise HTTPException(status_code=404, detail="Payment not found")
|
||||
|
||||
|
||||
return payment
|
||||
|
||||
|
||||
@@ -90,12 +101,15 @@ async def delete_payment(
|
||||
payment_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a payment"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoPaymentsService.delete(db, payment_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoPaymentsService.delete(
|
||||
db, payment_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Payment not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
"""
|
||||
Routes for PedimentoRectificationDestination CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_rectification_destination import PedimentoRectificationDestinationService
|
||||
from ..services.pedimento_rectification_destination import (
|
||||
PedimentoRectificationDestinationService,
|
||||
)
|
||||
from ..dtos.pedimento_rectification_destination import (
|
||||
PedimentoRectificationDestinationCreate,
|
||||
PedimentoRectificationDestinationUpdate,
|
||||
PedimentoRectificationDestinationResponse
|
||||
PedimentoRectificationDestinationResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,32 +26,42 @@ async def get_rectification_destination(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get rectification destination by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not rectification:
|
||||
raise HTTPException(status_code=404, detail="Rectification destination not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Rectification destination not found"
|
||||
)
|
||||
|
||||
return rectification
|
||||
|
||||
|
||||
@router.post("/", response_model=PedimentoRectificationDestinationResponse, status_code=201)
|
||||
@router.post(
|
||||
"/", response_model=PedimentoRectificationDestinationResponse, status_code=201
|
||||
)
|
||||
async def create_rectification_destination(
|
||||
pedimento_id: int,
|
||||
data: PedimentoRectificationDestinationCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create rectification destination"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.create(db, data, tenant_id, company_id)
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return rectification
|
||||
|
||||
|
||||
@@ -57,14 +71,19 @@ async def update_rectification_destination(
|
||||
data: PedimentoRectificationDestinationUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update rectification destination"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
rectification = PedimentoRectificationDestinationService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not rectification:
|
||||
raise HTTPException(status_code=404, detail="Rectification destination not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Rectification destination not found"
|
||||
)
|
||||
|
||||
return rectification
|
||||
|
||||
|
||||
@@ -73,12 +92,17 @@ async def delete_rectification_destination(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete rectification destination"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoRectificationDestinationService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoRectificationDestinationService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Rectification destination not found")
|
||||
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Rectification destination not found"
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
"""
|
||||
Routes for PedimentoRectificationOrigin CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_rectification_origin import PedimentoRectificationOriginService
|
||||
from ..services.pedimento_rectification_origin import (
|
||||
PedimentoRectificationOriginService,
|
||||
)
|
||||
from ..dtos.pedimento_rectification_origin import (
|
||||
PedimentoRectificationOriginCreate,
|
||||
PedimentoRectificationOriginUpdate,
|
||||
PedimentoRectificationOriginResponse
|
||||
PedimentoRectificationOriginResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +26,17 @@ async def get_rectification_origin(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get rectification origin by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not rectification:
|
||||
raise HTTPException(status_code=404, detail="Rectification origin not found")
|
||||
|
||||
|
||||
return rectification
|
||||
|
||||
|
||||
@@ -39,15 +46,18 @@ async def create_rectification_origin(
|
||||
data: PedimentoRectificationOriginCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create rectification origin"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
rectification = PedimentoRectificationOriginService.create(db, data, tenant_id, company_id)
|
||||
|
||||
rectification = PedimentoRectificationOriginService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return rectification
|
||||
|
||||
|
||||
@@ -57,14 +67,17 @@ async def update_rectification_origin(
|
||||
data: PedimentoRectificationOriginUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update rectification origin"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
rectification = PedimentoRectificationOriginService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
rectification = PedimentoRectificationOriginService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not rectification:
|
||||
raise HTTPException(status_code=404, detail="Rectification origin not found")
|
||||
|
||||
|
||||
return rectification
|
||||
|
||||
|
||||
@@ -73,12 +86,15 @@ async def delete_rectification_origin(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete rectification origin"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoRectificationOriginService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoRectificationOriginService.delete(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Rectification origin not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoTransportMeans CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from typing import Dict, Any, List
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_transport_means import PedimentoTransportMeansService
|
||||
from ..dtos.pedimento_transport_means import (
|
||||
PedimentoTransportMeansCreate,
|
||||
PedimentoTransportMeansUpdate,
|
||||
PedimentoTransportMeansResponse
|
||||
PedimentoTransportMeansResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -23,11 +24,14 @@ async def list_transport_means(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all transport means for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
transport_means = PedimentoTransportMeansService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
transport_means = PedimentoTransportMeansService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
return transport_means
|
||||
|
||||
|
||||
@@ -37,14 +41,17 @@ async def get_transport_mean(
|
||||
transport_mean_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific transport mean by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.get_by_id(db, transport_mean_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.get_by_id(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not transport_mean:
|
||||
raise HTTPException(status_code=404, detail="Transport mean not found")
|
||||
|
||||
|
||||
return transport_mean
|
||||
|
||||
|
||||
@@ -54,15 +61,18 @@ async def create_transport_mean(
|
||||
data: PedimentoTransportMeansCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new transport mean"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.create(db, data, tenant_id, company_id)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.create(
|
||||
db, data, tenant_id, company_id
|
||||
)
|
||||
return transport_mean
|
||||
|
||||
|
||||
@@ -73,14 +83,17 @@ async def update_transport_mean(
|
||||
data: PedimentoTransportMeansUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a transport mean"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.update(db, transport_mean_id, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.update(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not transport_mean:
|
||||
raise HTTPException(status_code=404, detail="Transport mean not found")
|
||||
|
||||
|
||||
return transport_mean
|
||||
|
||||
|
||||
@@ -90,12 +103,15 @@ async def delete_transport_mean(
|
||||
transport_mean_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a transport mean"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
success = PedimentoTransportMeansService.delete(db, transport_mean_id, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoTransportMeansService.delete(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Transport mean not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
"""
|
||||
Routes for PedimentoValidation CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimento_validation import PedimentoValidationService
|
||||
from ..dtos.pedimento_validation import (
|
||||
PedimentoValidationCreate,
|
||||
PedimentoValidationUpdate,
|
||||
PedimentoValidationResponse
|
||||
PedimentoValidationResponse,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,14 +24,17 @@ async def get_validation(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get validation by pedimento ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not validation:
|
||||
raise HTTPException(status_code=404, detail="Pedimento validation not found")
|
||||
|
||||
|
||||
return validation
|
||||
|
||||
|
||||
@@ -39,14 +44,15 @@ async def create_validation(
|
||||
data: PedimentoValidationCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create pedimento validation"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
raise HTTPException(status_code=400, detail="Pedimento ID mismatch")
|
||||
|
||||
|
||||
validation = PedimentoValidationService.create(db, data, tenant_id, company_id)
|
||||
return validation
|
||||
|
||||
@@ -57,14 +63,17 @@ async def update_validation(
|
||||
data: PedimentoValidationUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update pedimento validation"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
validation = PedimentoValidationService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
validation = PedimentoValidationService.update(
|
||||
db, pedimento_id, tenant_id, company_id, data
|
||||
)
|
||||
if not validation:
|
||||
raise HTTPException(status_code=404, detail="Pedimento validation not found")
|
||||
|
||||
|
||||
return validation
|
||||
|
||||
|
||||
@@ -73,12 +82,13 @@ async def delete_validation(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete pedimento validation"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentoValidationService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Pedimento validation not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"""
|
||||
Routes for Pedimentos CRUD operations
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import Dict, Any, Optional
|
||||
from core.database import get_core_db
|
||||
from core.security import validate_access_to_resource
|
||||
from core.security import validate_access_to_resource, get_current_user
|
||||
|
||||
from ..services.pedimentos import PedimentosService
|
||||
from ..dtos.pedimentos import PedimentosCreate, PedimentosUpdate, PedimentosResponse
|
||||
@@ -23,10 +24,11 @@ async def list_pedimentos(
|
||||
client_id: Optional[int] = Query(None, description="Filter by client ID"),
|
||||
year: Optional[str] = Query(None, description="Filter by year"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all pedimentos with pagination and filters"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
filters = {}
|
||||
if status:
|
||||
filters["status"] = status
|
||||
@@ -34,15 +36,17 @@ async def list_pedimentos(
|
||||
filters["client_id"] = client_id
|
||||
if year:
|
||||
filters["year"] = year
|
||||
|
||||
|
||||
skip = (page - 1) * page_size
|
||||
items, total = PedimentosService.get_all(db, tenant_id, company_id, skip, page_size, filters)
|
||||
|
||||
items, total = PedimentosService.get_all(
|
||||
db, tenant_id, company_id, skip, page_size, filters
|
||||
)
|
||||
|
||||
return {
|
||||
"items": [PedimentosResponse.model_validate(item) for item in items],
|
||||
"total": total,
|
||||
"page": page,
|
||||
"page_size": page_size
|
||||
"page_size": page_size,
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +55,15 @@ async def get_pedimento(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a pedimento by ID"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
pedimento = PedimentosService.get_by_id(db, pedimento_id, tenant_id, company_id)
|
||||
if not pedimento:
|
||||
raise HTTPException(status_code=404, detail="Pedimento not found")
|
||||
|
||||
|
||||
return pedimento
|
||||
|
||||
|
||||
@@ -67,10 +72,11 @@ async def create_pedimento(
|
||||
data: PedimentosCreate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
pedimento = PedimentosService.create(db, data, tenant_id, company_id)
|
||||
return pedimento
|
||||
|
||||
@@ -81,14 +87,15 @@ async def update_pedimento(
|
||||
data: PedimentosUpdate,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
pedimento = PedimentosService.update(db, pedimento_id, tenant_id, company_id, data)
|
||||
if not pedimento:
|
||||
raise HTTPException(status_code=404, detail="Pedimento not found")
|
||||
|
||||
|
||||
return pedimento
|
||||
|
||||
|
||||
@@ -97,12 +104,13 @@ async def delete_pedimento(
|
||||
pedimento_id: int,
|
||||
company_id: int = Query(..., description="Company ID"),
|
||||
db: Session = Depends(get_core_db),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a pedimento"""
|
||||
tenant_id = validate_access_to_resource(company_id)
|
||||
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
|
||||
success = PedimentosService.delete(db, pedimento_id, tenant_id, company_id)
|
||||
if not success:
|
||||
raise HTTPException(status_code=404, detail="Pedimento not found")
|
||||
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,32 +1,47 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigAdditional CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_additional import PedimentoConfigAdditional
|
||||
from ..dtos.pedimento_config_additional import PedimentoConfigAdditionalCreate, PedimentoConfigAdditionalUpdate
|
||||
from ..dtos.pedimento_config_additional import (
|
||||
PedimentoConfigAdditionalCreate,
|
||||
PedimentoConfigAdditionalUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigAdditionalService:
|
||||
"""Service class for PedimentoConfigAdditional business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int, company_id: int) -> Optional[PedimentoConfigAdditional]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int
|
||||
) -> Optional[PedimentoConfigAdditional]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigAdditional).filter(
|
||||
PedimentoConfigAdditional.pedimento_id == pedimento_id,
|
||||
PedimentoConfigAdditional.tenant_id == tenant_id,
|
||||
PedimentoConfigAdditional.company_id == company_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigAdditional)
|
||||
.filter(
|
||||
PedimentoConfigAdditional.pedimento_id == pedimento_id,
|
||||
PedimentoConfigAdditional.tenant_id == tenant_id,
|
||||
PedimentoConfigAdditional.company_id == company_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigAdditionalCreate, tenant_id: int, company_id: int) -> PedimentoConfigAdditional:
|
||||
def create(
|
||||
db: Session,
|
||||
config_data: PedimentoConfigAdditionalCreate,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
) -> PedimentoConfigAdditional:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigAdditional(**config_data.model_dump())
|
||||
config.tenant_id = tenant_id
|
||||
config.company_id = company_id
|
||||
|
||||
|
||||
db.add(config)
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
@@ -38,17 +53,19 @@ class PedimentoConfigAdditionalService:
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
config_data: PedimentoConfigAdditionalUpdate
|
||||
config_data: PedimentoConfigAdditionalUpdate,
|
||||
) -> Optional[PedimentoConfigAdditional]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -56,10 +73,12 @@ class PedimentoConfigAdditionalService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int, company_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
config = PedimentoConfigAdditionalService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,32 +1,47 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigCalculations CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_calculations import PedimentoConfigCalculations
|
||||
from ..dtos.pedimento_config_calculations import PedimentoConfigCalculationsCreate, PedimentoConfigCalculationsUpdate
|
||||
from ..dtos.pedimento_config_calculations import (
|
||||
PedimentoConfigCalculationsCreate,
|
||||
PedimentoConfigCalculationsUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigCalculationsService:
|
||||
"""Service class for PedimentoConfigCalculations business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int, company_id: int) -> Optional[PedimentoConfigCalculations]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int, company_id: int
|
||||
) -> Optional[PedimentoConfigCalculations]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigCalculations).filter(
|
||||
PedimentoConfigCalculations.pedimento_id == pedimento_id,
|
||||
PedimentoConfigCalculations.tenant_id == tenant_id,
|
||||
PedimentoConfigCalculations.company_id == company_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigCalculations)
|
||||
.filter(
|
||||
PedimentoConfigCalculations.pedimento_id == pedimento_id,
|
||||
PedimentoConfigCalculations.tenant_id == tenant_id,
|
||||
PedimentoConfigCalculations.company_id == company_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigCalculationsCreate, tenant_id: int, company_id: int) -> PedimentoConfigCalculations:
|
||||
def create(
|
||||
db: Session,
|
||||
config_data: PedimentoConfigCalculationsCreate,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
) -> PedimentoConfigCalculations:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigCalculations(**config_data.model_dump())
|
||||
config.tenant_id = tenant_id
|
||||
config.company_id = company_id
|
||||
|
||||
|
||||
db.add(config)
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
@@ -38,17 +53,19 @@ class PedimentoConfigCalculationsService:
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
config_data: PedimentoConfigCalculationsUpdate
|
||||
config_data: PedimentoConfigCalculationsUpdate,
|
||||
) -> Optional[PedimentoConfigCalculations]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -56,10 +73,12 @@ class PedimentoConfigCalculationsService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int, company_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(db, pedimento_id, tenant_id, company_id)
|
||||
config = PedimentoConfigCalculationsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigParameters CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_parameters import PedimentoConfigParameters
|
||||
from ..dtos.pedimento_config_parameters import PedimentoConfigParametersCreate, PedimentoConfigParametersUpdate
|
||||
from ..dtos.pedimento_config_parameters import (
|
||||
PedimentoConfigParametersCreate,
|
||||
PedimentoConfigParametersUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigParametersService:
|
||||
"""Service class for PedimentoConfigParameters business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoConfigParameters]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoConfigParameters]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigParameters).filter(
|
||||
PedimentoConfigParameters.pedimento_id == pedimento_id,
|
||||
PedimentoConfigParameters.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigParameters)
|
||||
.filter(
|
||||
PedimentoConfigParameters.pedimento_id == pedimento_id,
|
||||
PedimentoConfigParameters.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigParametersCreate) -> PedimentoConfigParameters:
|
||||
def create(
|
||||
db: Session, config_data: PedimentoConfigParametersCreate
|
||||
) -> PedimentoConfigParameters:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigParameters(**config_data.model_dump())
|
||||
db.add(config)
|
||||
@@ -33,17 +45,19 @@ class PedimentoConfigParametersService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
config_data: PedimentoConfigParametersUpdate
|
||||
config_data: PedimentoConfigParametersUpdate,
|
||||
) -> Optional[PedimentoConfigParameters]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -51,10 +65,12 @@ class PedimentoConfigParametersService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigParametersService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigSurcharges CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_surcharges import PedimentoConfigSurcharges
|
||||
from ..dtos.pedimento_config_surcharges import PedimentoConfigSurchargesCreate, PedimentoConfigSurchargesUpdate
|
||||
from ..dtos.pedimento_config_surcharges import (
|
||||
PedimentoConfigSurchargesCreate,
|
||||
PedimentoConfigSurchargesUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigSurchargesService:
|
||||
"""Service class for PedimentoConfigSurcharges business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoConfigSurcharges]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoConfigSurcharges]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigSurcharges).filter(
|
||||
PedimentoConfigSurcharges.pedimento_id == pedimento_id,
|
||||
PedimentoConfigSurcharges.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigSurcharges)
|
||||
.filter(
|
||||
PedimentoConfigSurcharges.pedimento_id == pedimento_id,
|
||||
PedimentoConfigSurcharges.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigSurchargesCreate) -> PedimentoConfigSurcharges:
|
||||
def create(
|
||||
db: Session, config_data: PedimentoConfigSurchargesCreate
|
||||
) -> PedimentoConfigSurcharges:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigSurcharges(**config_data.model_dump())
|
||||
db.add(config)
|
||||
@@ -33,17 +45,19 @@ class PedimentoConfigSurchargesService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
config_data: PedimentoConfigSurchargesUpdate
|
||||
config_data: PedimentoConfigSurchargesUpdate,
|
||||
) -> Optional[PedimentoConfigSurcharges]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -51,10 +65,12 @@ class PedimentoConfigSurchargesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigSurchargesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigUpdateRectification CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_update_rectification import PedimentoConfigUpdateRectification
|
||||
from ..dtos.pedimento_config_update_rectification import PedimentoConfigUpdateRectificationCreate, PedimentoConfigUpdateRectificationUpdate
|
||||
from ..models.pedimento_config_update_rectification import (
|
||||
PedimentoConfigUpdateRectification,
|
||||
)
|
||||
from ..dtos.pedimento_config_update_rectification import (
|
||||
PedimentoConfigUpdateRectificationCreate,
|
||||
PedimentoConfigUpdateRectificationUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigUpdateRectificationService:
|
||||
"""Service class for PedimentoConfigUpdateRectification business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoConfigUpdateRectification]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoConfigUpdateRectification]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigUpdateRectification).filter(
|
||||
PedimentoConfigUpdateRectification.pedimento_id == pedimento_id,
|
||||
PedimentoConfigUpdateRectification.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigUpdateRectification)
|
||||
.filter(
|
||||
PedimentoConfigUpdateRectification.pedimento_id == pedimento_id,
|
||||
PedimentoConfigUpdateRectification.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigUpdateRectificationCreate) -> PedimentoConfigUpdateRectification:
|
||||
def create(
|
||||
db: Session, config_data: PedimentoConfigUpdateRectificationCreate
|
||||
) -> PedimentoConfigUpdateRectification:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigUpdateRectification(**config_data.model_dump())
|
||||
db.add(config)
|
||||
@@ -33,17 +47,19 @@ class PedimentoConfigUpdateRectificationService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
config_data: PedimentoConfigUpdateRectificationUpdate
|
||||
config_data: PedimentoConfigUpdateRectificationUpdate,
|
||||
) -> Optional[PedimentoConfigUpdateRectification]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -51,10 +67,12 @@ class PedimentoConfigUpdateRectificationService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigUpdateRectificationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoConfigUpdates CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_config_updates import PedimentoConfigUpdates
|
||||
from ..dtos.pedimento_config_updates import PedimentoConfigUpdatesCreate, PedimentoConfigUpdatesUpdate
|
||||
from ..dtos.pedimento_config_updates import (
|
||||
PedimentoConfigUpdatesCreate,
|
||||
PedimentoConfigUpdatesUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoConfigUpdatesService:
|
||||
"""Service class for PedimentoConfigUpdates business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoConfigUpdates]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoConfigUpdates]:
|
||||
"""Get config by pedimento ID"""
|
||||
return db.query(PedimentoConfigUpdates).filter(
|
||||
PedimentoConfigUpdates.pedimento_id == pedimento_id,
|
||||
PedimentoConfigUpdates.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoConfigUpdates)
|
||||
.filter(
|
||||
PedimentoConfigUpdates.pedimento_id == pedimento_id,
|
||||
PedimentoConfigUpdates.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, config_data: PedimentoConfigUpdatesCreate) -> PedimentoConfigUpdates:
|
||||
def create(
|
||||
db: Session, config_data: PedimentoConfigUpdatesCreate
|
||||
) -> PedimentoConfigUpdates:
|
||||
"""Create a new config"""
|
||||
config = PedimentoConfigUpdates(**config_data.model_dump())
|
||||
db.add(config)
|
||||
@@ -33,17 +45,19 @@ class PedimentoConfigUpdatesService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
config_data: PedimentoConfigUpdatesUpdate
|
||||
config_data: PedimentoConfigUpdatesUpdate,
|
||||
) -> Optional[PedimentoConfigUpdates]:
|
||||
"""Update config"""
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return None
|
||||
|
||||
|
||||
update_data = config_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(config, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(config)
|
||||
return config
|
||||
@@ -51,10 +65,12 @@ class PedimentoConfigUpdatesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete config"""
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
config = PedimentoConfigUpdatesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not config:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(config)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoCustomsOffices CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_customs_offices import PedimentoCustomsOffices
|
||||
from ..dtos.pedimento_customs_offices import PedimentoCustomsOfficesCreate, PedimentoCustomsOfficesUpdate
|
||||
from ..dtos.pedimento_customs_offices import (
|
||||
PedimentoCustomsOfficesCreate,
|
||||
PedimentoCustomsOfficesUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoCustomsOfficesService:
|
||||
"""Service class for PedimentoCustomsOffices business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoCustomsOffices]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoCustomsOffices]:
|
||||
"""Get customs offices by pedimento ID"""
|
||||
return db.query(PedimentoCustomsOffices).filter(
|
||||
PedimentoCustomsOffices.pedimento_id == pedimento_id,
|
||||
PedimentoCustomsOffices.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoCustomsOffices)
|
||||
.filter(
|
||||
PedimentoCustomsOffices.pedimento_id == pedimento_id,
|
||||
PedimentoCustomsOffices.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoCustomsOfficesCreate) -> PedimentoCustomsOffices:
|
||||
def create(
|
||||
db: Session, data: PedimentoCustomsOfficesCreate
|
||||
) -> PedimentoCustomsOffices:
|
||||
"""Create new customs offices"""
|
||||
offices = PedimentoCustomsOffices(**data.model_dump())
|
||||
db.add(offices)
|
||||
@@ -33,17 +45,19 @@ class PedimentoCustomsOfficesService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoCustomsOfficesUpdate
|
||||
data: PedimentoCustomsOfficesUpdate,
|
||||
) -> Optional[PedimentoCustomsOffices]:
|
||||
"""Update customs offices"""
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not offices:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(offices, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(offices)
|
||||
return offices
|
||||
@@ -51,10 +65,12 @@ class PedimentoCustomsOfficesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete customs offices"""
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not offices:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(offices)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Service layer for PedimentoDates CRUD operations
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -10,16 +11,23 @@ from ..dtos.pedimento_dates import PedimentoDatesCreate, PedimentoDatesUpdate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PedimentoDatesService:
|
||||
"""Service class for PedimentoDates business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoDates]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoDates]:
|
||||
"""Get dates by pedimento ID"""
|
||||
return db.query(PedimentoDates).filter(
|
||||
PedimentoDates.pedimento_id == pedimento_id,
|
||||
PedimentoDates.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoDates)
|
||||
.filter(
|
||||
PedimentoDates.pedimento_id == pedimento_id,
|
||||
PedimentoDates.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoDatesCreate) -> PedimentoDates:
|
||||
@@ -32,20 +40,17 @@ class PedimentoDatesService:
|
||||
|
||||
@staticmethod
|
||||
def update(
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoDatesUpdate
|
||||
db: Session, pedimento_id: int, tenant_id: int, data: PedimentoDatesUpdate
|
||||
) -> Optional[PedimentoDates]:
|
||||
"""Update pedimento dates"""
|
||||
dates = PedimentoDatesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
if not dates:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(dates, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(dates)
|
||||
return dates
|
||||
@@ -56,7 +61,7 @@ class PedimentoDatesService:
|
||||
dates = PedimentoDatesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
if not dates:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(dates)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoDecrementables CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_decrementables import PedimentoDecrementables
|
||||
from ..dtos.pedimento_decrementables import PedimentoDecrementablesCreate, PedimentoDecrementablesUpdate
|
||||
from ..dtos.pedimento_decrementables import (
|
||||
PedimentoDecrementablesCreate,
|
||||
PedimentoDecrementablesUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoDecrementablesService:
|
||||
"""Service class for PedimentoDecrementables business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoDecrementables]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoDecrementables]:
|
||||
"""Get decrementables by pedimento ID"""
|
||||
return db.query(PedimentoDecrementables).filter(
|
||||
PedimentoDecrementables.pedimento_id == pedimento_id,
|
||||
PedimentoDecrementables.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoDecrementables)
|
||||
.filter(
|
||||
PedimentoDecrementables.pedimento_id == pedimento_id,
|
||||
PedimentoDecrementables.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoDecrementablesCreate) -> PedimentoDecrementables:
|
||||
def create(
|
||||
db: Session, data: PedimentoDecrementablesCreate
|
||||
) -> PedimentoDecrementables:
|
||||
"""Create new decrementables"""
|
||||
decrementables = PedimentoDecrementables(**data.model_dump())
|
||||
db.add(decrementables)
|
||||
@@ -33,17 +45,19 @@ class PedimentoDecrementablesService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoDecrementablesUpdate
|
||||
data: PedimentoDecrementablesUpdate,
|
||||
) -> Optional[PedimentoDecrementables]:
|
||||
"""Update decrementables"""
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not decrementables:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(decrementables, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(decrementables)
|
||||
return decrementables
|
||||
@@ -51,10 +65,12 @@ class PedimentoDecrementablesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete decrementables"""
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not decrementables:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(decrementables)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoIncrementables CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_incrementables import PedimentoIncrementables
|
||||
from ..dtos.pedimento_incrementables import PedimentoIncrementablesCreate, PedimentoIncrementablesUpdate
|
||||
from ..dtos.pedimento_incrementables import (
|
||||
PedimentoIncrementablesCreate,
|
||||
PedimentoIncrementablesUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoIncrementablesService:
|
||||
"""Service class for PedimentoIncrementables business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoIncrementables]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoIncrementables]:
|
||||
"""Get incrementables by pedimento ID"""
|
||||
return db.query(PedimentoIncrementables).filter(
|
||||
PedimentoIncrementables.pedimento_id == pedimento_id,
|
||||
PedimentoIncrementables.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoIncrementables)
|
||||
.filter(
|
||||
PedimentoIncrementables.pedimento_id == pedimento_id,
|
||||
PedimentoIncrementables.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoIncrementablesCreate) -> PedimentoIncrementables:
|
||||
def create(
|
||||
db: Session, data: PedimentoIncrementablesCreate
|
||||
) -> PedimentoIncrementables:
|
||||
"""Create new incrementables"""
|
||||
incrementables = PedimentoIncrementables(**data.model_dump())
|
||||
db.add(incrementables)
|
||||
@@ -33,17 +45,19 @@ class PedimentoIncrementablesService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoIncrementablesUpdate
|
||||
data: PedimentoIncrementablesUpdate,
|
||||
) -> Optional[PedimentoIncrementables]:
|
||||
"""Update incrementables"""
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not incrementables:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(incrementables, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(incrementables)
|
||||
return incrementables
|
||||
@@ -51,10 +65,12 @@ class PedimentoIncrementablesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete incrementables"""
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not incrementables:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(incrementables)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Service layer for PedimentoIndexes CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -12,12 +13,18 @@ class PedimentoIndexesService:
|
||||
"""Service class for PedimentoIndexes business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoIndexes]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoIndexes]:
|
||||
"""Get indexes by pedimento ID"""
|
||||
return db.query(PedimentoIndexes).filter(
|
||||
PedimentoIndexes.pedimento_id == pedimento_id,
|
||||
PedimentoIndexes.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoIndexes)
|
||||
.filter(
|
||||
PedimentoIndexes.pedimento_id == pedimento_id,
|
||||
PedimentoIndexes.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoIndexesCreate) -> PedimentoIndexes:
|
||||
@@ -30,20 +37,19 @@ class PedimentoIndexesService:
|
||||
|
||||
@staticmethod
|
||||
def update(
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoIndexesUpdate
|
||||
db: Session, pedimento_id: int, tenant_id: int, data: PedimentoIndexesUpdate
|
||||
) -> Optional[PedimentoIndexes]:
|
||||
"""Update indexes"""
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not indexes:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(indexes, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(indexes)
|
||||
return indexes
|
||||
@@ -51,10 +57,12 @@ class PedimentoIndexesService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete indexes"""
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
indexes = PedimentoIndexesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not indexes:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(indexes)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Service layer for PedimentoPayments CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -12,12 +13,18 @@ class PedimentoPaymentsService:
|
||||
"""Service class for PedimentoPayments business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoPayments]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoPayments]:
|
||||
"""Get payments by pedimento ID"""
|
||||
return db.query(PedimentoPayments).filter(
|
||||
PedimentoPayments.pedimento_id == pedimento_id,
|
||||
PedimentoPayments.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoPayments)
|
||||
.filter(
|
||||
PedimentoPayments.pedimento_id == pedimento_id,
|
||||
PedimentoPayments.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoPaymentsCreate) -> PedimentoPayments:
|
||||
@@ -30,20 +37,19 @@ class PedimentoPaymentsService:
|
||||
|
||||
@staticmethod
|
||||
def update(
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoPaymentsUpdate
|
||||
db: Session, pedimento_id: int, tenant_id: int, data: PedimentoPaymentsUpdate
|
||||
) -> Optional[PedimentoPayments]:
|
||||
"""Update payments"""
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not payments:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(payments, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(payments)
|
||||
return payments
|
||||
@@ -51,10 +57,12 @@ class PedimentoPaymentsService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete payments"""
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not payments:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(payments)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
"""
|
||||
Service layer for PedimentoRectificationDestination CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_rectification_destination import PedimentoRectificationDestination
|
||||
from ..dtos.pedimento_rectification_destination import PedimentoRectificationDestinationCreate, PedimentoRectificationDestinationUpdate
|
||||
from ..models.pedimento_rectification_destination import (
|
||||
PedimentoRectificationDestination,
|
||||
)
|
||||
from ..dtos.pedimento_rectification_destination import (
|
||||
PedimentoRectificationDestinationCreate,
|
||||
PedimentoRectificationDestinationUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoRectificationDestinationService:
|
||||
"""Service class for PedimentoRectificationDestination business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoRectificationDestination]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoRectificationDestination]:
|
||||
"""Get rectification destination by pedimento ID"""
|
||||
return db.query(PedimentoRectificationDestination).filter(
|
||||
PedimentoRectificationDestination.pedimento_id == pedimento_id,
|
||||
PedimentoRectificationDestination.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoRectificationDestination)
|
||||
.filter(
|
||||
PedimentoRectificationDestination.pedimento_id == pedimento_id,
|
||||
PedimentoRectificationDestination.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoRectificationDestinationCreate) -> PedimentoRectificationDestination:
|
||||
def create(
|
||||
db: Session, data: PedimentoRectificationDestinationCreate
|
||||
) -> PedimentoRectificationDestination:
|
||||
"""Create new rectification destination"""
|
||||
rectification = PedimentoRectificationDestination(**data.model_dump())
|
||||
db.add(rectification)
|
||||
@@ -33,17 +47,19 @@ class PedimentoRectificationDestinationService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoRectificationDestinationUpdate
|
||||
data: PedimentoRectificationDestinationUpdate,
|
||||
) -> Optional[PedimentoRectificationDestination]:
|
||||
"""Update rectification destination"""
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not rectification:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(rectification, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(rectification)
|
||||
return rectification
|
||||
@@ -51,10 +67,12 @@ class PedimentoRectificationDestinationService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete rectification destination"""
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
rectification = PedimentoRectificationDestinationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not rectification:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(rectification)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoRectificationOrigin CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_rectification_origin import PedimentoRectificationOrigin
|
||||
from ..dtos.pedimento_rectification_origin import PedimentoRectificationOriginCreate, PedimentoRectificationOriginUpdate
|
||||
from ..dtos.pedimento_rectification_origin import (
|
||||
PedimentoRectificationOriginCreate,
|
||||
PedimentoRectificationOriginUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoRectificationOriginService:
|
||||
"""Service class for PedimentoRectificationOrigin business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoRectificationOrigin]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoRectificationOrigin]:
|
||||
"""Get rectification origin by pedimento ID"""
|
||||
return db.query(PedimentoRectificationOrigin).filter(
|
||||
PedimentoRectificationOrigin.pedimento_id == pedimento_id,
|
||||
PedimentoRectificationOrigin.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoRectificationOrigin)
|
||||
.filter(
|
||||
PedimentoRectificationOrigin.pedimento_id == pedimento_id,
|
||||
PedimentoRectificationOrigin.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoRectificationOriginCreate) -> PedimentoRectificationOrigin:
|
||||
def create(
|
||||
db: Session, data: PedimentoRectificationOriginCreate
|
||||
) -> PedimentoRectificationOrigin:
|
||||
"""Create new rectification origin"""
|
||||
rectification = PedimentoRectificationOrigin(**data.model_dump())
|
||||
db.add(rectification)
|
||||
@@ -33,17 +45,19 @@ class PedimentoRectificationOriginService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoRectificationOriginUpdate
|
||||
data: PedimentoRectificationOriginUpdate,
|
||||
) -> Optional[PedimentoRectificationOrigin]:
|
||||
"""Update rectification origin"""
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not rectification:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(rectification, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(rectification)
|
||||
return rectification
|
||||
@@ -51,10 +65,12 @@ class PedimentoRectificationOriginService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete rectification origin"""
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
rectification = PedimentoRectificationOriginService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not rectification:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(rectification)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
"""
|
||||
Service layer for PedimentoTransportMeans CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_transport_means import PedimentoTransportMeans
|
||||
from ..dtos.pedimento_transport_means import PedimentoTransportMeansCreate, PedimentoTransportMeansUpdate
|
||||
from ..dtos.pedimento_transport_means import (
|
||||
PedimentoTransportMeansCreate,
|
||||
PedimentoTransportMeansUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoTransportMeansService:
|
||||
"""Service class for PedimentoTransportMeans business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoTransportMeans]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoTransportMeans]:
|
||||
"""Get transport means by pedimento ID"""
|
||||
return db.query(PedimentoTransportMeans).filter(
|
||||
PedimentoTransportMeans.pedimento_id == pedimento_id,
|
||||
PedimentoTransportMeans.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoTransportMeans)
|
||||
.filter(
|
||||
PedimentoTransportMeans.pedimento_id == pedimento_id,
|
||||
PedimentoTransportMeans.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoTransportMeansCreate) -> PedimentoTransportMeans:
|
||||
def create(
|
||||
db: Session, data: PedimentoTransportMeansCreate
|
||||
) -> PedimentoTransportMeans:
|
||||
"""Create new transport means"""
|
||||
transport = PedimentoTransportMeans(**data.model_dump())
|
||||
db.add(transport)
|
||||
@@ -33,17 +45,19 @@ class PedimentoTransportMeansService:
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoTransportMeansUpdate
|
||||
data: PedimentoTransportMeansUpdate,
|
||||
) -> Optional[PedimentoTransportMeans]:
|
||||
"""Update transport means"""
|
||||
transport = PedimentoTransportMeansService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
transport = PedimentoTransportMeansService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not transport:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(transport, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(transport)
|
||||
return transport
|
||||
@@ -51,10 +65,12 @@ class PedimentoTransportMeansService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete transport means"""
|
||||
transport = PedimentoTransportMeansService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
transport = PedimentoTransportMeansService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not transport:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(transport)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
"""
|
||||
Service layer for PedimentoValidation CRUD operations
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..models.pedimento_validation import PedimentoValidation
|
||||
from ..dtos.pedimento_validation import PedimentoValidationCreate, PedimentoValidationUpdate
|
||||
from ..dtos.pedimento_validation import (
|
||||
PedimentoValidationCreate,
|
||||
PedimentoValidationUpdate,
|
||||
)
|
||||
|
||||
|
||||
class PedimentoValidationService:
|
||||
"""Service class for PedimentoValidation business logic"""
|
||||
|
||||
@staticmethod
|
||||
def get_by_pedimento_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[PedimentoValidation]:
|
||||
def get_by_pedimento_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[PedimentoValidation]:
|
||||
"""Get validation by pedimento ID"""
|
||||
return db.query(PedimentoValidation).filter(
|
||||
PedimentoValidation.pedimento_id == pedimento_id,
|
||||
PedimentoValidation.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(PedimentoValidation)
|
||||
.filter(
|
||||
PedimentoValidation.pedimento_id == pedimento_id,
|
||||
PedimentoValidation.tenant_id == tenant_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, data: PedimentoValidationCreate) -> PedimentoValidation:
|
||||
@@ -30,20 +40,19 @@ class PedimentoValidationService:
|
||||
|
||||
@staticmethod
|
||||
def update(
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
data: PedimentoValidationUpdate
|
||||
db: Session, pedimento_id: int, tenant_id: int, data: PedimentoValidationUpdate
|
||||
) -> Optional[PedimentoValidation]:
|
||||
"""Update validation"""
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not validation:
|
||||
return None
|
||||
|
||||
|
||||
update_data = data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(validation, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(validation)
|
||||
return validation
|
||||
@@ -51,10 +60,12 @@ class PedimentoValidationService:
|
||||
@staticmethod
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""Delete validation"""
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(db, pedimento_id, tenant_id)
|
||||
validation = PedimentoValidationService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id
|
||||
)
|
||||
if not validation:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(validation)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Service layer for Pedimentos CRUD operations
|
||||
"""
|
||||
|
||||
from typing import List, Optional, Dict, Any
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import desc
|
||||
@@ -17,25 +18,26 @@ class PedimentosService:
|
||||
def get_all(
|
||||
db: Session,
|
||||
tenant_id: int,
|
||||
company_id: int,
|
||||
skip: int = 0,
|
||||
limit: int = 100,
|
||||
filters: Optional[Dict[str, Any]] = None
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
) -> tuple[List[Pedimentos], int]:
|
||||
"""
|
||||
Get all pedimentos for a tenant with pagination and filters
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
tenant_id: Tenant ID
|
||||
skip: Number of records to skip
|
||||
limit: Maximum number of records to return
|
||||
filters: Optional filters dict
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple of (list of pedimentos, total count)
|
||||
"""
|
||||
query = db.query(Pedimentos).filter(Pedimentos.tenant_id == tenant_id)
|
||||
|
||||
|
||||
if filters:
|
||||
if filters.get("status"):
|
||||
query = query.filter(Pedimentos.status == filters["status"])
|
||||
@@ -43,45 +45,52 @@ class PedimentosService:
|
||||
query = query.filter(Pedimentos.client_id == filters["client_id"])
|
||||
if filters.get("year"):
|
||||
query = query.filter(Pedimentos.year == filters["year"])
|
||||
|
||||
|
||||
total = query.count()
|
||||
items = query.order_by(desc(Pedimentos.created_at)).offset(skip).limit(limit).all()
|
||||
|
||||
items = (
|
||||
query.order_by(desc(Pedimentos.created_at)).offset(skip).limit(limit).all()
|
||||
)
|
||||
|
||||
return items, total
|
||||
|
||||
@staticmethod
|
||||
def get_by_id(db: Session, pedimento_id: int, tenant_id: int) -> Optional[Pedimentos]:
|
||||
def get_by_id(
|
||||
db: Session, pedimento_id: int, tenant_id: int
|
||||
) -> Optional[Pedimentos]:
|
||||
"""
|
||||
Get a pedimento by ID
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
pedimento_id: Pedimento ID
|
||||
tenant_id: Tenant ID
|
||||
|
||||
|
||||
Returns:
|
||||
Pedimento or None if not found
|
||||
"""
|
||||
return db.query(Pedimentos).filter(
|
||||
Pedimentos.id == pedimento_id,
|
||||
Pedimentos.tenant_id == tenant_id
|
||||
).first()
|
||||
return (
|
||||
db.query(Pedimentos)
|
||||
.filter(Pedimentos.id == pedimento_id, Pedimentos.tenant_id == tenant_id)
|
||||
.first()
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, pedimento_data: PedimentosCreate, tenant_id: int) -> Pedimentos:
|
||||
def create(
|
||||
db: Session, pedimento_data: PedimentosCreate, tenant_id: int
|
||||
) -> Pedimentos:
|
||||
"""
|
||||
Create a new pedimento
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
pedimento_data: Pedimento creation data
|
||||
|
||||
|
||||
Returns:
|
||||
Created pedimento
|
||||
"""
|
||||
pedimento = Pedimentos(**pedimento_data.model_dump())
|
||||
pedimento.tenant_id = 1
|
||||
|
||||
|
||||
db.add(pedimento)
|
||||
db.commit()
|
||||
db.refresh(pedimento)
|
||||
@@ -89,31 +98,28 @@ class PedimentosService:
|
||||
|
||||
@staticmethod
|
||||
def update(
|
||||
db: Session,
|
||||
pedimento_id: int,
|
||||
tenant_id: int,
|
||||
pedimento_data: PedimentosUpdate
|
||||
db: Session, pedimento_id: int, tenant_id: int, pedimento_data: PedimentosUpdate
|
||||
) -> Optional[Pedimentos]:
|
||||
"""
|
||||
Update a pedimento
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
pedimento_id: Pedimento ID
|
||||
tenant_id: Tenant ID
|
||||
pedimento_data: Updated data
|
||||
|
||||
|
||||
Returns:
|
||||
Updated pedimento or None if not found
|
||||
"""
|
||||
pedimento = PedimentosService.get_by_id(db, pedimento_id, tenant_id)
|
||||
if not pedimento:
|
||||
return None
|
||||
|
||||
|
||||
update_data = pedimento_data.model_dump(exclude_unset=True)
|
||||
for field, value in update_data.items():
|
||||
setattr(pedimento, field, value)
|
||||
|
||||
|
||||
db.commit()
|
||||
db.refresh(pedimento)
|
||||
return pedimento
|
||||
@@ -122,19 +128,19 @@ class PedimentosService:
|
||||
def delete(db: Session, pedimento_id: int, tenant_id: int) -> bool:
|
||||
"""
|
||||
Delete a pedimento
|
||||
|
||||
|
||||
Args:
|
||||
db: Database session
|
||||
pedimento_id: Pedimento ID
|
||||
tenant_id: Tenant ID
|
||||
|
||||
|
||||
Returns:
|
||||
True if deleted, False if not found
|
||||
"""
|
||||
pedimento = PedimentosService.get_by_id(db, pedimento_id, tenant_id)
|
||||
if not pedimento:
|
||||
return False
|
||||
|
||||
|
||||
db.delete(pedimento)
|
||||
db.commit()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user