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 url = apiURL(`inventario/${inventoryId.value}/serials`);
console.log('Creating serial at URL:', url, 'inventoryId:', inventoryId.value);
form.post(url, {
onSuccess: (response) => {

View File

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

View File

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

View File

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