Puliendo reporte y disenio de partes

This commit is contained in:
2026-01-15 18:03:06 -06:00
parent 5b08158d55
commit 238d728305
3 changed files with 33 additions and 12 deletions

View File

@@ -104,7 +104,8 @@ class FacturaImportacionMexService:
if broker: nombre_agente = broker.name
company = db.query(Company).filter(Company.id == header.company_id).first()
cliente_vendido = ClienteSchema(
# Datos Default (Company/Importer) - Used for fallback or Right Side (Enviado A)
cliente_default = ClienteSchema(
header="Importador / Consignatario",
nombre=getattr(company, 'name', "Empresa Local"),
direccion="DOMICILIO FISCAL",
@@ -113,6 +114,20 @@ class FacturaImportacionMexService:
programa=getattr(company, 'program', "IMMEX"), autorizacion=getattr(company, 'program_number', "")
)
# Left Side Logic (Consignatario / Sold To)
cliente_vendido = cliente_default
if compliance and compliance.sold_to_id:
# Clean header: "vendido_a" -> "VENDIDO A"
raw_header = compliance.sold_to_header or "CONSIGNATARIO"
clean_header = raw_header.replace("_", " ").upper()
# Fetch client data
cliente_vendido = self._obtener_datos_cliente(db, compliance.sold_to_id, clean_header)
# Right Side Logic (Enviado A) - Currently keeping default/company info as requested "solo la izquierda"
# If standard logic dictates this should be Shipped To, we could add that later.
cliente_enviado = cliente_default
remesa_valor = str(compliance.remesa) if (compliance and compliance.remesa) else ""
acuse_valor = str(compliance.edocument) if (compliance and compliance.edocument) else "N/A"
@@ -210,7 +225,7 @@ class FacturaImportacionMexService:
return FacturaImportacionCompleta(
cliente_proveedor=cliente_proveedor, cliente_vendido=cliente_vendido,
cliente_enviado=cliente_vendido, factura=factura_schema,
cliente_enviado=cliente_enviado, factura=factura_schema,
partidas=partidas_list, totales=totales
)

View File

@@ -143,7 +143,8 @@
part_photo: d.part_photo || '',
is_active: d.is_active ?? true,
sector: d.fa_data?.sector || '',
fraction_type: d.fa_data?.fraction_type || ''
fraction_type: d.fa_data?.fraction_type || '',
currency_type: '' // Initialize to match type
};
// Ensure currency_type is mapped correctly if coming from DB (optional, depending on DB values)
if (d.currency_key === 'MXN') formData.currency_type = 'NA';
@@ -383,25 +384,25 @@
<div class="md:col-span-4 space-y-2">
<Label for="fa_cost">Costo Unitario</Label>
<div class="relative">
<span class="absolute left-3 top-2.5 text-muted-foreground font-semibold">$</span>
<Input type="number" step="0.0001" id="fa_cost" bind:value={formData.unit_cost} class="pl-7" placeholder="0.0000" />
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground font-semibold text-sm">$</span>
<Input type="number" step="0.0001" id="fa_cost" bind:value={formData.unit_cost} class="pl-7 h-10" placeholder="0.0000" />
</div>
</div>
<div class="md:col-span-4 space-y-2">
<Label>Moneda</Label>
<div class="space-y-2">
<Button variant="outline" type="button" onclick={() => { formData.currency_type = 'CATALOG'; showCurrencyModal = true; }} class="w-full h-10 justify-between font-normal px-3">
<span class="flex items-center gap-2 text-muted-foreground"><FolderSearch class="h-4 w-4" /> {selectedCurrencyName || 'Catálogo'}</span>
</Button>
<div class="flex gap-4 mb-2">
<label class="text-sm flex items-center gap-2 cursor-pointer hover:text-primary transition-colors">
<label class="text-xs flex items-center gap-2 cursor-pointer hover:text-primary transition-colors">
<input type="radio" name="fa_currency_type" value="NA" bind:group={formData.currency_type} class="accent-primary" /> Nacional
</label>
<label class="text-sm flex items-center gap-2 cursor-pointer hover:text-primary transition-colors">
<label class="text-xs flex items-center gap-2 cursor-pointer hover:text-primary transition-colors">
<input type="radio" name="fa_currency_type" value="EX" bind:group={formData.currency_type} class="accent-primary" /> Extranjera
</label>
</div>
<Button variant="outline" size="sm" type="button" onclick={() => { formData.currency_type = 'CATALOG'; showCurrencyModal = true; }} class="w-full justify-between font-normal">
<span class="flex items-center gap-2"><FolderSearch class="h-3.5 w-3.5" /> {selectedCurrencyName || 'Catálogo'}</span>
</Button>
</div>
</div>
@@ -439,11 +440,11 @@
</div>
<div class="md:col-span-6 space-y-2">
<Label for="fa_sector">Sector</Label>
<Input id="fa_sector" bind:value={formData.sector} placeholder="Ej: Automotriz"/>
<Input id="fa_sector" bind:value={formData.sector} maxlength={8} placeholder="Ej: VIII"/>
</div>
<div class="md:col-span-6 space-y-2">
<Label for="fa_fraction_type">Tipo Tarifa</Label>
<Input id="fa_fraction_type" bind:value={formData.fraction_type} />
<Input id="fa_fraction_type" bind:value={formData.fraction_type} maxlength={7} />
</div>
</div>
</div>

View File

@@ -0,0 +1,5 @@
import { redirect } from '@sveltejs/kit';
export const load = () => {
throw redirect(302, '/dashboard/goods/parts');
};