feat(invoices): migrar de jApi a endpoint REST API #134

Merged
jsegarra merged 2 commits from golguin/hedera-web:invoice-view-migrate into beta 2025-04-02 21:37:30 +00:00
1 changed files with 24 additions and 12 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,38 @@ const columns = computed(() => [
} }
]); ]);
const fetchInvoices = async () => { const fetchInvoices = async clientFk => {
const params = { const { from, to } = {
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: [from, to]

Sera lo mismo que hacer const params = [{from, to}], no?

Sera lo mismo que hacer const params = [{from, to}], no?
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>