feature/catalogo-pedimento
This commit is contained in:
@@ -227,7 +227,7 @@ BASE_SELECT = """
|
||||
COALESCE(icm.vucem_operation_num,'') AS "C41",
|
||||
COALESCE(cl.material_key,'') AS "C42",
|
||||
CONCAT(ped.year,'-',ped.customs_office,'-',ped.license,'-',ped.pedimento_number) AS "C43",
|
||||
'' AS "C44",
|
||||
COALESCE(ptc.payment_date_code, 'P') AS "C44",
|
||||
COALESCE(ilc.octave_fraction,'') AS "C45",
|
||||
'' AS "C47",
|
||||
COALESCE(ped.pedimento_code,'') AS "C48",
|
||||
@@ -243,6 +243,8 @@ BASE_JOINS = """
|
||||
JOIN a76.invoice_compliance_mx icm ON icm.invoice_id = ih.id
|
||||
LEFT JOIN a76.pedimentos ped ON ped.id = icm.pedimento_id
|
||||
LEFT JOIN a76.pedimento_dates pd ON pd.pedimento_id = ped.id
|
||||
LEFT JOIN a76.pedimento_transport_means ptm ON ptm.pedimento_id = ped.id
|
||||
LEFT JOIN public.pedimento_transport_catalog ptc ON ptc.code = ptm.entry_exit
|
||||
LEFT JOIN a76.classes cl ON cl.id = il.class_id
|
||||
LEFT JOIN a76.item_line_quantities ilq ON ilq.item_line_id = il.id
|
||||
LEFT JOIN a76.item_line_financials ilf ON ilf.item_line_id = il.id
|
||||
@@ -440,20 +442,21 @@ def _build_row(
|
||||
peso_usado = (cant_ret * peso_neto / cant_orig) if cant_orig != 0 else Decimal(0)
|
||||
peso_saldo = peso_neto - peso_usado
|
||||
|
||||
# TIPO DE CAMBIO — per Clarion logic:
|
||||
# Si TipoPedimentoTransporteE IN ('4','1','98E') → usar Fecha_Inicio, else Fecha_Pago
|
||||
# TIPO DE CAMBIO:
|
||||
# C44 now carries payment_date_code from pedimento_transport_catalog:
|
||||
# E => Fecha_Inicio, P => Fecha_Pago.
|
||||
# If explicitly "invoice_date", we use invoice_date (C11) instead.
|
||||
tc = Decimal(1)
|
||||
fecha_pago = row.get("C7")
|
||||
fecha_inicio = row.get("C9")
|
||||
fecha_factura= row.get("C11")
|
||||
transport_type = str(row.get("C44") or "")
|
||||
payment_date_code = str(row.get("C44") or "").upper()
|
||||
|
||||
tc_fecha_display = None
|
||||
# TIPO DE CAMBIO
|
||||
tc_fecha = None
|
||||
if use_fp:
|
||||
tc_fecha = fecha_inicio if transport_type in ("1", "4", "98E") else fecha_pago
|
||||
tc_fecha = fecha_inicio if payment_date_code == "E" else fecha_pago
|
||||
else:
|
||||
tc_fecha = fecha_factura
|
||||
|
||||
|
||||
Reference in New Issue
Block a user