chore: initial commit del proyecto SCAII_Sync_Client
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
104
registros/scaf/reg_505.py
Normal file
104
registros/scaf/reg_505.py
Normal file
@@ -0,0 +1,104 @@
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
class Generador505SCAF:
|
||||
@staticmethod
|
||||
def preparar_json(fac: Dict[str, Any], id_pedimento: int, datos_empresa: Dict[str, Any],
|
||||
datos_prov: Dict[str, Any], datos_trans: Optional[Dict[str, Any]],
|
||||
tipo_moneda_global: str, tc_global: float) -> Dict[str, Any]:
|
||||
"""
|
||||
Lógica para Registro 505 (Facturas) - SCAF.
|
||||
"""
|
||||
|
||||
clave_moneda = fac.get("ClaveMoneda", "")
|
||||
valor_mc = fac.get("ValorImpoMC", 0)
|
||||
valor_me = fac.get("ValorImpoME", 0)
|
||||
|
||||
if tipo_moneda_global == "ME":
|
||||
clave_moneda = "USD"
|
||||
valor_mc = valor_me
|
||||
elif tipo_moneda_global == "MN":
|
||||
clave_moneda = "MXP"
|
||||
valor_mc = fac.get("ValorImpoMN", 0)
|
||||
|
||||
# SCAF usa el mismo mapeo de Valor Aduana que SCAII
|
||||
met_val_raw = fac.get("MetValor", 0)
|
||||
met_val_map = {1: "VTM", 2: "VMI", 3: "VMS", 4: "VPU", 5: "VR", 6: "A78"}
|
||||
met_val_str = f"VALADU.{met_val_map.get(met_val_raw, met_val_raw)}"
|
||||
|
||||
# 3. Incoterm
|
||||
incoterm = fac.get("Incoterm", "")
|
||||
incoterm_full = incoterm if incoterm else ""
|
||||
|
||||
# 4. Otros mapeos
|
||||
obs = fac.get("ObservacionesVU", "").replace("\r", "").replace("\n", "").replace("\t", "")
|
||||
contenedores = fac.get("ContenedoresTipo", "").replace(",", "|")
|
||||
|
||||
registro = {
|
||||
"numero_factura_505": fac.get("NumFactura"),
|
||||
"fecha_facturacion_505": str(fac.get("FechaFactura"))[:10],
|
||||
"termino_facturacion_505": incoterm if incoterm else "",
|
||||
"moneda_facturacion_505": clave_moneda if clave_moneda else "",
|
||||
"valor_moneda_facturacion_505": str(float(valor_mc or 0)),
|
||||
"valor_dolares_505": str(float(valor_me or 0)),
|
||||
"codigo_proveedor_comprador_505": datos_prov.get("CLAVETRANSFER", ""),
|
||||
"e_document_505": fac.get("EDocument", ""),
|
||||
"serie_certificado_cove_505": fac.get("NumeroCertificado", ""),
|
||||
"firma_electronica_cove_505": fac.get("FirmaElectronica", ""),
|
||||
"observaciones_factura_505": obs if obs else "",
|
||||
"numero_economico_505": contenedores if contenedores else "",
|
||||
"tipo_contenedor_numero_economico_505": str(fac.get("Remesa") or ""),
|
||||
"numero_contenedor_505": contenedores if contenedores else "",
|
||||
"tipo_contenedor_505": str(fac.get("Remesa") or ""),
|
||||
"numero_remesa_505": str(fac.get("Remesa") or ""),
|
||||
"tipo_operacion_505": "",
|
||||
"certificado_origen_505": "S" if fac.get("FUNGECOMOCO") else "N",
|
||||
"numero_certificado_origen_505": "",
|
||||
"numero_exportador_confiable_505": datos_empresa.get("NUMDEEXPORTADORCONFIABLE") or "",
|
||||
"incoterm_505": incoterm_full,
|
||||
"metodo_valoracion_505": met_val_str,
|
||||
"vinculacion_505": str(datos_prov.get("VINCULACION", 0)),
|
||||
"subdivision_505": "S" if fac.get("SUBDIVISION") else "N",
|
||||
"tipo_cambio_usd_505": str(float(fac.get("TipoCambio") or 0)),
|
||||
"se_genero_en_contingencia_505": "S" if fac.get("MODOCONTINGENCIA") else "N",
|
||||
"operacion_cove_505": fac.get("NUMOPERACIONVU", ""),
|
||||
"transportista_clave_505": fac.get("TRANSPORTISTA", ""),
|
||||
"rfc_505": datos_trans.get("RFC", "") if datos_trans else "",
|
||||
"caat_505": datos_trans.get("CODIGOCAAT", "") if datos_trans else "",
|
||||
"id_pedimento": id_pedimento,
|
||||
"PaisFactura_505": datos_prov.get("PAIS", ""),
|
||||
"Bultos_cantidad_505": str(fac.get("CANTBULTOS", 0)),
|
||||
"provcomp_numregidtrib_505": " ",
|
||||
"provcomp_rfc_505": " ",
|
||||
"provcomp_curp_505": " ",
|
||||
"provcomp_nombre_505": " ",
|
||||
"provcomp_calle_505": " ",
|
||||
"provcomp_numero_exterior_505": " ",
|
||||
"provcomp_numero_interior_505": " ",
|
||||
"provcomp_colonia_505": " ",
|
||||
"provcomp_localidad_505": " ",
|
||||
"provcomp_municipio_505": " ",
|
||||
"provcomp_estado_505": " ",
|
||||
"provcomp_pais_505": " ",
|
||||
"provcomp_codigo_postal_505": " ",
|
||||
"destinatario_clave_505": " ",
|
||||
"destinatario_numregidtrib_505": " ",
|
||||
"destinatario_rfc_505": " ",
|
||||
"destinatario_curp_505": " ",
|
||||
"destinatario_nombre_505": " ",
|
||||
"destinatario_calle_505": " ",
|
||||
"destinatario_numero_exterior_505": " ",
|
||||
"destinatario_numero_interior_505": " ",
|
||||
"destinatario_colonia_505": " ",
|
||||
"destinatario_localidad_505": " ",
|
||||
"destinatario_referencia_505": " ",
|
||||
"destinatario_municipio_505": " ",
|
||||
"destinatario_estado_505": " ",
|
||||
"destinatario_pais_505": " ",
|
||||
"destinatario_codigo_postal_505": " ",
|
||||
"uuid_505": " ",
|
||||
"path_pdf_cfdi_505": " ",
|
||||
"path_xml_cfdi_505": " ",
|
||||
"estatus_cove_505": " "
|
||||
}
|
||||
|
||||
return registro
|
||||
Reference in New Issue
Block a user