feat: refs #8277 enhance pre-accounting process and integrate user warehouse data
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jorge Penadés 2025-03-25 17:28:13 +01:00
parent 998cde58a1
commit 1badf92b1c
1 changed files with 30 additions and 24 deletions

View File

@ -14,10 +14,11 @@ import axios from 'axios';
import useNotify from 'src/composables/useNotify';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import VnDms from 'src/components/common/VnDms.vue';
import { date } from 'quasar';
import { useState } from 'src/composables/useState';
const { t } = useI18n();
const { notify } = useNotify();
const user = useState().getUser();
const dialog = ref();
const dmsDialog = ref();
const MAXDAYS = 365;
@ -237,7 +238,7 @@ async function preAccount() {
await axios.get('InvoiceIns/getMaxRef', {
params: { companyFk: selectedAgri.companyFk, year },
})
).data?.supplierRef;
).data;
return createInvoice(true);
} else if (selectedGestDoc) {
@ -247,28 +248,19 @@ async function preAccount() {
// If There's no gestDoc, upload the file
uploadFile();
}
// Generar factura
// Cabecera,
// ..........................................
// lineas...
// Actualizar entradas (contabilizada, numero de factura) MAS TARDE
// await axios.post('Entries/preAccount', {
// ids: selectedRows.value.map((row) => row.id),
// });
}
async function updateFile() {
await axios.post(`Dms/${selectedGestDoc.gestDocFk}/updateFile`, { dmsTypeId: 1 });
table.value.reload();
}
async function uploadFile() {
const firstSelectedEntry = selectedRows.value.at(0);
const { supplier, warehouseInFk, companyFk, invoiceNumber } = firstSelectedEntry;
const { supplier, companyFk, invoiceNumber } = firstSelectedEntry;
dmsData.value = {
dmsTypeFk: 1,
warehouseFk: warehouseInFk,
warehouseFk: user.value.warehouseFk,
companyFk: companyFk,
description: supplier + '.Fact: ' + invoiceNumber,
reference: invoiceNumber,
@ -285,18 +277,32 @@ async function createInvoice(isAgricultural) {
currencyFk,
gestDocFk: docFk,
} = selectedRows.value.at(0);
const lastDay = new Date(landed.getFullYear(), landed.getMonth() + 1, 0).getDate();
const dateLanded = new Date(landed);
const lastDay = new Date(dateLanded.getFullYear(), dateLanded.getMonth() + 1, 0);
const issued = isAgricultural ? lastDay : shipped;
const siiTrascendencyInvoiceInFk = isAgricultural ? 2 : 1;
await axios.post('InvoiceIns', {
supplierFk,
supplierRef,
issued,
companyFk,
docFk,
currencyFk,
siiTrascendencyInvoiceInFk,
});
let err;
try {
// Create invoice
await axios.post('InvoiceIns', {
supplierFk,
supplierRef,
issued,
companyFk,
docFk,
currencyFk,
siiTrascendencyInvoiceInFk,
});
// create tax, due-day and intrastat
// update entries
} catch (e) {
throw e;
} finally {
table.value.reload();
}
}
</script>
<template>