From fb3f3c64c9c19baab8fee929ec8414485f82ee1b Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 19 Dec 2022 09:59:03 +0100 Subject: [PATCH 01/71] refs #4858 --- back/methods/chat/sendCheckingPresence.js | 4 +++- back/methods/chat/sendQueued.js | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429..5520abb7c 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -43,7 +43,7 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); - await models.Chat.create({ + const chat = await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, dated: new Date(), @@ -52,6 +52,8 @@ module.exports = Self => { status: 0, attempts: 0 }); + console.log(chat); + await models.Chat.sendQueued(chat.id); return true; }; diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index 66fbfcdc5..cbe963235 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -3,7 +3,11 @@ module.exports = Self => { Self.remoteMethodCtx('sendQueued', { description: 'Send a RocketChat message', accessType: 'WRITE', - accepts: [], + accepts: [{ + arg: 'id', + type: 'number', + description: 'The message id' + }], returns: { type: 'object', root: true @@ -14,17 +18,20 @@ module.exports = Self => { } }); - Self.sendQueued = async() => { + Self.sendQueued = async id => { const models = Self.app.models; const maxAttempts = 3; const sentStatus = 1; const errorStatus = 2; + let filter = { + status: {neq: sentStatus}, + attempts: {lt: maxAttempts} + }; + // NOTA: Igual se deberia transaccionar por si coincidiera que en el momento que se esta enviando directamente + // tambien se esta ejecutando la cola que no lo envie dos veces. const chats = await models.Chat.find({ - where: { - status: {neq: sentStatus}, - attempts: {lt: maxAttempts} - } + where: id ? {id} : filter }); for (let chat of chats) { From d85717ca0466fea7d7ab409fdbd9c630efa32ae8 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 4 Jan 2023 11:23:06 +0100 Subject: [PATCH 02/71] feat: chat in real time --- back/methods/chat/send.js | 2 +- back/methods/chat/sendCheckingPresence.js | 39 ++++++++++++++++++++--- back/methods/chat/sendQueued.js | 31 +++++++++--------- db/changes/230201/00-chatRefactor.sql | 16 ++++++++++ 4 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 db/changes/230201/00-chatRefactor.sql diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index c5c8feead..7fda97c82 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -36,7 +36,7 @@ module.exports = Self => { dated: new Date(), checkUserStatus: 0, message: message, - status: 0, + status: 'pending', attempts: 0 }); diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 5520abb7c..604c471d7 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -27,11 +27,17 @@ module.exports = Self => { Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { if (!recipientId) return false; + let tx; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + const models = Self.app.models; const userId = ctx.req.accessToken.userId; const sender = await models.Account.findById(userId); @@ -49,12 +55,37 @@ module.exports = Self => { dated: new Date(), checkUserStatus: 1, message: message, - status: 0, + status: 'sending', attempts: 0 - }); - console.log(chat); - await models.Chat.sendQueued(chat.id); + }, myOptions); + + try { + await Self.sendCheckingUserStatus(chat); + await updateChat(chat, 'sent', myOptions); + } catch (error) { + await updateChat(chat, 'error', error, myOptions); + } + + if (tx) await tx.commit(); return true; }; + + /** + * Update status and attempts of a chat + * + * @param {object} chat - The chat + * @param {string} status - The new status + * @param {string} error - The error + * @param {object} options - Query options + * @return {Promise} - The request promise + */ + + async function updateChat(chat, status, error, options) { + return chat.updateAttributes({ + status: status, + attempts: ++chat.attempts, + error: error + }, options); + } }; diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index cbe963235..dcd530873 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -3,11 +3,6 @@ module.exports = Self => { Self.remoteMethodCtx('sendQueued', { description: 'Send a RocketChat message', accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - description: 'The message id' - }], returns: { type: 'object', root: true @@ -18,20 +13,25 @@ module.exports = Self => { } }); - Self.sendQueued = async id => { + Self.sendQueued = async() => { const models = Self.app.models; const maxAttempts = 3; - const sentStatus = 1; - const errorStatus = 2; - let filter = { - status: {neq: sentStatus}, - attempts: {lt: maxAttempts} - }; + const sentStatus = 'sent'; + const sendingStatus = 'sending'; + const errorStatus = 'error'; - // NOTA: Igual se deberia transaccionar por si coincidiera que en el momento que se esta enviando directamente - // tambien se esta ejecutando la cola que no lo envie dos veces. const chats = await models.Chat.find({ - where: id ? {id} : filter + where: { + status: { + neq: { + and: [ + sentStatus, + sendingStatus + ] + } + }, + attempts: {lt: maxAttempts} + } }); for (let chat of chats) { @@ -137,6 +137,7 @@ module.exports = Self => { * @param {string} error - The error * @return {Promise} - The request promise */ + async function updateChat(chat, status, error) { return chat.updateAttributes({ status: status, diff --git a/db/changes/230201/00-chatRefactor.sql b/db/changes/230201/00-chatRefactor.sql new file mode 100644 index 000000000..66d1bf3bf --- /dev/null +++ b/db/changes/230201/00-chatRefactor.sql @@ -0,0 +1,16 @@ +ALTER TABLE `vn`.`chat` ADD statusNew enum('pending','sent','error','sending') DEFAULT 'pending' NOT NULL; + +UPDATE `vn`.`chat` + SET statusNew = 'pending' +WHERE status = 0; + +UPDATE `vn`.`chat` + SET statusNew = 'sent' +WHERE status = 1; + +UPDATE `vn`.`chat` + SET statusNew = 'error' +WHERE status = 2; + +ALTER TABLE `vn`.`chat` CHANGE status status__ tinyint(1) DEFAULT NULL NULL; +ALTER TABLE `vn`.`chat` CHANGE statusNew status enum('pending','sent','error','sending') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'pending' NOT NULL; From 44055775cb278ed4720d3008b7b89cef5ea11e92 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 6 Feb 2023 10:11:41 +0100 Subject: [PATCH 03/71] fix: not use variables and direct send in send --- back/methods/chat/send.js | 11 +++++++++-- back/methods/chat/sendQueued.js | 18 +++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 21e25c1f0..5e3821677 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -30,16 +30,23 @@ module.exports = Self => { const recipient = to.replace('@', ''); if (sender.name != recipient) { - await models.Chat.create({ + const chat = await models.Chat.create({ senderFk: sender.id, recipient: to, dated: Date.vnNew(), checkUserStatus: 0, message: message, - status: 'pending', + status: 'sending', attempts: 0 }); + try { + await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); + await updateChat(chat, 'sent'); + } catch (error) { + await updateChat(chat, 'error', error); + } + return true; } diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index dcd530873..ad8363627 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -15,22 +15,18 @@ module.exports = Self => { Self.sendQueued = async() => { const models = Self.app.models; - const maxAttempts = 3; - const sentStatus = 'sent'; - const sendingStatus = 'sending'; - const errorStatus = 'error'; const chats = await models.Chat.find({ where: { status: { neq: { and: [ - sentStatus, - sendingStatus + 'sent', + 'sending' ] } }, - attempts: {lt: maxAttempts} + attempts: {lt: 3} } }); @@ -38,16 +34,16 @@ module.exports = Self => { if (chat.checkUserStatus) { try { await Self.sendCheckingUserStatus(chat); - await updateChat(chat, sentStatus); + await updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, errorStatus, error); + await updateChat(chat, 'error', error); } } else { try { await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); - await updateChat(chat, sentStatus); + await updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, errorStatus, error); + await updateChat(chat, 'error', error); } } } From f06fc92ae80dd38cb9e4afcbd34ef75e3ba791fb Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Feb 2023 15:15:26 +0100 Subject: [PATCH 04/71] refactor(chat): not use transactions --- back/methods/chat/send.js | 4 +-- back/methods/chat/sendCheckingPresence.js | 43 ++++------------------- back/methods/chat/sendQueued.js | 7 ++-- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index 5e3821677..79b20e307 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -42,9 +42,9 @@ module.exports = Self => { try { await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); - await updateChat(chat, 'sent'); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error); + await Self.updateChat(chat, 'error', error); } return true; diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index cabd3d85e..3eaf6b86b 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -24,24 +24,13 @@ module.exports = Self => { } }); - Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { + Self.sendCheckingPresence = async(ctx, recipientId, message) => { if (!recipientId) return false; - let tx; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - const models = Self.app.models; const userId = ctx.req.accessToken.userId; - const sender = await models.Account.findById(userId); - const recipient = await models.Account.findById(recipientId, null, myOptions); + const sender = await models.Account.findById(userId, {fields: ['id']}); + const recipient = await models.Account.findById(recipientId, null); // Prevent sending messages to yourself if (recipientId == userId) return false; @@ -57,35 +46,15 @@ module.exports = Self => { message: message, status: 'sending', attempts: 0 - }, myOptions); + }); try { await Self.sendCheckingUserStatus(chat); - await updateChat(chat, 'sent', myOptions); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error, myOptions); + await Self.updateChat(chat, 'error', error); } - if (tx) await tx.commit(); - return true; }; - - /** - * Update status and attempts of a chat - * - * @param {object} chat - The chat - * @param {string} status - The new status - * @param {string} error - The error - * @param {object} options - Query options - * @return {Promise} - The request promise - */ - - async function updateChat(chat, status, error, options) { - return chat.updateAttributes({ - status: status, - attempts: ++chat.attempts, - error: error - }, options); - } }; diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index ad8363627..8a0bdee34 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -131,16 +131,17 @@ module.exports = Self => { * @param {object} chat - The chat * @param {string} status - The new status * @param {string} error - The error + * @param {object} options - Query options * @return {Promise} - The request promise - */ + */ - async function updateChat(chat, status, error) { + Self.updateChat = async(chat, status, error) => { return chat.updateAttributes({ status: status, attempts: ++chat.attempts, error: error }); - } + }; /** * Returns the current user status on Rocketchat From be1993cf8b04f89bd0e2fc185054f13d07a469c0 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 2 Mar 2023 11:33:55 +0100 Subject: [PATCH 05/71] refs #5206 version with top-searcher and two fields for reference and id --- front/core/styles/variables.scss | 1 + front/salix/components/layout/style.scss | 6 +- .../front/extra-community/locale/es.yml | 4 +- modules/travel/front/index/index.html | 27 +- modules/travel/front/locale/es.yml | 10 +- modules/travel/front/main/index.html | 3 +- modules/travel/front/search-panel/index.html | 299 +++++++++++------- modules/travel/front/search-panel/index.js | 42 ++- modules/travel/front/search-panel/style.scss | 42 +++ modules/travel/front/summary/locale/es.yml | 6 +- 10 files changed, 279 insertions(+), 161 deletions(-) create mode 100644 modules/travel/front/search-panel/style.scss diff --git a/front/core/styles/variables.scss b/front/core/styles/variables.scss index bcc9fab66..c280838ca 100644 --- a/front/core/styles/variables.scss +++ b/front/core/styles/variables.scss @@ -2,6 +2,7 @@ $font-size: 11pt; $menu-width: 256px; +$right-menu-width: 318px; $topbar-height: 56px; $mobile-width: 800px; $float-spacing: 20px; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 612366228..6697bb1b0 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -88,13 +88,13 @@ vn-layout { } &.right-menu { & > vn-topbar > .end { - width: 80px + $menu-width; + width: 80px + $right-menu-width; } & > .main-view { - padding-right: $menu-width; + padding-right: $right-menu-width; } [fixed-bottom-right] { - right: $menu-width; + right: $right-menu-width; } } & > .main-view { diff --git a/modules/travel/front/extra-community/locale/es.yml b/modules/travel/front/extra-community/locale/es.yml index dc231226f..ed6179c91 100644 --- a/modules/travel/front/extra-community/locale/es.yml +++ b/modules/travel/front/extra-community/locale/es.yml @@ -6,6 +6,6 @@ Phy. KG: KG físico Vol. KG: KG Vol. Search by travel id or reference: Buscar por id de travel o referencia Search by extra community travel: Buscar por envío extra comunitario -Continent Out: Continente salida +Continent Out: Cont. salida W. Shipped: F. envío -W. Landed: F. llegada \ No newline at end of file +W. Landed: F. llegada diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 27a700083..14faef3ee 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -2,6 +2,9 @@ + + @@ -9,7 +12,6 @@ - Id Reference Agency Warehouse Out @@ -22,10 +24,9 @@ - - {{::travel.id}} {{::travel.ref}} {{::travel.agencyModeName}} {{::travel.warehouseOutName}} @@ -49,7 +50,7 @@ vn-tooltip="Clone" icon="icon-clone"> - @@ -78,7 +79,7 @@ fixed-bottom-right> - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value - \ No newline at end of file + diff --git a/modules/travel/front/locale/es.yml b/modules/travel/front/locale/es.yml index 7231d37cd..043702b99 100644 --- a/modules/travel/front/locale/es.yml +++ b/modules/travel/front/locale/es.yml @@ -1,7 +1,7 @@ #Ordenar alfabeticamente Reference: Referencia -Warehouse Out: Almacén salida -Warehouse In: Almacén llegada +Warehouse Out: Alm salida +Warehouse In: Alm llegada Shipped from: Salida desde Shipped to: Salida hasta Landed from: Llegada desde @@ -10,12 +10,12 @@ Shipped: F. salida Landed: F. llegada Delivered: Enviado Received: Recibido -Travel id: Id envío -Search travels by id: Buscar envíos por identificador +Travel id: Id +Search travels by id: Buscar envíos por identificador o referencia New travel: Nuevo envío travel: envío # Sections Travels: Envíos Log: Historial -Thermographs: Termógrafos \ No newline at end of file +Thermographs: Termógrafos diff --git a/modules/travel/front/main/index.html b/modules/travel/front/main/index.html index feb1e8b01..acf1a1612 100644 --- a/modules/travel/front/main/index.html +++ b/modules/travel/front/main/index.html @@ -7,7 +7,6 @@ - \ No newline at end of file + diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index 2e9c796c3..26f6b96c6 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -1,109 +1,190 @@ -
-
- - - - - - - - - - - - - - - - -
- - - - - - Or - - - - - -
- - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + Or +
+ + + + +
+
+ + + + + + + + + + + + +
+ + {{$ctrl.$t('Reference')}}: {{$ctrl.filter.ref}} + + + {{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}} + + + {{$ctrl.$t('Travel id')}}: {{$ctrl.filter.id}} + + + {{$ctrl.$t('Agency')}}: {{agency.selection.name}} + + + {{$ctrl.$t('Continent Out')}}: {{continent.selection.name}} + + + {{$ctrl.$t('Shipped from')}}: {{$ctrl.filter.shippedFrom | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('Shipped to')}}: {{$ctrl.filter.shippedTo | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('Days onward')}}: {{$ctrl.filter.scopeDays}} + + + {{$ctrl.$t('Landed from')}}: {{$ctrl.filter.landedFrom | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('Landed to')}}: {{$ctrl.filter.landedTo | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}} + + + {{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}} + +
+
diff --git a/modules/travel/front/search-panel/index.js b/modules/travel/front/search-panel/index.js index 877d4f9d3..69d8dafcd 100644 --- a/modules/travel/front/search-panel/index.js +++ b/modules/travel/front/search-panel/index.js @@ -1,43 +1,37 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; +import './style.scss'; class Controller extends SearchPanel { constructor($, $element) { super($, $element); - this.filter = this.$.filter; } - get shippedFrom() { - return this._shippedFrom; - } - - set shippedFrom(value) { - this._shippedFrom = value; + changeShipped() { this.filter.scopeDays = null; + this.addFilters(); } - get shippedTo() { - return this._shippedTo; - } - - set shippedTo(value) { - this._shippedTo = value; - this.filter.scopeDays = null; - } - - get scopeDays() { - return this._scopeDays; - } - - set scopeDays(value) { - this._scopeDays = value; - + changeScopeDays() { this.filter.shippedFrom = null; this.filter.shippedTo = null; + this.addFilters(); + } + + addFilters() { + this.model.addFilter({}, this.filter); + } + + removeParamFilter(param) { + this.filter[param] = null; + this.addFilters(); } } ngModule.vnComponent('vnTravelSearchPanel', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + model: '<' + } }); diff --git a/modules/travel/front/search-panel/style.scss b/modules/travel/front/search-panel/style.scss new file mode 100644 index 000000000..4d08c1402 --- /dev/null +++ b/modules/travel/front/search-panel/style.scss @@ -0,0 +1,42 @@ +@import "variables"; + +vn-travel-search-panel vn-side-menu { + .menu { + min-width: $right-menu-width; + } + & > div { + .input { + padding-left: $spacing-md; + padding-right: $spacing-md; + border-color: $color-spacer; + border-bottom: $border-thin; + } + .horizontal { + padding-left: $spacing-md; + padding-right: $spacing-md; + grid-auto-flow: column; + grid-column-gap: $spacing-sm; + align-items: center; + } + .chips { + display: flex; + flex-wrap: wrap; + padding: $spacing-md; + overflow: hidden; + max-width: 100%; + border-color: $color-spacer; + } + + .or { + align-self: center; + font-weight: bold; + font-size: 26px; + color: $color-font-secondary; + } + + .scope-days{ + display: flex; + align-items: center; + } + } +} diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml index aa002fad0..aa6adc938 100644 --- a/modules/travel/front/summary/locale/es.yml +++ b/modules/travel/front/summary/locale/es.yml @@ -1,9 +1,9 @@ Reference: Referencia -Warehouse In: Almacén entrada -Warehouse Out: Almacén salida +Warehouse In: Alm. entrada +Warehouse Out: Alm. salida Shipped: F. envío Landed: F. entrega -Total entries: Entradas totales +Total entries: Ent. totales Delivered: Enviada Received: Recibida Agency: Agencia From dbe42e3bf4490ac60a8d4dc37ea982fb4bd5bc7c Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 2 Mar 2023 13:55:47 +0100 Subject: [PATCH 06/71] refs #5206 version with plane added, needs to implement general search --- front/core/locale/es.yml | 10 +++--- modules/travel/front/index/index.html | 27 +++++++++++--- modules/travel/front/index/index.js | 1 + modules/travel/front/index/style.scss | 11 ++++++ modules/travel/front/main/index.html | 13 ------- modules/travel/front/main/index.js | 22 ------------ modules/travel/front/search-panel/index.html | 37 ++++++-------------- modules/travel/front/search-panel/index.js | 31 ++++++++++++++++ 8 files changed, 82 insertions(+), 70 deletions(-) create mode 100644 modules/travel/front/index/style.scss diff --git a/front/core/locale/es.yml b/front/core/locale/es.yml index d849fcdd2..f654c61cf 100644 --- a/front/core/locale/es.yml +++ b/front/core/locale/es.yml @@ -26,7 +26,7 @@ Value should have at most %s characters: El valor debe tener un máximo de %s ca Enter a new search: Introduce una nueva búsqueda No results: Sin resultados Ups! It seems there was an error: ¡Vaya! Parece que ha habido un error -General search: Busqueda general +General search: Búsqueda general January: Enero February: Febrero March: Marzo @@ -42,9 +42,9 @@ December: Diciembre Monday: Lunes Tuesday: Martes Wednesday: Miércoles -Thursday: Jueves -Friday: Viernes -Saturday: Sábado +Thursday: Jueves +Friday: Viernes +Saturday: Sábado Sunday: Domingo Has delivery: Hay reparto Loading: Cargando @@ -63,4 +63,4 @@ Loading...: Cargando... No results found: Sin resultados No data: Sin datos Undo changes: Deshacer cambios -Load more results: Cargar más resultados \ No newline at end of file +Load more results: Cargar más resultados diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 14faef3ee..06acd92a1 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -5,6 +5,13 @@ + + @@ -16,10 +23,10 @@ Agency Warehouse Out Shipped - Delivered + Warehouse In Landed - Received + @@ -35,14 +42,26 @@ {{::travel.shipped | date:'dd/MM/yyyy'}} - + + + + {{::travel.warehouseInName}} {{::travel.landed | date:'dd/MM/yyyy'}} - + + + + - - - diff --git a/modules/travel/front/main/index.js b/modules/travel/front/main/index.js index fbaf78c16..6a153f21a 100644 --- a/modules/travel/front/main/index.js +++ b/modules/travel/front/main/index.js @@ -4,28 +4,6 @@ import ModuleMain from 'salix/components/module-main'; export default class Travel extends ModuleMain { constructor() { super(); - - this.filterParams = { - scopeDays: 1 - }; - } - - fetchParams($params) { - if (!Object.entries($params).length) - $params.scopeDays = 1; - - if (typeof $params.scopeDays === 'number') { - const shippedFrom = Date.vnNew(); - shippedFrom.setHours(0, 0, 0, 0); - - const shippedTo = new Date(shippedFrom.getTime()); - shippedTo.setDate(shippedTo.getDate() + $params.scopeDays); - shippedTo.setHours(23, 59, 59, 999); - - Object.assign($params, {shippedFrom, shippedTo}); - } - - return $params; } } diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index 26f6b96c6..d39f32a7d 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -1,23 +1,18 @@ + label="General search" + info="Search travels by id" + ng-model="$ctrl.search" + ng-keydown="$ctrl.onKeyPress($event, 'search')"> - - + ng-model="$ctrl.totalEntries" + ng-keydown="$ctrl.onKeyPress($event, 'totalEntries')"> @@ -61,12 +56,9 @@ label="Days onward" ng-model="$ctrl.filter.scopeDays" on-change="$ctrl.changeScopeDays()" - display-controls="true"> + display-controls="true" + info="Cannot choose a range of dates and days onward at the same time"> - - @@ -103,11 +95,11 @@
- {{$ctrl.$t('Reference')}}: {{$ctrl.filter.ref}} + Id/{{$ctrl.$t('Reference')}}: {{$ctrl.filter.search}} {{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}} - - {{$ctrl.$t('Travel id')}}: {{$ctrl.filter.id}} - Date: Thu, 2 Mar 2023 15:10:17 +0100 Subject: [PATCH 07/71] refs #5206 implemented general search, missing tests --- modules/travel/front/index/index.html | 3 +- modules/travel/front/main/index.js | 3 -- modules/travel/front/search-panel/index.js | 39 ++++++++-------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 06acd92a1..df7fd5611 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -9,8 +9,7 @@ vn-id="model" url="Travels/filter" limit="20" - order="shipped DESC, landed DESC" - auto-load="true"> + order="shipped DESC, landed DESC"> { + if (param) + this.checkJustOneResult(); + }); } removeParamFilter(param) { @@ -51,12 +36,16 @@ class Controller extends SearchPanel { } onKeyPress($event, param) { - console.log('event'); if ($event.key === 'Enter') { this.filter[param] = this[param]; - this.addFilters(); + this.addFilters(param === 'search'); } } + + checkJustOneResult() { + if (this.model._orgData.length === 1) + this.$state.go('travel.card.summary', {id: this.model._orgData[0].id}); + } } ngModule.vnComponent('vnTravelSearchPanel', { From f2bd0253e28222d2ab5f90931742a6f1a9c12af1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 6 Mar 2023 09:27:53 +0100 Subject: [PATCH 08/71] refs #5092 added unbilled tickets section --- db/changes/231001/.gitkeep | 0 db/changes/231001/00-unbilledTickets.sql | 3 + .../09-invoice-in/05_unbilled_tickets.spec.js | 29 +++++ loopback/locale/en.json | 8 +- loopback/locale/es.json | 3 +- modules/client/front/locale/es.yml | 3 +- .../invoice-in/specs/unbilledTickets.spec.js | 47 ++++++++ .../methods/invoice-in/unbilledTickets.js | 112 ++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.js | 1 + modules/invoiceIn/front/index.js | 1 + modules/invoiceIn/front/routes.json | 17 ++- .../front/unbilled-tickets/index.html | 104 ++++++++++++++++ .../invoiceIn/front/unbilled-tickets/index.js | 66 +++++++++++ .../front/unbilled-tickets/locale/es.yml | 1 + .../front/unbilled-tickets/style.scss | 7 ++ 15 files changed, 392 insertions(+), 10 deletions(-) delete mode 100644 db/changes/231001/.gitkeep create mode 100644 db/changes/231001/00-unbilledTickets.sql create mode 100644 e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js create mode 100644 modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js create mode 100644 modules/invoiceIn/front/unbilled-tickets/index.html create mode 100644 modules/invoiceIn/front/unbilled-tickets/index.js create mode 100644 modules/invoiceIn/front/unbilled-tickets/locale/es.yml create mode 100644 modules/invoiceIn/front/unbilled-tickets/style.scss diff --git a/db/changes/231001/.gitkeep b/db/changes/231001/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/231001/00-unbilledTickets.sql b/db/changes/231001/00-unbilledTickets.sql new file mode 100644 index 000000000..d0c3fbbcb --- /dev/null +++ b/db/changes/231001/00-unbilledTickets.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative'); diff --git a/e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js b/e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js new file mode 100644 index 000000000..dd75d0b49 --- /dev/null +++ b/e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js @@ -0,0 +1,29 @@ +import getBrowser from '../../helpers/puppeteer'; + +describe('InvoiceIn unbilled tickets path', () => { + let browser; + let page; + const httpRequests = []; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + page.on('request', req => { + if (req.url().includes(`InvoiceIns/unbilledTickets`)) + httpRequests.push(req.url()); + }); + await page.loginAndModule('administrative', 'invoiceIn'); + await page.accessToSection('invoiceIn.unbilled-tickets'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should show unbilled tickets in a date range', async() => { + const request = httpRequests.find(req => + req.includes(`from`) && req.includes(`to`)); + + expect(request).toBeDefined(); + }); +}); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index eeb25f75d..dbe25dea3 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -147,8 +147,10 @@ "Receipt's bank was not found": "Receipt's bank was not found", "This receipt was not compensated": "This receipt was not compensated", "Client's email was not found": "Client's email was not found", - "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}", + "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}", "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", - "It is not possible to modify cloned sales": "It is not possible to modify cloned sales" -} + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Valid priorities: 1,2,3": "Valid priorities: 1,2,3", + "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 507cc9003..563c24c05 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -266,5 +266,6 @@ "There is no assigned email for this client": "No hay correo asignado para este cliente", "This locker has already been assigned": "Esta taquilla ya ha sido asignada", "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº {{id}}", - "Not exist this branch": "La rama no existe" + "Not exist this branch": "La rama no existe", + "Insert a date range": "Inserte un rango de fechas" } diff --git a/modules/client/front/locale/es.yml b/modules/client/front/locale/es.yml index de4b91e0b..fe87b2362 100644 --- a/modules/client/front/locale/es.yml +++ b/modules/client/front/locale/es.yml @@ -63,4 +63,5 @@ Consumption: Consumo Compensation Account: Cuenta para compensar Amount to return: Cantidad a devolver Delivered amount: Cantidad entregada -Unpaid: Impagado \ No newline at end of file +Unpaid: Impagado +Unbilled tickets: Tickets sin facturar diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js new file mode 100644 index 000000000..07e320a9f --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js @@ -0,0 +1,47 @@ +const models = require('vn-loopback/server/server').models; + +describe('invoiceIn unbilledTickets()', () => { + it('should return all unbilled tickets in a date range', async() => { + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + const ctx = { + args: { + from: new Date().setMonth(new Date().getMonth() - 12), + to: new Date(), + filter: {} + } + }; + + try { + const result = await models.InvoiceIn.unbilledTickets(ctx, options); + + expect(result.length).toBeGreaterThan(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should throw an error if a date range is not in args', async() => { + let error; + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + const ctx = { + args: { + filter: {} + } + }; + + try { + await models.InvoiceIn.unbilledTickets(ctx, options); + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toEqual(`Insert a date range`); + }); +}); diff --git a/modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js b/modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js new file mode 100644 index 000000000..3c33c8337 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js @@ -0,0 +1,112 @@ +const UserError = require('vn-loopback/util/user-error'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethodCtx('unbilledTickets', { + description: 'Find all unbilled tickets', + accessType: 'READ', + accepts: [ + { + arg: 'from', + type: 'date', + description: 'From date' + }, + { + arg: 'to', + type: 'date', + description: 'To date' + }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string' + }, + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/unbilledTickets`, + verb: 'GET' + } + }); + + Self.unbilledTickets = async(ctx, options) => { + const conn = Self.dataSource.connector; + const args = ctx.args; + + if (!args.from || !args.to) + throw new UserError(`Insert a date range`); + + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const stmts = []; + let stmt; + stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket`); + + stmts.push(new ParameterizedSQL( + `CREATE TEMPORARY TABLE tmp.ticket + (KEY (ticketFk)) + ENGINE = MEMORY + SELECT id ticketFk + FROM ticket t + WHERE shipped BETWEEN ? AND ? + AND refFk IS NULL`, [args.from, args.to])); + stmts.push(`CALL vn.ticket_getTax(NULL)`); + stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.filter`); + stmts.push(new ParameterizedSQL( + `CREATE TEMPORARY TABLE tmp.filter + ENGINE = MEMORY + SELECT + co.code company, + cou.country, + c.id clientId, + c.socialName clientSocialName, + SUM(s.quantity * s.price * ( 100 - s.discount ) / 100) amount, + negativeBase.taxableBase, + negativeBase.ticketFk, + c.isActive, + c.hasToInvoice, + c.isTaxDataChecked, + w.id comercialId, + CONCAT(w.firstName, ' ', w.lastName) comercialName + FROM vn.ticket t + JOIN vn.company co ON co.id = t.companyFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.country cou ON cou.id = c.countryFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN ( + SELECT ticketFk, taxableBase + FROM tmp.ticketAmount + GROUP BY ticketFk + HAVING taxableBase < 0 + ) negativeBase ON negativeBase.ticketFk = t.id + WHERE t.shipped BETWEEN ? AND ? + AND t.refFk IS NULL + AND c.typeFk IN ('normal','trust') + GROUP BY t.clientFk + HAVING amount <> 0`, [args.from, args.to])); + + stmt = new ParameterizedSQL(` + SELECT f.* + FROM tmp.filter f`); + + stmt.merge(conn.makeWhere(args.filter.where)); + stmt.merge(conn.makeOrderBy(args.filter.order)); + + const ticketsIndex = stmts.push(stmt) - 1; + + stmts.push(`DROP TEMPORARY TABLE tmp.filter, tmp.ticket, tmp.ticketTax, tmp.ticketAmount`); + + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + + return ticketsIndex === 0 ? result : result[ticketsIndex]; + }; +}; + diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 95ccc7b20..05909680c 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -6,4 +6,5 @@ module.exports = Self => { require('../methods/invoice-in/getTotals')(Self); require('../methods/invoice-in/invoiceInPdf')(Self); require('../methods/invoice-in/invoiceInEmail')(Self); + require('../methods/invoice-in/unbilledTickets')(Self); }; diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 7b6d6a77c..00a8d2c58 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -13,3 +13,4 @@ import './dueDay'; import './intrastat'; import './create'; import './log'; +import './unbilled-tickets'; diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 4867b7db9..1fe1b3255 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -9,10 +9,8 @@ ], "menus": { "main": [ - { - "state": "invoiceIn.index", - "icon": "icon-invoice-in" - } + { "state": "invoiceIn.index", "icon": "icon-invoice-in"}, + { "state": "invoiceIn.unbilled-tickets", "icon": "icon-ticket"} ], "card": [ { @@ -54,6 +52,15 @@ "administrative" ] }, + { + "url": "/unbilled-tickets", + "state": "invoiceIn.unbilled-tickets", + "component": "vn-unbilled-tickets", + "description": "Unbilled tickets", + "acl": [ + "administrative" + ] + }, { "url": "/:id", "state": "invoiceIn.card", @@ -133,4 +140,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/modules/invoiceIn/front/unbilled-tickets/index.html b/modules/invoiceIn/front/unbilled-tickets/index.html new file mode 100644 index 000000000..57cfa5138 --- /dev/null +++ b/modules/invoiceIn/front/unbilled-tickets/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Company + + Country + + Id Client + + Client + + Amount + + Base + + Id Ticket + + Active + + Has To Invoice + + Verified data + + Id Comercial + + Comercial +
{{ticket.company | dashIfEmpty}}{{ticket.country | dashIfEmpty}}{{ticket.clientId | dashIfEmpty}}{{ticket.clientSocialName | dashIfEmpty}}{{ticket.amount | currency: 'EUR':2 | dashIfEmpty}}{{ticket.taxableBase | dashIfEmpty}}{{ticket.ticketFk | dashIfEmpty}} + + + + + + + + + {{ticket.comercialId | dashIfEmpty}}{{ticket.comercialName | dashIfEmpty}}
+
+
+
diff --git a/modules/invoiceIn/front/unbilled-tickets/index.js b/modules/invoiceIn/front/unbilled-tickets/index.js new file mode 100644 index 000000000..f71fd35b3 --- /dev/null +++ b/modules/invoiceIn/front/unbilled-tickets/index.js @@ -0,0 +1,66 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + const now = new Date(); + const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); + const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); + this.params = { + from: firstDayOfMonth, + to: lastDayOfMonth + }; + this.$checkAll = false; + + this.smartTableOptions = { + activeButtons: { + search: true, + }, columns: [ + { + field: 'isActive', + searchable: false + }, + { + field: 'hasToInvoice', + searchable: false + }, + { + field: 'isTaxDataChecked', + searchable: false + }, + ] + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'company': + return {'company': value}; + case 'country': + return {'country': value}; + case 'clientId': + return {'clientId': value}; + case 'clientSocialName': + return {'clientSocialName': value}; + case 'amount': + return {'amount': value}; + case 'taxableBase': + return {'taxableBase': value}; + case 'ticketFk': + return {'ticketFk': value}; + case 'comercialId': + return {'comercialId': value}; + case 'comercialName': + return {'comercialName': value}; + } + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnUnbilledTickets', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/invoiceIn/front/unbilled-tickets/locale/es.yml b/modules/invoiceIn/front/unbilled-tickets/locale/es.yml new file mode 100644 index 000000000..9c6c3d735 --- /dev/null +++ b/modules/invoiceIn/front/unbilled-tickets/locale/es.yml @@ -0,0 +1 @@ +Has To Invoice: Facturar diff --git a/modules/invoiceIn/front/unbilled-tickets/style.scss b/modules/invoiceIn/front/unbilled-tickets/style.scss new file mode 100644 index 000000000..ad74a0071 --- /dev/null +++ b/modules/invoiceIn/front/unbilled-tickets/style.scss @@ -0,0 +1,7 @@ +@import "./variables"; + +vn-unbilled-tickets { + vn-date-picker{ + padding-right: 5%; + } +} From 4e800a7a454022a58714da645a56e4fbf95283d9 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 6 Mar 2023 09:30:14 +0100 Subject: [PATCH 09/71] . --- loopback/locale/en.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index dbe25dea3..32b5e0168 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -150,7 +150,5 @@ "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº {{id}}", "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", - "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", - "Valid priorities: 1,2,3": "Valid priorities: 1,2,3", - "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº 2" -} \ No newline at end of file + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales" +} From 874fd0656c58730df7b5bef998cfe0a99972fd0c Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 10 Mar 2023 10:05:16 +0100 Subject: [PATCH 10/71] refs #5206 url gets params --- modules/travel/front/index/index.html | 2 + modules/travel/front/search-panel/index.html | 145 ++++++++----------- modules/travel/front/search-panel/index.js | 58 +++++--- modules/travel/front/search-panel/style.scss | 5 - 4 files changed, 95 insertions(+), 115 deletions(-) diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index df7fd5611..a6952321f 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -26,6 +26,7 @@ Warehouse In Landed + Total entries @@ -61,6 +62,7 @@ ng-class="{active: travel.isReceived}"> + {{::travel.totalEntries}} - - - - + on-change="$ctrl.applyFilters()"> - - - - - - - - - - - Or -
- - -
-
- - - - - + on-change="$ctrl.applyFilters()"> + on-change="$ctrl.applyFilters()"> + + + + + + + + + + + + + + + +
Id/{{$ctrl.$t('Reference')}}: {{$ctrl.filter.search}} - - {{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}} - {{$ctrl.$t('Agency')}}: {{agency.selection.name}} - {{$ctrl.$t('Continent Out')}}: {{continent.selection.name}} + {{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}} - {{$ctrl.$t('Shipped from')}}: {{$ctrl.filter.shippedFrom | date:'dd/MM/yyyy'}} - - - {{$ctrl.$t('Shipped to')}}: {{$ctrl.filter.shippedTo | date:'dd/MM/yyyy'}} + {{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}} {{$ctrl.$t('Landed to')}}: {{$ctrl.filter.landedTo | date:'dd/MM/yyyy'}} - {{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}} + {{$ctrl.$t('Continent Out')}}: {{continent.selection.name}} - {{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}} + {{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}}
diff --git a/modules/travel/front/search-panel/index.js b/modules/travel/front/search-panel/index.js index 8269a7d51..9cf417da1 100644 --- a/modules/travel/front/search-panel/index.js +++ b/modules/travel/front/search-panel/index.js @@ -5,47 +5,59 @@ import './style.scss'; class Controller extends SearchPanel { constructor($, $element) { super($, $element); - this.filter = { - scopeDays: 1, - }; + this.initFilter(); + this.fetchData(); } - changeShipped() { - this.filter.scopeDays = null; - this.addFilters(); + $onChanges() { + if (this.model) + this.applyFilters(); } - changeScopeDays() { - this.filter.shippedFrom = null; - this.filter.shippedTo = null; - this.addFilters(); + fetchData() { + this.$http.get('AgencyModes').then(res => { + this.agencyModes = res.data; + }); + this.$http.get('Warehouses').then(res => { + this.warehouses = res.data; + }); + this.$http.get('Continents').then(res => { + this.continents = res.data; + }); } - addFilters(param) { - this.model.addFilter({}, this.filter) + initFilter() { + this.filter = {}; + if (this.$params.q) { + this.filter = JSON.parse(this.$params.q); + this.search = this.filter.search; + this.totalEntries = this.filter.totalEntries; + } + if (!this.filter.scopeDays) this.filter.scopeDays = 7; + } + + applyFilters(param) { + this.model.applyFilter({}, this.filter) .then(() => { - if (param) - this.checkJustOneResult(); + if (param && this.model._orgData.length === 1) + this.$state.go('travel.card.summary', {id: this.model._orgData[0].id}); + else + this.$state.go(this.$state.current.name, {q: JSON.stringify(this.filter)}, {location: 'replace'}); }); } removeParamFilter(param) { - if (this[param]) this[param] = null; - this.filter[param] = null; - this.addFilters(); + if (this[param]) delete this[param]; + delete this.filter[param]; + this.applyFilters(); } onKeyPress($event, param) { if ($event.key === 'Enter') { this.filter[param] = this[param]; - this.addFilters(param === 'search'); + this.applyFilters(param === 'search'); } } - - checkJustOneResult() { - if (this.model._orgData.length === 1) - this.$state.go('travel.card.summary', {id: this.model._orgData[0].id}); - } } ngModule.vnComponent('vnTravelSearchPanel', { diff --git a/modules/travel/front/search-panel/style.scss b/modules/travel/front/search-panel/style.scss index 4d08c1402..94fe7b239 100644 --- a/modules/travel/front/search-panel/style.scss +++ b/modules/travel/front/search-panel/style.scss @@ -33,10 +33,5 @@ vn-travel-search-panel vn-side-menu { font-size: 26px; color: $color-font-secondary; } - - .scope-days{ - display: flex; - align-items: center; - } } } From c4d6a19666f5ebdfe8af2390ca4574d777fc606e Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 10 Mar 2023 12:49:20 +0100 Subject: [PATCH 11/71] refs #5092 download as csv button --- db/changes/231001/00-unbilledTickets.sql | 3 +- .../methods/invoice-in/unbilledTicketsCsv.js | 53 +++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.js | 1 + .../front/unbilled-tickets/index.html | 28 ++++++---- .../invoiceIn/front/unbilled-tickets/index.js | 24 ++++++++- .../front/unbilled-tickets/locale/es.yml | 13 +++++ .../front/unbilled-tickets/style.scss | 3 ++ 7 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js diff --git a/db/changes/231001/00-unbilledTickets.sql b/db/changes/231001/00-unbilledTickets.sql index d0c3fbbcb..3d2bc562b 100644 --- a/db/changes/231001/00-unbilledTickets.sql +++ b/db/changes/231001/00-unbilledTickets.sql @@ -1,3 +1,4 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative'); + ('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'unbilledTicketsCsv', 'READ', 'ALLOW', 'ROLE', 'administrative'); diff --git a/modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js b/modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js new file mode 100644 index 000000000..bd6bb8d36 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js @@ -0,0 +1,53 @@ +const {toCSV} = require('vn-loopback/util/csv'); + +module.exports = Self => { + Self.remoteMethodCtx('unbilledTicketsCsv', { + description: 'Returns the unbilled tickets as .csv', + accessType: 'READ', + accepts: [{ + arg: 'unbilledTickets', + type: ['object'], + required: true + }, + { + arg: 'from', + type: 'date', + description: 'From date' + }, + { + arg: 'to', + type: 'date', + description: 'To date' + }], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/unbilledTicketsCsv', + verb: 'GET' + } + }); + + Self.unbilledTicketsCsv = async ctx => { + const args = ctx.args; + const content = toCSV(args.unbilledTickets); + + return [ + content, + 'text/csv', + `attachment; filename="unbilled-tickets-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"` + ]; + }; +}; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 05909680c..bdd9e1b11 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -7,4 +7,5 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInPdf')(Self); require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/unbilledTickets')(Self); + require('../methods/invoice-in/unbilledTicketsCsv')(Self); }; diff --git a/modules/invoiceIn/front/unbilled-tickets/index.html b/modules/invoiceIn/front/unbilled-tickets/index.html index 57cfa5138..eb669a015 100644 --- a/modules/invoiceIn/front/unbilled-tickets/index.html +++ b/modules/invoiceIn/front/unbilled-tickets/index.html @@ -13,17 +13,23 @@ expr-builder="$ctrl.exprBuilder(param, value)"> - - - + vn-one + label="From" + ng-model="$ctrl.params.from" + on-change="model.refresh()"> + + + + + diff --git a/modules/invoiceIn/front/unbilled-tickets/index.js b/modules/invoiceIn/front/unbilled-tickets/index.js index f71fd35b3..4d99257a7 100644 --- a/modules/invoiceIn/front/unbilled-tickets/index.js +++ b/modules/invoiceIn/front/unbilled-tickets/index.js @@ -3,8 +3,10 @@ import Section from 'salix/components/section'; import './style.scss'; export default class Controller extends Section { - constructor($element, $) { + constructor($element, $, vnReport) { super($element, $); + + this.vnReport = vnReport; const now = new Date(); const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); @@ -56,9 +58,27 @@ export default class Controller extends Section { return {'comercialName': value}; } } + + downloadCSV() { + const data = []; + this.$.model._orgData.forEach(element => { + data.push(Object.keys(element).map(key => { + return {newName: this.$t(key), value: element[key]}; + }).filter(item => item !== null) + .reduce((result, item) => { + result[item.newName] = item.value; + return result; + }, {})); + }); + this.vnReport.show('InvoiceIns/unbilledTicketsCsv', { + unbilledTickets: data, + from: this.params.from, + to: this.params.to + }); + } } -Controller.$inject = ['$element', '$scope']; +Controller.$inject = ['$element', '$scope', 'vnReport']; ngModule.vnComponent('vnUnbilledTickets', { template: require('./index.html'), diff --git a/modules/invoiceIn/front/unbilled-tickets/locale/es.yml b/modules/invoiceIn/front/unbilled-tickets/locale/es.yml index 9c6c3d735..9095eee22 100644 --- a/modules/invoiceIn/front/unbilled-tickets/locale/es.yml +++ b/modules/invoiceIn/front/unbilled-tickets/locale/es.yml @@ -1 +1,14 @@ Has To Invoice: Facturar +Download as CSV: Descargar como CSV +company: Compañía +country: País +clientId: Id Cliente +clientSocialName: Cliente +amount: Importe +taxableBase: Base +ticketFk: Id Ticket +isActive: Activo +hasToInvoice: Facturar +isTaxDataChecked: Datos comprobados +comercialId: Id Comercial +comercialName: Comercial diff --git a/modules/invoiceIn/front/unbilled-tickets/style.scss b/modules/invoiceIn/front/unbilled-tickets/style.scss index ad74a0071..555b25fa9 100644 --- a/modules/invoiceIn/front/unbilled-tickets/style.scss +++ b/modules/invoiceIn/front/unbilled-tickets/style.scss @@ -4,4 +4,7 @@ vn-unbilled-tickets { vn-date-picker{ padding-right: 5%; } + slot-actions{ + align-items: center; + } } From 0248c3c9e0eda364db04d4b20537b4b868faa798 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 13 Mar 2023 07:34:49 +0100 Subject: [PATCH 12/71] refs #5056 models and tables added --- db/changes/231001/.gitkeep | 0 db/changes/231001/00-wagon.sql | 67 +++++++++++++++++++ modules/wagon/back/model-config.json | 23 +++++++ .../wagon/back/models/collectionWagon.json | 34 ++++++++++ .../back/models/collectionWagonTicket.json | 43 ++++++++++++ modules/wagon/back/models/wagon.json | 31 +++++++++ modules/wagon/back/models/wagonConfig.json | 30 +++++++++ modules/wagon/back/models/wagonType.json | 18 +++++ modules/wagon/back/models/wagonTypeColor.json | 21 ++++++ modules/wagon/back/models/wagonTypeTray.json | 36 ++++++++++ 10 files changed, 303 insertions(+) delete mode 100644 db/changes/231001/.gitkeep create mode 100644 db/changes/231001/00-wagon.sql create mode 100644 modules/wagon/back/model-config.json create mode 100644 modules/wagon/back/models/collectionWagon.json create mode 100644 modules/wagon/back/models/collectionWagonTicket.json create mode 100644 modules/wagon/back/models/wagon.json create mode 100644 modules/wagon/back/models/wagonConfig.json create mode 100644 modules/wagon/back/models/wagonType.json create mode 100644 modules/wagon/back/models/wagonTypeColor.json create mode 100644 modules/wagon/back/models/wagonTypeTray.json diff --git a/db/changes/231001/.gitkeep b/db/changes/231001/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/231001/00-wagon.sql b/db/changes/231001/00-wagon.sql new file mode 100644 index 000000000..cd945cc46 --- /dev/null +++ b/db/changes/231001/00-wagon.sql @@ -0,0 +1,67 @@ +CREATE TABLE `vn`.`wagonType` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL UNIQUE, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; + +CREATE TABLE `vn`.`wagonTypeColor` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL UNIQUE, + `rgb` varchar(30) NOT NULL UNIQUE, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; + +CREATE TABLE `vn`.`wagonTypeTray` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `typeFk` int(11) unsigned, + `height` int(11) unsigned, + `colorFk` int(11) unsigned, + PRIMARY KEY (`id`), + UNIQUE KEY (`typeFk`,`height`), + CONSTRAINT `wagonTypeTray_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `wagonTypeTray_color` FOREIGN KEY (`colorFk`) REFERENCES `wagonTypeColor` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; + +CREATE TABLE `vn`.`wagonConfig` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `width` int(11) unsigned DEFAULT 1350, + `height` int(11) unsigned DEFAULT 1900, + `trayStep` int(11) unsigned DEFAULT 50, + `minTrayHeight` int(11) unsigned DEFAULT 200, + `maxTrays` int(11) unsigned DEFAULT 6, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; + +CREATE TABLE `vn`.`collectionWagon` ( + `collectionFk` int(11) NOT NULL, + `wagonFk` int(11) NOT NULL, + `position` int(11) unsigned, + PRIMARY KEY (`collectionFk`,`position`), + UNIQUE KEY `collectionWagon_unique` (`collectionFk`,`wagonFk`), + CONSTRAINT `collectionWagon_collection` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagon_wagon` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +CREATE TABLE `vn`.`collectionWagonTicket` ( + `ticketFk` int(11) NOT NULL, + `wagonFk` int(11) NOT NULL, + `trayFk` int(11) unsigned NOT NULL, + `side` SET('L', 'R') NULL, + PRIMARY KEY (`ticketFk`), + CONSTRAINT `collectionWagonTicket_ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagonTicket_wagon` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE, + CONSTRAINT `collectionWagonTicket_tray` FOREIGN KEY (`trayFk`) REFERENCES `wagonTypeTray` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +ALTER TABLE `vn`.`wagon` ADD `typeFk` int(11) unsigned DEFAULT NULL; +ALTER TABLE `vn`.`wagon` ADD CONSTRAINT `wagon_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('WagonType', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonTypeColor', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonTypeTray', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonConfig', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('CollectionWagon', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('CollectionWagonTicket', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('Wagon', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/wagon/back/model-config.json b/modules/wagon/back/model-config.json new file mode 100644 index 000000000..279d55e5c --- /dev/null +++ b/modules/wagon/back/model-config.json @@ -0,0 +1,23 @@ +{ + "Wagon": { + "dataSource": "vn" + }, + "WagonType": { + "dataSource": "vn" + }, + "WagonTypeColor": { + "dataSource": "vn" + }, + "WagonTypeTray": { + "dataSource": "vn" + }, + "WagonConfig": { + "dataSource": "vn" + }, + "CollectionWagon": { + "dataSource": "vn" + }, + "CollectionWagonTicket": { + "dataSource": "vn" + } +} diff --git a/modules/wagon/back/models/collectionWagon.json b/modules/wagon/back/models/collectionWagon.json new file mode 100644 index 000000000..f3f237428 --- /dev/null +++ b/modules/wagon/back/models/collectionWagon.json @@ -0,0 +1,34 @@ +{ + "name": "CollectionWagon", + "base": "VnModel", + "options": { + "mysql": { + "table": "collectionWagon" + } + }, + "properties": { + "collectionFk": { + "id": true, + "type": "number" + }, + "wagonFk": { + "type": "number", + "required": true + }, + "position": { + "type": "number" + } + }, + "relations": { + "collection": { + "type": "belongsTo", + "model": "Collection", + "foreignKey": "collectionFk" + }, + "wagon": { + "type": "belongsTo", + "model": "Wagon", + "foreignKey": "wagonFk" + } + } +} diff --git a/modules/wagon/back/models/collectionWagonTicket.json b/modules/wagon/back/models/collectionWagonTicket.json new file mode 100644 index 000000000..04527205c --- /dev/null +++ b/modules/wagon/back/models/collectionWagonTicket.json @@ -0,0 +1,43 @@ +{ + "name": "CollectionWagonTicket", + "base": "VnModel", + "options": { + "mysql": { + "table": "collectionWagonTicket" + } + }, + "properties": { + "ticketFk": { + "id": true, + "type": "number" + }, + "wagonFk": { + "type": "number", + "required": true + }, + "trayFk": { + "type": "number", + "required": true + }, + "side": { + "type": "string" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "wagon": { + "type": "belongsTo", + "model": "Wagon", + "foreignKey": "wagonFk" + }, + "tray": { + "type": "belongsTo", + "model": "WagonTypeTray", + "foreignKey": "trayFk" + } + } +} diff --git a/modules/wagon/back/models/wagon.json b/modules/wagon/back/models/wagon.json new file mode 100644 index 000000000..81b9f23e6 --- /dev/null +++ b/modules/wagon/back/models/wagon.json @@ -0,0 +1,31 @@ +{ + "name": "Wagon", + "base": "VnModel", + "options": { + "mysql": { + "table": "wagon" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "volume": { + "type": "number" + }, + "plate": { + "type": "string" + }, + "typeFk": { + "type": "number" + } + }, + "relations": { + "type": { + "type": "belongsTo", + "model": "WagonType", + "foreignKey": "typeFk" + } + } +} diff --git a/modules/wagon/back/models/wagonConfig.json b/modules/wagon/back/models/wagonConfig.json new file mode 100644 index 000000000..ee33f312e --- /dev/null +++ b/modules/wagon/back/models/wagonConfig.json @@ -0,0 +1,30 @@ +{ + "name": "WagonConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "wagonConfig" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "width": { + "type": "number" + }, + "height": { + "type": "string" + }, + "trayStep": { + "type": "number" + }, + "minTrayHeight": { + "type": "number" + }, + "maxTrays": { + "type": "number" + } + } +} diff --git a/modules/wagon/back/models/wagonType.json b/modules/wagon/back/models/wagonType.json new file mode 100644 index 000000000..feb8d046c --- /dev/null +++ b/modules/wagon/back/models/wagonType.json @@ -0,0 +1,18 @@ +{ + "name": "WagonType", + "base": "VnModel", + "options": { + "mysql": { + "table": "wagonType" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "name": { + "type": "string" + } + } +} diff --git a/modules/wagon/back/models/wagonTypeColor.json b/modules/wagon/back/models/wagonTypeColor.json new file mode 100644 index 000000000..573fd60f5 --- /dev/null +++ b/modules/wagon/back/models/wagonTypeColor.json @@ -0,0 +1,21 @@ +{ + "name": "WagonTypeColor", + "base": "VnModel", + "options": { + "mysql": { + "table": "wagonTypeColor" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "name": { + "type": "string" + }, + "rgb": { + "type": "string" + } + } +} diff --git a/modules/wagon/back/models/wagonTypeTray.json b/modules/wagon/back/models/wagonTypeTray.json new file mode 100644 index 000000000..b61510bcf --- /dev/null +++ b/modules/wagon/back/models/wagonTypeTray.json @@ -0,0 +1,36 @@ +{ + "name": "WagonTypeTray", + "base": "VnModel", + "options": { + "mysql": { + "table": "wagonTypeTray" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "typeFk": { + "type": "number" + }, + "height": { + "type": "number" + }, + "colorFk": { + "type": "number" + } + }, + "relations": { + "type": { + "type": "belongsTo", + "model": "WagonType", + "foreignKey": "typeFk" + }, + "color": { + "type": "belongsTo", + "model": "WagonTypeColor", + "foreignKey": "colorFk" + } + } +} From 6a2542758b70bb33495c40a376b194e8e1411214 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 15 Mar 2023 10:29:44 +0100 Subject: [PATCH 13/71] refs #5056 added fixtures --- modules/item/front/diary/index.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 0f00f5854..e29e76afa 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -16,15 +16,15 @@ - - + + @@ -44,7 +44,7 @@ - {{::sale.shipped | date:'dd/MM/yyyy' }} @@ -99,13 +99,13 @@ - - - From 53bca1e8a302d1939f39d2b80a93644a431954b7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 15 Mar 2023 11:36:10 +0100 Subject: [PATCH 14/71] refs #5056 added fixtures --- db/dump/fixtures.sql | 11 +++++++++++ modules/item/front/diary/index.html | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 80983a318..488285b6b 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2821,4 +2821,15 @@ INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `create (1, 1, util.VN_NOW()), (3, 3, util.VN_NOW()); +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `trayStep`, `minTrayHeight`, `maxTrays`) + VALUES + (1, 1350, 1900, 50, 200, 6); + + +INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) + VALUES + (1, 'red', '#ff0000'), + (2, 'green', '#00ff00'), + (3, 'blue', '#0000ff'); + diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index e29e76afa..0f00f5854 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -16,15 +16,15 @@ - - + + @@ -44,7 +44,7 @@ - {{::sale.shipped | date:'dd/MM/yyyy' }} @@ -99,13 +99,13 @@ - - - From f706b66efcb270f37f17cffcfa4f046eb234702c Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 15 Mar 2023 11:57:09 +0100 Subject: [PATCH 15/71] refs #5056 added divisible in wagonType --- db/changes/231001/00-wagon.sql | 4 ++-- db/dump/fixtures.sql | 4 ++-- ...ollectionWagonTicket.json => collection-wagon-ticket.json} | 0 .../models/{collectionWagon.json => collection-wagon.json} | 0 .../wagon/back/models/{wagonConfig.json => wagon-config.json} | 3 --- .../models/{wagonTypeColor.json => wagon-type-color.json} | 0 .../back/models/{wagonTypeTray.json => wagon-type-tray.json} | 0 modules/wagon/back/models/{wagonType.json => wagon-type.json} | 3 +++ 8 files changed, 7 insertions(+), 7 deletions(-) rename modules/wagon/back/models/{collectionWagonTicket.json => collection-wagon-ticket.json} (100%) rename modules/wagon/back/models/{collectionWagon.json => collection-wagon.json} (100%) rename modules/wagon/back/models/{wagonConfig.json => wagon-config.json} (88%) rename modules/wagon/back/models/{wagonTypeColor.json => wagon-type-color.json} (100%) rename modules/wagon/back/models/{wagonTypeTray.json => wagon-type-tray.json} (100%) rename modules/wagon/back/models/{wagonType.json => wagon-type.json} (82%) diff --git a/db/changes/231001/00-wagon.sql b/db/changes/231001/00-wagon.sql index cd945cc46..5249c1faf 100644 --- a/db/changes/231001/00-wagon.sql +++ b/db/changes/231001/00-wagon.sql @@ -1,6 +1,7 @@ CREATE TABLE `vn`.`wagonType` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL UNIQUE, + `divisible` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; @@ -26,8 +27,7 @@ CREATE TABLE `vn`.`wagonConfig` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `width` int(11) unsigned DEFAULT 1350, `height` int(11) unsigned DEFAULT 1900, - `trayStep` int(11) unsigned DEFAULT 50, - `minTrayHeight` int(11) unsigned DEFAULT 200, + `minTrayHeight` int(11) unsigned DEFAULT 50, `maxTrays` int(11) unsigned DEFAULT 6, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 488285b6b..302d16d76 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2821,9 +2821,9 @@ INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `create (1, 1, util.VN_NOW()), (3, 3, util.VN_NOW()); -INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `trayStep`, `minTrayHeight`, `maxTrays`) +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `minTrayHeight`, `maxTrays`) VALUES - (1, 1350, 1900, 50, 200, 6); + (1, 1350, 1900, 50, 6); INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) diff --git a/modules/wagon/back/models/collectionWagonTicket.json b/modules/wagon/back/models/collection-wagon-ticket.json similarity index 100% rename from modules/wagon/back/models/collectionWagonTicket.json rename to modules/wagon/back/models/collection-wagon-ticket.json diff --git a/modules/wagon/back/models/collectionWagon.json b/modules/wagon/back/models/collection-wagon.json similarity index 100% rename from modules/wagon/back/models/collectionWagon.json rename to modules/wagon/back/models/collection-wagon.json diff --git a/modules/wagon/back/models/wagonConfig.json b/modules/wagon/back/models/wagon-config.json similarity index 88% rename from modules/wagon/back/models/wagonConfig.json rename to modules/wagon/back/models/wagon-config.json index ee33f312e..8bad354f7 100644 --- a/modules/wagon/back/models/wagonConfig.json +++ b/modules/wagon/back/models/wagon-config.json @@ -17,9 +17,6 @@ "height": { "type": "string" }, - "trayStep": { - "type": "number" - }, "minTrayHeight": { "type": "number" }, diff --git a/modules/wagon/back/models/wagonTypeColor.json b/modules/wagon/back/models/wagon-type-color.json similarity index 100% rename from modules/wagon/back/models/wagonTypeColor.json rename to modules/wagon/back/models/wagon-type-color.json diff --git a/modules/wagon/back/models/wagonTypeTray.json b/modules/wagon/back/models/wagon-type-tray.json similarity index 100% rename from modules/wagon/back/models/wagonTypeTray.json rename to modules/wagon/back/models/wagon-type-tray.json diff --git a/modules/wagon/back/models/wagonType.json b/modules/wagon/back/models/wagon-type.json similarity index 82% rename from modules/wagon/back/models/wagonType.json rename to modules/wagon/back/models/wagon-type.json index feb8d046c..f57bf957d 100644 --- a/modules/wagon/back/models/wagonType.json +++ b/modules/wagon/back/models/wagon-type.json @@ -13,6 +13,9 @@ }, "name": { "type": "string" + }, + "divisible": { + "type": "boolean" } } } From 6609cce06521d4843f4d586a0d89dfafa737b23f Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 15 Mar 2023 12:14:58 +0100 Subject: [PATCH 16/71] refs #5056 minHeightBetweenTrays --- db/changes/231001/00-wagon.sql | 3 ++- db/dump/fixtures.sql | 5 +++-- modules/wagon/back/models/wagon-config.json | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/db/changes/231001/00-wagon.sql b/db/changes/231001/00-wagon.sql index 5249c1faf..c7725ab4f 100644 --- a/db/changes/231001/00-wagon.sql +++ b/db/changes/231001/00-wagon.sql @@ -27,7 +27,8 @@ CREATE TABLE `vn`.`wagonConfig` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `width` int(11) unsigned DEFAULT 1350, `height` int(11) unsigned DEFAULT 1900, - `minTrayHeight` int(11) unsigned DEFAULT 50, + `maxWagonHeight` int(11) unsigned DEFAULT 200, + `minHeightBetweenTrays` int(11) unsigned DEFAULT 50, `maxTrays` int(11) unsigned DEFAULT 6, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 302d16d76..45f90359e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2821,9 +2821,10 @@ INSERT INTO `vn`.`deviceProductionUser` (`deviceProductionFk`, `userFk`, `create (1, 1, util.VN_NOW()), (3, 3, util.VN_NOW()); -INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `minTrayHeight`, `maxTrays`) +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`) VALUES - (1, 1350, 1900, 50, 6); + (1, 1350, 1900, 200, 50, 6); + INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) diff --git a/modules/wagon/back/models/wagon-config.json b/modules/wagon/back/models/wagon-config.json index 8bad354f7..3d96e2864 100644 --- a/modules/wagon/back/models/wagon-config.json +++ b/modules/wagon/back/models/wagon-config.json @@ -17,7 +17,10 @@ "height": { "type": "string" }, - "minTrayHeight": { + "maxWagonHeight": { + "type": "number" + }, + "minHeightBetweenTrays": { "type": "number" }, "maxTrays": { From 1b8ed05f71b7e7edb0b67f19405374172215d5b2 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Mar 2023 13:28:28 +0100 Subject: [PATCH 17/71] =?UTF-8?q?refs=20#5395=20feat:=20modificado=20order?= =?UTF-8?q?By,=20a=C3=B1adida=20columna=20importa=20y=20corregidos=20error?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/claim-state/isEditable.js | 16 +++++++------- .../methods/travel/extraCommunityFilter.js | 2 ++ .../travel/front/extra-community/index.html | 21 ++++++++----------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/modules/claim/back/methods/claim-state/isEditable.js b/modules/claim/back/methods/claim-state/isEditable.js index 2d0a8dc44..ad51d543a 100644 --- a/modules/claim/back/methods/claim-state/isEditable.js +++ b/modules/claim/back/methods/claim-state/isEditable.js @@ -26,13 +26,13 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - - const state = await models.ClaimState.findById(id, { - include: { - relation: 'writeRole' - } - }, myOptions); - const roleWithGrants = state && state.writeRole().name; - return await models.Account.hasRole(userId, roleWithGrants, myOptions); + + const state = await models.ClaimState.findById(id, { + include: { + relation: 'writeRole' + } + }, myOptions); + const roleWithGrants = state && state.writeRole().name; + return await models.Account.hasRole(userId, roleWithGrants, myOptions); }; }; diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 027261c4b..5ee51de8e 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -130,6 +130,7 @@ module.exports = Self => { SUM(b.stickers) AS stickers, s.id AS cargoSupplierFk, s.nickname AS cargoSupplierNickname, + s.name AS supplierName, CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) as DECIMAL(10,0)) as volumeKg FROM travel t @@ -167,6 +168,7 @@ module.exports = Self => { SUM(b.stickers) AS stickers, e.evaNotes, e.notes, + e.invoiceAmount, CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg, CAST(SUM(vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) AS DECIMAL(10,0)) as volumeKg FROM tmp.travel tr diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html index ee8dcdf98..73e62b174 100644 --- a/modules/travel/front/extra-community/index.html +++ b/modules/travel/front/extra-community/index.html @@ -3,7 +3,7 @@ url="Travels/extraCommunityFilter" filter="::$ctrl.filter" data="travels" - order="shipped ASC, landed ASC, travelFk, loadPriority, agencyModeFk, evaNotes" + order="landed ASC, shipped ASC, travelFk, loadPriority, agencyModeFk, supplierName, evaNotes" limit="20" auto-load="true"> @@ -48,6 +48,9 @@ + @@ -107,6 +110,7 @@ {{::travel.cargoSupplierNickname}} + + - + - - + + From c46e15c8e463368135adff134285f2a287935e34 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 16 Mar 2023 09:35:00 +0100 Subject: [PATCH 18/71] refs #5092 changed section name --- db/changes/231201/.gitkeep | 0 .../00-unbilledClients.sql} | 4 +-- ...ts.spec.js => 05_unbilled_clients.spec.js} | 8 +++--- modules/client/front/locale/es.yml | 1 - ...ickets.spec.js => unbilledClients.spec.js} | 8 +++--- ...{unbilledTickets.js => unbilledClients.js} | 12 ++++---- ...ledTicketsCsv.js => unbilledClientsCsv.js} | 14 +++++----- modules/invoiceIn/back/models/invoice-in.js | 4 +-- modules/invoiceIn/front/index.js | 2 +- modules/invoiceIn/front/locale/es.yml | 1 + modules/invoiceIn/front/routes.json | 10 +++---- .../index.html | 28 +++++++++---------- .../index.js | 6 ++-- .../locale/es.yml | 0 .../style.scss | 2 +- 15 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 db/changes/231201/.gitkeep rename db/changes/{231001/00-unbilledTickets.sql => 231201/00-unbilledClients.sql} (56%) rename e2e/paths/09-invoice-in/{05_unbilled_tickets.spec.js => 05_unbilled_clients.spec.js} (71%) rename modules/invoiceIn/back/methods/invoice-in/specs/{unbilledTickets.spec.js => unbilledClients.spec.js} (82%) rename modules/invoiceIn/back/methods/invoice-in/{unbilledTickets.js => unbilledClients.js} (92%) rename modules/invoiceIn/back/methods/invoice-in/{unbilledTicketsCsv.js => unbilledClientsCsv.js} (75%) rename modules/invoiceIn/front/{unbilled-tickets => unbilled-clients}/index.html (80%) rename modules/invoiceIn/front/{unbilled-tickets => unbilled-clients}/index.js (94%) rename modules/invoiceIn/front/{unbilled-tickets => unbilled-clients}/locale/es.yml (100%) rename modules/invoiceIn/front/{unbilled-tickets => unbilled-clients}/style.scss (85%) diff --git a/db/changes/231201/.gitkeep b/db/changes/231201/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/231001/00-unbilledTickets.sql b/db/changes/231201/00-unbilledClients.sql similarity index 56% rename from db/changes/231001/00-unbilledTickets.sql rename to db/changes/231201/00-unbilledClients.sql index 3d2bc562b..16127dd18 100644 --- a/db/changes/231001/00-unbilledTickets.sql +++ b/db/changes/231201/00-unbilledClients.sql @@ -1,4 +1,4 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('InvoiceIn', 'unbilledTickets', 'READ', 'ALLOW', 'ROLE', 'administrative'), - ('InvoiceIn', 'unbilledTicketsCsv', 'READ', 'ALLOW', 'ROLE', 'administrative'); + ('InvoiceIn', 'unbilledClients', 'READ', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'unbilledClientsCsv', 'READ', 'ALLOW', 'ROLE', 'administrative'); diff --git a/e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js b/e2e/paths/09-invoice-in/05_unbilled_clients.spec.js similarity index 71% rename from e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js rename to e2e/paths/09-invoice-in/05_unbilled_clients.spec.js index dd75d0b49..629f24404 100644 --- a/e2e/paths/09-invoice-in/05_unbilled_tickets.spec.js +++ b/e2e/paths/09-invoice-in/05_unbilled_clients.spec.js @@ -1,6 +1,6 @@ import getBrowser from '../../helpers/puppeteer'; -describe('InvoiceIn unbilled tickets path', () => { +describe('InvoiceIn unbilled clients path', () => { let browser; let page; const httpRequests = []; @@ -9,18 +9,18 @@ describe('InvoiceIn unbilled tickets path', () => { browser = await getBrowser(); page = browser.page; page.on('request', req => { - if (req.url().includes(`InvoiceIns/unbilledTickets`)) + if (req.url().includes(`InvoiceIns/unbilledClients`)) httpRequests.push(req.url()); }); await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSection('invoiceIn.unbilled-tickets'); + await page.accessToSection('invoiceIn.unbilled-clients'); }); afterAll(async() => { await browser.close(); }); - it('should show unbilled tickets in a date range', async() => { + it('should show unbilled clients in a date range', async() => { const request = httpRequests.find(req => req.includes(`from`) && req.includes(`to`)); diff --git a/modules/client/front/locale/es.yml b/modules/client/front/locale/es.yml index fe87b2362..adbca8dbf 100644 --- a/modules/client/front/locale/es.yml +++ b/modules/client/front/locale/es.yml @@ -64,4 +64,3 @@ Compensation Account: Cuenta para compensar Amount to return: Cantidad a devolver Delivered amount: Cantidad entregada Unpaid: Impagado -Unbilled tickets: Tickets sin facturar diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/unbilledClients.spec.js similarity index 82% rename from modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js rename to modules/invoiceIn/back/methods/invoice-in/specs/unbilledClients.spec.js index 07e320a9f..fcb3173ab 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/unbilledTickets.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/unbilledClients.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; -describe('invoiceIn unbilledTickets()', () => { - it('should return all unbilled tickets in a date range', async() => { +describe('invoiceIn unbilledClients()', () => { + it('should return all unbilled clients in a date range', async() => { const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; const ctx = { @@ -13,7 +13,7 @@ describe('invoiceIn unbilledTickets()', () => { }; try { - const result = await models.InvoiceIn.unbilledTickets(ctx, options); + const result = await models.InvoiceIn.unbilledClients(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -35,7 +35,7 @@ describe('invoiceIn unbilledTickets()', () => { }; try { - await models.InvoiceIn.unbilledTickets(ctx, options); + await models.InvoiceIn.unbilledClients(ctx, options); await tx.rollback(); } catch (e) { error = e; diff --git a/modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js b/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js similarity index 92% rename from modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js rename to modules/invoiceIn/back/methods/invoice-in/unbilledClients.js index 3c33c8337..ad39bc547 100644 --- a/modules/invoiceIn/back/methods/invoice-in/unbilledTickets.js +++ b/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js @@ -2,8 +2,8 @@ const UserError = require('vn-loopback/util/user-error'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { - Self.remoteMethodCtx('unbilledTickets', { - description: 'Find all unbilled tickets', + Self.remoteMethodCtx('unbilledClients', { + description: 'Find all unbilled clients', accessType: 'READ', accepts: [ { @@ -27,12 +27,12 @@ module.exports = Self => { root: true }, http: { - path: `/unbilledTickets`, + path: `/unbilledClients`, verb: 'GET' } }); - Self.unbilledTickets = async(ctx, options) => { + Self.unbilledClients = async(ctx, options) => { const conn = Self.dataSource.connector; const args = ctx.args; @@ -99,14 +99,14 @@ module.exports = Self => { stmt.merge(conn.makeWhere(args.filter.where)); stmt.merge(conn.makeOrderBy(args.filter.order)); - const ticketsIndex = stmts.push(stmt) - 1; + const clientsIndex = stmts.push(stmt) - 1; stmts.push(`DROP TEMPORARY TABLE tmp.filter, tmp.ticket, tmp.ticketTax, tmp.ticketAmount`); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); - return ticketsIndex === 0 ? result : result[ticketsIndex]; + return clientsIndex === 0 ? result : result[clientsIndex]; }; }; diff --git a/modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js b/modules/invoiceIn/back/methods/invoice-in/unbilledClientsCsv.js similarity index 75% rename from modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js rename to modules/invoiceIn/back/methods/invoice-in/unbilledClientsCsv.js index bd6bb8d36..f9b30d83b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/unbilledTicketsCsv.js +++ b/modules/invoiceIn/back/methods/invoice-in/unbilledClientsCsv.js @@ -1,11 +1,11 @@ const {toCSV} = require('vn-loopback/util/csv'); module.exports = Self => { - Self.remoteMethodCtx('unbilledTicketsCsv', { - description: 'Returns the unbilled tickets as .csv', + Self.remoteMethodCtx('unbilledClientsCsv', { + description: 'Returns the unbilled clients as .csv', accessType: 'READ', accepts: [{ - arg: 'unbilledTickets', + arg: 'unbilledClients', type: ['object'], required: true }, @@ -35,19 +35,19 @@ module.exports = Self => { } ], http: { - path: '/unbilledTicketsCsv', + path: '/unbilledClientsCsv', verb: 'GET' } }); - Self.unbilledTicketsCsv = async ctx => { + Self.unbilledClientsCsv = async ctx => { const args = ctx.args; - const content = toCSV(args.unbilledTickets); + const content = toCSV(args.unbilledClients); return [ content, 'text/csv', - `attachment; filename="unbilled-tickets-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"` + `attachment; filename="unbilled-clients-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"` ]; }; }; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index bdd9e1b11..ebb2981e1 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -6,6 +6,6 @@ module.exports = Self => { require('../methods/invoice-in/getTotals')(Self); require('../methods/invoice-in/invoiceInPdf')(Self); require('../methods/invoice-in/invoiceInEmail')(Self); - require('../methods/invoice-in/unbilledTickets')(Self); - require('../methods/invoice-in/unbilledTicketsCsv')(Self); + require('../methods/invoice-in/unbilledClients')(Self); + require('../methods/invoice-in/unbilledClientsCsv')(Self); }; diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index 00a8d2c58..7576848bf 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -13,4 +13,4 @@ import './dueDay'; import './intrastat'; import './create'; import './log'; -import './unbilled-tickets'; +import './unbilled-clients'; diff --git a/modules/invoiceIn/front/locale/es.yml b/modules/invoiceIn/front/locale/es.yml index 35b43f9f6..2b444f75b 100644 --- a/modules/invoiceIn/front/locale/es.yml +++ b/modules/invoiceIn/front/locale/es.yml @@ -22,3 +22,4 @@ Total stems: Total tallos Show agricultural receipt as PDF: Ver recibo agrícola como PDF Send agricultural receipt as PDF: Enviar recibo agrícola como PDF New InvoiceIn: Nueva Factura +Unbilled clients: Clientes sin facturar diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 1fe1b3255..567323571 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -10,7 +10,7 @@ "menus": { "main": [ { "state": "invoiceIn.index", "icon": "icon-invoice-in"}, - { "state": "invoiceIn.unbilled-tickets", "icon": "icon-ticket"} + { "state": "invoiceIn.unbilled-clients", "icon": "person"} ], "card": [ { @@ -53,10 +53,10 @@ ] }, { - "url": "/unbilled-tickets", - "state": "invoiceIn.unbilled-tickets", - "component": "vn-unbilled-tickets", - "description": "Unbilled tickets", + "url": "/unbilled-clients", + "state": "invoiceIn.unbilled-clients", + "component": "vn-unbilled-clients", + "description": "Unbilled clients", "acl": [ "administrative" ] diff --git a/modules/invoiceIn/front/unbilled-tickets/index.html b/modules/invoiceIn/front/unbilled-clients/index.html similarity index 80% rename from modules/invoiceIn/front/unbilled-tickets/index.html rename to modules/invoiceIn/front/unbilled-clients/index.html index eb669a015..514f1e8ff 100644 --- a/modules/invoiceIn/front/unbilled-tickets/index.html +++ b/modules/invoiceIn/front/unbilled-clients/index.html @@ -1,6 +1,6 @@ @@ -74,34 +74,34 @@ - - - - - - - - + + + + + + + + - - + +
Agency + Amount + Reference {{::travel.agencyModeName}} @@ -157,22 +161,15 @@ {{::entry.supplierName}} {{::entry.invoiceAmount | currency: 'EUR': 2}} {{::entry.ref}}{{::entry.invoiceNumber}} {{::entry.stickers}} {{::entry.loadedkg}} {{::entry.volumeKg}} - - {{::entry.notes}} - - - - {{::entry.evaNotes}} - -
{{ticket.company | dashIfEmpty}}{{ticket.country | dashIfEmpty}}{{ticket.clientId | dashIfEmpty}}{{ticket.clientSocialName | dashIfEmpty}}{{ticket.amount | currency: 'EUR':2 | dashIfEmpty}}{{ticket.taxableBase | dashIfEmpty}}{{ticket.ticketFk | dashIfEmpty}}
{{client.company | dashIfEmpty}}{{client.country | dashIfEmpty}}{{client.clientId | dashIfEmpty}}{{client.clientSocialName | dashIfEmpty}}{{client.amount | currency: 'EUR':2 | dashIfEmpty}}{{client.taxableBase | dashIfEmpty}}{{client.ticketFk | dashIfEmpty}} + ng-model="client.isActive"> + ng-model="client.hasToInvoice"> + ng-model="client.isTaxDataChecked"> {{ticket.comercialId | dashIfEmpty}}{{ticket.comercialName | dashIfEmpty}}{{client.comercialId | dashIfEmpty}}{{client.comercialName | dashIfEmpty}}
diff --git a/modules/invoiceIn/front/unbilled-tickets/index.js b/modules/invoiceIn/front/unbilled-clients/index.js similarity index 94% rename from modules/invoiceIn/front/unbilled-tickets/index.js rename to modules/invoiceIn/front/unbilled-clients/index.js index 4d99257a7..a53872f8b 100644 --- a/modules/invoiceIn/front/unbilled-tickets/index.js +++ b/modules/invoiceIn/front/unbilled-clients/index.js @@ -70,8 +70,8 @@ export default class Controller extends Section { return result; }, {})); }); - this.vnReport.show('InvoiceIns/unbilledTicketsCsv', { - unbilledTickets: data, + this.vnReport.show('InvoiceIns/unbilledClientsCsv', { + unbilledClients: data, from: this.params.from, to: this.params.to }); @@ -80,7 +80,7 @@ export default class Controller extends Section { Controller.$inject = ['$element', '$scope', 'vnReport']; -ngModule.vnComponent('vnUnbilledTickets', { +ngModule.vnComponent('vnUnbilledClients', { template: require('./index.html'), controller: Controller }); diff --git a/modules/invoiceIn/front/unbilled-tickets/locale/es.yml b/modules/invoiceIn/front/unbilled-clients/locale/es.yml similarity index 100% rename from modules/invoiceIn/front/unbilled-tickets/locale/es.yml rename to modules/invoiceIn/front/unbilled-clients/locale/es.yml diff --git a/modules/invoiceIn/front/unbilled-tickets/style.scss b/modules/invoiceIn/front/unbilled-clients/style.scss similarity index 85% rename from modules/invoiceIn/front/unbilled-tickets/style.scss rename to modules/invoiceIn/front/unbilled-clients/style.scss index 555b25fa9..dbed8b967 100644 --- a/modules/invoiceIn/front/unbilled-tickets/style.scss +++ b/modules/invoiceIn/front/unbilled-clients/style.scss @@ -1,6 +1,6 @@ @import "./variables"; -vn-unbilled-tickets { +vn-unbilled-clients { vn-date-picker{ padding-right: 5%; } From 3f356335db93ac0945f034294bfdf03fbdac145d Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 16 Mar 2023 09:47:58 +0100 Subject: [PATCH 19/71] refs #5092 added popovers --- .../front/unbilled-clients/index.html | 49 ++++++++++++++----- .../invoiceIn/front/unbilled-clients/index.js | 2 - 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/modules/invoiceIn/front/unbilled-clients/index.html b/modules/invoiceIn/front/unbilled-clients/index.html index 514f1e8ff..c4c561191 100644 --- a/modules/invoiceIn/front/unbilled-clients/index.html +++ b/modules/invoiceIn/front/unbilled-clients/index.html @@ -56,18 +56,15 @@ Id Ticket - + Active - + Has To Invoice - + Verified data - - Id Comercial - Comercial @@ -77,34 +74,60 @@ {{client.company | dashIfEmpty}} {{client.country | dashIfEmpty}} - {{client.clientId | dashIfEmpty}} + + + {{::client.clientId | dashIfEmpty}} + + {{client.clientSocialName | dashIfEmpty}} {{client.amount | currency: 'EUR':2 | dashIfEmpty}} {{client.taxableBase | dashIfEmpty}} - {{client.ticketFk | dashIfEmpty}} - + + + {{::client.ticketFk | dashIfEmpty}} + + + - + - + - {{client.comercialId | dashIfEmpty}} - {{client.comercialName | dashIfEmpty}} + + + {{::client.comercialName | dashIfEmpty}} + +
+ + + + + + diff --git a/modules/invoiceIn/front/unbilled-clients/index.js b/modules/invoiceIn/front/unbilled-clients/index.js index a53872f8b..b1f55abac 100644 --- a/modules/invoiceIn/front/unbilled-clients/index.js +++ b/modules/invoiceIn/front/unbilled-clients/index.js @@ -52,8 +52,6 @@ export default class Controller extends Section { return {'taxableBase': value}; case 'ticketFk': return {'ticketFk': value}; - case 'comercialId': - return {'comercialId': value}; case 'comercialName': return {'comercialName': value}; } From 2f2d65bfd67c3880a9fc76e8d0c4718027c86b31 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 10:33:24 +0100 Subject: [PATCH 20/71] =?UTF-8?q?refs=20#5342=20feat:=20a=C3=B1adido=20ico?= =?UTF-8?q?no=20en=20los=20tickets=20que=20tengan=20sales=20fragiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- db/changes/231201/00-sale_getWarnings.sql | 35 +++++++++++++++ db/changes/231201/00-ticket_getWarnings.sql | 36 ++++++++++++++++ .../back/methods/sales-monitor/salesFilter.js | 19 +++++++- modules/monitor/front/index/locale/es.yml | 3 +- .../monitor/front/index/tickets/index.html | 43 +++++++++++-------- 6 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 db/changes/231201/00-sale_getWarnings.sql create mode 100644 db/changes/231201/00-ticket_getWarnings.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index dde790aaa..8f4e45398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- +- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia ### Changed - diff --git a/db/changes/231201/00-sale_getWarnings.sql b/db/changes/231201/00-sale_getWarnings.sql new file mode 100644 index 000000000..ee2c7b8f2 --- /dev/null +++ b/db/changes/231201/00-sale_getWarnings.sql @@ -0,0 +1,35 @@ +DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`() +BEGIN +/** + * Calcula las advertencias de cada venta para un conjunto de tickets. + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.sale_warnings + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings; + CREATE TEMPORARY TABLE tmp.sale_warnings ( + ticketFk INT(11), + saleFk INT(11), + isFragile INTEGER(1) DEFAULT 0, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; + + -- Frágil + INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile) + SELECT tt.ticketFk, s.id, TRUE + FROM tmp.sale_getWarnings tt + LEFT JOIN sale s ON s.ticketFk = tt.ticketFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE dm.code IN ('AGENCY', 'DELIVERY') + AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE')); +END$$ +DELIMITER ; diff --git a/db/changes/231201/00-ticket_getWarnings.sql b/db/changes/231201/00-ticket_getWarnings.sql new file mode 100644 index 000000000..0cd420bd3 --- /dev/null +++ b/db/changes/231201/00-ticket_getWarnings.sql @@ -0,0 +1,36 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_getWarnings`; + +DELIMITER $$ +$$ +CREATE PROCEDURE `vn`.`ticket_getWarnings`() +BEGIN +/** + * Calcula las adventencias para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticket_warnings + */ + CALL sale_getWarnings(); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings; + CREATE TEMPORARY TABLE tmp.ticket_warnings + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT + sw.ticketFk, + MAX(sw.isFragile) AS isFragile, + 0 AS totalWarnings + FROM tmp.sale_warnings sw + GROUP BY sw.ticketFk; + + UPDATE tmp.ticket_warnings tw + SET tw.totalWarnings = + ( + (tw.isFragile) + ); + + DROP TEMPORARY TABLE + tmp.sale_warnings; +END$$ +DELIMITER ; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 881fc637a..c9a25b1a1 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -295,11 +295,26 @@ module.exports = Self => { risk = t.debt + t.credit, totalProblems = totalProblems + 1 `); + stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getWarnings'); + stmt = new ParameterizedSQL(` - SELECT t.*, tp.*, - ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk + CREATE TEMPORARY TABLE tmp.sale_getWarnings + (INDEX (ticketFk, agencyModeFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.agencyModeFk + FROM tmp.filter f`); + stmts.push(stmt); + + stmts.push('CALL ticket_getWarnings()'); + + stmt = new ParameterizedSQL(` + SELECT t.*, + tp.*, + ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk, + tw.* FROM tmp.tickets t LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id + LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id JOIN clientConfig cc`); const hasProblems = args.problems; diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index 126528caa..f114a2259 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -12,4 +12,5 @@ Theoretical: Teórica Practical: Práctica Preparation: Preparación Auto-refresh: Auto-refresco -Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos \ No newline at end of file +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos +Is fragile: Es frágil diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index b8559154e..539d4b3cb 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -19,13 +19,13 @@ Tickets monitor - + - State + Zone @@ -80,7 +81,7 @@ @@ -169,12 +170,20 @@ class="link"> {{ticket.refFk}} - {{ticket.state}} + + + + - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value From 1cd768f7b87e74387b9fa7da9c86cf983d24359f Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 16 Mar 2023 10:39:02 +0100 Subject: [PATCH 21/71] refs #5056 moved sql --- db/changes/231201/.gitkeep | 0 db/changes/{231001 => 231201}/00-wagon.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 db/changes/231201/.gitkeep rename db/changes/{231001 => 231201}/00-wagon.sql (100%) diff --git a/db/changes/231201/.gitkeep b/db/changes/231201/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/231001/00-wagon.sql b/db/changes/231201/00-wagon.sql similarity index 100% rename from db/changes/231001/00-wagon.sql rename to db/changes/231201/00-wagon.sql From 23ce51abf07c23fb7b0253d72706bba3bd3e2ce7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Mar 2023 11:34:57 +0100 Subject: [PATCH 22/71] refs #5342 add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f4e45398..e7d1da557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2312.01] - 2023-04-06 ### Added -- (Monitor tickets) Muestra un icono al lado de la zona, si es frágil y se envía por agencia +- (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia ### Changed - From 9565bb33f2c30635d4dd7e3660e5e35c31b442c0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 16 Mar 2023 14:12:54 +0100 Subject: [PATCH 23/71] refs #5425 modificacion de los campos --- e2e/helpers/selectors.js | 2 +- modules/entry/front/latest-buys/index.html | 2 +- modules/item/front/basic-data/index.html | 2 +- modules/item/front/index/index.html | 2 +- modules/item/front/locale/es.yml | 4 ++-- modules/item/front/summary/index.html | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f20d75310..d4c68ff00 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -410,7 +410,7 @@ export default { advancedSearchButton: 'vn-item-search-panel button[type=submit]', advancedSmartTableButton: 'vn-item-index vn-button[icon="search"]', advancedSmartTableGrouping: 'vn-item-index vn-textfield[name=grouping]', - weightByPieceCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Weight/Piece"]', + weightByPieceCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Weight per unit"]', saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' }, itemFixedPrice: { diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 727b19220..0fe2de94d 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -63,7 +63,7 @@ Origin - Weight/Piece + Weight per unit Active diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index 974aa37d8..5e6752aea 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -124,7 +124,7 @@ diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 6f5cce7c0..47e71c2df 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -46,7 +46,7 @@ Buyer - Weight/Piece + Weight per unit Multiplier diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml index 0fc014742..115a69528 100644 --- a/modules/item/front/locale/es.yml +++ b/modules/item/front/locale/es.yml @@ -40,11 +40,11 @@ Create: Crear Client card: Ficha del cliente Shipped: F. envío stems: Tallos -Weight/Piece: Peso/tallo +Weight per unit: Peso por unidad (gramos) Search items by id, name or barcode: Buscar articulos por identificador, nombre o codigo de barras SalesPerson: Comercial Concept: Concepto -Units/Box: Unidades/Caja +Units/Box: Unidades/caja # Sections Items: Artículos diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index 46a2baef4..cdcc2ae49 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -110,7 +110,7 @@ - Date: Fri, 17 Mar 2023 09:32:20 +0100 Subject: [PATCH 24/71] =?UTF-8?q?refs=20#5425=20modificaci=C3=B3n=20usuari?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/helpers/selectors.js | 2 +- modules/entry/front/latest-buys/index.html | 2 +- modules/item/front/basic-data/index.html | 2 +- modules/item/front/index/index.html | 2 +- modules/item/front/locale/es.yml | 2 +- modules/item/front/summary/index.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index d4c68ff00..f20d75310 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -410,7 +410,7 @@ export default { advancedSearchButton: 'vn-item-search-panel button[type=submit]', advancedSmartTableButton: 'vn-item-index vn-button[icon="search"]', advancedSmartTableGrouping: 'vn-item-index vn-textfield[name=grouping]', - weightByPieceCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Weight per unit"]', + weightByPieceCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Weight/Piece"]', saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' }, itemFixedPrice: { diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 0fe2de94d..727b19220 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -63,7 +63,7 @@ Origin - Weight per unit + Weight/Piece Active diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html index 5e6752aea..974aa37d8 100644 --- a/modules/item/front/basic-data/index.html +++ b/modules/item/front/basic-data/index.html @@ -124,7 +124,7 @@ diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 47e71c2df..6f5cce7c0 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -46,7 +46,7 @@ Buyer - Weight per unit + Weight/Piece Multiplier diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml index 115a69528..37f774e4e 100644 --- a/modules/item/front/locale/es.yml +++ b/modules/item/front/locale/es.yml @@ -40,7 +40,7 @@ Create: Crear Client card: Ficha del cliente Shipped: F. envío stems: Tallos -Weight per unit: Peso por unidad (gramos) +Weight/Piece: Peso (gramos)/tallo Search items by id, name or barcode: Buscar articulos por identificador, nombre o codigo de barras SalesPerson: Comercial Concept: Concepto diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index cdcc2ae49..46a2baef4 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -110,7 +110,7 @@ - Date: Mon, 20 Mar 2023 10:15:18 +0100 Subject: [PATCH 25/71] refs #5092 showing clients with multiple negative bases --- modules/invoiceIn/back/methods/invoice-in/unbilledClients.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js b/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js index ad39bc547..790185d25 100644 --- a/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js +++ b/modules/invoiceIn/back/methods/invoice-in/unbilledClients.js @@ -89,8 +89,8 @@ module.exports = Self => { WHERE t.shipped BETWEEN ? AND ? AND t.refFk IS NULL AND c.typeFk IN ('normal','trust') - GROUP BY t.clientFk - HAVING amount <> 0`, [args.from, args.to])); + GROUP BY t.clientFk, negativeBase.taxableBase + HAVING amount < 0`, [args.from, args.to])); stmt = new ParameterizedSQL(` SELECT f.* From a670795f9d93d2074c636015f4902b8051baeb36 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 20 Mar 2023 13:22:21 +0100 Subject: [PATCH 26/71] refs #5432 mod ng-show, add tooltip and disabled --- modules/ticket/front/sale/index.html | 6 ++++-- modules/ticket/front/sale/locale/es.yml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 8764417a8..6f0361c35 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -28,8 +28,10 @@ + disabled="!$ctrl.hasSelectedSales()" + vn-tooltip="Select lines to see the options" + ng-click="moreOptions.show($event)"> + Date: Mon, 20 Mar 2023 13:41:32 +0100 Subject: [PATCH 27/71] refs #5432 quitar comentario --- modules/ticket/front/sale/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 6f0361c35..6fc986e8f 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -31,7 +31,6 @@ disabled="!$ctrl.hasSelectedSales()" vn-tooltip="Select lines to see the options" ng-click="moreOptions.show($event)"> - Date: Tue, 21 Mar 2023 10:44:00 +0100 Subject: [PATCH 28/71] refs #5056 wagonType backs and test --- db/changes/231201/00-wagon.sql | 10 ++- db/dump/fixtures.sql | 7 +- .../back/methods/wagonType/createWagonType.js | 57 +++++++++++++++++ .../back/methods/wagonType/deleteWagonType.js | 43 +++++++++++++ .../back/methods/wagonType/editWagonType.js | 64 +++++++++++++++++++ .../wagonType/specs/crudWagonType.spec.js | 63 ++++++++++++++++++ modules/wagon/back/models/wagon-type.js | 5 ++ modules/wagon/back/models/wagon.json | 3 + 8 files changed, 246 insertions(+), 6 deletions(-) create mode 100644 modules/wagon/back/methods/wagonType/createWagonType.js create mode 100644 modules/wagon/back/methods/wagonType/deleteWagonType.js create mode 100644 modules/wagon/back/methods/wagonType/editWagonType.js create mode 100644 modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js create mode 100644 modules/wagon/back/models/wagon-type.js diff --git a/db/changes/231201/00-wagon.sql b/db/changes/231201/00-wagon.sql index c7725ab4f..2924fdc99 100644 --- a/db/changes/231201/00-wagon.sql +++ b/db/changes/231201/00-wagon.sql @@ -15,7 +15,7 @@ CREATE TABLE `vn`.`wagonTypeColor` ( CREATE TABLE `vn`.`wagonTypeTray` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `typeFk` int(11) unsigned, - `height` int(11) unsigned, + `height` int(11) unsigned NOT NULL, `colorFk` int(11) unsigned, PRIMARY KEY (`id`), UNIQUE KEY (`typeFk`,`height`), @@ -54,7 +54,8 @@ CREATE TABLE `vn`.`collectionWagonTicket` ( CONSTRAINT `collectionWagonTicket_tray` FOREIGN KEY (`trayFk`) REFERENCES `wagonTypeTray` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; -ALTER TABLE `vn`.`wagon` ADD `typeFk` int(11) unsigned DEFAULT NULL; +ALTER TABLE `vn`.`wagon` ADD `typeFk` int(11) unsigned NOT NULL; +ALTER TABLE `vn`.`wagon` ADD `label` int(11) unsigned NOT NULL; ALTER TABLE `vn`.`wagon` ADD CONSTRAINT `wagon_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) @@ -65,4 +66,7 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri ('WagonConfig', '*', '*', 'ALLOW', 'ROLE', 'employee'), ('CollectionWagon', '*', '*', 'ALLOW', 'ROLE', 'employee'), ('CollectionWagonTicket', '*', '*', 'ALLOW', 'ROLE', 'employee'), - ('Wagon', '*', '*', 'ALLOW', 'ROLE', 'employee'); + ('Wagon', '*', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonType', 'createWagonType', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonType', 'deleteWagonType', '*', 'ALLOW', 'ROLE', 'employee'), + ('WagonType', 'editWagonType', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 571769e8c..1c8134ca3 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2838,8 +2838,9 @@ INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minH INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) VALUES - (1, 'red', '#ff0000'), - (2, 'green', '#00ff00'), - (3, 'blue', '#0000ff'); + (1, 'white', '#ffffff'), + (2, 'red', '#ff0000'), + (3, 'green', '#00ff00'), + (4, 'blue', '#0000ff'); diff --git a/modules/wagon/back/methods/wagonType/createWagonType.js b/modules/wagon/back/methods/wagonType/createWagonType.js new file mode 100644 index 000000000..fed915b28 --- /dev/null +++ b/modules/wagon/back/methods/wagonType/createWagonType.js @@ -0,0 +1,57 @@ +module.exports = Self => { + Self.remoteMethodCtx('createWagonType', { + description: 'Creates a new wagon type', + accessType: 'WRITE', + accepts: [ + { + arg: 'name', + type: 'String', + required: true + }, + { + arg: 'divisible', + type: 'boolean', + required: true + }, { + arg: 'trays', + type: 'any', + required: true + } + ], + http: { + path: `/createWagonType`, + verb: 'PATCH' + } + }); + + Self.createWagonType = async(ctx, options) => { + const args = ctx.args; + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const newWagonType = await models.WagonType.create({name: args.name, divisible: args.divisible}, myOptions); + args.trays.forEach(async tray => { + await models.WagonTypeTray.create({ + typeFk: newWagonType.id, + height: tray.position, + colorFk: tray.color.id + }, myOptions); + }); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/wagon/back/methods/wagonType/deleteWagonType.js b/modules/wagon/back/methods/wagonType/deleteWagonType.js new file mode 100644 index 000000000..46b65e32f --- /dev/null +++ b/modules/wagon/back/methods/wagonType/deleteWagonType.js @@ -0,0 +1,43 @@ +module.exports = Self => { + Self.remoteMethodCtx('deleteWagonType', { + description: 'Deletes a wagon type', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'Number', + required: true + } + ], + http: { + path: `/deleteWagonType`, + verb: 'DELETE' + } + }); + + Self.deleteWagonType = async(ctx, options) => { + const args = ctx.args; + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + await models.Wagon.destroyAll({typeFk: args.id}, myOptions); + await models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); + await models.WagonType.destroyAll({id: args.id}, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/wagon/back/methods/wagonType/editWagonType.js b/modules/wagon/back/methods/wagonType/editWagonType.js new file mode 100644 index 000000000..bd5ad1f16 --- /dev/null +++ b/modules/wagon/back/methods/wagonType/editWagonType.js @@ -0,0 +1,64 @@ +module.exports = Self => { + Self.remoteMethodCtx('editWagonType', { + description: 'Edits a new wagon type', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'String', + required: true + }, + { + arg: 'name', + type: 'String', + required: true + }, + { + arg: 'divisible', + type: 'boolean', + required: true + }, { + arg: 'trays', + type: 'any', + required: true + } + ], + http: { + path: `/editWagonType`, + verb: 'PATCH' + } + }); + + Self.editWagonType = async(ctx, options) => { + const args = ctx.args; + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const wagonType = await models.WagonType.findById(args.id, null, myOptions); + wagonType.updateAttributes({name: args.name, divisible: args.divisible}, myOptions); + models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); + args.trays.forEach(async tray => { + await models.WagonTypeTray.create({ + typeFk: args.id, + height: tray.position, + colorFk: tray.color.id + }, myOptions); + }); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js new file mode 100644 index 000000000..92ac61060 --- /dev/null +++ b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js @@ -0,0 +1,63 @@ +const models = require('vn-loopback/server/server').models; + +describe('WagonType crudWagonType()', () => { + const ctx = { + args: { + name: 'Mock wagon type', + divisible: true, + trays: [{position: 0, color: {id: 1}}, + {position: 50, color: {id: 2}}, + {position: 100, color: {id: 3}}] + } + }; + + it(`should create, edit and delete a new wagon type and its trays`, async() => { + const tx = await models.WagonType.beginTransaction({}); + + try { + const options = {transaction: tx}; + + // create + await models.WagonType.createWagonType(ctx, options); + + const newWagonType = await models.WagonType.findOne({where: {name: ctx.args.name}}, options); + const newWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); + + expect(newWagonType).not.toEqual(null); + expect(newWagonType.name).toEqual(ctx.args.name); + expect(newWagonType.divisible).toEqual(ctx.args.divisible); + expect(newWagonTrays.length).toEqual(ctx.args.trays.length); + + ctx.args = { + id: newWagonType.id, + name: 'Edited wagon type', + divisible: false, + trays: [{position: 0, color: {id: 1}}] + }; + + // edit + await models.WagonType.editWagonType(ctx, options); + + const editedWagonType = await models.WagonType.findById(newWagonType.id, null, options); + const editedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); + + expect(editedWagonType.name).toEqual(ctx.args.name); + expect(editedWagonType.divisible).toEqual(ctx.args.divisible); + expect(editedWagonTrays.length).toEqual(ctx.args.trays.length); + + // delete + await models.WagonType.deleteWagonType(ctx, options); + + const deletedWagonType = await models.WagonType.findById(newWagonType.id, null, options); + const deletedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); + + expect(deletedWagonType).toEqual(null); + expect(deletedWagonTrays).toEqual([]); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/wagon/back/models/wagon-type.js b/modules/wagon/back/models/wagon-type.js new file mode 100644 index 000000000..bebf7a9d9 --- /dev/null +++ b/modules/wagon/back/models/wagon-type.js @@ -0,0 +1,5 @@ +module.exports = Self => { + require('../methods/wagonType/createWagonType')(Self); + require('../methods/wagonType/editWagonType')(Self); + require('../methods/wagonType/deleteWagonType')(Self); +}; diff --git a/modules/wagon/back/models/wagon.json b/modules/wagon/back/models/wagon.json index 81b9f23e6..61ee61e61 100644 --- a/modules/wagon/back/models/wagon.json +++ b/modules/wagon/back/models/wagon.json @@ -11,6 +11,9 @@ "id": true, "type": "number" }, + "label": { + "type": "number" + }, "volume": { "type": "number" }, From d1f0ae386540126412fa75148e9a644e3638bb3f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Mar 2023 11:26:25 +0100 Subject: [PATCH 29/71] refs #4858 fix: filtro corregido --- back/methods/chat/sendCheckingPresence.js | 3 +++ back/methods/chat/sendQueued.js | 19 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3eaf6b86b..29232490a 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -38,6 +38,9 @@ module.exports = Self => { if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); + if (process.env.NODE_ENV == 'test') + message = `[Test:Environment to user ${userId}] ` + message; + const chat = await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, diff --git a/back/methods/chat/sendQueued.js b/back/methods/chat/sendQueued.js index 8a0bdee34..ef1a417ab 100644 --- a/back/methods/chat/sendQueued.js +++ b/back/methods/chat/sendQueued.js @@ -19,12 +19,11 @@ module.exports = Self => { const chats = await models.Chat.find({ where: { status: { - neq: { - and: [ - 'sent', - 'sending' - ] - } + nin: [ + 'sent', + 'sending' + ] + }, attempts: {lt: 3} } @@ -34,16 +33,16 @@ module.exports = Self => { if (chat.checkUserStatus) { try { await Self.sendCheckingUserStatus(chat); - await updateChat(chat, 'sent'); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error); + await Self.updateChat(chat, 'error', error); } } else { try { await Self.sendMessage(chat.senderFk, chat.recipient, chat.message); - await updateChat(chat, 'sent'); + await Self.updateChat(chat, 'sent'); } catch (error) { - await updateChat(chat, 'error', error); + await Self.updateChat(chat, 'error', error); } } } From 4141a9735600521fc172539aa8d2b1c266249701 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Mar 2023 11:37:26 +0100 Subject: [PATCH 30/71] refs #4858 fix: backTest --- back/methods/chat/spec/sendQueued.spec.js | 4 ++-- db/changes/{230201 => 231201}/00-chatRefactor.sql | 0 db/dump/fixtures.sql | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename db/changes/{230201 => 231201}/00-chatRefactor.sql (100%) diff --git a/back/methods/chat/spec/sendQueued.spec.js b/back/methods/chat/spec/sendQueued.spec.js index ed791756b..67cd47f4a 100644 --- a/back/methods/chat/spec/sendQueued.spec.js +++ b/back/methods/chat/spec/sendQueued.spec.js @@ -10,7 +10,7 @@ describe('Chat sendCheckingPresence()', () => { const chat = { checkUserStatus: 1, - status: 0, + status: 'pending', attempts: 0 }; @@ -27,7 +27,7 @@ describe('Chat sendCheckingPresence()', () => { const chat = { checkUserStatus: 0, - status: 0, + status: 'pending', attempts: 0 }; diff --git a/db/changes/230201/00-chatRefactor.sql b/db/changes/231201/00-chatRefactor.sql similarity index 100% rename from db/changes/230201/00-chatRefactor.sql rename to db/changes/231201/00-chatRefactor.sql diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2145f8429..e6e998d59 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2631,8 +2631,8 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES - (1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 0), - (1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 0); + (1101, '@PetterParker', util.VN_CURDATE(), 1, 'First test message', 0, 'sent'), + (1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending'); INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`) From 1d0024c5382e5512613bae9d93388527f255fb87 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Mar 2023 14:08:34 +0100 Subject: [PATCH 31/71] =?UTF-8?q?refs=20#5013=20feat:=20a=C3=B1adida=20obs?= =?UTF-8?q?ervacion=20para=20cada=20ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/231201/00-observationType.sql | 2 ++ print/templates/reports/invoice/invoice.html | 11 +++++++++++ print/templates/reports/invoice/sql/tickets.sql | 9 ++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 db/changes/231201/00-observationType.sql diff --git a/db/changes/231201/00-observationType.sql b/db/changes/231201/00-observationType.sql new file mode 100644 index 000000000..20e3608e4 --- /dev/null +++ b/db/changes/231201/00-observationType.sql @@ -0,0 +1,2 @@ +INSERT INTO `vn`.`observationType` (`description`, `code`, `hasNewBornMessage`) +VALUES ('Factura', 'invocieOut', '0'); diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index 2d180878a..2c37126fc 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -119,6 +119,16 @@ {{ticketSubtotal(ticket) | currency('EUR', $i18n.locale)}} + +
+
+
{{$t('observations')}}
+
+
{{ticket.description}}
+
+
+
+
@@ -251,6 +261,7 @@ +