From b352fc10e7f1d4864896cb42076fe54eadcbaae6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Mar 2024 14:44:06 +0100 Subject: [PATCH 1/6] refs #6532 redirect grafana, remove mermas --- modules/item/front/index.js | 1 - modules/item/front/waste/detail/index.html | 43 ---------------- modules/item/front/waste/detail/index.js | 7 --- modules/item/front/waste/detail/style.scss | 25 --------- modules/item/front/waste/index/index.html | 51 +------------------ modules/item/front/waste/index/index.js | 22 ++------ modules/item/front/waste/index/index.spec.js | 53 -------------------- 7 files changed, 5 insertions(+), 197 deletions(-) delete mode 100644 modules/item/front/waste/detail/index.html delete mode 100644 modules/item/front/waste/detail/index.js delete mode 100644 modules/item/front/waste/detail/style.scss delete mode 100644 modules/item/front/waste/index/index.spec.js diff --git a/modules/item/front/index.js b/modules/item/front/index.js index d2ffcc8fb..354477d4d 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -20,7 +20,6 @@ import './botanical'; import './barcode'; import './summary'; import './waste/index/'; -import './waste/detail'; import './fixed-price'; import './fixed-price-search-panel'; import './item-type'; diff --git a/modules/item/front/waste/detail/index.html b/modules/item/front/waste/detail/index.html deleted file mode 100644 index 1b44088bf..000000000 --- a/modules/item/front/waste/detail/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - -
- -
{{detail.family}} ({{detail.buyer}})
-
- - - - Item - Percentage - Dwindle - Total - - - - - - - {{::waste.itemFk}} - - - {{::(waste.percentage / 100) | percentage: 2}} - {{::waste.dwindle | currency: 'EUR'}} - {{::waste.total | currency: 'EUR'}} - - - -
-
-
- - \ No newline at end of file diff --git a/modules/item/front/waste/detail/index.js b/modules/item/front/waste/detail/index.js deleted file mode 100644 index 2949a493b..000000000 --- a/modules/item/front/waste/detail/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnItemWasteDetail', { - template: require('./index.html'), - controller: Section -}); diff --git a/modules/item/front/waste/detail/style.scss b/modules/item/front/waste/detail/style.scss deleted file mode 100644 index 55a6eb2ef..000000000 --- a/modules/item/front/waste/detail/style.scss +++ /dev/null @@ -1,25 +0,0 @@ -@import "variables"; - -vn-item-waste { - .header { - margin-bottom: 16px; - text-transform: uppercase; - font-size: 1.25rem; - line-height: 1; - padding: 7px; - padding-bottom: 7px; - padding-bottom: 4px; - font-weight: lighter; - background-color: #fde6ca; - border-bottom: 1px solid #f7931e; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - vn-table vn-th.waste-family, - vn-table vn-td.waste-family { - max-width: 64px; - width: 64px - } -} \ No newline at end of file diff --git a/modules/item/front/waste/index/index.html b/modules/item/front/waste/index/index.html index f1475c1b3..7fb3b870e 100644 --- a/modules/item/front/waste/index/index.html +++ b/modules/item/front/waste/index/index.html @@ -1,49 +1,2 @@ - - - - - - - - Buyer - Family - Percentage - Dwindle - Total - - - - - - {{::detail.buyer}} - {{::detail.family}} - {{::(detail.percentage / 100) | percentage: 2}} - {{::detail.dwindle | currency: 'EUR'}} - {{::detail.total | currency: 'EUR'}} - - - - - - - - {{::waste.family}} - {{::(waste.percentage / 100) | percentage: 2}} - {{::waste.dwindle | currency: 'EUR'}} - {{::waste.total | currency: 'EUR'}} - - - - - - + + diff --git a/modules/item/front/waste/index/index.js b/modules/item/front/waste/index/index.js index b11f54b08..86d9d3778 100644 --- a/modules/item/front/waste/index/index.js +++ b/modules/item/front/waste/index/index.js @@ -5,27 +5,11 @@ import './style.scss'; export default class Controller extends Section { constructor($element, $) { super($element, $); - - this.getWasteConfig(); } - getWasteConfig() { - return this.wasteConfig = JSON.parse(localStorage.getItem('wasteConfig')) || {}; - } - - setWasteConfig() { - localStorage.setItem('wasteConfig', JSON.stringify(this.wasteConfig)); - } - - toggleHidePanel(detail) { - if (!this.wasteConfig[detail.buyer]) { - this.wasteConfig[detail.buyer] = { - hidden: true - }; - } else - this.wasteConfig[detail.buyer].hidden = !this.wasteConfig[detail.buyer].hidden; - - this.setWasteConfig(); + async $onInit() { + this.$state.go('item.index'); + window.location.href = 'https://grafana.verdnatura.es/d/TTNXQAxVk'; } } diff --git a/modules/item/front/waste/index/index.spec.js b/modules/item/front/waste/index/index.spec.js deleted file mode 100644 index fd7332f68..000000000 --- a/modules/item/front/waste/index/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Item', () => { - describe('Component vnItemWasteIndex', () => { - let $scope; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.model = crudModel; - const $element = angular.element(''); - controller = $componentController('vnItemWasteIndex', {$element, $scope}); - })); - - describe('getWasteConfig / setWasteConfig', () => { - it('should return the local storage wasteConfig', () => { - const result = controller.getWasteConfig(); - - expect(result).toEqual({}); - }); - - it('should set and return the local storage wasteConfig', () => { - controller.wasteConfig = {salesPerson: {hidden: true}}; - controller.setWasteConfig(); - - const result = controller.getWasteConfig(); - - expect(result).toEqual(controller.wasteConfig); - }); - }); - - describe('toggleHidePanel()', () => { - it('should make details hidden by default', () => { - controller.wasteConfig = {}; - - controller.toggleHidePanel({buyer: 'salesPerson'}); - - expect(controller.wasteConfig.salesPerson.hidden).toEqual(true); - }); - - it('should toggle hidden false', () => { - controller.wasteConfig = {salesPerson: {hidden: true}}; - - controller.toggleHidePanel({buyer: 'salesPerson'}); - - expect(controller.wasteConfig.salesPerson.hidden).toEqual(false); - }); - }); - }); -}); From eb2b0d41de4e4cdabce5587c72c292fba3c1dc04 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 25 Mar 2024 13:33:39 +0100 Subject: [PATCH 2/6] feat: refs #7002 update direction if device exists --- .../worker-time-control/updateTimeEntry.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js index 7e4455447..e86834502 100644 --- a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js @@ -29,7 +29,7 @@ module.exports = Self => { Self.updateTimeEntry = async(ctx, timeEntryId, direction, options) => { const currentUserId = ctx.req.accessToken.userId; const models = Self.app.models; - const myOptions = {}; + const myOptions = {userId: currentUserId}; let tx; if (typeof options == 'object') @@ -41,19 +41,24 @@ module.exports = Self => { } try { - const {id, userFk, timed} = await Self.findById(timeEntryId, null, myOptions); - const isSubordinate = await models.Worker.isSubordinate(ctx, userFk, myOptions); + const timeEntry = await Self.findById(timeEntryId, null, myOptions); + const isSubordinate = await models.Worker.isSubordinate(ctx, timeEntry.userFk, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == userFk; + const isHimself = currentUserId == timeEntry.userFk; const notAllowed = isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss); if (notAllowed) throw new UserError(`You don't have enough privileges`); - await models.WorkerTimeControl.deleteById(id, myOptions); - const timeEntryUpdatedId = await Self.clockIn(userFk, timed, direction, null, myOptions); - - await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, userFk, timed, myOptions); + let timeEntryUpdatedId; + if (timeEntry.device) { + timeEntry.updateAttribute('direction', direction); + timeEntryUpdatedId = timeEntry.id; + } else { + await models.WorkerTimeControl.deleteById(timeEntry.id, myOptions); + timeEntryUpdatedId = await Self.clockIn(timeEntry.userFk, timeEntry.timed, direction, null, myOptions); + } + await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, timeEntry.userFk, timeEntry.timed, myOptions); if (tx) await tx.commit(); return timeEntryUpdatedId; } catch (e) { From 6ded14b593b0fa378b99b65512d022c7397f240f Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Mar 2024 14:25:25 +0100 Subject: [PATCH 3/6] feat: refs #7002 update direction if it was not manual --- .../worker-time-control/updateTimeEntry.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js index e86834502..bbe8fd0fe 100644 --- a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js @@ -41,26 +41,24 @@ module.exports = Self => { } try { - const timeEntry = await Self.findById(timeEntryId, null, myOptions); - const isSubordinate = await models.Worker.isSubordinate(ctx, timeEntry.userFk, myOptions); + const {id, userFk, timed, manual} = await Self.findById(timeEntryId, null, myOptions); + const isSubordinate = await models.Worker.isSubordinate(ctx, userFk, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHimself = currentUserId == timeEntry.userFk; + const isHimself = currentUserId == userFk; const notAllowed = isSubordinate === false || (isSubordinate && isHimself && !isTeamBoss); if (notAllowed) throw new UserError(`You don't have enough privileges`); - let timeEntryUpdatedId; - if (timeEntry.device) { - timeEntry.updateAttribute('direction', direction); - timeEntryUpdatedId = timeEntry.id; - } else { - await models.WorkerTimeControl.deleteById(timeEntry.id, myOptions); - timeEntryUpdatedId = await Self.clockIn(timeEntry.userFk, timeEntry.timed, direction, null, myOptions); - } + await models.WorkerTimeControl.deleteById(id, myOptions); + const {id: newTimeEntryId} = await Self.clockIn( + userFk, timed, direction, null, myOptions + ); + + if (!manual) await Self.updateAll({id: newTimeEntryId}, {manual: false}, myOptions); + await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, userFk, timed, myOptions); - await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, timeEntry.userFk, timeEntry.timed, myOptions); if (tx) await tx.commit(); - return timeEntryUpdatedId; + return newTimeEntryId; } catch (e) { if (tx) await tx.rollback(); throw e; From e7a29119d0ca53d37b6b9696eaf78d0d0ddb82da Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Mar 2024 13:38:04 +0100 Subject: [PATCH 4/6] feat: refs #7002 add test --- .../worker-time-control/specs/clockIn.spec.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js index 0ee439941..343eb2a71 100644 --- a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js @@ -71,6 +71,34 @@ describe('workerTimeControl clockIn()', () => { } }); + it('should updates the time entry direction and remaining not be manual', async() => { + activeCtx.accessToken.userId = HHRRId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const entryTime = "2000-12-25T11:00:00.000Z"; + ctx.args = {timed: entryTime, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + const middleTime ="2000-12-25T16:00:00.000Z"; + ctx.args = {timed: middleTime, direction: 'middle'}; + const middleEntryTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + middleEntryTime.updateAttribute('manual', false); + + const direction = 'out'; + const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(ctx, middleEntryTime.id, direction, options); + + const outTimeEntry = await models.WorkerTimeControl.findById(outTimeEntryId, null, options); + expect(outTimeEntry.manual).toBeFalsy(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); + describe('as Role errors', () => { it('should add if the current user is team boss and the target user is himself', async() => { activeCtx.accessToken.userId = teamBossId; @@ -144,7 +172,7 @@ describe('workerTimeControl clockIn()', () => { const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); const direction = 'out'; - const {id:outTimeEntryId} = await models.WorkerTimeControl.updateTimeEntry( + const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry( ctx, middleTime.id, direction, options ); From 5d5dc9583ace8dbfd65c75d03473eb0179597b61 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 27 Mar 2024 14:44:46 +0100 Subject: [PATCH 5/6] refs #6532 change url --- .../templates/email/buyer-week-waste/buyer-week-waste.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html index d8b7a622b..ecec9c215 100644 --- a/print/templates/email/buyer-week-waste/buyer-week-waste.html +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -28,10 +28,10 @@

