From 01eb68aed8c8fc2d3a499c9455e07d37950a6f34 Mon Sep 17 00:00:00 2001 From: carlosfonseca Date: Thu, 16 Nov 2023 13:40:05 -0500 Subject: [PATCH 001/159] Se crea actualizacion de tarjeta en invoices out --- package-lock.json | 12 ++-- src/components/ui/CardList2.vue | 85 +++++++++++++++++++++++++ src/pages/InvoiceOut/InvoiceOutList.vue | 30 ++++----- 3 files changed, 106 insertions(+), 21 deletions(-) create mode 100644 src/components/ui/CardList2.vue diff --git a/package-lock.json b/package-lock.json index a3a9dcc63..c541ee00e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "salix-front", - "version": "23.40.01", + "version": "23.48.01", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "salix-front", - "version": "0.0.1", + "version": "23.48.01", "dependencies": { - "@quasar/cli": "^2.2.1", + "@quasar/cli": "^2.3.0", "@quasar/extras": "^1.16.4", "axios": "^1.4.0", "chromium": "^3.0.3", @@ -946,9 +946,9 @@ } }, "node_modules/@quasar/cli": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.2.1.tgz", - "integrity": "sha512-PMwJ76IeeNRRBw+08hUMjhqGC6JKJ/t1zIb+IOiyR5D4rkBR26Ha/Z46OD3KfwUprq4Q8s4ieB1+d3VY8FhPKg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.3.0.tgz", + "integrity": "sha512-DNFDemicj3jXe5+Ib+5w9Bwj1U3yoHQkqn0bU/qysIl/p0MmGA1yqOfUF0V4fw/5or1dfCvStIA/oZxUcC+2pQ==", "dependencies": { "@quasar/ssl-certificate": "^1.0.0", "ci-info": "^3.8.0", diff --git a/src/components/ui/CardList2.vue b/src/components/ui/CardList2.vue new file mode 100644 index 000000000..0a9eb8c0b --- /dev/null +++ b/src/components/ui/CardList2.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/pages/InvoiceOut/InvoiceOutList.vue b/src/pages/InvoiceOut/InvoiceOutList.vue index 137dedba8..14df6769a 100644 --- a/src/pages/InvoiceOut/InvoiceOutList.vue +++ b/src/pages/InvoiceOut/InvoiceOutList.vue @@ -10,7 +10,7 @@ import { toDate, toCurrency } from 'src/filters/index'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import InvoiceOutFilter from './InvoiceOutFilter.vue'; import VnLv from 'src/components/ui/VnLv.vue'; -import CardList from 'src/components/ui/CardList.vue'; +import CardList2 from 'src/components/ui/CardList2.vue'; const stateStore = useStateStore(); const router = useRouter(); @@ -73,7 +73,7 @@ function viewSummary(id) { auto-load > From 505052d84dfd0955e249e9222c112221c9e2f538 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Thu, 16 Nov 2023 16:44:35 -0300 Subject: [PATCH 002/159] [WIP] global invoices --- package-lock.json | 12 +- src/composables/useState.js | 6 +- src/composables/useUserConfig.js | 15 +- src/i18n/en/index.js | 1 + src/i18n/es/index.js | 1 + src/pages/InvoiceOut/InvoiceOutGlobal.vue | 32 +++ src/pages/InvoiceOut/InvoiceOutGlobalForm.vue | 214 ++++++++++++++++++ src/router/modules/invoiceOut.js | 28 ++- src/services/InvoiceOut.service.js | 53 +++++ 9 files changed, 341 insertions(+), 21 deletions(-) create mode 100644 src/pages/InvoiceOut/InvoiceOutGlobal.vue create mode 100644 src/pages/InvoiceOut/InvoiceOutGlobalForm.vue create mode 100644 src/services/InvoiceOut.service.js diff --git a/package-lock.json b/package-lock.json index a3a9dcc63..c541ee00e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "salix-front", - "version": "23.40.01", + "version": "23.48.01", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "salix-front", - "version": "0.0.1", + "version": "23.48.01", "dependencies": { - "@quasar/cli": "^2.2.1", + "@quasar/cli": "^2.3.0", "@quasar/extras": "^1.16.4", "axios": "^1.4.0", "chromium": "^3.0.3", @@ -946,9 +946,9 @@ } }, "node_modules/@quasar/cli": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.2.1.tgz", - "integrity": "sha512-PMwJ76IeeNRRBw+08hUMjhqGC6JKJ/t1zIb+IOiyR5D4rkBR26Ha/Z46OD3KfwUprq4Q8s4ieB1+d3VY8FhPKg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.3.0.tgz", + "integrity": "sha512-DNFDemicj3jXe5+Ib+5w9Bwj1U3yoHQkqn0bU/qysIl/p0MmGA1yqOfUF0V4fw/5or1dfCvStIA/oZxUcC+2pQ==", "dependencies": { "@quasar/ssl-certificate": "^1.0.0", "ci-info": "^3.8.0", diff --git a/src/composables/useState.js b/src/composables/useState.js index f0ff830ab..1c797e992 100644 --- a/src/composables/useState.js +++ b/src/composables/useState.js @@ -8,6 +8,7 @@ const user = ref({ nickname: '', lang: '', darkMode: null, + companyFk: null, }); const roles = ref([]); @@ -23,6 +24,7 @@ export function useState() { nickname: user.value.nickname, lang: user.value.lang, darkMode: user.value.darkMode, + companyFk: user.value.companyFk, }; }); } @@ -34,6 +36,7 @@ export function useState() { nickname: data.nickname, lang: data.lang, darkMode: data.darkMode, + companyFk: data.companyFk, }; } @@ -59,7 +62,6 @@ export function useState() { delete state.value[name]; } - return { getUser, setUser, @@ -69,6 +71,6 @@ export function useState() { get, unset, drawer, - headerMounted + headerMounted, }; } diff --git a/src/composables/useUserConfig.js b/src/composables/useUserConfig.js index 767ffb54e..2a22ae339 100644 --- a/src/composables/useUserConfig.js +++ b/src/composables/useUserConfig.js @@ -5,10 +5,17 @@ export function useUserConfig() { const state = useState(); async function fetch() { - const { data } = await axios.get('UserConfigs/getUserConfig'); - const user = state.getUser().value; - user.darkMode = data.darkMode; - state.setUser(user); + try { + const { data } = await axios.get('UserConfigs/getUserConfig'); + const user = state.getUser().value; + user.darkMode = data.darkMode; + user.companyFk = data.companyFk; + state.setUser(user); + + return data; + } catch (error) { + console.error('Error fetching user config:', error); + } } return { diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 948332d46..5fec1bdc2 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -348,6 +348,7 @@ export default { pageTitles: { invoiceOuts: 'Invoices Out', list: 'List', + globalInvoicing: 'Global invoicing', createInvoiceOut: 'Create invoice out', summary: 'Summary', basicData: 'Basic Data', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 9b452ab22..671dfa3a4 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -348,6 +348,7 @@ export default { pageTitles: { invoiceOuts: 'Fact. emitidas', list: 'Listado', + globalInvoicing: 'Facturación global', createInvoiceOut: 'Crear fact. emitida', summary: 'Resumen', basicData: 'Datos básicos', diff --git a/src/pages/InvoiceOut/InvoiceOutGlobal.vue b/src/pages/InvoiceOut/InvoiceOutGlobal.vue new file mode 100644 index 000000000..6fb6e618a --- /dev/null +++ b/src/pages/InvoiceOut/InvoiceOutGlobal.vue @@ -0,0 +1,32 @@ + + + + + + + diff --git a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue new file mode 100644 index 000000000..6d29d9ba5 --- /dev/null +++ b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue @@ -0,0 +1,214 @@ + + + + + + { + "en": { + "invoiceDate": "Invoice date", + "maxShipped": "Max date", + "allClients": "All clients", + "oneClient": "One client", + "company": "Company", + "printer": "Printer", + "invoiceOut": "Invoice out", + "client": "Client" + }, + "es": { + "invoiceDate": "Fecha de factura", + "maxShipped": "Fecha límite", + "allClients": "Todos los clientes", + "oneClient": "Un solo cliente", + "company": "Empresa", + "printer": "Impresora", + "invoiceOut": "Facturar", + "client": "Cliente" + + } + } + diff --git a/src/router/modules/invoiceOut.js b/src/router/modules/invoiceOut.js index daf5041e9..e8e18a810 100644 --- a/src/router/modules/invoiceOut.js +++ b/src/router/modules/invoiceOut.js @@ -5,12 +5,12 @@ export default { name: 'InvoiceOut', meta: { title: 'invoiceOuts', - icon: 'vn:invoice-out' + icon: 'vn:invoice-out', }, component: RouterView, redirect: { name: 'InvoiceOutMain' }, menus: { - main: ['InvoiceOutList'], + main: ['InvoiceOutList', 'InvoiceOutGlobal'], card: [], }, children: [ @@ -28,8 +28,17 @@ export default { icon: 'view_list', }, component: () => import('src/pages/InvoiceOut/InvoiceOutList.vue'), - } - ] + }, + { + path: 'global-invoicing', + name: 'InvoiceOutGlobal', + meta: { + title: 'globalInvoicing', + icon: 'view_list', + }, + component: () => import('src/pages/InvoiceOut/InvoiceOutGlobal.vue'), + }, + ], }, { name: 'InvoiceOutCard', @@ -41,11 +50,12 @@ export default { name: 'InvoiceOutSummary', path: 'summary', meta: { - title: 'summary' + title: 'summary', }, - component: () => import('src/pages/InvoiceOut/Card/InvoiceOutSummary.vue'), - } - ] + component: () => + import('src/pages/InvoiceOut/Card/InvoiceOutSummary.vue'), + }, + ], }, - ] + ], }; diff --git a/src/services/InvoiceOut.service.js b/src/services/InvoiceOut.service.js new file mode 100644 index 000000000..b5f23869e --- /dev/null +++ b/src/services/InvoiceOut.service.js @@ -0,0 +1,53 @@ +import axios from 'axios'; + +const invoiceOutService = { + getInvoiceOutConfig: async (path = '', params) => { + try { + const { data } = await axios.get(path, { + params, + }); + + return data; + } catch (err) { + console.error('Error fetching invoice date'); + } + }, + + getCompanies: async (filter) => { + try { + const { data } = await axios.get('Companies', { + filter, + }); + + return data; + } catch (err) { + console.error('Error fetching companies'); + } + }, + + getPrinters: async (filter) => { + try { + const { data } = await axios.get('Printers', { + filter, + }); + + return data; + } catch (err) { + console.error('Error fetching printers'); + } + }, + + getClients: async (filter) => { + try { + const { data } = await axios.get('Clients', { + filter, + }); + + return data; + } catch (err) { + console.error('Error fetching clients'); + } + }, +}; + +export default invoiceOutService; From 97f732d3cf446f5c6bcc83560243d3f21c06911d Mon Sep 17 00:00:00 2001 From: Joel Crespo Date: Mon, 20 Nov 2023 13:06:14 -0300 Subject: [PATCH 003/159] wip --- package-lock.json | 12 +- src/i18n/en/index.js | 1 + src/i18n/es/index.js | 1 + .../InvoiceOut/InvoiceOutNegativeBases.vue | 104 ++++++++++++++++++ src/router/modules/invoiceOut.js | 13 ++- 5 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 src/pages/InvoiceOut/InvoiceOutNegativeBases.vue diff --git a/package-lock.json b/package-lock.json index a3a9dcc63..c541ee00e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "salix-front", - "version": "23.40.01", + "version": "23.48.01", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "salix-front", - "version": "0.0.1", + "version": "23.48.01", "dependencies": { - "@quasar/cli": "^2.2.1", + "@quasar/cli": "^2.3.0", "@quasar/extras": "^1.16.4", "axios": "^1.4.0", "chromium": "^3.0.3", @@ -946,9 +946,9 @@ } }, "node_modules/@quasar/cli": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.2.1.tgz", - "integrity": "sha512-PMwJ76IeeNRRBw+08hUMjhqGC6JKJ/t1zIb+IOiyR5D4rkBR26Ha/Z46OD3KfwUprq4Q8s4ieB1+d3VY8FhPKg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.3.0.tgz", + "integrity": "sha512-DNFDemicj3jXe5+Ib+5w9Bwj1U3yoHQkqn0bU/qysIl/p0MmGA1yqOfUF0V4fw/5or1dfCvStIA/oZxUcC+2pQ==", "dependencies": { "@quasar/ssl-certificate": "^1.0.0", "ci-info": "^3.8.0", diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 948332d46..f98c9a4bd 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -348,6 +348,7 @@ export default { pageTitles: { invoiceOuts: 'Invoices Out', list: 'List', + negativeBases: 'Negative Bases', createInvoiceOut: 'Create invoice out', summary: 'Summary', basicData: 'Basic Data', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 9b452ab22..cbe194865 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -348,6 +348,7 @@ export default { pageTitles: { invoiceOuts: 'Fact. emitidas', list: 'Listado', + negativeBases: 'Bases Negativas', createInvoiceOut: 'Crear fact. emitida', summary: 'Resumen', basicData: 'Datos básicos', diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue new file mode 100644 index 000000000..781996f7b --- /dev/null +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue @@ -0,0 +1,104 @@ + + + + + + + +es: + Search invoice: Buscar factura emitida + You can search by invoice reference: Puedes buscar por referencia de la factura + diff --git a/src/router/modules/invoiceOut.js b/src/router/modules/invoiceOut.js index daf5041e9..067c6be8f 100644 --- a/src/router/modules/invoiceOut.js +++ b/src/router/modules/invoiceOut.js @@ -10,7 +10,7 @@ export default { component: RouterView, redirect: { name: 'InvoiceOutMain' }, menus: { - main: ['InvoiceOutList'], + main: ['InvoiceOutList', 'InvoiceOutNegativeBases'], card: [], }, children: [ @@ -28,7 +28,16 @@ export default { icon: 'view_list', }, component: () => import('src/pages/InvoiceOut/InvoiceOutList.vue'), - } + }, + { + path: 'negative-bases', + name: 'InvoiceOutNegativeBases', + meta: { + title: 'negativeBases', + icon: 'view_list', + }, + component: () => import('src/pages/InvoiceOut/InvoiceOutNegativeBases.vue'), + }, ] }, { From c3b9f013f6a17fc585d952cd25475986f448a4a0 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 20 Nov 2023 14:58:41 -0300 Subject: [PATCH 004/159] form integration and view content --- src/composables/useNotify.js | 15 + src/i18n/en/index.js | 12 + src/i18n/es/index.js | 14 + src/pages/InvoiceOut/InvoiceOutGlobal.vue | 185 ++++++++++- src/pages/InvoiceOut/InvoiceOutGlobalForm.vue | 156 ++++------ src/services/InvoiceOut.service.js | 70 ++--- src/stores/invoiceOutGlobal.js | 286 ++++++++++++++++++ 7 files changed, 600 insertions(+), 138 deletions(-) create mode 100644 src/composables/useNotify.js create mode 100644 src/stores/invoiceOutGlobal.js diff --git a/src/composables/useNotify.js b/src/composables/useNotify.js new file mode 100644 index 000000000..30bb70b28 --- /dev/null +++ b/src/composables/useNotify.js @@ -0,0 +1,15 @@ +import { Notify } from 'quasar'; +import { i18n } from 'src/boot/i18n'; + +export default function useNotify() { + const notify = (message, type) => { + Notify.create({ + message: i18n.global.t(message), + type: type, + }); + }; + + return { + notify, + }; +} diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 5fec1bdc2..106bc1a6a 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -390,6 +390,18 @@ export default { shipped: 'Shipped', totalWithVat: 'Amount', }, + globalInvoices: { + errors: { + chooseValidClient: 'Choose a valid client', + chooseValidCompany: 'Choose a valid company', + chooseValidPrinter: 'Choose a valid printer', + fillDates: 'Invoice date and the max date should be filled', + invoiceDateLessThanMaxDate: "Invoice date can't be less than max date", + invoiceWithFutureDate: 'Exists an invoice with a future date', + noTicketsToInvoice: "There aren't clients to invoice", + criticalInvoiceError: 'Critical invoicing error, process stopped', + }, + }, }, worker: { pageTitles: { diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 671dfa3a4..c15d6e714 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -390,6 +390,20 @@ export default { shipped: 'F. envío', totalWithVat: 'Importe', }, + globalInvoices: { + errors: { + chooseValidClient: 'Selecciona un cliente válido', + chooseValidCompany: 'Selecciona una empresa válida', + chooseValidPrinter: 'Selecciona una impresora válida', + fillDates: + 'La fecha de la factura y la fecha máxima deben estar completas', + invoiceDateLessThanMaxDate: + 'La fecha de la factura no puede ser menor que la fecha máxima', + invoiceWithFutureDate: 'Existe una factura con una fecha futura', + noTicketsToInvoice: 'No hay clientes para facturar', + criticalInvoiceError: 'Error crítico en la facturación, proceso detenido', + }, + }, }, worker: { pageTitles: { diff --git a/src/pages/InvoiceOut/InvoiceOutGlobal.vue b/src/pages/InvoiceOut/InvoiceOutGlobal.vue index 6fb6e618a..2b260ae9e 100644 --- a/src/pages/InvoiceOut/InvoiceOutGlobal.vue +++ b/src/pages/InvoiceOut/InvoiceOutGlobal.vue @@ -1,17 +1,95 @@ - + + + + { + "en": { + "status": { + "packageInvoicing": "Build packaging tickets", + "invoicing": "Invoicing client", + "stopping": "Stopping process", + "done": "Ended process" + }, + "of": "of" + }, + "es": { + "status":{ + "packageInvoicing": "Generación de tickets de empaque", + "invoicing": "Facturando a cliente", + "stopping": "Deteniendo proceso", + "done": "Proceso detenido", + }, + "of": "de" + } + } + diff --git a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue index 6d29d9ba5..baa1b86ed 100644 --- a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue +++ b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue @@ -1,100 +1,60 @@ @@ -197,7 +170,8 @@ const makeInvoice = () => {}; "company": "Company", "printer": "Printer", "invoiceOut": "Invoice out", - "client": "Client" + "client": "Client", + "stop": "Stop" }, "es": { "invoiceDate": "Fecha de factura", @@ -207,8 +181,8 @@ const makeInvoice = () => {}; "company": "Empresa", "printer": "Impresora", "invoiceOut": "Facturar", - "client": "Cliente" - + "client": "Cliente", + "stop": "Parar" } } diff --git a/src/services/InvoiceOut.service.js b/src/services/InvoiceOut.service.js index b5f23869e..039943483 100644 --- a/src/services/InvoiceOut.service.js +++ b/src/services/InvoiceOut.service.js @@ -1,52 +1,52 @@ import axios from 'axios'; -const invoiceOutService = { - getInvoiceOutConfig: async (path = '', params) => { - try { - const { data } = await axios.get(path, { - params, - }); +const request = async (method, url, params = {}) => { + try { + let response; - return data; - } catch (err) { - console.error('Error fetching invoice date'); + if (method === 'GET') { + response = await axios.get(url, { params }); + } else if (method === 'POST') { + response = await axios.post(url, params); } + return response.data; + } catch (err) { + console.error(`Error with ${method} request to ${url}`, err); + return err.response; + } +}; + +const invoiceOutService = { + getInvoiceDate: async (params) => { + return await request('GET', 'InvoiceOuts/getInvoiceDate', params); + }, + + getFindOne: async (params) => { + return await request('GET', 'InvoiceOutConfigs/findOne', params); }, getCompanies: async (filter) => { - try { - const { data } = await axios.get('Companies', { - filter, - }); - - return data; - } catch (err) { - console.error('Error fetching companies'); - } + return await request('GET', 'Companies', { filter }); }, getPrinters: async (filter) => { - try { - const { data } = await axios.get('Printers', { - filter, - }); - - return data; - } catch (err) { - console.error('Error fetching printers'); - } + return await request('GET', 'Printers', { filter }); }, getClients: async (filter) => { - try { - const { data } = await axios.get('Clients', { - filter, - }); + return await request('GET', 'Clients', { filter }); + }, - return data; - } catch (err) { - console.error('Error fetching clients'); - } + getClientsToInvoice: async (params) => { + return await request('POST', 'InvoiceOuts/clientsToInvoice', params); + }, + + invoiceClient: async (params) => { + return await request('POST', 'InvoiceOuts/invoiceClient', params); + }, + + makePdfAndNotify: async (invoiceId, params) => { + return await request('POST', `InvoiceOuts/${invoiceId}/makePdfAndNotify`, params); }, }; diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js new file mode 100644 index 000000000..7223f7655 --- /dev/null +++ b/src/stores/invoiceOutGlobal.js @@ -0,0 +1,286 @@ +import { defineStore } from 'pinia'; +import { useUserConfig } from 'src/composables/useUserConfig'; +import invoiceOutService from 'src/services/InvoiceOut.service.js'; +import useNotify from 'src/composables/useNotify.js'; + +const { notify } = useNotify(); + +export const useInvoiceOutGlobalStore = defineStore({ + id: 'invoiceOutGlobal', + + state: () => ({ + initialDataLoading: true, + formInitialData: { + companyFk: null, + invoiceDate: null, + maxShipped: null, + clientId: null, + }, + clientsOptions: [], + companiesOptions: [], + printersOptions: [], + addresses: [], + minInvoicingDate: null, + parallelism: null, + invoicing: false, + isInvoicing: false, + status: null, + addressIndex: 0, + printer: null, + errors: [], + nRequests: 0, + nPdfs: 0, + totalPdfs: 0, + }), + actions: { + async init() { + await this.fetchAllData(); + }, + + async fetchAllData() { + try { + const userInfo = await useUserConfig().fetch(); + const date = Date.vnNew(); + this.formInitialData.maxShipped = new Date( + date.getFullYear(), + date.getMonth(), + 0 + ) + .toISOString() + .substring(0, 10); + + await Promise.all([ + this.fetchClients(), + this.fetchParallelism(), + this.fetchCompanies(userInfo.companyFk), + this.fetchPrinters(), + this.fetchInvoiceOutConfig(userInfo.companyFk), + ]); + + this.initialDataLoading = false; + } catch (err) { + console.error('Error fetching invoice out global initial data'); + } + }, + + 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) { + const params = { companyFk: companyFk }; + const { issued } = await invoiceOutService.getInvoiceDate(params); + + const stringDate = issued.substring(0, 10); + this.minInvoicingDate = stringDate; + this.formInitialData.invoiceDate = stringDate; + }, + + async fetchParallelism() { + const filter = { fields: ['parallelism'] }; + const { parallelism } = await invoiceOutService.getFindOne(filter); + this.parallelism = parallelism; + }, + + async makeInvoice(formData, clientsToInvoice) { + this.invoicing = true; + this.status = 'packageInvoicing'; + try { + const params = { + invoiceDate: new Date(formData.invoiceDate), + maxShipped: new Date(formData.maxShipped), + clientId: formData.clientId ? formData.clientId.value : null, + companyFk: formData.companyFk.value, + }; + + this.validateMakeInvoceParams(params, clientsToInvoice); + + if (clientsToInvoice == 'all') params.clientId = undefined; + + const addressesResponse = await invoiceOutService.getClientsToInvoice( + params + ); + + this.addresses = addressesResponse; + + if (!this.addresses || !this.addresses.length > 0) { + notify( + 'invoiceOut.globalInvoices.errors.noTicketsToInvoice', + 'negative' + ); + throw new Error("There aren't addresses to invoice"); + } + + this.addresses.forEach(async (address) => { + await this.invoiceClient(address, formData); + }); + } catch (err) { + this.handleError(err); + } + }, + + validateMakeInvoceParams(params, clientsToInvoice) { + if (clientsToInvoice === 'one' && !params.clientId) { + notify('invoiceOut.globalInvoices.errors.chooseValidClient', 'negative'); + throw new Error('Invalid client'); + } + if (!params.invoiceDate || !params.maxShipped) { + notify('invoiceOut.globalInvoices.errors.fillDates', 'negative'); + throw new Error('Missing dates'); + } + if (params.invoiceDate < params.maxShipped) { + notify( + 'invoiceOut.globalInvoices.errors.invoiceDateLessThanMaxDate', + 'negative' + ); + throw new Error('Invalid date range'); + } + + const invoiceDateTime = new Date(params.invoiceDate).getTime(); + const minInvoiceDateTime = new Date(this.minInvoicingDate).getTime(); + + if (this.minInvoicingDate && invoiceDateTime < minInvoiceDateTime) { + notify( + 'invoiceOut.globalInvoices.errors.invoiceWithFutureDate', + 'negative' + ); + throw new Error('Invoice date in the future'); + } + + if (!params.companyFk) { + notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative'); + throw new Error('Invalid company'); + } + if (!this.printer) { + notify('invoiceOut.globalInvoices.errors.chooseValidPrinter', 'negative'); + throw new Error('Invalid printer'); + } + }, + + async invoiceClient(address, formData) { + if (this.nRequests === this.parallelism || this.isInvoicing) return; + + if (this.status === 'stopping') { + if (this.nRequests) return; + this.invoicing = false; + this.status = 'done'; + return; + } + + const params = { + clientId: address.clientId, + addressId: address.id, + invoiceDate: new Date(formData.invoiceDate), + maxShipped: new Date(formData.maxShipped), + companyFk: formData.companyFk.value, + }; + + this.status = 'invoicing'; + this.invoicing = true; + + const invoiceResponse = await invoiceOutService.invoiceClient(params); + + if (invoiceResponse.data.error) { + if (invoiceResponse.status >= 400 && invoiceResponse.status < 500) { + this.invoiceClientError(address, invoiceResponse); + this.addressIndex++; + return; + } else { + this.invoicing = false; + this.status = 'done'; + notify( + 'invoiceOut.globalInvoices.errors.criticalInvoiceError', + 'negative' + ); + throw new Error('Critical invoicing error, process stopped'); + } + } else { + this.isInvoicing = false; + if (invoiceResponse.data) { + this.makePdfAndNotify(invoiceResponse.data, address); + } + } + }, + + async makePdfAndNotify(invoiceId, client) { + try { + this.nRequests++; + this.totalPdfs++; + const params = { printerFk: this.printer.value }; + await invoiceOutService.makePdfAndNotify(invoiceId, params); + this.nPdfs++; + this.nRequests--; + } catch (err) { + this.invoiceClientError(client, err, true); + } + }, + + invoiceClientError(client, response, isWarning) { + const message = response.data?.error?.message || response.message; + this.errors.unshift({ client, message, isWarning }); + }, + + handleError(err) { + this.invoicing = false; + this.status = null; + throw err; + }, + + // State mutations actions + + setPrinterValue(printer) { + this.printer = printer; + }, + + setStatusValue(status) { + this.status = status; + }, + }, + + getters: { + getNAddresses(state) { + return state.addresses.length; + }, + getPercentage(state) { + if (this.getNAdresses <= 0 || !state.addressIndex) { + return 0; + } + let porcentaje = (state.addressIndex / this.getNAddresses) * 100; + return porcentaje; + }, + getAddressNumber(state) { + return state.addressIndex; + }, + }, +}); From bcd3b2be93c2b658fba48258f63366d23434480e Mon Sep 17 00:00:00 2001 From: carlosfonseca Date: Tue, 21 Nov 2023 07:11:00 -0500 Subject: [PATCH 005/159] Se agrega un desplegable en el detalle de las tarjetas --- src/components/ui/CardDescriptor.vue | 54 +++++++++++++++++----------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index f63b75de6..a000bd1e4 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -52,6 +52,16 @@ watch($props, async () => { entity.value = null; await fetch(); }); + +const options = [ + 'Transferir factura a ...', + 'Ver factura ...', + 'Enviar factura ...', + 'Eliminar factura', + 'Asentar factura', + 'Regenerar PDF factura', + 'Abono ...', +]; - + From 737d3020febcf4c91357b4942f7186e992978701 Mon Sep 17 00:00:00 2001 From: carlosfonseca Date: Wed, 22 Nov 2023 09:33:47 -0500 Subject: [PATCH 009/159] Se hacen las mejoras en las tarjetas y menu lateral --- src/components/ui/CardList2.vue | 58 +++++++---- src/components/ui/VnFilterPanel.vue | 65 +++++++------ src/i18n/es/index.js | 4 +- src/pages/InvoiceOut/InvoiceOutFilter.vue | 113 +++++++++++++--------- src/pages/InvoiceOut/InvoiceOutList.vue | 8 +- 5 files changed, 143 insertions(+), 105 deletions(-) diff --git a/src/components/ui/CardList2.vue b/src/components/ui/CardList2.vue index 0a9eb8c0b..fd70a6854 100644 --- a/src/components/ui/CardList2.vue +++ b/src/components/ui/CardList2.vue @@ -4,65 +4,88 @@ const $props = defineProps({ title: { type: String, default: null }, }); + + @@ -77,9 +100,4 @@ const $props = defineProps({ .list-items { width: 75%; } -@media (max-width: $breakpoint-md) { - .actions { - margin-top: 30px; - } -} diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index d78c3ba13..3fd34fee3 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -106,6 +106,7 @@ function formatValue(value) { return `"${value}"`; } + -es: +es: No filters applied: No se han aplicado filtros Applied filters: Filtros aplicados Remove filters: Eliminar filtros diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index c15d6e714..ce9babcd3 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -526,8 +526,8 @@ export default { logOut: 'Cerrar sesión', }, smartCard: { - openCard: 'Ver ficha', - openSummary: 'Abrir detalles', + openCard: 'Ficha', + openSummary: 'Detalles', viewDescription: 'Ver descripción', }, cardDescriptor: { diff --git a/src/pages/InvoiceOut/InvoiceOutFilter.vue b/src/pages/InvoiceOut/InvoiceOutFilter.vue index 1ecaf828b..6711d17c6 100644 --- a/src/pages/InvoiceOut/InvoiceOutFilter.vue +++ b/src/pages/InvoiceOut/InvoiceOutFilter.vue @@ -43,66 +43,72 @@ function setWorkers(data) { - - - - - - - - - - - - - - - - + outlined + rounded + v-model="params.clientFk" + /> + + + + + + + + + + - - + /> - - + /> @@ -112,15 +118,18 @@ function setWorkers(data) {