feat: mejorar la gestión de errores y optimizar la carga de datos en los componentes de devolución

This commit is contained in:
Juan Felipe Zapata Moreno 2026-01-30 16:48:25 -06:00
parent 8210d7dd2f
commit b895836849
4 changed files with 10 additions and 9 deletions

View File

@ -89,7 +89,6 @@ const closeCreateModal = () => {
const createSerial = () => { const createSerial = () => {
const url = apiURL(`inventario/${inventoryId.value}/serials`); const url = apiURL(`inventario/${inventoryId.value}/serials`);
console.log('Creating serial at URL:', url, 'inventoryId:', inventoryId.value);
form.post(url, { form.post(url, {
onSuccess: (response) => { onSuccess: (response) => {

View File

@ -76,9 +76,11 @@ const canSubmit = computed(() => {
}); });
/** Watchers */ /** Watchers */
watch(() => props.show, (isShown) => { watch(() => props.show, async (isShown) => {
if (isShown) { if (isShown) {
resetForm(); resetForm();
// Cargar el estado de la caja registradora
await cashRegisterStore.loadCurrentRegister();
if (props.sale) { if (props.sale) {
searchSale(); searchSale();
} }
@ -130,7 +132,7 @@ const searchSale = async () => {
quantity_sold: item.quantity_sold, quantity_sold: item.quantity_sold,
quantity_already_returned: item.quantity_already_returned, quantity_already_returned: item.quantity_already_returned,
quantity_returnable: item.quantity_returnable, quantity_returnable: item.quantity_returnable,
available_serials: item.serials || [], available_serials: item.available_serials || [],
// Estado de selección // Estado de selección
selected: false, selected: false,
quantity: 0, quantity: 0,

View File

@ -35,7 +35,6 @@ const openDetailModal = async (returnItem) => {
selectedReturn.value = response.model || response; selectedReturn.value = response.model || response;
showDetailModal.value = true; showDetailModal.value = true;
} catch (error) { } catch (error) {
console.error('Error al cargar detalles:', error);
window.Notify.error('Error al cargar los detalles de la devolución'); window.Notify.error('Error al cargar los detalles de la devolución');
} }
}; };

View File

@ -22,7 +22,8 @@ const emit = defineEmits(['close', 'cancelled']);
/** Computados */ /** Computados */
const returnItems = computed(() => { const returnItems = computed(() => {
return props.returnData?.details || []; const items = props.returnData?.details || [];
return items;
}); });
const hasItems = computed(() => { const hasItems = computed(() => {
@ -59,8 +60,8 @@ const getRefundMethodBadge = (method) => {
const getRefundMethodLabel = (method) => { const getRefundMethodLabel = (method) => {
const labels = { const labels = {
cash: 'Efectivo', cash: 'Efectivo',
card: 'Tarjeta', credit_card: 'Credito',
store_credit: 'Crédito tienda' debit_card: 'Debito'
}; };
return labels[method] || method || '-'; return labels[method] || method || '-';
}; };
@ -68,8 +69,8 @@ const getRefundMethodLabel = (method) => {
const getRefundMethodIcon = (method) => { const getRefundMethodIcon = (method) => {
const icons = { const icons = {
cash: 'payments', cash: 'payments',
card: 'credit_card', credit_card: 'credit_card',
store_credit: 'account_balance_wallet' debit_card: 'credit_card'
}; };
return icons[method] || 'payment'; return icons[method] || 'payment';
}; };