- Replace tarifa_id+estado='ocupado' query with the same logic used in
ShowServicios: filter by servicio_id, date range, historiales_count
- Full-account plans (pantallas == completa): look for estado='pendiente'
accounts without assigned profiles
- Partial plans (screen sharing): look for estado='activo' accounts
with remaining slots (historiales_count <= pantallas_servicio - pantallas)
- Wrap purchase in DB::transaction to avoid race conditions
- Remove incorrect cuenta->update(['estado' => 'ocupado']) — availability
is now tracked via historial_cuentas count, not a flag
- Use effective price (Preferencial override) for saldo deduction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>