Initial commit - Horux Despachos NL
This commit is contained in:
102
apps/api/src/services/email/templates/documento-subido.ts
Normal file
102
apps/api/src/services/email/templates/documento-subido.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { baseTemplate, heading, infoBox, primaryButton, BRAND_COLORS as C } from './base.js';
|
||||
|
||||
export interface DocumentoSubidoData {
|
||||
/** Kind: para el título/subject. */
|
||||
kind: 'declaracion' | 'extra';
|
||||
/** Quién subió el documento (email). */
|
||||
subidoPor: string;
|
||||
/** RFC del contribuyente. */
|
||||
contribuyenteRfc: string;
|
||||
/** Razón social / nombre del contribuyente. */
|
||||
contribuyenteNombre: string;
|
||||
/** Nombre del despacho (opcional, se incluye en el body cuando existe). */
|
||||
despachoNombre?: string;
|
||||
/** Si es declaración: periodo + tipo + impuestos + monto. */
|
||||
declaracion?: {
|
||||
periodo: string; // "Abril 2026"
|
||||
tipo: 'normal' | 'complementaria';
|
||||
impuestos: string[]; // ['IVA', 'ISR']
|
||||
montoPago: number | null;
|
||||
};
|
||||
/** Si es extra: nombre del documento + categoria. */
|
||||
extra?: {
|
||||
nombre: string;
|
||||
descripcion?: string | null;
|
||||
categoria?: string | null;
|
||||
};
|
||||
/** URL al sistema (ej. https://despachos.horuxfin.com/documentos). */
|
||||
link: string;
|
||||
}
|
||||
|
||||
export function documentoSubidoEmail(data: DocumentoSubidoData): string {
|
||||
const titulo = data.kind === 'declaracion'
|
||||
? 'Nueva declaración subida'
|
||||
: 'Nuevo documento subido';
|
||||
|
||||
const contenidoEspecifico = data.kind === 'declaracion' && data.declaracion
|
||||
? declaracionBlock(data.declaracion)
|
||||
: data.extra
|
||||
? extraBlock(data.extra)
|
||||
: '';
|
||||
|
||||
return baseTemplate(`
|
||||
${heading(titulo)}
|
||||
<p style="color:${C.textPrimary};margin:0 0 16px;">
|
||||
<strong>${escapeHtml(data.subidoPor)}</strong> subió un ${data.kind === 'declaracion' ? 'acuse de declaración' : 'documento'}
|
||||
para <strong>${escapeHtml(data.contribuyenteNombre)}</strong>.
|
||||
</p>
|
||||
${infoBox(`
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Contribuyente</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};font-weight:600;">${escapeHtml(data.contribuyenteNombre)}</p>
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">RFC</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};font-family:monospace;">${escapeHtml(data.contribuyenteRfc)}</p>
|
||||
${contenidoEspecifico}
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Fecha</p>
|
||||
<p style="margin:0;color:${C.textPrimary};">${new Date().toLocaleString('es-MX')}</p>
|
||||
`)}
|
||||
<div style="margin-top:24px;">
|
||||
${primaryButton('Ver en el sistema', data.link)}
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
function declaracionBlock(d: NonNullable<DocumentoSubidoData['declaracion']>): string {
|
||||
const impuestosStr = d.impuestos.join(', ');
|
||||
const tipoLabel = d.tipo === 'complementaria' ? 'Complementaria' : 'Normal';
|
||||
const montoLabel = d.montoPago == null ? '—' : d.montoPago === 0 ? 'Sin pago' : formatCurrency(d.montoPago);
|
||||
return `
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Periodo</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${escapeHtml(d.periodo)}</p>
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Tipo</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${tipoLabel}</p>
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Impuestos</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${escapeHtml(impuestosStr)}</p>
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Monto a pagar</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${montoLabel}</p>
|
||||
`;
|
||||
}
|
||||
|
||||
function extraBlock(e: NonNullable<DocumentoSubidoData['extra']>): string {
|
||||
return `
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Documento</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};font-weight:600;">${escapeHtml(e.nombre)}</p>
|
||||
${e.categoria ? `
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Categoría</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${escapeHtml(e.categoria)}</p>
|
||||
` : ''}
|
||||
${e.descripcion ? `
|
||||
<p style="margin:0 0 6px;color:${C.textMuted};font-size:13px;">Descripción</p>
|
||||
<p style="margin:0 0 12px;color:${C.textPrimary};">${escapeHtml(e.descripcion)}</p>
|
||||
` : ''}
|
||||
`;
|
||||
}
|
||||
|
||||
function formatCurrency(n: number): string {
|
||||
return n.toLocaleString('es-MX', { style: 'currency', currency: 'MXN', minimumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
function escapeHtml(s: string): string {
|
||||
return s.replace(/[&<>"']/g, (ch) => ({
|
||||
'&': '&', '<': '<', '>': '>', '"': '"', "'": ''',
|
||||
})[ch]!);
|
||||
}
|
||||
Reference in New Issue
Block a user