diff --git a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
index baa1b86ed..be1a65f59 100644
--- a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
+++ b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
@@ -1,8 +1,11 @@
+ onFetchCompanies(data)" auto-load />
+ onFetchPrinters(data)" auto-load />
+ onFetchClients(data)" auto-load />
+
@@ -97,44 +118,122 @@ const inputSelectfilter = (val, update) => {
/>
+ inputSelectFilter(val, update, abort, clientsOptions)
+ "
+ v-model="formData.clientId"
/>
+ :model-value="toDate(formData.invoiceDate)"
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+ :model-value="toDate(formData.maxShipped)"
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+ inputSelectFilter(val, update, abort, companiesOptions)
+ "
+ v-model="formData.companyFk"
/>
+ inputSelectFilter(val, update, abort, printersOptions)
+ "
+ v-model="formData.printer"
/>
{
- return await request('GET', 'Companies', { filter });
- },
-
- getPrinters: async (filter) => {
- return await request('GET', 'Printers', { filter });
- },
-
- getClients: async (filter) => {
- return await request('GET', 'Clients', { filter });
- },
-
getClientsToInvoice: async (params) => {
return await request('POST', 'InvoiceOuts/clientsToInvoice', params);
},
diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js
index 33bf0db3d..d449a577d 100644
--- a/src/stores/invoiceOutGlobal.js
+++ b/src/stores/invoiceOutGlobal.js
@@ -16,10 +16,8 @@ export const useInvoiceOutGlobalStore = defineStore({
invoiceDate: null,
maxShipped: null,
clientId: null,
+ printer: null,
},
- clientsOptions: [],
- companiesOptions: [],
- printersOptions: [],
addresses: [],
minInvoicingDate: null,
parallelism: null,
@@ -27,8 +25,8 @@ export const useInvoiceOutGlobalStore = defineStore({
isInvoicing: false,
status: null,
addressIndex: 0,
- printer: null,
errors: [],
+ printer: null,
nRequests: 0,
nPdfs: 0,
totalPdfs: 0,
@@ -51,10 +49,7 @@ export const useInvoiceOutGlobalStore = defineStore({
.substring(0, 10);
await Promise.all([
- this.fetchClients(),
this.fetchParallelism(),
- this.fetchCompanies(userInfo.companyFk),
- this.fetchPrinters(),
this.fetchInvoiceOutConfig(userInfo.companyFk),
]);
@@ -64,45 +59,10 @@ export const useInvoiceOutGlobalStore = defineStore({
}
},
- async fetchClients() {
- const clientsFilter = { fields: ['id', 'name'], order: 'id', limit: 30 };
- const clientsResponse = await invoiceOutService.getClients(clientsFilter);
- this.clientsOptions = clientsResponse.map((client) => {
- return { value: client.id, label: client.name };
- });
- },
-
- async fetchCompanies(companyFk) {
- const companiesFilters = { order: ['code'] };
- const companiesResponse = await invoiceOutService.getCompanies(
- companiesFilters
- );
- this.companiesOptions = companiesResponse.map((company) => {
- return { value: company.id, label: company.code };
- });
-
- this.formInitialData.companyFk = this.companiesOptions.find(
- (company) => companyFk === company.value
- );
- },
-
- async fetchPrinters() {
- const printersFilters = {
- fields: ['id', 'name'],
- where: { isLabeler: false },
- order: 'name ASC',
- limit: 30,
- };
- const printersResponse = await invoiceOutService.getPrinters(printersFilters);
- this.printersOptions = printersResponse.map((printer) => {
- return { value: printer.id, label: printer.name };
- });
- },
-
async fetchInvoiceOutConfig(companyFk) {
+ this.formInitialData.companyFk = companyFk;
const params = { companyFk: companyFk };
const { issued } = await invoiceOutService.getInvoiceDate(params);
-
const stringDate = issued.substring(0, 10);
this.minInvoicingDate = stringDate;
this.formInitialData.invoiceDate = stringDate;
@@ -118,11 +78,12 @@ export const useInvoiceOutGlobalStore = defineStore({
this.invoicing = true;
this.status = 'packageInvoicing';
try {
+ this.printer = formData.printer;
const params = {
invoiceDate: new Date(formData.invoiceDate),
maxShipped: new Date(formData.maxShipped),
- clientId: formData.clientId ? formData.clientId.value : null,
- companyFk: formData.companyFk.value,
+ clientId: formData.clientId ? formData.clientId : null,
+ companyFk: formData.companyFk,
};
this.validateMakeInvoceParams(params, clientsToInvoice);
@@ -204,7 +165,7 @@ export const useInvoiceOutGlobalStore = defineStore({
addressId: address.id,
invoiceDate: new Date(formData.invoiceDate),
maxShipped: new Date(formData.maxShipped),
- companyFk: formData.companyFk.value,
+ companyFk: formData.companyFk,
};
this.status = 'invoicing';
@@ -238,7 +199,7 @@ export const useInvoiceOutGlobalStore = defineStore({
try {
this.nRequests++;
this.totalPdfs++;
- const params = { printerFk: this.printer.value };
+ const params = { printerFk: this.printer };
await invoiceOutService.makePdfAndNotify(invoiceId, params);
this.nPdfs++;
this.nRequests--;
@@ -280,10 +241,6 @@ export const useInvoiceOutGlobalStore = defineStore({
// State mutations actions
- setPrinterValue(printer) {
- this.printer = printer;
- },
-
setStatusValue(status) {
this.status = status;
},