# control/embarque/obtener - [show]

Path: /var/www/html/qaservicesapp/app/Http/Controllers/ShalomControl/EmbarqueController.php

## 🧾 **Descripción**

Obtiene la información completa de una **Orden de Servicio (OSE)**, incluyendo:

- Datos generales de la guía
- Datos del remitente, destino y ruta
- Contenido (tipos y cantidades de unidades)
- Estado de embarque y paquetes embarcados
- Atributos del tipo de pago
- Usuario creador
- Validaciones de estado

Es un servicio para **consulta detallada** de una guía antes o durante el proceso de embarque.

---

# 🚀 **Endpoint**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-post-%2Fshow"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr"><span style="color: rgb(224, 62, 45);">**`POST /show`**</span></div></div>---

# 📥 **Request Body**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22ose_id%22%3A-%22number%22"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"ose_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"cap_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"terminal"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### Parámetros requeridos

<div class="_tableContainer_1rjym_1" id="bkmrk-campo-tipo-obligator"><div class="group _tableWrapper_1rjym_13 flex w-fit flex-col-reverse" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="1085" data-start="806"><thead data-end="850" data-start="806"><tr data-end="850" data-start="806"><th data-col-size="sm" data-end="814" data-start="806">Campo</th><th data-col-size="sm" data-end="821" data-start="814">Tipo</th><th data-col-size="sm" data-end="835" data-start="821">Obligatorio</th><th data-col-size="sm" data-end="850" data-start="835">Descripción</th></tr></thead><tbody data-end="1085" data-start="896"><tr data-end="962" data-start="896"><td data-col-size="sm" data-end="905" data-start="896">ose\_id</td><td data-col-size="sm" data-end="914" data-start="905">number</td><td data-col-size="sm" data-end="919" data-start="914">Sí</td><td data-col-size="sm" data-end="962" data-start="919">ID de la orden de servicio a consultar.</td></tr><tr data-end="1022" data-start="963"><td data-col-size="sm" data-end="972" data-start="963">cap\_id</td><td data-col-size="sm" data-end="981" data-start="972">number</td><td data-col-size="sm" data-end="986" data-start="981">Sí</td><td data-col-size="sm" data-end="1022" data-start="986">ID de carga (embarque) asociado.</td></tr><tr data-end="1085" data-start="1023"><td data-col-size="sm" data-end="1034" data-start="1023">terminal</td><td data-col-size="sm" data-end="1043" data-start="1034">string</td><td data-col-size="sm" data-end="1048" data-start="1043">No</td><td data-col-size="sm" data-end="1085" data-start="1048">Terminal desde donde se consulta.</td></tr></tbody></table>

</div></div>---

# 🔐 **Seguridad**

El servicio depende del middleware global (token/sesión del sistema).  
No hace validación explícita dentro de la función.

---

# 🧠 **Flujo del Servicio (resumen real)**

### 1. **Validación inicial**

- Verifica obligatorio `ose_id`.
- Verifica obligatorio `cap_id`.

### 2. **Obtiene datos de la orden**

Consulta principal:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-fecha%2C-monto%2C"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 29.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 29.6px;"><td style="height: 29.6px;">`<span class="hljs-keyword">SELECT</span>    fecha, monto, guia, remitente, destinatario,    tipo_pago, origen, destino, usuario,    ose_id, estado_pago, tipo_entrega,    contenido <span class="hljs-operator">=</span> <span class="hljs-keyword">null</span>,    ruta <span class="hljs-operator">=</span> <span class="hljs-keyword">null</span>,    embarque_guia <span class="hljs-operator">=</span> <span class="hljs-string">'SIN GUIA'</span>,    cant_paq <span class="hljs-operator">=</span> <span class="hljs-number">0</span>,    cant_total <span class="hljs-operator">=</span> <span class="hljs-number">0</span>,    embarcados <span class="hljs-operator">=</span> <span class="hljs-keyword">null</span>,    cap_id <span class="hljs-operator">=</span> <span class="hljs-string">''</span><span class="hljs-keyword">FROM</span> emp_ordenservicio<span class="hljs-keyword">WHERE</span> ose_id <span class="hljs-operator">=</span> <span class="hljs-operator"><</span>ose_id<span class="hljs-operator">></span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Si no existe → *"Orden de servicio no encontrada"*  
Si está anulada (`estado_pago = 'AN'`) → error.

---

### 3. **Obtiene nombres de terminales**

Se reemplazan los IDs de origen/destino por su nombre y alias:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-nombre%2C-alias"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">SELECT</span> nombre, <span class="hljs-keyword">alias</span> <span class="hljs-keyword">FROM</span> emp_terminal <span class="hljs-keyword">WHERE</span> ter_id = origen<span class="hljs-keyword">SELECT</span> nombre, <span class="hljs-keyword">alias</span> <span class="hljs-keyword">FROM</span> emp_terminal <span class="hljs-keyword">WHERE</span> ter_id = destino`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Crea la ruta: `<span class="hljs-attr">ruta</span> = origen_alias + <span class="hljs-string">' - '</span> + destino_alias`

---

### 4. **Obtiene contenido de la OSE**

