feat: refs #7235 update invoice out global form to fetch config based on serial type #1082
|
@ -115,6 +115,9 @@ onMounted(async () => {
|
|||
<VnSelect
|
||||
:label="t('invoiceOutSerialType')"
|
||||
v-model="formData.serialType"
|
||||
@update:model-value="
|
||||
invoiceOutGlobalStore.fetchInvoiceOutConfig(formData)
|
||||
"
|
||||
:options="serialTypesOptions"
|
||||
option-value="type"
|
||||
option-label="type"
|
||||
|
|
|
@ -19,7 +19,7 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
maxShipped: null,
|
||||
clientId: null,
|
||||
printer: null,
|
||||
serialType: null,
|
||||
serialType: 'global',
|
||||
},
|
||||
addresses: [],
|
||||
minInvoicingDate: null,
|
||||
|
@ -41,7 +41,6 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
|
||||
async fetchAllData() {
|
||||
try {
|
||||
const userInfo = await useUserConfig().fetch();
|
||||
const date = Date.vnNew();
|
||||
this.formInitialData.maxShipped = new Date(
|
||||
date.getFullYear(),
|
||||
|
@ -53,7 +52,7 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
|
||||
await Promise.all([
|
||||
this.fetchParallelism(),
|
||||
this.fetchInvoiceOutConfig(userInfo.companyFk),
|
||||
this.fetchInvoiceOutConfig(),
|
||||
]);
|
||||
|
||||
this.initialDataLoading = false;
|
||||
|
@ -62,21 +61,23 @@ export const useInvoiceOutGlobalStore = defineStore({
|
|||
}
|
||||
},
|
||||
|
||||
async fetchInvoiceOutConfig(companyFk) {
|
||||
async fetchInvoiceOutConfig(formData = this.formInitialData) {
|
||||
try {
|
||||
this.formInitialData.companyFk = companyFk;
|
||||
const params = { companyFk: companyFk };
|
||||
const userInfo = await useUserConfig().fetch();
|
||||
|
||||
const params = {
|
||||
companyFk: userInfo.companyFk,
|
||||
serialType: formData.serialType,
|
||||
};
|
||||
|
||||
const { data } = await axios.get('InvoiceOuts/getInvoiceDate', {
|
||||
params,
|
||||
});
|
||||
|
||||
const stringDate = data.issued.substring(0, 10);
|
||||
this.minInvoicingDate = stringDate;
|
||||
this.formInitialData.invoiceDate = stringDate;
|
||||
|
||||
this.minInvoicingDate = new Date(data.issued);
|
||||
this.minInvoicingDate = data?.issued
|
||||
? new Date(data.issued)
|
||||
: Date.vnNew();
|
||||
this.formInitialData.invoiceDate = this.minInvoicingDate;
|
||||
formData.invoiceDate = this.minInvoicingDate;
|
||||
} catch (err) {
|
||||
console.error('Error fetching invoice out global initial data');
|
||||
jsegarra
commented
@alexm Hace poco hiciste una PR en el que eliminabas todos los try/catch. @alexm Hace poco hiciste una PR en el que eliminabas todos los try/catch.
Puedes verificar que este caso debe existir o se ha colado?
alexm
commented
Si puede que alguno se haya quedado, si se quita mejor Si puede que alguno se haya quedado, si se quita mejor
|
||||
throw new Error();
|
||||
|
|
Loading…
Reference in New Issue
Si de userInfo, solo usas 1 parámetro, casi que podrías hacer const {companyFk}, no afecta dejarlo asi