feat(invoices): migrar de jApi a endpoint REST API
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

- Reemplazar consulta SQL directa por llamada a endpoint
This commit is contained in:
Guido 2025-03-31 16:03:57 -03:00
parent 8ef7f531fb
commit 5881f12306
1 changed files with 24 additions and 11 deletions

View File

@ -8,9 +8,10 @@ import { currency, formatDate } from 'src/lib/filters.js';
import { usePrintService } from 'src/composables/usePrintService'; import { usePrintService } from 'src/composables/usePrintService';
import { useAppStore } from 'stores/app'; import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { onUserId } from 'src/utils/onUserId';
const { t } = useI18n(); const { t } = useI18n();
const jApi = inject('jApi'); const api = inject('api');
const { openReport } = usePrintService(); const { openReport } = usePrintService();
const appStore = useAppStore(); const appStore = useAppStore();
const { isHeaderMounted } = storeToRefs(appStore); const { isHeaderMounted } = storeToRefs(appStore);
@ -50,27 +51,39 @@ const columns = computed(() => [
} }
]); ]);
const fetchInvoices = async () => { const fetchInvoices = async clientFk => {
const params = { const params = {
from: new Date(currentYear.value, 0), from: new Date(currentYear.value, 0),
to: new Date(currentYear.value, 11, 31, 23, 59, 59) to: new Date(currentYear.value, 11, 31, 23, 59, 59)
}; };
invoices.value = await jApi.query( const filter = {
`SELECT id, ref, issued, amount, hasPdf where: {
FROM myInvoice clientFk,
WHERE issued BETWEEN #from AND #to issued: {
ORDER BY issued DESC between: [params.from, params.to]
LIMIT 100`, }
params },
); order: ['issued DESC'],
fields: ['id', 'ref', 'issued', 'amount', 'hasPdf'],
limit: 100
};
const { data } = await api.get('InvoiceOuts', {
params: {
filter: JSON.stringify(filter)
}
});
invoices.value = data;
}; };
onMounted(async () => { onMounted(async () => {
await fetchInvoices();
for (let year = currentYear.value - 5; year <= currentYear.value; year++) { for (let year = currentYear.value - 5; year <= currentYear.value; year++) {
years.value.push(year); years.value.push(year);
} }
}); });
onUserId(fetchInvoices);
</script> </script>
<template> <template>