Merge pull request 'feat: refs #7235 update invoice out global form to fetch config based on serial type' (!1082) from 7235-InvoiceOutBySerial into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1082
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Javi Gallego 2024-12-18 08:09:31 +00:00
commit 1e779ea0be
2 changed files with 15 additions and 11 deletions

View File

@ -115,6 +115,9 @@ onMounted(async () => {
<VnSelect <VnSelect
:label="t('invoiceOutSerialType')" :label="t('invoiceOutSerialType')"
v-model="formData.serialType" v-model="formData.serialType"
@update:model-value="
invoiceOutGlobalStore.fetchInvoiceOutConfig(formData)
"
:options="serialTypesOptions" :options="serialTypesOptions"
option-value="type" option-value="type"
option-label="type" option-label="type"

View File

@ -19,7 +19,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: null, maxShipped: null,
clientId: null, clientId: null,
printer: null, printer: null,
serialType: null, serialType: 'global',
}, },
addresses: [], addresses: [],
minInvoicingDate: null, minInvoicingDate: null,
@ -41,7 +41,6 @@ export const useInvoiceOutGlobalStore = defineStore({
async fetchAllData() { async fetchAllData() {
try { try {
const userInfo = await useUserConfig().fetch();
const date = Date.vnNew(); const date = Date.vnNew();
this.formInitialData.maxShipped = new Date( this.formInitialData.maxShipped = new Date(
date.getFullYear(), date.getFullYear(),
@ -53,7 +52,7 @@ export const useInvoiceOutGlobalStore = defineStore({
await Promise.all([ await Promise.all([
this.fetchParallelism(), this.fetchParallelism(),
this.fetchInvoiceOutConfig(userInfo.companyFk), this.fetchInvoiceOutConfig(),
]); ]);
this.initialDataLoading = false; this.initialDataLoading = false;
@ -62,21 +61,23 @@ export const useInvoiceOutGlobalStore = defineStore({
} }
}, },
async fetchInvoiceOutConfig(companyFk) { async fetchInvoiceOutConfig(formData = this.formInitialData) {
try { try {
this.formInitialData.companyFk = companyFk; const userInfo = await useUserConfig().fetch();
const params = { companyFk: companyFk }; const params = {
companyFk: userInfo.companyFk,
serialType: formData.serialType,
};
const { data } = await axios.get('InvoiceOuts/getInvoiceDate', { const { data } = await axios.get('InvoiceOuts/getInvoiceDate', {
params, params,
}); });
const stringDate = data.issued.substring(0, 10); this.minInvoicingDate = data?.issued
this.minInvoicingDate = stringDate; ? new Date(data.issued)
this.formInitialData.invoiceDate = stringDate; : Date.vnNew();
this.minInvoicingDate = new Date(data.issued);
this.formInitialData.invoiceDate = this.minInvoicingDate; this.formInitialData.invoiceDate = this.minInvoicingDate;
formData.invoiceDate = this.minInvoicingDate;
} catch (err) { } catch (err) {
console.error('Error fetching invoice out global initial data'); console.error('Error fetching invoice out global initial data');
throw new Error(); throw new Error();