From ad3c6dcee2b2066dacabf0b7bbfd92f69dae98f9 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 3 May 2023 14:34:36 +0200 Subject: [PATCH 01/29] wip #5595 --- loopback/common/models/vn-model.js | 12 ++++++++++++ modules/ticket/back/methods/ticket/makeInvoice.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f469e893a..992598fb5 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -197,6 +197,18 @@ module.exports = function(Self) { * Shortcut to VnMySQL.executeP() */ rawSql(query, params, options, cb) { + const userId = options.userId; + if (userId) { + params.unshift(userId); + return this.dataSource.connector.executeP( + `CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?)); + ${query}; + CALL account.myUser_logout();`, + params, + options, + cb + ); + } return this.dataSource.connector.executeP(query, params, options, cb); }, diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 9739f5985..c2de55c96 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -29,7 +29,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') From b3100d2653e3c0b2d9ebec5768390676f666dedb Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 4 May 2023 09:55:36 +0200 Subject: [PATCH 02/29] refs #5595 remove OkPackets from logIn and logOut --- loopback/common/models/vn-model.js | 2 +- loopback/server/connectors/vn-mysql.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 992598fb5..1cb389099 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -197,7 +197,7 @@ module.exports = function(Self) { * Shortcut to VnMySQL.executeP() */ rawSql(query, params, options, cb) { - const userId = options.userId; + const userId = options?.userId; if (userId) { params.unshift(userId); return this.dataSource.connector.executeP( diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 40ad78bde..9ba65d517 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -17,6 +17,12 @@ class VnMySQL extends MySQL { executeP(query, params, options = {}, cb) { return new Promise((resolve, reject) => { this.execute(query, params, options, (error, response) => { + if(options?.userId) + { + response.shift(); // Remove OkPacket from logIn + response.pop(); // Remove OkPacket from logOut + response = response[response.length - 1] // Keep only query response + } if (cb) cb(error, response); if (error) From 2c7473b0649317f63372decee0b88565fd43e18f Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 23 May 2023 15:06:38 +0200 Subject: [PATCH 03/29] =?UTF-8?q?refs=20#5252=20feat:=20permite=20crear=20?= =?UTF-8?q?un=20abono=20con=20o=20sin=20almac=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/232201/00-ticket_warehouse.sql | 1 + .../back/methods/invoiceOut/refund.js | 22 +++++++++---- .../front/descriptor-menu/index.html | 30 ++++++++++------- .../invoiceOut/front/descriptor-menu/index.js | 4 +-- .../front/descriptor-menu/locale/es.yml | 3 +- modules/ticket/back/methods/sale/refund.js | 13 +++++--- modules/ticket/back/methods/ticket/refund.js | 9 ++++-- .../ticket/front/descriptor-menu/index.html | 29 ++++++++++------- modules/ticket/front/descriptor-menu/index.js | 19 +++++------ .../front/descriptor-menu/locale/es.yml | 5 ++- modules/ticket/front/sale/index.html | 32 +++++++++++++------ modules/ticket/front/sale/index.js | 5 ++- modules/ticket/front/sale/locale/es.yml | 4 +-- 13 files changed, 114 insertions(+), 62 deletions(-) create mode 100644 db/changes/232201/00-ticket_warehouse.sql diff --git a/db/changes/232201/00-ticket_warehouse.sql b/db/changes/232201/00-ticket_warehouse.sql new file mode 100644 index 000000000..171538566 --- /dev/null +++ b/db/changes/232201/00-ticket_warehouse.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`ticket` MODIFY COLUMN warehouseFk smallint(6) unsigned DEFAULT 1 NULL; diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index ad480dc7d..c722d9806 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -2,11 +2,19 @@ module.exports = Self => { Self.remoteMethod('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', - accepts: [{ - arg: 'ref', - type: 'string', - description: 'The invoice reference' - }], + accepts: [ + { + arg: 'ref', + type: 'string', + description: 'The invoice reference', + required: true + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true + } + ], returns: { type: ['number'], root: true @@ -17,7 +25,7 @@ module.exports = Self => { } }); - Self.refund = async(ref, options) => { + Self.refund = async(ref, withWarehouse, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -35,7 +43,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); + const refundedTickets = await models.Ticket.refund(ticketsIds, withWarehouse, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 389fcf81b..106f8e3cc 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -76,14 +76,27 @@ translate> Show CITES letter - - Refund + Refund... + + + + with warehouse + + + without warehouse + + + @@ -97,12 +110,7 @@ on-accept="$ctrl.bookInvoiceOut()" question="Are you sure you want to book this invoice?"> - - - @@ -148,4 +156,4 @@ - \ No newline at end of file + diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 57ea653a8..38c3c9434 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -114,9 +114,9 @@ class Controller extends Section { }); } - refundInvoiceOut() { + refundInvoiceOut(withWarehouse) { const query = 'InvoiceOuts/refund'; - const params = {ref: this.invoiceOut.ref}; + const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse}; this.$http.post(query, params).then(res => { const refundTicket = res.data; this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index df0ba57cf..393efd58c 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -13,10 +13,11 @@ InvoiceOut deleted: Factura eliminada Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura? Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? InvoiceOut booked: Factura asentada -Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? +Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketIds}}" +Refund...: Abono... diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index af58a6286..307407a27 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -11,6 +11,11 @@ module.exports = Self => { { arg: 'servicesIds', type: ['number'] + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true } ], returns: { @@ -23,7 +28,7 @@ module.exports = Self => { } }); - Self.refund = async(salesIds, servicesIds, options) => { + Self.refund = async(salesIds, servicesIds, withWarehouse, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -65,7 +70,7 @@ module.exports = Self => { const now = Date.vnNew(); const [firstTicketId] = ticketsIds; - const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, myOptions); + const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); for (const sale of sales) { const createdSale = await models.Sale.create({ @@ -110,7 +115,7 @@ module.exports = Self => { } }; - async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, myOptions) { + async function createTicketRefund(ticketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions) { const models = Self.app.models; const filter = {include: {relation: 'address'}}; @@ -122,7 +127,7 @@ module.exports = Self => { addressFk: ticket.address().id, agencyModeFk: refundAgencyMode.id, nickname: ticket.address().nickname, - warehouseFk: ticket.warehouseFk, + warehouseFk: withWarehouse ? ticket.warehouseFk : null, companyFk: ticket.companyFk, landed: now, zoneFk: refoundZoneId diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js index 91f48cfd6..fe17b7101 100644 --- a/modules/ticket/back/methods/ticket/refund.js +++ b/modules/ticket/back/methods/ticket/refund.js @@ -7,6 +7,11 @@ module.exports = Self => { arg: 'ticketsIds', type: ['number'], required: true + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true } ], returns: { @@ -19,7 +24,7 @@ module.exports = Self => { } }); - Self.refund = async(ticketsIds, options) => { + Self.refund = async(ticketsIds, withWarehouse, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -41,7 +46,7 @@ module.exports = Self => { const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions); + const refundedTickets = await models.Sale.refund(salesIds, servicesIds, withWarehouse, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index c2ebc3e3a..afa5db41a 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -141,12 +141,27 @@ translate> Recalculate components - - Refund all + Refund all... + + + + with warehouse + + + without warehouse + + + @@ -319,14 +334,6 @@ message="Recalculate components"> - - - - this.vnApp.showSuccess(this.$t('Data saved!'))); } - async refund() { - const params = {ticketsIds: [this.id]}; + refund(withWarehouse) { + const params = {ticketsIds: [this.id], withWarehouse: withWarehouse}; const query = 'Tickets/refund'; - return this.$http.post(query, params).then(res => { - const refundTicket = res.data; - this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { - ticketId: refundTicket.id - })); - this.$state.go('ticket.card.sale', {id: refundTicket.id}); - }); + return this.$http.post(query, params) + .then(res => { + const refundTicket = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); + }); } onSmsSend(sms) { diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index b51637524..3830523cf 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -10,7 +10,9 @@ Send CSV: Enviar CSV Send CSV Delivery Note: Enviar albarán en CSV Send PDF Delivery Note: Enviar albarán en PDF Show Proforma: Ver proforma -Refund all: Abonar todo +Refund all...: Abonar todo... +with warehouse: con almacén +without warehouse: sin almacén Invoice sent: Factura enviada The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" Transfer client: Transferir cliente @@ -18,3 +20,4 @@ SMS Notify changes: SMS Notificar cambios PDF sent!: ¡PDF enviado! Already exist signed delivery note: Ya existe albarán de entrega firmado Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán de entrega? +Create a single ticket with all the content of the current ticket: Crea un ticket único con todo el contenido del ticket actual diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index b2c0db18d..689e34c63 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -481,7 +481,7 @@ on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)"> - - Add claim + Add claim Unmark as reserved - - Refund - + + Refund... + + + + with warehouse + + + without warehouse + + + + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index b7cdc22b9..332cf34c1 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -510,13 +510,12 @@ class Controller extends Section { }); } - createRefund() { + createRefund(withWarehouse) { const sales = this.selectedValidSales(); if (!sales) return; const salesIds = sales.map(sale => sale.id); - - const params = {salesIds: salesIds}; + const params = {salesIds: salesIds, withWarehouse: withWarehouse}; const query = 'Sales/refund'; this.$http.post(query, params).then(res => { const refundTicket = res.data; diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 6eb558a56..0b1fd84ea 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,10 +36,10 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Refund: Abono +Refund...: Abono... Promotion mana: Maná promoción Claim mana: Maná reclamación History: Historial Do you want to continue?: ¿Desea continuar? Claim out of time: Reclamación fuera de plazo -Do you want to create a claim?: ¿Quieres crear una reclamación? \ No newline at end of file +Do you want to create a claim?: ¿Quieres crear una reclamación? From 96feb24f122ee9e4edbc5470d4ebd078bc17ba49 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 25 May 2023 13:28:44 +0200 Subject: [PATCH 04/29] refs #5252 fix: back test --- .../invoiceOut/back/methods/invoiceOut/specs/refund.spec.js | 2 +- modules/ticket/back/methods/sale/specs/refund.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index 35f2b4023..e2d17841f 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -15,7 +15,7 @@ describe('InvoiceOut refund()', () => { const options = {transaction: tx}; try { - const result = await models.InvoiceOut.refund('T1111111', options); + const result = await models.InvoiceOut.refund('T1111111', true, options); expect(result).toBeDefined(); diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 83b3755e2..9c0ec73cc 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -22,7 +22,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options); + const refundedTicket = await models.Sale.refund(salesIds, servicesIds, true, options); expect(refundedTicket).toBeDefined(); @@ -40,7 +40,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const ticket = await models.Sale.refund(salesIds, servicesIds, options); + const ticket = await models.Sale.refund(salesIds, servicesIds, true, options); const refundedTicket = await models.Ticket.findOne({ where: { From 71d8a355bd126428d85274d8aab799f903f13092 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 25 May 2023 15:03:22 +0200 Subject: [PATCH 05/29] refs #5252 fix: te2e --- e2e/helpers/selectors.js | 1 + e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js | 13 ++++++++++++- modules/ticket/front/sale/index.html | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 086909ebf..821120a74 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -595,6 +595,7 @@ export default { moreMenuUpdateDiscount: 'vn-item[name="discount"]', moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', moreMenuRefund: 'vn-item[name="refund"]', + refundWithWarehouse: 'vn-item[name="refundWithWarehouse"]', moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 2158eec8b..e5ba708cc 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -224,14 +224,25 @@ describe('Ticket Edit sale path', () => { await page.accessToSection('ticket.card.sale'); }); - it('should select the third sale and create a refund', async() => { + it('should select the first sale and create a refund with warehouse', async() => { await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuRefund); + await page.waitToClick(selectors.ticketSales.refundWithWarehouse); await page.waitForSnackbar(); await page.waitForState('ticket.card.sale'); }); + // it('should select the first sale and create a refund without warehouse', async() => { + // await page.accessToSearchResult('15'); + // await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); + // await page.waitToClick(selectors.ticketSales.moreMenu); + // await page.waitToClick(selectors.ticketSales.moreMenuRefund); + // await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse); + // await page.waitForSnackbar(); + // await page.waitForState('ticket.card.sale'); + // }); + it('should show error trying to delete a ticket with a refund', async() => { await page.accessToSearchResult('16'); await page.waitToClick(selectors.ticketDescriptor.moreMenu); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 689e34c63..0ed62641b 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -530,6 +530,7 @@ Unmark as reserved with warehouse without warehouse From 8adc104cf473892b5c1292a8985c8ed2f6cc4b71 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 26 May 2023 08:39:58 +0200 Subject: [PATCH 06/29] refs #5735 fix currency --- modules/client/front/credit-management/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/front/credit-management/index.html b/modules/client/front/credit-management/index.html index d7456fd06..b9064ff69 100644 --- a/modules/client/front/credit-management/index.html +++ b/modules/client/front/credit-management/index.html @@ -68,7 +68,7 @@ {{::clientInforma.rating}} - {{::clientInforma.recommendedCredit}} + {{::clientInforma.recommendedCredit | currency: 'EUR': 2}} From 3ecfbe2052cb8acfaead97f91c1b3dd85baf2283 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 26 May 2023 12:03:36 +0200 Subject: [PATCH 07/29] refs #5252 refactor: creadas varaibles --- .../invoiceOut/back/methods/invoiceOut/specs/refund.spec.js | 3 ++- modules/ticket/back/methods/sale/specs/refund.spec.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index e2d17841f..3d0ea6809 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -3,6 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('InvoiceOut refund()', () => { const userId = 5; + const withWarehouse = true; const activeCtx = { accessToken: {userId: userId}, }; @@ -15,7 +16,7 @@ describe('InvoiceOut refund()', () => { const options = {transaction: tx}; try { - const result = await models.InvoiceOut.refund('T1111111', true, options); + const result = await models.InvoiceOut.refund('T1111111', withWarehouse, options); expect(result).toBeDefined(); diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 9c0ec73cc..b870a36f7 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -6,8 +6,8 @@ describe('Sale refund()', () => { const activeCtx = { accessToken: {userId: userId}, }; - const servicesIds = [3]; + const withWarehouse = true; beforeEach(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -22,7 +22,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const refundedTicket = await models.Sale.refund(salesIds, servicesIds, true, options); + const refundedTicket = await models.Sale.refund(salesIds, servicesIds, withWarehouse, options); expect(refundedTicket).toBeDefined(); @@ -40,7 +40,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const ticket = await models.Sale.refund(salesIds, servicesIds, true, options); + const ticket = await models.Sale.refund(salesIds, servicesIds, withWarehouse, options); const refundedTicket = await models.Ticket.findOne({ where: { From 527116f1ec57527e296cd45c9267c88015d4e922 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 26 May 2023 12:20:02 +0200 Subject: [PATCH 08/29] refs #5252 fix: te2e --- e2e/helpers/selectors.js | 1 + .../05-ticket/01-sale/02_edit_sale.spec.js | 21 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 821120a74..65d446790 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,6 +596,7 @@ export default { moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', moreMenuRefund: 'vn-item[name="refund"]', refundWithWarehouse: 'vn-item[name="refundWithWarehouse"]', + refundWithoutWarehouse: 'vn-item[name="refundWithoutWarehouse"]', moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index e5ba708cc..8699ee002 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -220,7 +220,7 @@ describe('Ticket Edit sale path', () => { it('should log in as salesAssistant and navigate to ticket sales', async() => { await page.loginAndModule('salesAssistant', 'ticket'); - await page.accessToSearchResult('16'); + await page.accessToSearchResult('17'); await page.accessToSection('ticket.card.sale'); }); @@ -233,15 +233,15 @@ describe('Ticket Edit sale path', () => { await page.waitForState('ticket.card.sale'); }); - // it('should select the first sale and create a refund without warehouse', async() => { - // await page.accessToSearchResult('15'); - // await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); - // await page.waitToClick(selectors.ticketSales.moreMenu); - // await page.waitToClick(selectors.ticketSales.moreMenuRefund); - // await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse); - // await page.waitForSnackbar(); - // await page.waitForState('ticket.card.sale'); - // }); + it('should select the first sale and create a refund without warehouse', async() => { + await page.accessToSearchResult('18'); + await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); + await page.waitToClick(selectors.ticketSales.moreMenu); + await page.waitToClick(selectors.ticketSales.moreMenuRefund); + await page.waitToClick(selectors.ticketSales.refundWithoutWarehouse); + await page.waitForSnackbar(); + await page.waitForState('ticket.card.sale'); + }); it('should show error trying to delete a ticket with a refund', async() => { await page.accessToSearchResult('16'); @@ -257,7 +257,6 @@ describe('Ticket Edit sale path', () => { it('should select the third sale and create a claim of it', async() => { await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); - await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); From 153542d2be20985c936a46dca32d20cf19a3778e Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 30 May 2023 09:49:39 +0200 Subject: [PATCH 09/29] refs #5595 taking active connection --- loopback/common/models/vn-model.js | 52 ++++++++++++++----- loopback/server/connectors/vn-mysql.js | 6 --- .../ticket/back/methods/ticket/saveSign.js | 2 +- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 1cb389099..f27000afd 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -196,20 +196,48 @@ module.exports = function(Self) { /* * Shortcut to VnMySQL.executeP() */ - rawSql(query, params, options, cb) { + async rawSql(query, params, options) { const userId = options?.userId; - if (userId) { - params.unshift(userId); - return this.dataSource.connector.executeP( - `CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?)); - ${query}; - CALL account.myUser_logout();`, - params, - options, - cb - ); + const connector = this.dataSource.connector; + let conn; + let res; + const opts = Object.assign({}, options); + + try { + if (userId) { + conn = await new Promise((resolve, reject) => { + connector.client.getConnection(function(err, conn) { + if (err) + reject(err); + else + resolve(conn); + }); + }); + + const opts = Object.assign({}, options); + if (!opts.transaction) { + opts.transaction = { + connection: conn, + connector + }; + } + + await connector.executeP( + 'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))', + [userId], opts + ); + } + + res = await connector.executeP(query, params, opts); + + if (userId) { + await connector.executeP('CALL account.myUser_logout()', null, opts); + } + } finally { + if (conn) conn.release(); } - return this.dataSource.connector.executeP(query, params, options, cb); + + return res; }, /* diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 9ba65d517..40ad78bde 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -17,12 +17,6 @@ class VnMySQL extends MySQL { executeP(query, params, options = {}, cb) { return new Promise((resolve, reject) => { this.execute(query, params, options, (error, response) => { - if(options?.userId) - { - response.shift(); // Remove OkPacket from logIn - response.pop(); // Remove OkPacket from logOut - response = response[response.length - 1] // Keep only query response - } if (cb) cb(error, response); if (error) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index aede7de8e..3fd9cd0bb 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -32,7 +32,7 @@ module.exports = Self => { Self.saveSign = async(ctx, options) => { const args = Object.assign({}, ctx.args); const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let dms; let gestDocCreated = false; From 632662c4404496b6519f019d947f08345b8fd57c Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 30 May 2023 10:49:10 +0200 Subject: [PATCH 10/29] refs #5595 added userId in makeInvoice --- modules/ticket/back/methods/ticket/makeInvoice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index f2536f1b0..ee82b874f 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -28,7 +28,7 @@ module.exports = function(Self) { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); - const myOptions = {userId}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') From 0263d76021d75a5ad815de75cc064db21d1644e1 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 31 May 2023 14:58:16 +0200 Subject: [PATCH 11/29] refs #5701 update to mariadb 10.7.7 --- db/Dockerfile | 15 ++------------- db/docker/docker-temp-stop.sh | 1 - db/dump/mysqlPlugins.sql | 4 ---- 3 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 db/dump/mysqlPlugins.sql diff --git a/db/Dockerfile b/db/Dockerfile index 053fbcee6..8e99e85af 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -1,19 +1,10 @@ -FROM mariadb:10.7.5 +FROM mariadb:10.7.7 -ENV MYSQL_ROOT_PASSWORD root +ENV MARIADB_ROOT_PASSWORD root ENV TZ Europe/Madrid ARG MOCKDATE=2001-01-01 11:00:00 ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update \ - && apt-get install -y --no-install-recommends curl ca-certificates \ - && curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \ - && echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \ - && apt-get update \ - && apt-get install -y vn-mariadb \ - && apt-get purge -y --auto-remove curl ca-certificates \ - && rm -rf /var/lib/apt/lists/* - COPY docker/docker.cnf /etc/mysql/conf.d/ COPY \ docker/docker-init.sh \ @@ -31,13 +22,11 @@ WORKDIR /docker-boot COPY \ import-changes.sh \ config.ini \ - dump/mysqlPlugins.sql \ dump/structure.sql \ dump/mockDate.sql \ dump/dumpedFixtures.sql \ ./ RUN gosu mysql docker-init.sh \ - && docker-dump.sh mysqlPlugins \ && docker-dump.sh structure \ && sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ && docker-dump.sh mockDate \ diff --git a/db/docker/docker-temp-stop.sh b/db/docker/docker-temp-stop.sh index df66959df..418331f75 100755 --- a/db/docker/docker-temp-stop.sh +++ b/db/docker/docker-temp-stop.sh @@ -4,4 +4,3 @@ CMD=mysqld docker_setup_env "$CMD" -docker_temp_server_stop diff --git a/db/dump/mysqlPlugins.sql b/db/dump/mysqlPlugins.sql deleted file mode 100644 index c3b6f6ee4..000000000 --- a/db/dump/mysqlPlugins.sql +++ /dev/null @@ -1,4 +0,0 @@ - --- Import compiled functions -CREATE AGGREGATE FUNCTION minacum RETURNS INT SONAME 'minacum.so'; -CREATE AGGREGATE FUNCTION multimax RETURNS INT SONAME 'multimax.so'; From 4f3b6c303578584629ae7528935c5450c7abd666 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 31 May 2023 15:00:33 +0200 Subject: [PATCH 12/29] typo --- db/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/Dockerfile b/db/Dockerfile index 8e99e85af..719b85393 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -1,6 +1,6 @@ FROM mariadb:10.7.7 -ENV MARIADB_ROOT_PASSWORD root +ENV MYSQL_ROOT_PASSWORD root ENV TZ Europe/Madrid ARG MOCKDATE=2001-01-01 11:00:00 ARG DEBIAN_FRONTEND=noninteractive From f9528b922c6207ba181de9128e85b6580cd36fc1 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 1 Jun 2023 08:32:06 +0200 Subject: [PATCH 13/29] refs #5595 added userId in options --- back/methods/collection/newCollection.js | 12 ++++---- back/methods/edi/updateData.js | 4 +-- .../back/methods/account/change-password.js | 6 ++-- .../back/methods/account/set-password.js | 6 ++-- .../account/specs/change-password.spec.js | 3 +- .../account/specs/set-password.spec.js | 5 ++-- .../importToNewRefundTicket.js | 2 +- .../back/methods/client/confirmTransaction.js | 2 +- .../methods/client/consumptionSendQueued.js | 6 ++-- .../back/methods/client/createReceipt.js | 2 +- modules/client/back/methods/client/filter.js | 4 +-- modules/client/back/methods/client/getCard.js | 6 ++-- modules/client/back/methods/client/getDebt.js | 6 ++-- .../client/back/methods/client/setPassword.js | 6 ++-- .../back/methods/client/specs/getCard.spec.js | 3 +- .../back/methods/client/specs/getDebt.spec.js | 3 +- .../methods/client/specs/setPassword.spec.js | 5 ++-- .../back/methods/client/specs/summary.spec.js | 15 +++++----- modules/client/back/methods/client/summary.js | 6 ++-- .../back/methods/tpv-transaction/confirm.js | 6 ++-- .../back/methods/tpv-transaction/end.js | 2 +- .../back/methods/tpv-transaction/start.js | 2 +- .../entry/back/methods/entry/importBuys.js | 4 +-- .../back/methods/invoice-in/toBook.js | 2 +- .../back/methods/invoiceOut/book.js | 6 ++-- .../methods/invoiceOut/clientsToInvoice.js | 2 +- .../methods/invoiceOut/createManualInvoice.js | 2 +- .../back/methods/invoiceOut/invoiceClient.js | 2 +- .../back/methods/invoiceOut/refund.js | 6 ++-- .../methods/invoiceOut/specs/book.spec.js | 3 +- .../methods/invoiceOut/specs/refund.spec.js | 3 +- modules/item/back/methods/item/getBalance.js | 6 ++-- modules/item/back/methods/item/new.js | 6 ++-- .../methods/item/specs/getBalance.spec.js | 7 +++-- .../item/back/methods/item/specs/new.spec.js | 3 +- .../back/methods/order-row/addToOrder.js | 6 ++-- .../order-row/specs/addToOrder.spec.js | 3 +- modules/order/back/methods/order/confirm.js | 2 +- modules/order/back/methods/order/new.js | 6 ++-- .../order/back/methods/order/newFromTicket.js | 6 ++-- .../back/methods/order/specs/new.spec.js | 5 ++-- .../methods/order/specs/newFromTicket.spec.js | 3 +- .../methods/agency-term/createInvoiceIn.js | 6 ++-- .../agency-term/specs/createInvoiceIn.spec.js | 3 +- .../route/back/methods/route/guessPriority.js | 2 +- .../route/back/methods/route/updateVolume.js | 2 +- .../back/methods/sale/recalculatePrice.js | 2 +- modules/ticket/back/methods/sale/refund.js | 6 ++-- .../back/methods/sale/specs/refund.spec.js | 7 +++-- .../back/methods/sale/specs/reserve.spec.js | 4 +-- .../ticket/back/methods/sale/updatePrice.js | 2 +- modules/ticket/back/methods/sale/usesMana.js | 2 +- .../back/methods/ticket-request/confirm.js | 2 +- modules/ticket/back/methods/ticket/addSale.js | 2 +- .../ticket/back/methods/ticket/closeAll.js | 8 ++--- modules/ticket/back/methods/ticket/closure.js | 29 ++++++++++--------- .../back/methods/ticket/componentUpdate.js | 2 +- .../ticket/back/methods/ticket/getSales.js | 6 ++-- modules/ticket/back/methods/ticket/new.js | 6 ++-- .../back/methods/ticket/priceDifference.js | 2 +- .../methods/ticket/recalculateComponents.js | 2 +- modules/ticket/back/methods/ticket/refund.js | 6 ++-- .../ticket/back/methods/ticket/setDeleted.js | 2 +- .../methods/ticket/specs/getSales.spec.js | 3 +- .../back/methods/ticket/specs/summary.spec.js | 9 +++--- .../ticket/specs/transferSales.spec.js | 16 +++++----- modules/ticket/back/methods/ticket/summary.js | 6 ++-- .../back/methods/ticket/transferSales.js | 2 +- .../back/methods/ticket/updateDiscount.js | 2 +- .../methods/thermograph/createThermograph.js | 6 ++-- .../specs/createThermograph.spec.js | 7 +++-- .../back/methods/travel/deleteThermograph.js | 6 ++-- .../back/methods/department/getLeaves.js | 7 +++-- .../worker-time-control/addTimeEntry.js | 6 ++-- .../worker-time-control/deleteTimeEntry.js | 6 ++-- .../methods/worker-time-control/sendMail.js | 2 +- modules/worker/back/methods/worker/new.js | 2 +- .../back/methods/worker/specs/new.spec.js | 18 ++++++++---- .../agency/getAgenciesWithWarehouse.js | 6 ++-- .../zone/back/methods/agency/landsThatDay.js | 6 ++-- .../specs/getAgenciesWithWarehouse.spec.js | 5 ++-- .../methods/agency/specs/landsThatDay.spec.js | 3 +- modules/zone/back/methods/zone/deleteZone.js | 2 +- modules/zone/back/methods/zone/getEvents.js | 6 ++-- modules/zone/back/methods/zone/getLeaves.js | 6 ++-- .../methods/zone/getUpcomingDeliveries.js | 6 ++-- .../back/methods/zone/specs/getEvents.spec.js | 3 +- .../back/methods/zone/specs/getLeaves.spec.js | 3 +- .../zone/specs/getUpcomingDeliveries.spec.js | 3 +- 89 files changed, 238 insertions(+), 207 deletions(-) diff --git a/back/methods/collection/newCollection.js b/back/methods/collection/newCollection.js index 31e419b67..2be9f8b0e 100644 --- a/back/methods/collection/newCollection.js +++ b/back/methods/collection/newCollection.js @@ -30,11 +30,11 @@ module.exports = Self => { Self.newCollection = async(ctx, collectionFk, sectorFk, vWagons) => { let query = ''; + const userId = ctx.req.accessToken.userId; if (!collectionFk) { - const userId = ctx.req.accessToken.userId; query = `CALL vn.collectionTrain_newBeta(?,?,?)`; - const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId]); + const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId], {userId}); if (result.length == 0) throw new Error(`No collections for today`); @@ -42,16 +42,16 @@ module.exports = Self => { } query = `CALL vn.collectionTicket_get(?)`; - const [tickets] = await Self.rawSql(query, [collectionFk]); + const [tickets] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionSale_get(?)`; - const [sales] = await Self.rawSql(query, [collectionFk]); + const [sales] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionPlacement_get(?)`; - const [placements] = await Self.rawSql(query, [collectionFk]); + const [placements] = await Self.rawSql(query, [collectionFk], {userId}); query = `CALL vn.collectionSticker_print(?,?)`; - await Self.rawSql(query, [collectionFk, sectorFk]); + await Self.rawSql(query, [collectionFk, sectorFk], {userId}); return makeCollection(tickets, sales, placements, collectionFk); }; diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index 232695f4e..5c9961874 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -16,14 +16,14 @@ module.exports = Self => { } }); - Self.updateData = async() => { + Self.updateData = async ctx => { const models = Self.app.models; // Get files checksum const tx = await Self.beginTransaction({}); try { - const options = {transaction: tx}; + const options = {transaction: tx, userId: ctx.req.accessToken.userId}; const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options); const updatableFiles = []; diff --git a/modules/account/back/methods/account/change-password.js b/modules/account/back/methods/account/change-password.js index 549508ffa..bace3e628 100644 --- a/modules/account/back/methods/account/change-password.js +++ b/modules/account/back/methods/account/change-password.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('changePassword', { + Self.remoteMethodCtx('changePassword', { description: 'Changes the user password', accessType: 'WRITE', accepts: [ @@ -27,9 +27,9 @@ module.exports = Self => { } }); - Self.changePassword = async function(id, oldPassword, newPassword) { + Self.changePassword = async function(ctx, id, oldPassword, newPassword) { await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, - [id, oldPassword, newPassword]); + [id, oldPassword, newPassword], {userId: ctx.req.accessToken.userId}); await Self.app.models.Account.syncById(id, newPassword); }; }; diff --git a/modules/account/back/methods/account/set-password.js b/modules/account/back/methods/account/set-password.js index b4204d103..81a310e45 100644 --- a/modules/account/back/methods/account/set-password.js +++ b/modules/account/back/methods/account/set-password.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('setPassword', { + Self.remoteMethodCtx('setPassword', { description: 'Sets the user password', accessType: 'WRITE', accepts: [ @@ -21,9 +21,9 @@ module.exports = Self => { } }); - Self.setPassword = async function(id, newPassword) { + Self.setPassword = async function(ctx, id, newPassword) { await Self.rawSql(`CALL account.user_setPassword(?, ?)`, - [id, newPassword]); + [id, newPassword], {userId: ctx.req.accessToken.userId}); await Self.app.models.Account.syncById(id, newPassword); }; }; diff --git a/modules/account/back/methods/account/specs/change-password.spec.js b/modules/account/back/methods/account/specs/change-password.spec.js index 17fadb3c6..0274cbded 100644 --- a/modules/account/back/methods/account/specs/change-password.spec.js +++ b/modules/account/back/methods/account/specs/change-password.spec.js @@ -2,8 +2,9 @@ const {models} = require('vn-loopback/server/server'); describe('account changePassword()', () => { it('should throw an error when old password is wrong', async() => { + const ctx = {req: {accessToken: {userId: 9}}}; let err; - await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999') + await models.Account.changePassword(ctx, 1, 'wrongPassword', 'nightmare.9999') .catch(error => err = error.sqlMessage); expect(err).toBeDefined(); diff --git a/modules/account/back/methods/account/specs/set-password.spec.js b/modules/account/back/methods/account/specs/set-password.spec.js index 5de2a7bad..f54fba36f 100644 --- a/modules/account/back/methods/account/specs/set-password.spec.js +++ b/modules/account/back/methods/account/specs/set-password.spec.js @@ -1,14 +1,15 @@ const {models} = require('vn-loopback/server/server'); describe('Account setPassword()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should throw an error when password does not meet requirements', async() => { - let req = models.Account.setPassword(1, 'insecurePass'); + let req = models.Account.setPassword(ctx, 1, 'insecurePass'); await expectAsync(req).toBeRejected(); }); it('should update password when it passes requirements', async() => { - let req = models.Account.setPassword(1, 'Very$ecurePa22.'); + let req = models.Account.setPassword(ctx, 1, 'Very$ecurePa22.'); await expectAsync(req).toBeResolved(); }); diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index 83043f012..cdf3fc2c3 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -63,7 +63,7 @@ module.exports = Self => { }; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/confirmTransaction.js b/modules/client/back/methods/client/confirmTransaction.js index a1969d6fd..fcb33c4ca 100644 --- a/modules/client/back/methods/client/confirmTransaction.js +++ b/modules/client/back/methods/client/confirmTransaction.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index 07b5fb57b..a7081c550 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -1,7 +1,7 @@ const {Email} = require('vn-print'); module.exports = Self => { - Self.remoteMethod('consumptionSendQueued', { + Self.remoteMethodCtx('consumptionSendQueued', { description: 'Send all queued invoices', accessType: 'WRITE', accepts: [], @@ -15,7 +15,7 @@ module.exports = Self => { } }); - Self.consumptionSendQueued = async() => { + Self.consumptionSendQueued = async ctx => { const queues = await Self.rawSql(` SELECT id, @@ -68,7 +68,7 @@ module.exports = Self => { SET status = 'printed', printed = ? WHERE id = ?`, - [Date.vnNew(), queue.id]); + [Date.vnNew(), queue.id], {userId: ctx.req.accessToken.userId}); } catch (error) { await Self.rawSql(` UPDATE clientConsumptionQueue diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index cb032270a..b70b9bbe0 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -55,7 +55,7 @@ module.exports = function(Self) { date.setHours(0, 0, 0, 0); let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index 1ae569fd3..3bf29501b 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -72,7 +72,7 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const conn = Self.dataSource.connector; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const postalCode = []; const args = ctx.args; @@ -120,7 +120,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT + `SELECT DISTINCT c.id, c.name, c.fi, diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 414cbe058..941ae0495 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -1,5 +1,5 @@ module.exports = function(Self) { - Self.remoteMethod('getCard', { + Self.remoteMethodCtx('getCard', { description: 'Get client basic data and debt', accepts: { arg: 'id', @@ -18,8 +18,8 @@ module.exports = function(Self) { } }); - Self.getCard = async(id, options) => { - const myOptions = {}; + Self.getCard = async(ctx, id, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/getDebt.js b/modules/client/back/methods/client/getDebt.js index 859746083..6ed59684b 100644 --- a/modules/client/back/methods/client/getDebt.js +++ b/modules/client/back/methods/client/getDebt.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getDebt', { + Self.remoteMethodCtx('getDebt', { description: 'Returns the boolean debt of a client', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getDebt = async(clientFk, options) => { - const myOptions = {}; + Self.getDebt = async(ctx, clientFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/client/setPassword.js b/modules/client/back/methods/client/setPassword.js index e5b8949e7..fbed2828d 100644 --- a/modules/client/back/methods/client/setPassword.js +++ b/modules/client/back/methods/client/setPassword.js @@ -1,6 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('setPassword', { + Self.remoteMethodCtx('setPassword', { description: 'Sets the password of a non-worker client', accepts: [ { @@ -21,14 +21,14 @@ module.exports = Self => { } }); - Self.setPassword = async function(id, newPassword) { + Self.setPassword = async function(ctx, id, newPassword) { const models = Self.app.models; const isClient = await models.Client.findById(id); const isAccount = await models.Account.findById(id); if (isClient && !isAccount) - await models.Account.setPassword(id, newPassword); + await models.Account.setPassword(ctx, id, newPassword); else throw new UserError(`Modifiable password only via recovery or by an administrator`); }; diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index e713c9883..962e0a2d4 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -5,10 +5,11 @@ describe('Client getCard()', () => { const tx = await models.Client.beginTransaction({}); try { + const ctx = {req: {accessToken: {userId: 9}}}; const options = {transaction: tx}; const id = 1101; - const result = await models.Client.getCard(id, options); + const result = await models.Client.getCard(ctx, id, options); expect(result.id).toEqual(id); expect(result.name).toEqual('Bruce Wayne'); diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index 471d45a6d..b3b5286c0 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -3,11 +3,12 @@ const models = require('vn-loopback/server/server').models; describe('client getDebt()', () => { it('should return the client debt', async() => { const tx = await models.Client.beginTransaction({}); + const ctx = {req: {accessToken: {userId: 9}}}; try { const options = {transaction: tx}; - const result = await models.Client.getDebt(1101, options); + const result = await models.Client.getDebt(ctx, 1101, options); expect(result.debt).toEqual(jasmine.any(Number)); diff --git a/modules/client/back/methods/client/specs/setPassword.spec.js b/modules/client/back/methods/client/specs/setPassword.spec.js index 590172a02..c004b0372 100644 --- a/modules/client/back/methods/client/specs/setPassword.spec.js +++ b/modules/client/back/methods/client/specs/setPassword.spec.js @@ -1,11 +1,12 @@ const models = require('vn-loopback/server/server').models; describe('Client setPassword', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should throw an error the setPassword target is not just a client but a worker', async() => { let error; try { - await models.Client.setPassword(1, 't0pl3v3l.p455w0rd!'); + await models.Client.setPassword(ctx, 1, 't0pl3v3l.p455w0rd!'); } catch (e) { error = e; } @@ -17,7 +18,7 @@ describe('Client setPassword', () => { let error; try { - await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!'); + await models.Client.setPassword(ctx, 1101, 't0pl3v3l.p455w0rd!'); } catch (e) { error = e; } diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index f2d576e39..227f4c398 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('client summary()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return a summary object containing data', async() => { const clientId = 1101; const tx = await models.Client.beginTransaction({}); @@ -8,7 +9,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.id).toEqual(clientId); expect(result.name).toEqual('Bruce Wayne'); @@ -27,7 +28,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.mana.mana).toEqual(0.34); @@ -45,7 +46,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.debt.debt).toEqual(jasmine.any(Number)); @@ -63,7 +64,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.averageInvoiced.invoiced).toEqual(1500); @@ -81,7 +82,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.totalGreuge).toEqual(203.71); @@ -99,7 +100,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.recovery).toEqual(null); @@ -117,7 +118,7 @@ describe('client summary()', () => { try { const options = {transaction: tx}; - const result = await models.Client.summary(clientId, options); + const result = await models.Client.summary(ctx, clientId, options); expect(result.recovery.id).toEqual(3); await tx.rollback(); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 7dab1f68b..8de887b47 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('summary', { + Self.remoteMethodCtx('summary', { description: 'Returns a client summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(clientFk, options) => { + Self.summary = async(ctx, clientFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getSummary(models.Client, clientFk, myOptions); summaryObj.mana = await models.Client.getMana(clientFk, myOptions); - summaryObj.debt = await models.Client.getDebt(clientFk, myOptions); + summaryObj.debt = await models.Client.getDebt(ctx, clientFk, myOptions); summaryObj.averageInvoiced = await models.Client.getAverageInvoiced(clientFk, myOptions); summaryObj.totalGreuge = await models.Greuge.sumAmount(clientFk, myOptions); summaryObj.recovery = await getRecoveries(models.Recovery, clientFk, myOptions); diff --git a/modules/client/back/methods/tpv-transaction/confirm.js b/modules/client/back/methods/tpv-transaction/confirm.js index 41229a1fd..4faa21bb5 100644 --- a/modules/client/back/methods/tpv-transaction/confirm.js +++ b/modules/client/back/methods/tpv-transaction/confirm.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); const base64url = require('base64url'); module.exports = Self => { - Self.remoteMethod('confirm', { + Self.remoteMethodCtx('confirm', { description: 'Confirms electronic payment transaction', accessType: 'WRITE', accepts: [ @@ -30,7 +30,7 @@ module.exports = Self => { } }); - Self.confirm = async(signatureVersion, merchantParameters, signature) => { + Self.confirm = async(ctx, signatureVersion, merchantParameters, signature) => { const $ = Self.app.models; let transaction; @@ -83,7 +83,7 @@ module.exports = Self => { params['Ds_Currency'], params['Ds_Response'], params['Ds_ErrorCode'] - ]); + ], {userId: ctx.req.accessToken.userId}); return true; } catch (err) { diff --git a/modules/client/back/methods/tpv-transaction/end.js b/modules/client/back/methods/tpv-transaction/end.js index 5a757aa48..3233f482f 100644 --- a/modules/client/back/methods/tpv-transaction/end.js +++ b/modules/client/back/methods/tpv-transaction/end.js @@ -34,6 +34,6 @@ module.exports = Self => { 'CALL hedera.tpvTransaction_end(?, ?)', [ orderId, status - ]); + ], {userId}); }; }; diff --git a/modules/client/back/methods/tpv-transaction/start.js b/modules/client/back/methods/tpv-transaction/start.js index ea6ed05eb..178c56d76 100644 --- a/modules/client/back/methods/tpv-transaction/start.js +++ b/modules/client/back/methods/tpv-transaction/start.js @@ -40,7 +40,7 @@ module.exports = Self => { amount, companyId, userId - ]); + ], {userId}); if (!row) throw new UserError('Transaction error'); diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index fdc6b058e..1e6f01a5e 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -46,7 +46,7 @@ module.exports = Self => { const args = ctx.args; const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -79,7 +79,7 @@ module.exports = Self => { ], myOptions); const buyUltimate = await Self.rawSql(` - SELECT * + SELECT * FROM tmp.buyUltimate WHERE warehouseFk = ? `, [travel.warehouseInFk], myOptions); diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js index 588d53f1f..877552f41 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toBook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js @@ -21,7 +21,7 @@ module.exports = Self => { Self.toBook = async(ctx, id, options) => { let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/book.js b/modules/invoiceOut/back/methods/invoiceOut/book.js index 7aa0eac1f..af5633ff2 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/book.js +++ b/modules/invoiceOut/back/methods/invoiceOut/book.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('book', { + Self.remoteMethodCtx('book', { description: 'Book an invoiceOut', accessType: 'WRITE', accepts: { @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.book = async(ref, options) => { + Self.book = async(ctx, ref, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index f18b0c682..63b00fe38 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, options) => { let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index a458aa18e..18e6903d6 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -51,7 +51,7 @@ module.exports = Self => { const args = ctx.args; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index c8f8a6778..421cbaea1 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -50,7 +50,7 @@ module.exports = Self => { Self.invoiceClient = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index ad480dc7d..93c2b7749 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', accepts: [{ @@ -17,7 +17,7 @@ module.exports = Self => { } }); - Self.refund = async(ref, options) => { + Self.refund = async(ctx, ref, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -35,7 +35,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); + const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index ee72f2218..3af7542ca 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('invoiceOut book()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const invoiceOutId = 5; it('should update the booked property', async() => { @@ -12,7 +13,7 @@ describe('invoiceOut book()', () => { const bookedDate = originalInvoiceOut.booked; const invoiceOutRef = originalInvoiceOut.ref; - await models.InvoiceOut.book(invoiceOutRef, options); + await models.InvoiceOut.book(ctx, invoiceOutRef, options); const updatedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index 35f2b4023..25bddf2c6 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -3,6 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('InvoiceOut refund()', () => { const userId = 5; + const ctx = {req: {accessToken: userId}}; const activeCtx = { accessToken: {userId: userId}, }; @@ -15,7 +16,7 @@ describe('InvoiceOut refund()', () => { const options = {transaction: tx}; try { - const result = await models.InvoiceOut.refund('T1111111', options); + const result = await models.InvoiceOut.refund(ctx, 'T1111111', options); expect(result).toBeDefined(); diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 5751b0a04..d4e2d0f74 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getBalance', { + Self.remoteMethodCtx('getBalance', { description: 'Returns the ', accessType: 'READ', accepts: [{ @@ -19,8 +19,8 @@ module.exports = Self => { } }); - Self.getBalance = async(filter, options) => { - const myOptions = {}; + Self.getBalance = async(ctx, filter, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/item/back/methods/item/new.js b/modules/item/back/methods/item/new.js index d066f2c9f..c82e2a6b1 100644 --- a/modules/item/back/methods/item/new.js +++ b/modules/item/back/methods/item/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('new', { + Self.remoteMethodCtx('new', { description: 'returns the created item', accessType: 'WRITE', accepts: [{ @@ -19,9 +19,9 @@ module.exports = Self => { } }); - Self.new = async(params, options) => { + Self.new = async(ctx, params, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 1ffd3c302..e013d8956 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item getBalance()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the balance lines of a client type loses in which one has highlighted true', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -25,7 +26,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(filter, options); + const results = await models.Item.getBalance(ctx, filter, options); const result = results.find(element => element.clientType == 'loses'); @@ -59,8 +60,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(firstFilter, options); - const secondItemBalance = await models.Item.getBalance(secondFilter, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[5].claimFk).toEqual(2); diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index a1c741649..2ffaf87a5 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item new()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -30,7 +31,7 @@ describe('item new()', () => { tag: 1 }; - let item = await models.Item.new(itemParams, options); + let item = await models.Item.new(ctx, itemParams, options); let itemType = await models.ItemType.findById(item.typeFk, options); diff --git a/modules/order/back/methods/order-row/addToOrder.js b/modules/order/back/methods/order-row/addToOrder.js index 639fa8be7..0bf65ef1f 100644 --- a/modules/order/back/methods/order-row/addToOrder.js +++ b/modules/order/back/methods/order-row/addToOrder.js @@ -1,7 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('addToOrder', { + Self.remoteMethodCtx('addToOrder', { description: 'Creates rows (lines) for a order', accessType: 'WRITE', accepts: [{ @@ -21,8 +21,8 @@ module.exports = Self => { } }); - Self.addToOrder = async(params, options) => { - const myOptions = {}; + Self.addToOrder = async(ctx, params, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order-row/specs/addToOrder.spec.js b/modules/order/back/methods/order-row/specs/addToOrder.spec.js index d902a1062..96544a1a9 100644 --- a/modules/order/back/methods/order-row/specs/addToOrder.spec.js +++ b/modules/order/back/methods/order-row/specs/addToOrder.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order addToOrder()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const orderId = 8; it('should add a row to a given order', async() => { const tx = await models.Order.beginTransaction({}); @@ -21,7 +22,7 @@ describe('order addToOrder()', () => { }] }; - await models.OrderRow.addToOrder(params, options); + await models.OrderRow.addToOrder(ctx, params, options); const modifiedRows = await models.OrderRow.find({where: {orderFk: orderId}}, options); diff --git a/modules/order/back/methods/order/confirm.js b/modules/order/back/methods/order/confirm.js index 52acc8648..5fdab29b3 100644 --- a/modules/order/back/methods/order/confirm.js +++ b/modules/order/back/methods/order/confirm.js @@ -23,7 +23,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const query = `CALL hedera.order_confirmWithUser(?, ?)`; - const response = await Self.rawSql(query, [orderFk, userId]); + const response = await Self.rawSql(query, [orderFk, userId], {userId}); return response; }; diff --git a/modules/order/back/methods/order/new.js b/modules/order/back/methods/order/new.js index 147859dcc..d65b18e12 100644 --- a/modules/order/back/methods/order/new.js +++ b/modules/order/back/methods/order/new.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('new', { + Self.remoteMethodCtx('new', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [ @@ -32,8 +32,8 @@ module.exports = Self => { } }); - Self.new = async(landed, addressId, agencyModeId, options) => { - const myOptions = {}; + Self.new = async(ctx, landed, addressId, agencyModeId, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/order/back/methods/order/newFromTicket.js b/modules/order/back/methods/order/newFromTicket.js index e0578ff9a..3614d8e32 100644 --- a/modules/order/back/methods/order/newFromTicket.js +++ b/modules/order/back/methods/order/newFromTicket.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('newFromTicket', { + Self.remoteMethodCtx('newFromTicket', { description: 'Create a new order and returns the new ID', accessType: 'WRITE', accepts: [{ @@ -18,7 +18,7 @@ module.exports = Self => { } }); - Self.newFromTicket = async(ticketFk, options) => { + Self.newFromTicket = async(ctx, ticketFk, options) => { const myOptions = {}; let tx; @@ -39,7 +39,7 @@ module.exports = Self => { const addressFk = ticket.addressFk; const agencyModeFk = ticket.agencyModeFk; - const orderID = await Self.app.models.Order.new(landed, addressFk, agencyModeFk, myOptions); + const orderID = await Self.app.models.Order.new(ctx, landed, addressFk, agencyModeFk, myOptions); if (tx) await tx.commit(); diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js index f11367579..c43527f66 100644 --- a/modules/order/back/methods/order/specs/new.spec.js +++ b/modules/order/back/methods/order/specs/new.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const UserError = require('vn-loopback/util/user-error'); describe('order new()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should throw an error if the client isnt active', async() => { const tx = await models.Order.beginTransaction({}); @@ -13,7 +14,7 @@ describe('order new()', () => { const addressFk = 6; const agencyModeFk = 1; - await models.Order.new(landed, addressFk, agencyModeFk, options); + await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); await tx.rollback(); } catch (e) { @@ -34,7 +35,7 @@ describe('order new()', () => { const addressFk = 121; const agencyModeFk = 1; - orderId = await models.Order.new(landed, addressFk, agencyModeFk, options); + orderId = await models.Order.new(ctx, landed, addressFk, agencyModeFk, options); const highestOrderIdInFixtures = 3; diff --git a/modules/order/back/methods/order/specs/newFromTicket.spec.js b/modules/order/back/methods/order/specs/newFromTicket.spec.js index 6f18d1751..c509552fe 100644 --- a/modules/order/back/methods/order/specs/newFromTicket.spec.js +++ b/modules/order/back/methods/order/specs/newFromTicket.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order newFromTicket()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should create a new order from an existing ticket', async() => { const tx = await models.Order.beginTransaction({}); @@ -9,7 +10,7 @@ describe('order newFromTicket()', () => { const ticketId = 11; - const orderId = await models.Order.newFromTicket(ticketId, options); + const orderId = await models.Order.newFromTicket(ctx, ticketId, options); const highestOrderIdInFixtures = 3; diff --git a/modules/route/back/methods/agency-term/createInvoiceIn.js b/modules/route/back/methods/agency-term/createInvoiceIn.js index 836655bd3..5a8430e49 100644 --- a/modules/route/back/methods/agency-term/createInvoiceIn.js +++ b/modules/route/back/methods/agency-term/createInvoiceIn.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('createInvoiceIn', { + Self.remoteMethodCtx('createInvoiceIn', { description: 'Creates an invoiceIn from one or more agency terms', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,11 @@ module.exports = Self => { } }); - Self.createInvoiceIn = async(rows, dms, options) => { + Self.createInvoiceIn = async(ctx, rows, dms, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js index 628c5fb9a..d3a0755ef 100644 --- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js +++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('AgencyTerm createInvoiceIn()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -42,7 +43,7 @@ describe('AgencyTerm createInvoiceIn()', () => { const oldInvoiceInDueDay = await models.InvoiceInDueDay.findById(invoiceInDueDayId, null, options); const oldInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); - await models.AgencyTerm.createInvoiceIn(rows, dms, options); + await models.AgencyTerm.createInvoiceIn(ctx, rows, dms, options); const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options); diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js index eab9f3473..67b68aa89 100644 --- a/modules/route/back/methods/route/guessPriority.js +++ b/modules/route/back/methods/route/guessPriority.js @@ -26,7 +26,7 @@ module.exports = Self => { const tx = await Self.beginTransaction({}); try { - let options = {transaction: tx}; + let options = {transaction: tx, userId}; const priority = await Self.rawSql(query, [id], options); diff --git a/modules/route/back/methods/route/updateVolume.js b/modules/route/back/methods/route/updateVolume.js index f3b8da130..cdced3882 100644 --- a/modules/route/back/methods/route/updateVolume.js +++ b/modules/route/back/methods/route/updateVolume.js @@ -24,7 +24,7 @@ module.exports = Self => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index 2c8e6768b..fd3d6aa9b 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -23,7 +23,7 @@ module.exports = Self => { Self.recalculatePrice = async(ctx, sales, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 18ccee976..35eb001e6 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with sales and services if provided', accessType: 'WRITE', accepts: [ @@ -23,9 +23,9 @@ module.exports = Self => { } }); - Self.refund = async(salesIds, servicesIds, options) => { + Self.refund = async(ctx, salesIds, servicesIds, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 83b3755e2..e7c5da71f 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -3,8 +3,9 @@ const LoopBackContext = require('loopback-context'); describe('Sale refund()', () => { const userId = 5; + const ctx = {req: {accessToken: userId}}; const activeCtx = { - accessToken: {userId: userId}, + accessToken: {userId}, }; const servicesIds = [3]; @@ -22,7 +23,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const refundedTicket = await models.Sale.refund(salesIds, servicesIds, options); + const refundedTicket = await models.Sale.refund(ctx, salesIds, servicesIds, options); expect(refundedTicket).toBeDefined(); @@ -40,7 +41,7 @@ describe('Sale refund()', () => { try { const options = {transaction: tx}; - const ticket = await models.Sale.refund(salesIds, servicesIds, options); + const ticket = await models.Sale.refund(ctx, salesIds, servicesIds, options); const refundedTicket = await models.Ticket.findOne({ where: { diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js index 259cb8cd5..7ba5999b3 100644 --- a/modules/ticket/back/methods/sale/specs/reserve.spec.js +++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js @@ -52,7 +52,7 @@ describe('sale reserve()', () => { try { const options = {transaction: tx}; - originalTicketSales = await models.Ticket.getSales(11, options); + originalTicketSales = await models.Ticket.getSales(ctx, 11, options); expect(originalTicketSales[0].reserved).toEqual(false); expect(originalTicketSales[1].reserved).toEqual(false); @@ -63,7 +63,7 @@ describe('sale reserve()', () => { await models.Sale.reserve(ctx, ticketId, sales, reserved, options); - const reservedTicketSales = await models.Ticket.getSales(ticketId, options); + const reservedTicketSales = await models.Ticket.getSales(ctx, ticketId, options); expect(reservedTicketSales[0].reserved).toEqual(true); expect(reservedTicketSales[1].reserved).toEqual(true); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 505de5180..649395da6 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -31,7 +31,7 @@ module.exports = Self => { Self.updatePrice = async(ctx, id, newPrice, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 3f55293bf..75d8cdda7 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -22,7 +22,7 @@ module.exports = Self => { Object.assign(myOptions, options); const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); - const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); + const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions); const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions); if (!workerDepartment) return false; diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index f7f7fbc2a..2061ca355 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -34,7 +34,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 37d97b2c7..85b0510ae 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -35,7 +35,7 @@ module.exports = Self => { Self.addSale = async(ctx, id, itemId, quantity, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 6690126b9..660c16893 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); const closure = require('./closure'); module.exports = Self => { - Self.remoteMethod('closeAll', { + Self.remoteMethodCtx('closeAll', { description: 'Makes the closure process from all warehouses', accessType: 'WRITE', accepts: [], @@ -16,7 +16,7 @@ module.exports = Self => { } }); - Self.closeAll = async() => { + Self.closeAll = async ctx => { const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); @@ -59,7 +59,7 @@ module.exports = Self => { GROUP BY t.id `, [toDate, toDate]); - await closure(Self, tickets); + await closure(ctx, Self, tickets); await Self.rawSql(` UPDATE ticket t @@ -73,7 +73,7 @@ module.exports = Self => { AND util.dayEnd(?) AND al.code NOT IN('DELIVERED','PACKED') AND t.routeFk - AND z.name LIKE '%MADRID%'`, [toDate, toDate]); + AND z.name LIKE '%MADRID%'`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); return { message: 'Success' diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 9b3355d6c..eee5e28e2 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -4,13 +4,14 @@ const smtp = require('vn-print/core/smtp'); const config = require('vn-print/core/config'); const storage = require('vn-print/core/storage'); -module.exports = async function(Self, tickets, reqArgs = {}) { +module.exports = async function(ctx, Self, tickets, reqArgs = {}) { + const userId = ctx.req.accessToken.userId; if (tickets.length == 0) return; const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]); + await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId}); const [invoiceOut] = await Self.rawSql(` SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued @@ -52,7 +53,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) { fileName: fileName }); - await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]); + await Self.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id], {userId}); if (isToBeMailed) { const invoiceAttachment = { @@ -91,7 +92,7 @@ module.exports = async function(Self, tickets, reqArgs = {}) { // Incoterms authorization const [{firstOrder}] = await Self.rawSql(` SELECT COUNT(*) as firstOrder - FROM ticket t + FROM ticket t JOIN client c ON c.id = t.clientFk WHERE t.clientFk = ? AND NOT t.isDeleted @@ -111,14 +112,14 @@ module.exports = async function(Self, tickets, reqArgs = {}) { await email.send(); const [sample] = await Self.rawSql( - `SELECT id - FROM sample + `SELECT id + FROM sample WHERE code = 'incoterms-authorization' `); await Self.rawSql(` INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) - `, [ticket.clientFk, sample.id, ticket.companyFk]); + `, [ticket.clientFk, sample.id, ticket.companyFk], {userId}); } } catch (error) { // Domain not found @@ -152,23 +153,23 @@ module.exports = async function(Self, tickets, reqArgs = {}) { async function invalidEmail(ticket) { await Self.rawSql(`UPDATE client SET email = NULL WHERE id = ?`, [ ticket.clientFk - ]); + ], {userId}); const oldInstance = `{"email": "${ticket.recipient}"}`; const newInstance = `{"email": ""}`; await Self.rawSql(` - INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) + INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, [ ticket.clientFk, oldInstance, newInstance - ]); + ], {userId}); - const body = `No se ha podido enviar el albarán ${ticket.id} - al cliente ${ticket.clientFk} - ${ticket.clientName} - porque la dirección de email "${ticket.recipient}" no es correcta + const body = `No se ha podido enviar el albarán ${ticket.id} + al cliente ${ticket.clientFk} - ${ticket.clientName} + porque la dirección de email "${ticket.recipient}" no es correcta o no está disponible.

- Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. + Para evitar que se repita este error, se ha eliminado la dirección de email de la ficha del cliente. Actualiza la dirección de email con una correcta.`; smtp.send({ diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index dac8e4f52..a8b631d7c 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -101,7 +101,7 @@ module.exports = Self => { Self.componentUpdate = async(ctx, options) => { const args = ctx.args; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/getSales.js b/modules/ticket/back/methods/ticket/getSales.js index 321e8e24e..e721d90ae 100644 --- a/modules/ticket/back/methods/ticket/getSales.js +++ b/modules/ticket/back/methods/ticket/getSales.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getSales', { + Self.remoteMethodCtx('getSales', { description: 'New filter', accessType: 'READ', accepts: [{ @@ -20,10 +20,10 @@ module.exports = Self => { } }); - Self.getSales = async(id, options) => { + Self.getSales = async(ctx, id, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index 5f7cf3cb6..b461fb26d 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -59,9 +59,9 @@ module.exports = Self => { Self.new = async(ctx, options) => { const args = ctx.args; - const myUserId = ctx.req.accessToken.userId; + const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') @@ -123,7 +123,7 @@ module.exports = Self => { args.routeId || null, args.landed, true, - myUserId + userId ], myOptions); const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions); diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 27fdb9160..42a71f1c8 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -60,7 +60,7 @@ module.exports = Self => { Self.priceDifference = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/recalculateComponents.js b/modules/ticket/back/methods/ticket/recalculateComponents.js index 5b9e8e5dc..eb9c8a72e 100644 --- a/modules/ticket/back/methods/ticket/recalculateComponents.js +++ b/modules/ticket/back/methods/ticket/recalculateComponents.js @@ -21,7 +21,7 @@ module.exports = Self => { }); Self.recalculateComponents = async(ctx, id, options) => { - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js index 91f48cfd6..e534cd0b8 100644 --- a/modules/ticket/back/methods/ticket/refund.js +++ b/modules/ticket/back/methods/ticket/refund.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('refund', { + Self.remoteMethodCtx('refund', { description: 'Create refund tickets with all their sales and services', accessType: 'WRITE', accepts: [ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.refund = async(ticketsIds, options) => { + Self.refund = async(ctx, ticketsIds, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -41,7 +41,7 @@ module.exports = Self => { const services = await models.TicketService.find(filter, myOptions); const servicesIds = services.map(service => service.id); - const refundedTickets = await models.Sale.refund(salesIds, servicesIds, myOptions); + const refundedTickets = await models.Sale.refund(ctx, salesIds, servicesIds, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 228e2e765..7cc300547 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -24,7 +24,7 @@ module.exports = Self => { Self.setDeleted = async(ctx, id, options) => { const models = Self.app.models; const $t = ctx.req.__; // $translate - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/specs/getSales.spec.js b/modules/ticket/back/methods/ticket/specs/getSales.spec.js index b9f78e40b..7c0a67d45 100644 --- a/modules/ticket/back/methods/ticket/specs/getSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getSales.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('ticket getSales()', () => { + const ctx = {req: {accessToken: 9}}; it('should return the sales of a ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const sales = await models.Ticket.getSales(16, options); + const sales = await models.Ticket.getSales(ctx, 16, options); expect(sales.length).toEqual(4); expect(sales[0].item).toBeDefined(); diff --git a/modules/ticket/back/methods/ticket/specs/summary.spec.js b/modules/ticket/back/methods/ticket/specs/summary.spec.js index 5d2991b0a..2c4aedf1e 100644 --- a/modules/ticket/back/methods/ticket/specs/summary.spec.js +++ b/modules/ticket/back/methods/ticket/specs/summary.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('ticket summary()', () => { + const ctx = {req: {accessToken: 9}}; it('should return a summary object containing data from 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.id).toEqual(1); expect(result.nickname).toEqual('Bat cave'); @@ -25,7 +26,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.sales.length).toEqual(4); @@ -42,7 +43,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithoutVat).toEqual(jasmine.any(Number)); @@ -59,7 +60,7 @@ describe('ticket summary()', () => { try { const options = {transaction: tx}; - const result = await models.Ticket.summary(1, options); + const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithVat).toEqual(jasmine.any(Number)); diff --git a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js index 270aae2f8..562688917 100644 --- a/modules/ticket/back/methods/ticket/specs/transferSales.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferSales.spec.js @@ -67,7 +67,7 @@ describe('sale transferSales()', () => { const ticketId = 11; const receiverTicketId = null; - const sales = await models.Ticket.getSales(ticketId, options); + const sales = await models.Ticket.getSales(ctx, ticketId, options); await models.Ticket.transferSales(ctx, ticketId, receiverTicketId, sales, options); @@ -89,7 +89,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); expect(formerTicketSales.length).toEqual(2); @@ -98,8 +98,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(formerTicketId, options); - let createdTicketSales = await models.Ticket.getSales(createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + let createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); expect(formerTicketSales.length).toEqual(0); expect(createdTicketSales.length).toEqual(2); @@ -120,7 +120,7 @@ describe('sale transferSales()', () => { const options = {transaction: tx}; const currentTicketId = 22; - const currentTicketSales = await models.Ticket.getSales(currentTicketId, options); + const currentTicketSales = await models.Ticket.getSales(ctx, currentTicketId, options); const receiverTicketId = undefined; @@ -147,7 +147,7 @@ describe('sale transferSales()', () => { const formerTicketId = 22; let createdTicketId = undefined; - let formerTicketSales = await models.Ticket.getSales(formerTicketId, options); + let formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); const completeSaleId = formerTicketSales[1].id; let partialSaleTotalQuantity = formerTicketSales[0].quantity; @@ -161,8 +161,8 @@ describe('sale transferSales()', () => { createdTicketId = createdTicket.id; - formerTicketSales = await models.Ticket.getSales(formerTicketId, options); - createdTicketSales = await models.Ticket.getSales(createdTicketId, options); + formerTicketSales = await models.Ticket.getSales(ctx, formerTicketId, options); + createdTicketSales = await models.Ticket.getSales(ctx, createdTicketId, options); const [createdPartialSale] = createdTicketSales.filter(sale => { return sale.id != completeSaleId; diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index a57968fc1..1ce91e1b2 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('summary', { + Self.remoteMethodCtx('summary', { description: 'Returns a ticket summary', accessType: 'READ', accepts: [{ @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.summary = async(ticketFk, options) => { + Self.summary = async(ctx, ticketFk, options) => { const models = Self.app.models; const myOptions = {}; @@ -28,7 +28,7 @@ module.exports = Self => { const summaryObj = await getTicketData(Self, ticketFk, myOptions); - summaryObj.sales = await models.Ticket.getSales(ticketFk, myOptions); + summaryObj.sales = await models.Ticket.getSales(ctx, ticketFk, myOptions); summaryObj.packagings = await models.TicketPackaging.find({ where: {ticketFk: ticketFk}, diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 5737e628f..01ada49d0 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.transferSales = async(ctx, id, ticketId, sales, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; let tx; if (typeof options == 'object') diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 4b31c0ce4..6feeafa1a 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -44,7 +44,7 @@ module.exports = Self => { Self.updateDiscount = async(ctx, id, salesIds, newDiscount, manaCode, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') diff --git a/modules/travel/back/methods/thermograph/createThermograph.js b/modules/travel/back/methods/thermograph/createThermograph.js index 75d967628..243e2129f 100644 --- a/modules/travel/back/methods/thermograph/createThermograph.js +++ b/modules/travel/back/methods/thermograph/createThermograph.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('createThermograph', { + Self.remoteMethodCtx('createThermograph', { description: 'Creates a new thermograph', accessType: 'WRITE', accepts: [{ @@ -36,10 +36,10 @@ module.exports = Self => { } }); - Self.createThermograph = async(thermographId, model, temperatureFk, warehouseId, options) => { + Self.createThermograph = async(ctx, thermographId, model, temperatureFk, warehouseId, options) => { const models = Self.app.models; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const date = Date.vnNew(); if (typeof options == 'object') diff --git a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js index 32014e303..90855bf81 100644 --- a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js +++ b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js @@ -5,6 +5,7 @@ describe('Termograph createThermograph()', () => { const model = 'DISPOSABLE'; const temperatureFk = 'COOL'; const warehouseId = 1; + const ctx = {req: {accessToken: {userId: 9}}}; it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => { const tx = await models.Thermograph.beginTransaction({}); @@ -12,7 +13,7 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - const createdThermograph = await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); + const createdThermograph = await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); expect(createdThermograph.id).toEqual(thermographId); expect(createdThermograph.model).toEqual(model); @@ -37,8 +38,8 @@ describe('Termograph createThermograph()', () => { try { const options = {transaction: tx}; - await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); - await models.Thermograph.createThermograph(thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/deleteThermograph.js b/modules/travel/back/methods/travel/deleteThermograph.js index ba541c560..d22fc8b29 100644 --- a/modules/travel/back/methods/travel/deleteThermograph.js +++ b/modules/travel/back/methods/travel/deleteThermograph.js @@ -26,9 +26,9 @@ module.exports = Self => { await models.Dms.removeFile(ctx, travelThermograph.dmsFk); await Self.rawSql(` - UPDATE travelThermograph - SET travelFk = NULL, dmsFk = NULL - WHERE id = ?`, [id]); + UPDATE travelThermograph + SET travelFk = NULL, dmsFk = NULL + WHERE id = ?`, [id], {userId}); const oldInstance = { travelFk: travelThermograph.travelFk, diff --git a/modules/worker/back/methods/department/getLeaves.js b/modules/worker/back/methods/department/getLeaves.js index 614f3388e..48fe78e08 100644 --- a/modules/worker/back/methods/department/getLeaves.js +++ b/modules/worker/back/methods/department/getLeaves.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getLeaves', { + Self.remoteMethodCtx, ('getLeaves', { description: 'Returns the nodes for a department', accepts: [{ arg: 'parentId', @@ -20,10 +20,11 @@ module.exports = Self => { } }); - Self.getLeaves = async(parentId = null, search) => { + Self.getLeaves = async(ctx, parentId = null, search) => { let [res] = await Self.rawSql( `CALL department_getLeaves(?, ?)`, - [parentId, search] + [parentId, search], + {userId: ctx.req.accessToken.userId} ); let map = new Map(); diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index bcc96985f..cc652fb90 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -33,15 +33,15 @@ module.exports = Self => { Self.addTimeEntry = async(ctx, workerId, options) => { const models = Self.app.models; const args = ctx.args; - const currentUserId = ctx.req.accessToken.userId; - const myOptions = {}; + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == workerId; + const isHimself = userId == workerId; if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js index 80482901f..8f9541596 100644 --- a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js @@ -22,10 +22,10 @@ module.exports = Self => { }); Self.deleteTimeEntry = async(ctx, id, options) => { - const currentUserId = ctx.req.accessToken.userId; + const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -33,7 +33,7 @@ module.exports = Self => { const targetTimeEntry = await Self.findById(id, null, myOptions); const isSubordinate = await models.Worker.isSubordinate(ctx, targetTimeEntry.userFk, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == targetTimeEntry.userFk; + const isHimself = userId == targetTimeEntry.userFk; if (isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 2c827e320..d19b799e1 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -33,7 +33,7 @@ module.exports = Self => { const conn = Self.dataSource.connector; const args = ctx.args; let tx; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 398411118..27acc98ab 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -119,7 +119,7 @@ module.exports = Self => { Self.new = async(ctx, options) => { const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; const args = ctx.args; let tx; diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 44f6e9b09..b2804c203 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -36,6 +36,7 @@ describe('Worker new', () => { payMethodFk: 1, roleFk: 1 }; + const req = {accessToken: {userId: 9}}; it('should return error if personal mail already exists', async() => { const user = await models.VnUser.findById(employeeId, {fields: ['email']}); @@ -46,7 +47,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {email: user.email}) + args: Object.assign({}, defaultWorker, {email: user.email}), + req }; await models.Worker.new(ctx, options); @@ -69,7 +71,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {code: worker.code}) + args: Object.assign({}, defaultWorker, {code: worker.code}), + req }; await models.Worker.new(ctx, options); @@ -92,7 +95,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {fi: worker.fi}) + args: Object.assign({}, defaultWorker, {fi: worker.fi}), + req }; await models.Worker.new(ctx, options); @@ -119,7 +123,8 @@ describe('Worker new', () => { try { const options = {transaction: tx}; const ctx = { - args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}) + args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}), + req }; await models.Worker.new(ctx, options); @@ -133,7 +138,7 @@ describe('Worker new', () => { }); it('should create a new worker', async() => { - const newWorker = await models.Worker.new({args: defaultWorker}); + const newWorker = await models.Worker.new({args: defaultWorker, req}); await models.Worker.destroyById(newWorker.id); await models.Address.destroyAll({clientFk: newWorker.id}); @@ -155,7 +160,8 @@ describe('Worker new', () => { { fi: client.fi, email: client.email - }) + }), + req }; const newWorker = await models.Worker.new(newWorkerData); diff --git a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js index 846ad6a3d..c8ab4f67c 100644 --- a/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js +++ b/modules/zone/back/methods/agency/getAgenciesWithWarehouse.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getAgenciesWithWarehouse', { + Self.remoteMethodCtx('getAgenciesWithWarehouse', { description: 'Returns a list of agencies that can land a shipment on a day for an address and a warehouse', accepts: [ { @@ -28,8 +28,8 @@ module.exports = Self => { } }); - Self.getAgenciesWithWarehouse = async(addressFk, landed, warehouseFk, options) => { - const myOptions = {}; + Self.getAgenciesWithWarehouse = async(ctx, addressFk, landed, warehouseFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/landsThatDay.js b/modules/zone/back/methods/agency/landsThatDay.js index b7f13ddda..4d73e4d08 100644 --- a/modules/zone/back/methods/agency/landsThatDay.js +++ b/modules/zone/back/methods/agency/landsThatDay.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('landsThatDay', { + Self.remoteMethodCtx('landsThatDay', { description: 'Returns a list of agencies that can land a shipment on a day for an address', accepts: [ { @@ -22,8 +22,8 @@ module.exports = Self => { } }); - Self.landsThatDay = async(addressFk, landed, options) => { - const myOptions = {}; + Self.landsThatDay = async(ctx, addressFk, landed, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js index 4f79b2315..f760559cb 100644 --- a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js +++ b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js @@ -2,6 +2,7 @@ const app = require('vn-loopback/server/server'); describe('Agency getAgenciesWithWarehouse()', () => { const today = Date.vnNew(); + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the agencies that can handle the given delivery request', async() => { const tx = await app.models.Zone.beginTransaction({}); @@ -9,7 +10,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, today, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, today, 1, options); expect(agencies.length).toEqual(3); expect(agencies[0].agencyMode).toEqual('inhouse pickup'); @@ -30,7 +31,7 @@ describe('Agency getAgenciesWithWarehouse()', () => { const options = {transaction: tx}; const addressId = 101; - const agencies = await app.models.Agency.getAgenciesWithWarehouse(addressId, null, 1, options); + const agencies = await app.models.Agency.getAgenciesWithWarehouse(ctx, addressId, null, 1, options); expect(agencies.length).toEqual(0); diff --git a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js index 4bde37984..1ec675071 100644 --- a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js +++ b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js @@ -1,6 +1,7 @@ const {models} = require('vn-loopback/server/server'); describe('Agency landsThatDay()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; const today = Date.vnNew(); it('should return a list of agencies that can land a shipment on a day for an address', async() => { const tx = await models.Agency.beginTransaction({}); @@ -8,7 +9,7 @@ describe('Agency landsThatDay()', () => { try { const options = {transaction: tx}; - const agencies = await models.Agency.landsThatDay(101, today, options); + const agencies = await models.Agency.landsThatDay(ctx, 101, today, options); expect(agencies.length).toBeGreaterThanOrEqual(3); diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index e3846132b..bcfb91e3d 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -26,7 +26,7 @@ module.exports = Self => { today.setHours(0, 0, 0, 0); let tx; - const myOptions = {}; + const myOptions = {userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getEvents.js b/modules/zone/back/methods/zone/getEvents.js index a8ee8bb7b..03fb31438 100644 --- a/modules/zone/back/methods/zone/getEvents.js +++ b/modules/zone/back/methods/zone/getEvents.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getEvents', { + Self.remoteMethodCtx('getEvents', { description: 'Returns delivery days for a postcode', accepts: [ { @@ -25,8 +25,8 @@ module.exports = Self => { } }); - Self.getEvents = async(geoFk, agencyModeFk, options) => { - const myOptions = {}; + Self.getEvents = async(ctx, geoFk, agencyModeFk, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getLeaves.js b/modules/zone/back/methods/zone/getLeaves.js index ed421e339..a6db3b711 100644 --- a/modules/zone/back/methods/zone/getLeaves.js +++ b/modules/zone/back/methods/zone/getLeaves.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethod('getLeaves', { + Self.remoteMethodCtx('getLeaves', { description: 'Returns the nodes for a zone', accepts: [ { @@ -31,8 +31,8 @@ module.exports = Self => { } }); - Self.getLeaves = async(id, parentId = null, search, options) => { - const myOptions = {}; + Self.getLeaves = async(ctx, id, parentId = null, search, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/getUpcomingDeliveries.js b/modules/zone/back/methods/zone/getUpcomingDeliveries.js index 2a1c39ed6..e8b7e7636 100644 --- a/modules/zone/back/methods/zone/getUpcomingDeliveries.js +++ b/modules/zone/back/methods/zone/getUpcomingDeliveries.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('getUpcomingDeliveries', { + Self.remoteMethodCtx('getUpcomingDeliveries', { description: 'Returns the upcomings deliveries', accessType: 'READ', accepts: [], @@ -13,8 +13,8 @@ module.exports = Self => { } }); - Self.getUpcomingDeliveries = async options => { - const myOptions = {}; + Self.getUpcomingDeliveries = async(ctx, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/zone/back/methods/zone/specs/getEvents.spec.js b/modules/zone/back/methods/zone/specs/getEvents.spec.js index d1c51baff..c1dee3e0f 100644 --- a/modules/zone/back/methods/zone/specs/getEvents.spec.js +++ b/modules/zone/back/methods/zone/specs/getEvents.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('zone getEvents()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return all events for the specified geo and agency mode', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getEvents(20, 1, options); + let result = await models.Zone.getEvents(ctx, 20, 1, options); expect(result.events.length).toEqual(10); diff --git a/modules/zone/back/methods/zone/specs/getLeaves.spec.js b/modules/zone/back/methods/zone/specs/getLeaves.spec.js index db7359671..9342a0b50 100644 --- a/modules/zone/back/methods/zone/specs/getLeaves.spec.js +++ b/modules/zone/back/methods/zone/specs/getLeaves.spec.js @@ -1,13 +1,14 @@ const models = require('vn-loopback/server/server').models; describe('zone getLeaves()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should return the country and the childs containing the search value', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getLeaves(1, null, '46000', options); + let result = await models.Zone.getLeaves(ctx, 1, null, '46000', options); expect(result.length).toEqual(1); diff --git a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js index acef079f6..fe542fbf3 100644 --- a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js +++ b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js @@ -1,12 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('zone getUpcomingDeliveries()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; it('should check returns data', async() => { const tx = await models.Zone.beginTransaction({}); try { const options = {transaction: tx}; - let result = await models.Zone.getUpcomingDeliveries(options); + let result = await models.Zone.getUpcomingDeliveries(ctx, options); const firstResultLines = result[0].lines; const secondResultLines = result[1].lines; From fe32a2af050dd43bacb57db4029281b1f9479114 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 5 Jun 2023 08:35:07 +0200 Subject: [PATCH 14/29] refs #5667 RoleInherit & Sms: Translations added --- modules/account/back/locale/role-inherit/en.yml | 1 + modules/account/back/locale/role-inherit/es.yml | 1 + modules/client/back/locale/sms/en.yml | 10 ++++++++++ modules/client/back/locale/sms/es.yml | 10 ++++++++++ 4 files changed, 22 insertions(+) create mode 100644 modules/client/back/locale/sms/en.yml create mode 100644 modules/client/back/locale/sms/es.yml diff --git a/modules/account/back/locale/role-inherit/en.yml b/modules/account/back/locale/role-inherit/en.yml index 760881325..8422ecdce 100644 --- a/modules/account/back/locale/role-inherit/en.yml +++ b/modules/account/back/locale/role-inherit/en.yml @@ -1,4 +1,5 @@ name: subrole columns: + id: id role: rol inheritsFrom: inherits diff --git a/modules/account/back/locale/role-inherit/es.yml b/modules/account/back/locale/role-inherit/es.yml index c352c6ff2..10381628c 100644 --- a/modules/account/back/locale/role-inherit/es.yml +++ b/modules/account/back/locale/role-inherit/es.yml @@ -1,4 +1,5 @@ name: subrol columns: + id: id role: rol inheritsFrom: hereda diff --git a/modules/client/back/locale/sms/en.yml b/modules/client/back/locale/sms/en.yml new file mode 100644 index 000000000..cb52f80ec --- /dev/null +++ b/modules/client/back/locale/sms/en.yml @@ -0,0 +1,10 @@ +name: SMS +columns: + id: id + senderFk: sender + sender: sender number + destination: destination + message: message + statusCode: status code + status: status + created: created diff --git a/modules/client/back/locale/sms/es.yml b/modules/client/back/locale/sms/es.yml new file mode 100644 index 000000000..f314921c1 --- /dev/null +++ b/modules/client/back/locale/sms/es.yml @@ -0,0 +1,10 @@ +name: SMS +columns: + id: id + senderFk: remitente + sender: número remitente + destination: destinatario + message: mensaje + statusCode: código estado + status: estado + created: creado From 6ef7055bc97658a499744a1cc62f0497b1234633 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 6 Jun 2023 11:05:04 +0200 Subject: [PATCH 15/29] refs #5563 Display show values in logs --- front/salix/components/log/index.html | 6 ++-- front/salix/components/log/index.js | 41 +++++++++++++++++++++------ front/salix/components/log/style.scss | 4 +++ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index d5675975b..a50bafe5d 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -75,16 +75,16 @@ {{::prop.nameI18n}}: - , + ,
{{::prop.nameI18n}}: - + - ← + ←
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index ef1b370b5..362eb8089 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -64,29 +64,47 @@ export default class Controller extends Section { set logs(value) { this._logs = value; if (!value) return; + const empty = {}; const validations = window.validations; + const castJsonValue = this.castJsonValue; + for (const log of value) { - const oldValues = log.oldInstance || empty; - const newValues = log.newInstance || empty; + const notDelete = log.action != 'delete'; + const olds = (notDelete ? log.oldInstance : null) || empty; + const vals = (notDelete ? log.newInstance : log.oldInstance) || empty; const locale = validations[log.changedModel]?.locale || empty; log.changedModelI18n = firstUpper(locale.name) || log.changedModel; - let props = Object.keys(oldValues).concat(Object.keys(newValues)); + let props = Object.keys(olds).concat(Object.keys(vals)); props = [...new Set(props)]; log.props = []; for (const prop of props) { + if (prop.endsWith('$')) continue; log.props.push({ name: prop, nameI18n: firstUpper(locale.columns?.[prop]) || prop, - old: this.castJsonValue(oldValues[prop]), - new: this.castJsonValue(newValues[prop]) + old: getVal(olds, prop), + val: getVal(vals, prop) }); } log.props.sort( (a, b) => a.nameI18n.localeCompare(b.nameI18n)); } + + function getVal(vals, prop) { + let val, id; + const showProp = `${prop}$`; + + if (vals[showProp] != null) { + val = vals[showProp]; + id = vals[prop]; + } else + val = vals[prop]; + + return {val: castJsonValue(val), id}; + } } get models() { @@ -113,10 +131,6 @@ export default class Controller extends Section { : value; } - mainVal(prop, action) { - return action == 'delete' ? prop.old : prop.new; - } - relativeDate(dateVal) { if (dateVal == null) return ''; const date = new Date(dateVal); @@ -238,3 +252,12 @@ ngModule.vnComponent('vnLog', { url: '@' } }); + +ngModule.component('vnLogValue', { + template: + '' + + ' #{{::$ctrl.val.id}}', + bindings: { + val: ' .id-value { + font-size: .9rem; + color: $color-font-secondary; +} From 6f3704c365f4fb4ab90d959a3836743806e3cae0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 6 Jun 2023 11:42:35 +0200 Subject: [PATCH 16/29] hotfix colors ticket advance ticket future --- db/changes/232202/00-procedurecanAdvance.sql | 127 ++++++++++++++++++ .../232202/00-procedurecanbePostponed.sql | 74 ++++++++++ modules/ticket/front/advance/index.html | 2 +- modules/ticket/front/advance/index.js | 7 - modules/ticket/front/future/index.html | 2 +- 5 files changed, 203 insertions(+), 9 deletions(-) create mode 100644 db/changes/232202/00-procedurecanAdvance.sql create mode 100644 db/changes/232202/00-procedurecanbePostponed.sql diff --git a/db/changes/232202/00-procedurecanAdvance.sql b/db/changes/232202/00-procedurecanAdvance.sql new file mode 100644 index 000000000..d82294b3c --- /dev/null +++ b/db/changes/232202/00-procedurecanAdvance.sql @@ -0,0 +1,127 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM config; + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) +SELECT + origin.ticketFk futureId, + dest.ticketFk id, + dest.state, + origin.futureState, + origin.futureIpt, + dest.ipt, + origin.workerFk, + origin.futureLiters, + origin.futureLines, + dest.shipped, + origin.shipped futureShipped, + dest.totalWithVat, + origin.totalWithVat futureTotalWithVat, + dest.agency, + origin.futureAgency, + dest.lines, + dest.liters, + origin.futureLines - origin.hasStock AS notMovableLines, + (origin.futureLines = origin.hasStock) AS isFullMovable, + origin.classColor futureClassColor, + dest.classColor + FROM ( + SELECT + s.ticketFk, + t.workerFk, + t.shipped, + t.totalWithVat, + st.name futureState, + t.addressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(st.amount,0))) hasStock, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT + t.id ticketFk, + t.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t.shipped, + t.totalWithVat, + am.name agency, + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, + st.classColor + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t.warehouseFk = vWarehouseFk + AND st.order <= 5 + GROUP BY t.id + ) dest ON dest.addressFk = origin.addressFk + WHERE origin.hasStock != 0; + DROP TEMPORARY TABLE tmp.stock; +END$$ +DELIMITER ; diff --git a/db/changes/232202/00-procedurecanbePostponed.sql b/db/changes/232202/00-procedurecanbePostponed.sql new file mode 100644 index 000000000..9d42dcc4b --- /dev/null +++ b/db/changes/232202/00-procedurecanbePostponed.sql @@ -0,0 +1,74 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vOriginDated Fecha en cuestión + * @param vFutureDated Fecha en el futuro a sondear + * @param vWarehouseFk Identificador de vn.warehouse + */ + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT sv.ticketFk id, + sub2.id futureId, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + st.name state, + sub2.iptd futureIpt, + sub2.state futureState, + t.clientFk, + t.warehouseFk, + ts.alertLevel, + t.shipped, + sub2.shipped futureShipped, + t.workerFk, + st.code stateCode, + sub2.code futureStateCode, + st.classColor, + sub2.classColor futureClassColor + FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ( + SELECT * + FROM ( + SELECT + t.addressFk, + t.id, + t.shipped, + st.name state, + st.code, + st.classColor, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + WHERE t.shipped BETWEEN vFutureDated + AND util.dayend(vFutureDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vOriginDated AND util.dayend(vOriginDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + GROUP BY sv.ticketFk + HAVING futureId; +END$$ +DELIMITER ; diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index c937fe2ac..e6f16c965 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -150,7 +150,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.futureClassColor}}"> {{::ticket.futureState | dashIfEmpty}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 7b8008426..0cec41227 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -102,13 +102,6 @@ export default class Controller extends Section { return checkedLines; } - stateColor(state) { - if (state === 'OK') - return 'success'; - else if (state === 'Libre') - return 'notice'; - } - dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/future/index.html b/modules/ticket/front/future/index.html index 2f0290c27..78b0f9864 100644 --- a/modules/ticket/front/future/index.html +++ b/modules/ticket/front/future/index.html @@ -158,7 +158,7 @@ {{::ticket.futureIpt | dashIfEmpty}} + class="chip {{ticket.futureClassColor}}"> {{::ticket.futureState}} From 05111c9268a6cdf05b2c095c3a0a3ef33bf55cec Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 6 Jun 2023 11:43:14 +0200 Subject: [PATCH 17/29] hotfix test front --- modules/ticket/front/advance/index.spec.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index 6874f914b..da8614ca5 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -61,24 +61,6 @@ describe('Component vnTicketAdvance', () => { }); }); - describe('stateColor()', () => { - it('should return success to the OK tickets', () => { - const ok = controller.stateColor(controller.$.model.data[0].state); - const notOk = controller.stateColor(controller.$.model.data[1].state); - - expect(ok).toEqual('success'); - expect(notOk).not.toEqual('success'); - }); - - it('should return success to the FREE tickets', () => { - const notFree = controller.stateColor(controller.$.model.data[0].state); - const free = controller.stateColor(controller.$.model.data[1].state); - - expect(free).toEqual('notice'); - expect(notFree).not.toEqual('notice'); - }); - }); - describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { const now = Date.vnNew(); From bd4eee66066d560b36f5452eb8664d9054d0bde2 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 7 Jun 2023 14:17:46 +0200 Subject: [PATCH 18/29] refs #5252 eliminado warehouseFk = 1 por defecto #5252 --- db/changes/232201/00-ticket_warehouse.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/232201/00-ticket_warehouse.sql b/db/changes/232201/00-ticket_warehouse.sql index 171538566..b5255ee3f 100644 --- a/db/changes/232201/00-ticket_warehouse.sql +++ b/db/changes/232201/00-ticket_warehouse.sql @@ -1 +1 @@ -ALTER TABLE `vn`.`ticket` MODIFY COLUMN warehouseFk smallint(6) unsigned DEFAULT 1 NULL; +ALTER TABLE `vn`.`ticket` MODIFY COLUMN warehouseFk smallint(6) unsigned DEFAULT NULL NULL; From 9a63ce86aa9cccdf060220ba0a125ff04b24ccf5 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 7 Jun 2023 23:54:27 +0200 Subject: [PATCH 19/29] refs #5667 filter by changes, align entity id to right, duplicated code remove from Log models --- front/salix/components/log/index.html | 15 +++-- front/salix/components/log/index.js | 14 +++-- front/salix/components/log/locale/es.yml | 3 + front/salix/components/log/style.scss | 1 + loopback/common/models/log.json | 61 ++++++++++++++++++- modules/account/back/models/role-log.json | 49 --------------- modules/account/back/models/user-log.json | 49 --------------- modules/claim/back/models/claim-log.json | 49 --------------- modules/client/back/models/client-log.json | 49 --------------- modules/entry/back/models/entry-log.json | 49 --------------- .../invoiceIn/back/models/invoice-in-log.json | 52 ---------------- modules/item/back/models/item-log.json | 49 --------------- modules/route/back/models/route-log.json | 49 --------------- .../shelving/back/models/shelving-log.json | 57 ++--------------- .../supplier/back/models/supplier-log.json | 49 --------------- modules/ticket/back/models/ticket-log.json | 57 ++--------------- modules/travel/back/models/travel-log.json | 49 --------------- .../back/models/device-production-log.json | 59 +++--------------- modules/worker/back/models/worker-log.json | 49 --------------- modules/zone/back/models/zone-log.json | 49 --------------- 20 files changed, 97 insertions(+), 761 deletions(-) diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index a50bafe5d..e6ade48fb 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -53,12 +53,10 @@ -
#{{::log.changedModelId}} - {{::log.changedModelValue}} + {{::log.changedModelValue}}
- .model-id { color: $color-font-secondary; font-size: .9rem; + float: right; } } } diff --git a/loopback/common/models/log.json b/loopback/common/models/log.json index 54046f072..6d246371c 100644 --- a/loopback/common/models/log.json +++ b/loopback/common/models/log.json @@ -1,4 +1,61 @@ { - "name": "Log", - "base": "VnModel" + "name": "Log", + "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "oldJson": { + "type": "String", + "mysql": {"columnName": "oldInstance"} + }, + "newJson": { + "type": "String", + "mysql": {"columnName": "newInstance"} + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "string" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } } diff --git a/modules/account/back/models/role-log.json b/modules/account/back/models/role-log.json index 510e98b68..324000b68 100644 --- a/modules/account/back/models/role-log.json +++ b/modules/account/back/models/role-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "account.roleLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/account/back/models/user-log.json b/modules/account/back/models/user-log.json index c5aa08e05..8c0234aca 100644 --- a/modules/account/back/models/user-log.json +++ b/modules/account/back/models/user-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "account.userLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/claim/back/models/claim-log.json b/modules/claim/back/models/claim-log.json index 9f28af63e..2c061b08f 100644 --- a/modules/claim/back/models/claim-log.json +++ b/modules/claim/back/models/claim-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "claimLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/client/back/models/client-log.json b/modules/client/back/models/client-log.json index 316dbe972..c0e69df35 100644 --- a/modules/client/back/models/client-log.json +++ b/modules/client/back/models/client-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "clientLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json index b4370e3bc..ac4d803d1 100644 --- a/modules/entry/back/models/entry-log.json +++ b/modules/entry/back/models/entry-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "entryLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/invoiceIn/back/models/invoice-in-log.json b/modules/invoiceIn/back/models/invoice-in-log.json index 70892d0f9..43ebb4c55 100644 --- a/modules/invoiceIn/back/models/invoice-in-log.json +++ b/modules/invoiceIn/back/models/invoice-in-log.json @@ -5,57 +5,5 @@ "mysql": { "table": "invoiceInLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": [ - "creationDate DESC", - "id DESC" - ] } } diff --git a/modules/item/back/models/item-log.json b/modules/item/back/models/item-log.json index 19c132187..8b8534d11 100644 --- a/modules/item/back/models/item-log.json +++ b/modules/item/back/models/item-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "itemLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/route/back/models/route-log.json b/modules/route/back/models/route-log.json index 93f570593..63c233bdd 100644 --- a/modules/route/back/models/route-log.json +++ b/modules/route/back/models/route-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "routeLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/shelving/back/models/shelving-log.json b/modules/shelving/back/models/shelving-log.json index e8245f770..03a5dda1a 100644 --- a/modules/shelving/back/models/shelving-log.json +++ b/modules/shelving/back/models/shelving-log.json @@ -1,58 +1,9 @@ { - "name": "ShelvingLog", + "name": "ShelvingLog", "base": "Log", - "options": { - "mysql": { - "table": "shelvingLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" + "options": { + "mysql": { + "table": "shelvingLog" } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/supplier/back/models/supplier-log.json b/modules/supplier/back/models/supplier-log.json index 86fa2e54a..1fe4752a0 100644 --- a/modules/supplier/back/models/supplier-log.json +++ b/modules/supplier/back/models/supplier-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "supplierLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index df04348da..d5d1e5520 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -1,58 +1,9 @@ { - "name": "TicketLog", + "name": "TicketLog", "base": "Log", - "options": { - "mysql": { - "table": "ticketLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "number" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" + "options": { + "mysql": { + "table": "ticketLog" } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/travel/back/models/travel-log.json b/modules/travel/back/models/travel-log.json index e781c2948..e01d57943 100644 --- a/modules/travel/back/models/travel-log.json +++ b/modules/travel/back/models/travel-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "travelLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/worker/back/models/device-production-log.json b/modules/worker/back/models/device-production-log.json index 71c54a9c1..b87fe5e6b 100644 --- a/modules/worker/back/models/device-production-log.json +++ b/modules/worker/back/models/device-production-log.json @@ -1,55 +1,14 @@ { - "name": "DeviceProductionLog", - "base": "Log", - "options": { - "mysql": { - "table": "deviceProductionLog" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "deviceProduction": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "created": { - "type": "date" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "changedModel": { - "type": "string" - }, - "changedModelId": { - "type": "number" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" + "name": "DeviceProductionLog", + "base": "Log", + "options": { + "mysql": { + "table": "deviceProductionLog" } }, - "scope": { - "order": ["created DESC", "id DESC"] + "properties": { + "deviceProduction": { + "type": "number" + } } } diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json index 6eb8b75be..1ca1ac5ff 100644 --- a/modules/worker/back/models/worker-log.json +++ b/modules/worker/back/models/worker-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "workerLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } diff --git a/modules/zone/back/models/zone-log.json b/modules/zone/back/models/zone-log.json index 72dd305b2..403966ddd 100644 --- a/modules/zone/back/models/zone-log.json +++ b/modules/zone/back/models/zone-log.json @@ -5,54 +5,5 @@ "mysql": { "table": "zoneLog" } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "originFk": { - "type": "number", - "required": true - }, - "userFk": { - "type": "number" - }, - "action": { - "type": "string", - "required": true - }, - "changedModel": { - "type": "string" - }, - "oldInstance": { - "type": "object" - }, - "newInstance": { - "type": "object" - }, - "creationDate": { - "type": "date" - }, - "changedModelId": { - "type": "string" - }, - "changedModelValue": { - "type": "string" - }, - "description": { - "type": "string" - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "VnUser", - "foreignKey": "userFk" - } - }, - "scope": { - "order": ["creationDate DESC", "id DESC"] } } From 5ba8a153169542d3efab62d0c11d612f4c1af7ff Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Jun 2023 10:25:25 +0200 Subject: [PATCH 20/29] refs #5809 deploy 232401 dev in test --- CHANGELOG.md | 6 ++--- Dockerfile | 4 +-- Jenkinsfile | 8 +++--- .../00-ticket_warehouse.sql | 0 e2e/paths/06-claim/05_summary.spec.js | 6 ++++- .../order/front/catalog-search-panel/index.js | 4 +-- modules/order/front/catalog/index.html | 26 +++++++++---------- package-lock.json | 4 +-- webpack.config.js | 2 +- 9 files changed, 32 insertions(+), 28 deletions(-) rename db/changes/{232201 => 232401}/00-ticket_warehouse.sql (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c4ee3aa..4f2c0e6e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2324.01] - 2023-06-08 ### Added -- - +- (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén +- (General -> Desplegables) Mejorada eficiencia de carga de datos ### Changed -- +- (General -> Permisos) Mejorada seguridad ### Fixed - diff --git a/Dockerfile b/Dockerfile index ee87cd0d0..e1173ad73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,9 @@ RUN apt-get update \ ca-certificates \ gnupg2 \ graphicsmagick \ - && curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \ + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ - && npm install -g npm@8.19.2 + && npm install -g npm@9.6.6 # Puppeteer diff --git a/Jenkinsfile b/Jenkinsfile index 5f329ee61..cf9b8cd67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ pipeline { NODE_ENV = "" } steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'npm install --no-audit --prefer-offline' sh 'gulp install --ci' } @@ -57,14 +57,14 @@ pipeline { parallel { stage('Frontend') { steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2' } } } stage('Backend') { steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'npm run test:back:ci' } } @@ -80,7 +80,7 @@ pipeline { CREDENTIALS = credentials('docker-registry') } steps { - nodejs('node-v14') { + nodejs('node-v20') { sh 'gulp build' } diff --git a/db/changes/232201/00-ticket_warehouse.sql b/db/changes/232401/00-ticket_warehouse.sql similarity index 100% rename from db/changes/232201/00-ticket_warehouse.sql rename to db/changes/232401/00-ticket_warehouse.sql diff --git a/e2e/paths/06-claim/05_summary.spec.js b/e2e/paths/06-claim/05_summary.spec.js index 9656ea656..1333ed01a 100644 --- a/e2e/paths/06-claim/05_summary.spec.js +++ b/e2e/paths/06-claim/05_summary.spec.js @@ -49,7 +49,11 @@ describe('Claim summary path', () => { }); it(`should click on the first sale ID making the item descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstSaleItemId); + const firstItem = selectors.claimSummary.firstSaleItemId; + await page.evaluate(selectors => { + document.querySelector(selectors).scrollIntoView(); + }, firstItem); + await page.click(firstItem); await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage); const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover); diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index ed0af1d6e..21c0c50fa 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -23,7 +23,7 @@ class Controller extends SearchPanel { addValue() { this.filter.values.push({}); - setTimeout(() => this.popover.relocate()); + setTimeout(() => this.parentPopover.relocate()); } changeTag() { @@ -36,7 +36,7 @@ ngModule.vnComponent('vnOrderCatalogSearchPanel', { controller: Controller, bindings: { onSubmit: '&?', - popover: ' @@ -31,7 +31,7 @@ label="Category"> - - @@ -104,20 +104,20 @@ on-close="$ctrl.onPopoverClose()">
- + class="colored"> Id: {{$ctrl.itemId}} - {{$ctrl.itemName}}
- + class="colored"> {{category.selection.name}} - + class="colored"> {{type.selection.name}} + class="colored">
{{::tagGroup.tagSelection.name}}: @@ -163,4 +163,4 @@
- \ No newline at end of file + diff --git a/package-lock.json b/package-lock.json index a224c4bb3..4ed50e256 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "salix-back", - "version": "23.22.01", + "version": "23.24.01", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "salix-back", - "version": "23.22.01", + "version": "23.24.01", "license": "GPL-3.0", "dependencies": { "axios": "^1.2.2", diff --git a/webpack.config.js b/webpack.config.js index 7a94b993d..a102b838e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,7 +9,7 @@ let mode = env == 'development' ? env : 'production'; let baseConfig = { entry: {salix: 'salix'}, - mode: mode, + mode, output: { path: path.join(__dirname, 'dist'), publicPath: '/' From dd72ac910748e175c8c8ec485c5e2d9b1d4b9114 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Jun 2023 10:48:35 +0200 Subject: [PATCH 21/29] refs #5809 version 232601 init --- CHANGELOG.md | 9 +++++++++ db/changes/232601/.gitkeep | 0 package.json | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/changes/232601/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f2c0e6e5..ca342abbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2326.01] - 2023-06-29 + +### Added + +### Changed + +### Fixed +- + ## [2324.01] - 2023-06-08 ### Added diff --git a/db/changes/232601/.gitkeep b/db/changes/232601/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index f1b3daca3..4358c86a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.24.01", + "version": "23.26.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From bdffc0401fd98a4ff2b410f97c0509269a557151 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 8 Jun 2023 15:29:03 +0200 Subject: [PATCH 22/29] refs #5760 update getChanges, traduccion --- .eslintrc.yml | 4 ++-- .../ticket/back/methods/ticket-log/getChanges.js | 16 ++++++++-------- modules/ticket/front/descriptor/locale/es.yml | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 13fc2b140..ee20324ff 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,6 +1,6 @@ extends: [eslint:recommended, google, plugin:jasmine/recommended] parserOptions: - ecmaVersion: 2018 + ecmaVersion: 2020 sourceType: "module" plugins: - jasmine @@ -35,4 +35,4 @@ rules: space-in-parens: ["error", "never"] jasmine/no-focused-tests: 0 jasmine/prefer-toHaveBeenCalledWith: 0 - arrow-spacing: ["error", { "before": true, "after": true }] \ No newline at end of file + arrow-spacing: ["error", { "before": true, "after": true }] diff --git a/modules/ticket/back/methods/ticket-log/getChanges.js b/modules/ticket/back/methods/ticket-log/getChanges.js index 7a6de49e8..1b74ec1d7 100644 --- a/modules/ticket/back/methods/ticket-log/getChanges.js +++ b/modules/ticket/back/methods/ticket-log/getChanges.js @@ -61,15 +61,15 @@ module.exports = Self => { const oldQuantity = log.oldInstance.quantity; const newQuantity = log.newInstance?.quantity || 0; - if (oldQuantity || newQuantity) { - const changeMessage = $t('Change quantity', { - concept: log.changedModelValue, - oldQuantity: oldQuantity || 0, - newQuantity: newQuantity || 0, - }); - changes.push(changeMessage); + if (oldQuantity > newQuantity) { + const changeMessage = $t('Change quantity', { + concept: log.changedModelValue, + oldQuantity: oldQuantity || 0, + newQuantity: newQuantity || 0, + }); + changes.push(changeMessage); } - } + } return changes.join('\n'); }; diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index d921b5dc2..3da013467 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -23,4 +23,4 @@ Restore ticket: Restaurar ticket You are going to restore this ticket: Vas a restaurar este ticket Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? -Send changes: "Verdnatura le recuerda:\rPedido {{ticketId}} día {{created | date: 'dd/MM/yyyy'}}\r{{changes}}" +Send changes: "Verdnatura:\rPedido {{ticketId}}\r{{changes}}" From 9c007504ea8be832d70ae8f27dcf01238744c8a0 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 9 Jun 2023 01:22:36 +0200 Subject: [PATCH 23/29] refs #5667 UI improved, filter by record --- front/core/styles/util.scss | 7 +++ front/core/styles/variables.scss | 2 - front/salix/components/background/style.scss | 4 +- front/salix/components/layout/style.scss | 4 +- front/salix/components/log/index.html | 50 ++++++++++---------- front/salix/components/log/index.js | 17 +++++-- front/salix/components/log/locale/es.yml | 7 ++- front/salix/components/log/style.scss | 24 ++++++++-- front/salix/styles/misc.scss | 7 ++- 9 files changed, 76 insertions(+), 46 deletions(-) diff --git a/front/core/styles/util.scss b/front/core/styles/util.scss index 95a523ff4..8c345ddcc 100644 --- a/front/core/styles/util.scss +++ b/front/core/styles/util.scss @@ -1,4 +1,11 @@ +@import "./variables"; +@import "./effects"; +@mixin mobile { + @media screen and (max-width: $mobile-width) { + @content; + } +} @mixin browser($browser) { html[data-browser*="#{$browser}"] & { @content; diff --git a/front/core/styles/variables.scss b/front/core/styles/variables.scss index bcc9fab66..0a74c8277 100644 --- a/front/core/styles/variables.scss +++ b/front/core/styles/variables.scss @@ -1,5 +1,3 @@ -@import "./util"; - $font-size: 11pt; $menu-width: 256px; $topbar-height: 56px; diff --git a/front/salix/components/background/style.scss b/front/salix/components/background/style.scss index c75b69c52..5bc56683e 100644 --- a/front/salix/components/background/style.scss +++ b/front/salix/components/background/style.scss @@ -1,4 +1,4 @@ -@import "variables"; +@import "util"; @keyframes fadein { from { @@ -16,7 +16,7 @@ vn-background { background-color: black; z-index: 14; - @media screen and (max-width: $mobile-width) { + @include mobile { &.shown { display: block; opacity: .3; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 612366228..fa3e8f918 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -1,4 +1,4 @@ -@import "effects"; +@import "util"; vn-layout { & > vn-topbar { @@ -134,7 +134,7 @@ vn-layout { border-radius: 50%; } } - @media screen and (max-width: $mobile-width) { + @include mobile { & > vn-topbar { & > .start > .logo { display: none; diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index e6ade48fb..f68919f00 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -16,7 +16,7 @@ + class="vn-w-sm vn-px-sm vn-pb-xl">
-
- - - {{::$ctrl.relativeDate(log.creationDate)}} -
+
+ {{::$ctrl.relativeDate(log.creationDate)}} + + +
+ ng-if="::$ctrl.showModelName"> #{{::log.changedModelId}} + + {{::log.changedModelValue}}
+ +
- - - - - -
diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index 3392c53be..8aea255a2 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -165,11 +165,10 @@ export default class Controller extends Section { switch (prop) { case 'search': const or = []; - if (/^[\w_-]+$/.test(value)) - or.push({changedModelId: value}); - if (!/^[0-9]+$/.test(value)) - or.push({changedModelValue: {like: `%${value}%`}}); - return or.length ? {or} : null; + if (/^\s*[0-9]+\s*$/.test(value)) + return {changedModelId: value.trim()}; + else + return {changedModelValue: {like: `%${value}%`}}; case 'changes': return {or: [ {oldJson: {like: `%${value}%`}}, @@ -222,6 +221,14 @@ export default class Controller extends Section { return this.$.model.applyFilter(lbFilter); } + filterByEntity(log) { + this.$.filter = { + who: 'all', + search: log.changedModelId, + changedModel: log.changedModel + }; + } + searchUser(search) { if (/^[0-9]+$/.test(search)) { return {id: search}; diff --git a/front/salix/components/log/locale/es.yml b/front/salix/components/log/locale/es.yml index 0f2755f2e..90a42911b 100644 --- a/front/salix/components/log/locale/es.yml +++ b/front/salix/components/log/locale/es.yml @@ -3,8 +3,8 @@ Concept: Concepto Search: Buscar Search by id or concept: Buscar por identificador o concepto Search by changes: | - Buscar por cambios realizados. Los atributos deben buscarse por su nombre - interno, para obtenerlo situar el cursor sobre el nombre. + Buscar por cambios. Los atributos deben buscarse por su nombre interno, + para obtenerlo situar el cursor sobre el atributo. Entity: Entidad Action: Acción Author: Autor @@ -16,9 +16,12 @@ Creates: Crea Edits: Modifica Deletes: Elimina Accesses: Accede +All: Todo System: Sistema Details: Detalles note: nota Changes: Cambios today: hoy yesterday: ayer +Show all record changes: Mostrar todos los cambios realizados en el registro +Quit filter: Quitar filtro diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index cec591a7f..de294972d 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -1,5 +1,4 @@ -@import "variables"; -@import "effects"; +@import "util"; vn-log { .change { @@ -77,7 +76,7 @@ vn-log { border-radius: 50%; width: 24px; height: 24px; - font-size: 1.4em; + font-size: 18px; &.notice { background-color: $color-notice-medium @@ -98,16 +97,33 @@ vn-log { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + max-height: 18px; + & > vn-icon { + @extend %clickable-light; + vertical-align: middle; + padding: 2px; + margin: -2px; + font-size: 18px; + color: $color-font-secondary; + float: right; + display: none; + + @include mobile { + display: initial; + } + } & > .model-value { font-style: italic; } & > .model-id { color: $color-font-secondary; font-size: .9rem; - float: right; } } + &:hover > .model > vn-icon { + display: initial; + } } } .changes { diff --git a/front/salix/styles/misc.scss b/front/salix/styles/misc.scss index 02bfd9f17..9b2829d0b 100644 --- a/front/salix/styles/misc.scss +++ b/front/salix/styles/misc.scss @@ -1,5 +1,4 @@ -@import "./variables"; -@import "./effects"; +@import "./util"; form vn-horizontal { align-items: center; @@ -22,10 +21,10 @@ form vn-horizontal { } } - @media screen and (max-width: $mobile-width) { + @include mobile { flex-direction: column; align-items: initial; - + & > * { &, &:first-child, From ec9dfa90fd0b8061f6812ff4b4f87fde7f7f7510 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 9 Jun 2023 08:06:45 +0200 Subject: [PATCH 24/29] refs #5760 fixtures --- db/dump/fixtures.sql | 7 ++++--- .../back/methods/ticket-log/specs/getChanges.spec.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 3476bfe48..88b837247 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2781,12 +2781,14 @@ UPDATE `account`.`user` SET `hasGrant` = 1 WHERE `id` = 66; -INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`) +INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, `changedModel`, `oldInstance`, `newInstance`, changedModelId, `description`) VALUES (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL), (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL), (7, 18, 'update', 'Sale', '{"price":3}', '{"price":5}', 1, NULL), - (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"); + (7, 18, 'update', NULL, NULL, NULL, NULL, "Cambio cantidad Melee weapon heavy shield 1x0.5m de '5' a '10'"), + (16, 9, 'update', 'Sale', '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', '{"quantity":8,"concept":"Shield", "price": 10.5, "itemFk": 1}' , 5689, 'Shield'); + INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedModel, changedModelId, changedModelValue, oldInstance, newInstance, description) VALUES @@ -2800,7 +2802,6 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM (1, 18, 'select', '2000-12-27 03:40:30', 'Ticket', 45, NULL , NULL, NULL, NULL), (1, 18, 'insert', '2000-04-10 09:40:15', 'Sale', 5689, 'Shield' , NULL, '{"quantity":10,"concept":"Shield", "price": 10.5, "itemFk": 1}', NULL), (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); - INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); diff --git a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js index c0f7dde0e..04f42f7be 100644 --- a/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js +++ b/modules/ticket/back/methods/ticket-log/specs/getChanges.spec.js @@ -7,7 +7,7 @@ describe('ticketLog getChanges()', () => { return value; }; it('should return the changes in the sales of a ticket', async() => { - const ticketId = 7; + const ticketId = 16; const changues = await models.TicketLog.getChanges(ctx, ticketId); From c66feb53f0aab7dcaf95fab743b39b8a31b74ae2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 9 Jun 2023 08:29:18 +0200 Subject: [PATCH 25/29] refs #5760 fix fixtures --- db/dump/fixtures.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 88b837247..4441ec19c 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2781,7 +2781,7 @@ UPDATE `account`.`user` SET `hasGrant` = 1 WHERE `id` = 66; -INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, `changedModel`, `oldInstance`, `newInstance`, changedModelId, `description`) +INSERT INTO `vn`.`ticketLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`) VALUES (7, 18, 'update', 'Sale', '{"quantity":1}', '{"quantity":10}', 1, NULL), (7, 18, 'update', 'Ticket', '{"quantity":1,"concept":"Chest ammo box"}', '{"quantity":10,"concept":"Chest ammo box"}', 1, NULL), From fdb9d2ed7f6e9dc01aa58d8c5a5af5817bbecf7a Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 9 Jun 2023 14:38:44 +0200 Subject: [PATCH 26/29] refs #5701 fix dockerFile and sh's --- db/Dockerfile | 20 +++++-------------- ...ocker-temp-start.sh => docker-fixtures.sh} | 3 +++ db/docker/docker-init.sh | 2 ++ db/docker/docker-structure.sh | 18 +++++++++++++++++ db/docker/docker-temp-stop.sh | 6 ------ 5 files changed, 28 insertions(+), 21 deletions(-) rename db/docker/{docker-temp-start.sh => docker-fixtures.sh} (62%) create mode 100755 db/docker/docker-structure.sh delete mode 100755 db/docker/docker-temp-stop.sh diff --git a/db/Dockerfile b/db/Dockerfile index 719b85393..15f947e08 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -7,11 +7,9 @@ ARG DEBIAN_FRONTEND=noninteractive COPY docker/docker.cnf /etc/mysql/conf.d/ COPY \ - docker/docker-init.sh \ - docker/docker-temp-start.sh \ - docker/docker-temp-stop.sh \ docker/docker-dump.sh \ - docker/docker-start.sh \ + docker/docker-structure.sh \ + docker/docker-fixtures.sh \ /usr/local/bin/ RUN mkdir /mysql-data \ @@ -26,20 +24,12 @@ COPY \ dump/mockDate.sql \ dump/dumpedFixtures.sql \ ./ -RUN gosu mysql docker-init.sh \ - && docker-dump.sh structure \ - && sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ - && docker-dump.sh mockDate \ - && docker-dump.sh dumpedFixtures \ - && gosu mysql docker-temp-stop.sh - +RUN sed -i -e 's/@mockDate/'"$MOCKDATE"'/g' mockDate.sql \ + && gosu mysql docker-structure.sh COPY changes ./changes COPY dump/fixtures.sql ./ ARG STAMP=unknown -RUN gosu mysql docker-temp-start.sh \ - && ./import-changes.sh \ - && docker-dump.sh fixtures \ - && gosu mysql docker-temp-stop.sh +RUN gosu mysql docker-fixtures.sh RUN echo "[INFO] -> Import finished" \ && rm -rf /docker-boot diff --git a/db/docker/docker-temp-start.sh b/db/docker/docker-fixtures.sh similarity index 62% rename from db/docker/docker-temp-start.sh rename to db/docker/docker-fixtures.sh index fc067102f..0de6114d9 100755 --- a/db/docker/docker-temp-start.sh +++ b/db/docker/docker-fixtures.sh @@ -5,3 +5,6 @@ CMD=mysqld docker_setup_env "$CMD" docker_temp_server_start "$CMD" +bash import-changes.sh +docker-dump.sh fixtures +docker_temp_server_stop diff --git a/db/docker/docker-init.sh b/db/docker/docker-init.sh index ccd14283e..b58510436 100755 --- a/db/docker/docker-init.sh +++ b/db/docker/docker-init.sh @@ -12,3 +12,5 @@ docker_init_database_dir "$CMD" docker_temp_server_start "$CMD" docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* +echo $MARIADB_PID +export MARIADB_PID diff --git a/db/docker/docker-structure.sh b/db/docker/docker-structure.sh new file mode 100755 index 000000000..b119e38fd --- /dev/null +++ b/db/docker/docker-structure.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +. /usr/local/bin/docker-entrypoint.sh +CMD=mysqld + +mysql_check_config "$CMD" +docker_setup_env "$CMD" +docker_create_db_directories + +docker_verify_minimum_env +docker_init_database_dir "$CMD" +docker_temp_server_start "$CMD" +docker_setup_db +docker_process_init_files /docker-entrypoint-initdb.d/* +docker-dump.sh structure +docker-dump.sh mockDate +docker-dump.sh dumpedFixtures +docker_temp_server_stop diff --git a/db/docker/docker-temp-stop.sh b/db/docker/docker-temp-stop.sh deleted file mode 100755 index 418331f75..000000000 --- a/db/docker/docker-temp-stop.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -. /usr/local/bin/docker-entrypoint.sh -CMD=mysqld - -docker_setup_env "$CMD" From 0fb114b06dcf5a10486990d51de6a128d2f32f40 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 9 Jun 2023 21:45:36 +0200 Subject: [PATCH 27/29] refs #5667 Search & entity filters moved to top --- front/salix/components/log/index.html | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index f68919f00..8b33c811b 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -110,6 +110,25 @@
+ + + + + + + + - - - - - - - - From decc5e471f00c584cfbcf86adf92b376dcc8b572 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 9 Jun 2023 21:57:47 +0200 Subject: [PATCH 28/29] refs #5667 Changes added to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f2c0e6e5..d4717b711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Tickets -> Abono) Al abonar permite crear el ticket abono con almacén o sin almmacén - (General -> Desplegables) Mejorada eficiencia de carga de datos +- (General -> Históricos) Ahora, ademas de los ids, se muestra la descripión de los atributos +- (General -> Históricos) Botón para hacer más ágil mostrar sólo los cambios en un registro +- (General -> Históricos) Filtro por cambios ### Changed - (General -> Permisos) Mejorada seguridad +- (General -> Históricos) Elementos de la interfaz reorganizados para hacerla más ágil e intuitiva ### Fixed - From 33f2d556fd92606eb9c105c9448c5d2ae125e1b0 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 12 Jun 2023 07:33:45 +0200 Subject: [PATCH 29/29] refs #5701 fix(db/dockerFile): fix docker-temp-stop --- db/Dockerfile | 3 +++ db/docker/docker-init.sh | 2 -- db/docker/docker-structure.sh | 15 ++------------- db/docker/docker-temp-stop.sh | 7 +++++++ 4 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 db/docker/docker-temp-stop.sh diff --git a/db/Dockerfile b/db/Dockerfile index 15f947e08..448b8b03a 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -7,6 +7,9 @@ ARG DEBIAN_FRONTEND=noninteractive COPY docker/docker.cnf /etc/mysql/conf.d/ COPY \ + docker/docker-start.sh \ + docker/docker-init.sh \ + docker/docker-temp-stop.sh \ docker/docker-dump.sh \ docker/docker-structure.sh \ docker/docker-fixtures.sh \ diff --git a/db/docker/docker-init.sh b/db/docker/docker-init.sh index b58510436..ccd14283e 100755 --- a/db/docker/docker-init.sh +++ b/db/docker/docker-init.sh @@ -12,5 +12,3 @@ docker_init_database_dir "$CMD" docker_temp_server_start "$CMD" docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* -echo $MARIADB_PID -export MARIADB_PID diff --git a/db/docker/docker-structure.sh b/db/docker/docker-structure.sh index b119e38fd..75a1c24f3 100755 --- a/db/docker/docker-structure.sh +++ b/db/docker/docker-structure.sh @@ -1,18 +1,7 @@ #!/bin/bash -. /usr/local/bin/docker-entrypoint.sh -CMD=mysqld - -mysql_check_config "$CMD" -docker_setup_env "$CMD" -docker_create_db_directories - -docker_verify_minimum_env -docker_init_database_dir "$CMD" -docker_temp_server_start "$CMD" -docker_setup_db -docker_process_init_files /docker-entrypoint-initdb.d/* +. docker-init.sh docker-dump.sh structure docker-dump.sh mockDate docker-dump.sh dumpedFixtures -docker_temp_server_stop +. docker-temp-stop.sh diff --git a/db/docker/docker-temp-stop.sh b/db/docker/docker-temp-stop.sh new file mode 100644 index 000000000..df66959df --- /dev/null +++ b/db/docker/docker-temp-stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +. /usr/local/bin/docker-entrypoint.sh +CMD=mysqld + +docker_setup_env "$CMD" +docker_temp_server_stop