chore: initial commit del proyecto SCAII_Sync_Client
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
101
registros/scaf/reg_551.py
Normal file
101
registros/scaf/reg_551.py
Normal file
@@ -0,0 +1,101 @@
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
class Generador551SCAF:
|
||||
@staticmethod
|
||||
def preparar_json(par: Dict[str, Any], id_factura: int, datos_parte: Dict[str, Any],
|
||||
um_data: Optional[Dict[str, Any]], met_val: str, cla_mon: str,
|
||||
num_remesa: int, num_partida_remesa: int) -> Dict[str, Any]:
|
||||
"""
|
||||
Lógica para Registro 551 (Partidas) - SCAF.
|
||||
Homologado con la lógica de pesos y valores de WinDev.
|
||||
"""
|
||||
|
||||
# 1. Lógica de Fracción (Regla Octava)
|
||||
frac_raw = par.get("Fraccion", "")
|
||||
frac_oct = par.get("FraccionOctava", "")
|
||||
frac_final = frac_oct if frac_oct and frac_oct.strip() else frac_raw
|
||||
|
||||
# 2. Descripciones
|
||||
desc_esp = par.get("Descripcion", " ").replace("\r", "").replace("\n", "").replace("\t", "")
|
||||
|
||||
# 3. Arancel (Mapping)
|
||||
tipo_frac = par.get("TipoFracc", "")
|
||||
arancel_map = {"TLCS": 3, "GENERAL": 0, "PROSEC": 1}
|
||||
id_arancel = str(arancel_map.get(tipo_frac, 0))
|
||||
|
||||
# 4. Unidad de Medida OMA y Comercial
|
||||
oma_final = str(par.get("ClaveOMA") or " ").strip()
|
||||
oma_raw = str(par.get("UnidadMedida", "")).strip().upper()
|
||||
if not oma_final or oma_final == "None":
|
||||
oma_final = "C62_1" if oma_raw in ["6", "PZA"] else oma_raw
|
||||
|
||||
map_um_num = {
|
||||
"PZA": "6", "PIEZA": "6", "PZ": "6", "PC": "6", "PIEZAS": "6",
|
||||
"KGS": "1", "KGM": "1", "KG": "1", "KILOS": "1", "KILO": "1",
|
||||
"LTS": "5", "L": "5", "LITROS": "5", "LITRO": "5",
|
||||
"MTR": "2", "M": "2", "METROS": "2", "METRO": "2",
|
||||
"PAR": "7", "PARES": "7",
|
||||
"CJ": "3", "CAJA": "3", "CAJAS": "3",
|
||||
"JGO": "12", "JUEGO": "12", "SET": "12", "KIT": "12"
|
||||
}
|
||||
|
||||
# Priorizar la clave que venga de la base de datos (CLAVEOMA)
|
||||
if um_data and um_data.get("CLAVEOMA"):
|
||||
um_comercial_num = str(um_data["CLAVEOMA"]).strip()
|
||||
else:
|
||||
um_comercial_num = map_um_num.get(oma_raw, oma_raw)
|
||||
|
||||
registro = {
|
||||
"id_factura": id_factura,
|
||||
"fraccion_551": str(frac_final),
|
||||
"descripcion_mercancia_551": desc_esp[:250],
|
||||
"numero_parte_551": str(par.get("NumParte") or " "),
|
||||
"valor_mercancia_551": float(par.get("ValorDolares") or 0), # SCAF suele usar Dolares para MC
|
||||
"cantidad_comercial_551": float(par.get("Cantidad") or 0),
|
||||
"unidad_medida_comercial_551": um_comercial_num,
|
||||
"cantidad_tarifa_551": float(par.get("Cantidad") or 0),
|
||||
"umt_551": " ",
|
||||
"valor_agregado_551": "0",
|
||||
"vinculacion_551": "0",
|
||||
"metodo_valoracion_551": str(met_val),
|
||||
"marca_551": str(par.get("Marca") or " ").strip() or " ",
|
||||
"modelo_551": str(par.get("Modelo") or " ").strip() or " ",
|
||||
"pais_origen_destino_551": str(par.get("PaisOrigen") or " "),
|
||||
"pais_comprador_vendedor_551": "MEX",
|
||||
"entidad_federativa_origen_551": " ",
|
||||
"entidad_federativa_destino_551": " ",
|
||||
"entidad_federativa_comprador_551": " ",
|
||||
"entidad_federativa_vendedor_551": " ",
|
||||
"identificador_arancel_aplicar_551": id_arancel,
|
||||
"clave_industria_551": str(par.get("Sector") or " "),
|
||||
"peso_bruto_551": float(par.get("PesoBruto") or 0),
|
||||
"uso_mercancia_551": " ",
|
||||
"estado_mercancia_551": " ",
|
||||
"moneda_partida_551": str(cla_mon),
|
||||
"numero_factura_551": str(par.get("NumFactura") or " "),
|
||||
"tipo_bulto_551": " ",
|
||||
"cantidad_bultos_551": float(par.get("CantBultos") or 0),
|
||||
|
||||
# --- PARIDAD WINDEV ---
|
||||
"peso_bruto_kg_551": str(float(par.get("PesoNeto") or 0)),
|
||||
"peso_neto_kg_551": str(float(par.get("ValorAduanasMN") or 0)),
|
||||
|
||||
"numero_remesa_551": str(num_remesa or " "),
|
||||
"numero_partida_remesa_551": str(num_partida_remesa),
|
||||
"cantidad_alterna_551": float(par.get("CantidadAlterna") or 0),
|
||||
"unidad_medida_alterna_551": str(par.get("UnidadAlterna", " ")),
|
||||
"descripcion_ingles_551": " ",
|
||||
"identificador_sistema_scaii_scaf_551": "SCAF",
|
||||
"vu_submodelo_551": " ",
|
||||
"vu_serie_551": " ",
|
||||
"valor_unitario_aduana_551": str(float(par.get("CostoUnitarioME") or 0)),
|
||||
"valor_dolares_551": str(float(par.get("ValorDolares") or 0)),
|
||||
"unidad_medida_oma_551": oma_final,
|
||||
"valor_dolares_cove_551": "0",
|
||||
"subdivision_fraccion_551": str(frac_final)[-2:] if len(str(frac_final)) >= 2 else "00",
|
||||
"codigo_carta_porte_551": " ",
|
||||
"nodo_551": "85858585",
|
||||
"CantidadComercialOMA_551": str(float(par.get("Cantidad") or 0))
|
||||
}
|
||||
|
||||
return registro
|
||||
Reference in New Issue
Block a user