Consulta:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-tipo%2C-cantida"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">SELECT</span> tipo, cantidad<span class="hljs-keyword">FROM</span> emp_os_detalle<span class="hljs-keyword">WHERE</span> osd_osid <span class="hljs-operator">=</span> <span class="hljs-operator"><</span>ose_id<span class="hljs-operator">></span> <span class="hljs-keyword">AND</span> osd_eliminado <span class="hljs-operator">=</span> <span class="hljs-number">0</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Construye:

- contenido → `"5 CAJA / 2 SOBRE / ..."`
- cant\_total → sumatoria de cantidades

---

### 5. **Obtiene estado de embarque**

Consulta:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-emb_estado_gu"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`SELECT emb_estado_guia, emb_cant_paquetes_embarcadosFROM emp_embarque_historial<span class="hljs-type">WHERE</span> <span class="hljs-variable">emb_ose_id</span> <span class="hljs-operator">=</span> <ose_id>  <span class="hljs-type">AND</span> <span class="hljs-variable">emb_carg_id</span> <span class="hljs-operator">=</span> <cap_id>  <span class="hljs-type">AND</span> <span class="hljs-variable">status</span> <span class="hljs-operator">=</span> <span class="hljs-number">1</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Calcula:

- emb\_guia → `GUIA EMBARCADA` si existe algún registro con valor &gt; 0
- cant\_paq → cantidad de paquetes registrados
- embarcados → array de los paquetes embarcados

---

### 6. **Traduce tipo de pago**

Consulta atributos:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-abreviatura%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">SELECT</span> abreviatura, valor<span class="hljs-keyword">FROM</span> emp_atributos<span class="hljs-keyword">WHERE</span> concepto <span class="hljs-operator">=</span> <span class="hljs-string">'tipospago'</span><span class="hljs-keyword">AND</span> atr_idpadre <span class="hljs-operator">=</span> <span class="hljs-number">90</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Aplica la conversión: `<span class="hljs-attr">orden.tipo_pago</span> = abreviatura del valor recibido`

---

### 7. **Obtiene nombre del remitente**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-documento%2C-no"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">SELECT</span> documento, nombre_completo<span class="hljs-keyword">FROM</span> emp_persona<span class="hljs-keyword">WHERE</span> documento <span class="hljs-operator">=</span> orden.remitente`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

### 8. **Obtiene usuario creador**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-select-usr_alias-fro"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">SELECT</span> usr_alias <span class="hljs-keyword">FROM</span> emp_usuario <span class="hljs-keyword">WHERE</span> usr_id <span class="hljs-operator">=</span> orden.usuario`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

### 9. **Devuelve respuesta final**

Incluye:

- datos completos de la OSE
- contenido
- tipo de pago traducido
- cantidades
- ruta
- paquetes embarcados

---

# 📤 **Response 200 – Ejemplo**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-true%2C-%22"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Orden encontrada"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>    <span class="hljs-attr">"ose_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">152233</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-12"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"guia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"G-998877"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"remitente"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"EMPRESA S.A."</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"destinatario"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"CLIENTE SAC"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"tipo_pago"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"CR"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"origen"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"LIMA"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"destino"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"AREQUIPA"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"ruta"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"LIM - AQP"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"contenido"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"5 CAJA / 2 SOBRE"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"cant_total"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">7</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"embarque_guia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"SIN GUIA"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"cant_paq"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"usuario"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"jrojas"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"cap_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">22</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"embarcados"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span>  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# ❗ **Posibles Errores**

### 1. Falta ose\_id

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Es obligatorio enviar un ose_id"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### 2. Falta cap\_id

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C--1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 28.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 28.6px;"><td style="height: 28.6px;">`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Es obligatorio enviar un cap_id"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### 3. OSE no encontrada

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-true%2C-%22-1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Orden de servicio no encontrada"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### 4. Guía anulada

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C--2"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"La guía se encuentra anulada."</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 📚 **Schemas (estructuras usadas)**

### **Orden de Servicio (emp\_ordenservicio)**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22ose_id%22%3A-%22number%22-1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"ose_id"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"fecha"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"datetime"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"monto"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"guia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"remitente"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"destinatario"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"tipo_pago"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"origen"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"destino"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"usuario"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"estado_pago"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Detalle OSE (emp\_os\_detalle)**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22tipo%22%3A-%22string%22%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"tipo"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"cantidad"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Terminal (emp\_terminal)**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22nombre%22%3A-%22string%22"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 33.8px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 33.8px;"><td style="height: 33.8px;">`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"nombre"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"alias"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Embarque Historial**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22emb_estado_guia%22%3A"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"emb_estado_guia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"number"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"emb_cant_paquetes_embarcados"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 🗃 **Lógica en pseudo-código**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-if-%21ose_id--%3E-error-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 29.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 29.6px;"><td style="height: 29.6px;">`if !ose_id -> errorif !cap_id -> errororden = SELECT from emp_ordenservicioif not found -> return mensajeif anulada -> errororigen = SELECT terminaldestino = SELECT terminalorden.ruta = origen.alias + " - " + destino.aliasdetalles = SELECT detalle OSEcontenido = concatenar tipo + cantidadcant_total = sum cantidadesembarques = SELECT embarques para ose_id y cap_idcalcular emb_guia, cant_paq, embarcados[]tipo_pago = traducir via emp_atributosremitente = SELECT personausuario = SELECT usuarioreturn orden completa`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>