refactor: refs #8277 update invoice creation logic and adjust data filtering options

This commit is contained in:
Jorge Penadés 2025-04-14 12:04:13 +02:00
parent 09d88e25ea
commit e680cbc25d
1 changed files with 7 additions and 7 deletions
src/pages/Entry

View File

@ -172,7 +172,8 @@ const columns = computed(() => [
name: 'accountType',
options: entryAccounts.value,
optionLabel: 'type',
optionValue: 'code',
optionValue: 'id',
sortBy: 'id',
},
},
{
@ -247,7 +248,7 @@ async function preAccount() {
params: { companyFk: firstRow.companyFk, year },
})
).data;
return createInvoice(true);
return createInvoice();
} else if (dmsFk) {
supplierRef = (
await axios.get(`Dms/${dmsFk}`, {
@ -284,16 +285,15 @@ async function uploadFile() {
async function afterUploadFile({ reference }, res) {
supplierRef = reference;
dmsFk = res.data[0].id;
await createInvoice(false);
await createInvoice();
}
async function createInvoice(isAgricultural) {
async function createInvoice() {
try {
await axios.post(`Entries/preAccount`, {
await axios.post(`Entries/addInvoiceIn`, {
ids: selectedRows.value.map((entry) => entry.id),
supplierRef,
dmsFk,
isAgricultural,
});
notify(t('entry.preAccount.success'), 'positive');
} catch (e) {
@ -333,7 +333,7 @@ async function createInvoice(isAgricultural) {
/>
<FetchData
url="EntryAccounts"
:filter="{ fields: ['code', 'type'] }"
:filter="{ fields: ['id', 'type'] }"
@on-fetch="(data) => (entryAccounts = data)"
auto-load
/>