diff --git a/app/Http/Livewire/Whatsapp/ShowCorreoConfig.php b/app/Http/Livewire/Whatsapp/ShowCorreoConfig.php
index 46ff34a..58e5700 100644
--- a/app/Http/Livewire/Whatsapp/ShowCorreoConfig.php
+++ b/app/Http/Livewire/Whatsapp/ShowCorreoConfig.php
@@ -3,6 +3,7 @@
namespace App\Http\Livewire\Whatsapp;
use App\Models\WhatsappSystemConfig;
+use App\Services\BancolombiaParser;
use App\Services\CorreoImapService;
use Livewire\Component;
use Jantinnerezo\LivewireAlert\LivewireAlert;
@@ -82,7 +83,14 @@ class ShowCorreoConfig extends Component
timeout: 20
);
- $this->emails = $service->fetchLatest(5);
+ $raw = $service->fetchLatest(5);
+
+ // Añadir datos parseados de Bancolombia a cada correo
+ $this->emails = array_map(function (array $email) {
+ $email['bancolombia'] = BancolombiaParser::parse($email['body']);
+ return $email;
+ }, $raw);
+
$this->testStatus = 'ok';
} catch (\Throwable $e) {
$this->testStatus = 'error';
diff --git a/app/Services/BancolombiaParser.php b/app/Services/BancolombiaParser.php
new file mode 100644
index 0000000..06f619e
--- /dev/null
+++ b/app/Services/BancolombiaParser.php
@@ -0,0 +1,119 @@
+ 'Bancolombia',
+ 'tipo' => self::detectarTipo($text),
+ 'destinatario' => self::extraer($text, '/Bancolombia[:\s]+([A-ZÁÉÍÓÚÑÜ][A-Za-záéíóúñü\s]+?),\s+recibiste/u'),
+ 'remitente' => self::extraer($text, '/transferencia\s+de\s+(.+?)\s+por\s+\$/iu'),
+ 'valor' => self::extraerValor($text),
+ 'cuenta' => self::extraer($text, '/cuenta\s+\*(\d+)/iu'),
+ 'llave' => self::extraer($text, '/llave\s+([@\w.\-]+)/iu'),
+ 'fecha' => self::extraer($text, '/el\s+(\d{1,2}\/\d{1,2}\/\d{2,4})/iu'),
+ 'hora' => self::extraer($text, '/a\s+las\s+(\d{1,2}:\d{2})/iu'),
+ 'texto_original' => $text,
+ ];
+
+ return $result;
+ }
+
+ // ─────────────────────────────────────────────────────────
+ // Helpers privados
+ // ─────────────────────────────────────────────────────────
+
+ private static function esBancolombia(string $text): bool
+ {
+ return stripos($text, 'bancolombia') !== false
+ && (
+ stripos($text, 'transferencia') !== false
+ || stripos($text, 'pago') !== false
+ || stripos($text, 'recibiste') !== false
+ || stripos($text, 'enviaste') !== false
+ );
+ }
+
+ private static function detectarTipo(string $text): string
+ {
+ if (stripos($text, 'recibiste') !== false) {
+ return 'transferencia_recibida';
+ }
+ if (stripos($text, 'enviaste') !== false) {
+ return 'transferencia_enviada';
+ }
+ if (stripos($text, 'pago') !== false) {
+ return 'pago';
+ }
+ return 'notificacion';
+ }
+
+ /**
+ * Ejecuta un regex y devuelve el primer grupo capturado, trimmed.
+ */
+ private static function extraer(string $text, string $pattern): string
+ {
+ if (preg_match($pattern, $text, $m)) {
+ return trim($m[1]);
+ }
+ return '';
+ }
+
+ /**
+ * Extrae el valor monetario como string limpio, ej: "1000.00"
+ * y también como float.
+ * Devuelve el string formateado con separadores originales.
+ */
+ private static function extraerValor(string $text): string
+ {
+ // Captura números con puntos y comas: $1,000.00 | $1.000,00 | $500
+ if (preg_match('/por\s+\$([0-9][0-9.,]*)/iu', $text, $m)) {
+ return trim($m[1]);
+ }
+ return '';
+ }
+
+ /**
+ * Elimina etiquetas HTML y decodifica entidades.
+ */
+ private static function stripHtml(string $text): string
+ {
+ // Reemplazar
,
,
{{ $email['body'] }}
+ Texto completo:
+{{ $email['body'] }}
@else
(Sin contenido de texto)
@endif