- \ No newline at end of file + From d30cac971ff5c7ed91dd40dd34fc43ab7cb1aaea Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 28 Mar 2024 07:22:28 +0100 Subject: [PATCH 6/6] refs #6930 updates --- modules/invoiceOut/front/index/index.js | 5 +++-- modules/route/front/index/index.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index 403c51d58..f109cd5b0 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -23,15 +23,16 @@ export default class Controller extends Section { } openPdf() { + const access_token = this.vnToken.tokenMultimedia; if (this.checked.length <= 1) { const [invoiceOutId] = this.checked; - const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.tokenMultimedia}`; + const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`; window.open(url, '_blank'); } else { const invoiceOutIds = this.checked; const invoicesIds = invoiceOutIds.join(','); const serializedParams = this.$httpParamSerializer({ - access_token: this.vnToken.token, + access_token, ids: invoicesIds }); const url = `api/InvoiceOuts/downloadZip?${serializedParams}`; diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 0c5dfe7f3..bb32e1f13 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -35,16 +35,18 @@ export default class Controller extends Section { showRouteReport() { const routesIds = []; + const access_token = this.vnToken.tokenMultimedia; + for (let route of this.checked) routesIds.push(route.id); const stringRoutesIds = routesIds.join(','); if (this.checked.length <= 1) { - const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.tokenMultimedia}`; + const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${access_token}`; window.open(url, '_blank'); } else { const serializedParams = this.$httpParamSerializer({ - access_token: this.vnToken.token, + access_token, id: stringRoutesIds }); const url = `api/Routes/downloadZip?${serializedParams}`;