Merge branch 'beta' into feature/photo-view
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

This commit is contained in:
Javier Segarra 2025-04-02 21:37:42 +00:00
commit 6817d409e1
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 { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
import { onUserId } from 'src/utils/onUserId';
const { t } = useI18n();
const jApi = inject('jApi');
const api = inject('api');
const { openReport } = usePrintService();
const appStore = useAppStore();
const { isHeaderMounted } = storeToRefs(appStore);
@ -50,27 +51,38 @@ const columns = computed(() => [
}
]);
const fetchInvoices = async () => {
const params = {
const fetchInvoices = async clientFk => {
const { from, to } = {
from: new Date(currentYear.value, 0),
to: new Date(currentYear.value, 11, 31, 23, 59, 59)
};
invoices.value = await jApi.query(
`SELECT id, ref, issued, amount, hasPdf
FROM myInvoice
WHERE issued BETWEEN #from AND #to
ORDER BY issued DESC
LIMIT 100`,
params
);
const filter = {
where: {
clientFk,
issued: {
between: [from, to]
}
},
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 () => {
await fetchInvoices();
for (let year = currentYear.value - 5; year <= currentYear.value; year++) {
years.value.push(year);
}
});
onUserId(fetchInvoices);
</script>
<template>