fix: refs #8388 improve error handling and notification for invoice booking
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2025-03-17 13:25:40 +01:00
parent af0a672356
commit 01d1ca83ea
1 changed files with 6 additions and 7 deletions

View File

@ -56,22 +56,21 @@ async function checkToBook(id) {
componentProps: { componentProps: {
title: t('Are you sure you want to book this invoice?'), title: t('Are you sure you want to book this invoice?'),
message: messages.reduce((acc, msg) => `${acc}<p>${msg}</p>`, ''), message: messages.reduce((acc, msg) => `${acc}<p>${msg}</p>`, ''),
promise: () => toBook(id),
}, },
}).onOk(() => toBook(id)); });
} }
async function toBook(id) { async function toBook(id) {
let type = 'positive'; let err;
let message = t('globals.dataSaved');
try { try {
await axios.post(`InvoiceIns/${id}/toBook`); await axios.post(`InvoiceIns/${id}/toBook`);
store.data.isBooked = true; store.data.isBooked = true;
} catch (e) { } catch (e) {
type = 'negative'; err = true;
message = t('It was not able to book the invoice'); throw e;
} finally { } finally {
notify({ type, message }); if (!err) notify({ type: 'positive', message: t('globals.dataSaved') });
} }
} }
</script> </script>