diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml
index ec9a824b6..9e94eba0d 100644
--- a/modules/invoiceIn/back/locale/invoiceIn/en.yml
+++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml
@@ -16,5 +16,5 @@ columns:
bookEntried: book entried
isVatDeductible: is VAT deductible
withholdingSageFk: withholding
- expenceFkDeductible: expence deductible
+ expenseFkDeductible: expense deductible
editorFk: editor
\ No newline at end of file
diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml
index 64e96b379..bd64c4327 100644
--- a/modules/invoiceIn/back/locale/invoiceIn/es.yml
+++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml
@@ -16,5 +16,5 @@ columns:
bookEntried: fecha asiento
isVatDeductible: impuesto deducible
withholdingSageFk: código de retención
- expenceFkDeductible: gasto deducible
+ expenseFkDeductible: gasto deducible
editorFk: editor
\ No newline at end of file
diff --git a/modules/invoiceIn/back/locale/invoiceInTax/en.yml b/modules/invoiceIn/back/locale/invoiceInTax/en.yml
index c0d12c37d..6af547d3f 100644
--- a/modules/invoiceIn/back/locale/invoiceInTax/en.yml
+++ b/modules/invoiceIn/back/locale/invoiceInTax/en.yml
@@ -4,7 +4,7 @@ columns:
invoiceInFk: invoice in
taxCodeFk: tax
taxableBase: taxable base
- expenceFk: expence
+ expenseFk: expense
foreignValue: foreign amount
taxTypeSageFk: tax type
transactionTypeSageFk: transaction type
diff --git a/modules/invoiceIn/back/locale/invoiceInTax/es.yml b/modules/invoiceIn/back/locale/invoiceInTax/es.yml
index 7cb847ed8..92f3855e4 100644
--- a/modules/invoiceIn/back/locale/invoiceInTax/es.yml
+++ b/modules/invoiceIn/back/locale/invoiceInTax/es.yml
@@ -4,7 +4,7 @@ columns:
invoiceInFk: factura recibida
taxCodeFk: código IVA
taxableBase: base imponible
- expenceFk: código gasto
+ expenseFk: código gasto
foreignValue: importe divisa
taxTypeSageFk: código impuesto
transactionTypeSageFk: código transacción
diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js
index f5eab9099..dd193af85 100644
--- a/modules/invoiceIn/back/methods/invoice-in/filter.js
+++ b/modules/invoiceIn/back/methods/invoice-in/filter.js
@@ -146,7 +146,7 @@ module.exports = Self => {
ii.docFk AS dmsFk,
dm.file,
ii.supplierFk,
- ii.expenceFkDeductible deductibleExpenseFk,
+ ii.expenseFkDeductible deductibleExpenseFk,
s.name AS supplierName,
s.account,
SUM(iid.amount) AS amount,
diff --git a/modules/invoiceIn/back/methods/invoice-in/getTotals.js b/modules/invoiceIn/back/methods/invoice-in/getTotals.js
index f35c10617..7bef9f7e9 100644
--- a/modules/invoiceIn/back/methods/invoice-in/getTotals.js
+++ b/modules/invoiceIn/back/methods/invoice-in/getTotals.js
@@ -29,15 +29,18 @@ module.exports = Self => {
SELECT iit.*,
SUM(iidd.amount) totalDueDay
FROM vn.invoiceIn ii
- LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
- CAST(SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) AS DECIMAL(10,2)) totalVat
+ LEFT JOIN (
+ SELECT SUM(iit.taxableBase) totalTaxableBase,
+ CAST(
+ SUM(IFNULL(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase))
+ AS DECIMAL(10, 2)
+ ) totalVat
FROM vn.invoiceInTax iit
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
- WHERE iit.invoiceInFk = ?) iit ON TRUE
+ WHERE iit.invoiceInFk = ?
+ ) iit ON TRUE
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
- WHERE
- ii.id = ?`, [id, id]);
-
+ WHERE ii.id = ?`, [id, id]);
return result;
};
};
diff --git a/modules/invoiceIn/back/models/invoice-in-tax.json b/modules/invoiceIn/back/models/invoice-in-tax.json
index 1f68476c3..5bfbbe2a8 100644
--- a/modules/invoiceIn/back/models/invoice-in-tax.json
+++ b/modules/invoiceIn/back/models/invoice-in-tax.json
@@ -19,10 +19,7 @@
"type": "number"
},
"expenseFk": {
- "type": "number",
- "mysql": {
- "columnName": "expenceFk"
- }
+ "type": "number"
},
"created": {
"type": "date"
diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json
index 754899866..5be55c851 100644
--- a/modules/invoiceIn/back/models/invoice-in.json
+++ b/modules/invoiceIn/back/models/invoice-in.json
@@ -51,7 +51,7 @@
"deductibleExpenseFk": {
"type": "number",
"mysql": {
- "columnName": "expenceFkDeductible"
+ "columnName": "expenseFkDeductible"
}
}
},
diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json
index 03147c08b..468063602 100644
--- a/modules/item/back/models/expense.json
+++ b/modules/item/back/models/expense.json
@@ -3,7 +3,7 @@
"base": "VnModel",
"options": {
"mysql": {
- "table": "expence"
+ "table": "expense"
}
},
"properties": {
diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json
index 6db1f5efc..097fe7708 100644
--- a/modules/item/back/models/item.json
+++ b/modules/item/back/models/item.json
@@ -117,10 +117,7 @@
"description": "The item family"
},
"expenseFk": {
- "type": "number",
- "mysql": {
- "columnName": "expenceFk"
- }
+ "type": "number"
},
"minPrice": {
"type": "number"
@@ -131,9 +128,6 @@
"nonRecycledPlastic": {
"type": "number"
},
- "minQuantity": {
- "type": "number"
- },
"packingOut": {
"type": "number"
},
diff --git a/modules/item/front/basic-data/index.html b/modules/item/front/basic-data/index.html
index 426c17800..3e47faa5f 100644
--- a/modules/item/front/basic-data/index.html
+++ b/modules/item/front/basic-data/index.html
@@ -105,7 +105,7 @@
url="Expenses"
label="Expense"
ng-model="$ctrl.item.expenseFk"
- vn-name="expence"
+ vn-name="expense"
initial-data="$ctrl.item.expense">
diff --git a/modules/route/back/methods/agency-term/createInvoiceIn.js b/modules/route/back/methods/agency-term/createInvoiceIn.js
index 5a8430e49..f00ab95c6 100644
--- a/modules/route/back/methods/agency-term/createInvoiceIn.js
+++ b/modules/route/back/methods/agency-term/createInvoiceIn.js
@@ -54,7 +54,7 @@ module.exports = Self => {
dmsFk: firstDms.id,
}, myOptions);
- const expence = await models.AgencyTermConfig.findOne(null, myOptions);
+ const expense = await models.AgencyTermConfig.findOne(null, myOptions);
const [taxTypeSage] = await Self.rawSql(`
SELECT IFNULL(s.taxTypeSageFk, CodigoIva) value
@@ -78,7 +78,7 @@ module.exports = Self => {
await models.InvoiceInTax.create({
invoiceInFk: newInvoiceIn.id,
taxableBase: firstRow.totalPrice,
- expenseFk: expence.expenceFk,
+ expenseFk: expense.expenseFk,
taxTypeSageFk: taxTypeSage.value,
transactionTypeSageFk: transactionTypeSage.value
}, myOptions);
diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js
index fc35e979f..afefa77d1 100644
--- a/modules/route/back/methods/route/filter.js
+++ b/modules/route/back/methods/route/filter.js
@@ -105,7 +105,7 @@ module.exports = Self => {
}
});
- filter = mergeFilters(ctx.args.filter, {where});
+ filter = mergeFilters(filter, {where});
let stmts = [];
let stmt;
@@ -129,9 +129,11 @@ module.exports = Self => {
r.description,
am.name agencyName,
u.name AS workerUserName,
- v.numberPlate AS vehiclePlateNumber
+ v.numberPlate AS vehiclePlateNumber,
+ Date_format(r.time, '%H:%i') hour
FROM route r
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
+ LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.id`
diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js
new file mode 100644
index 000000000..7e70cb1f1
--- /dev/null
+++ b/modules/route/back/methods/route/getByWorker.js
@@ -0,0 +1,65 @@
+const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
+
+module.exports = Self => {
+ Self.remoteMethodCtx('getByWorker', {
+ description: 'Return the routes by worker',
+ accessType: 'READ',
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/getByWorker`,
+ verb: 'GET'
+ }
+ });
+
+ Self.getByWorker = async ctx => {
+ const models = Self.app.models;
+ const userId = ctx.req.accessToken.userId;
+ const myOptions = {};
+
+ if (typeof options == 'object')
+ Object.assign(myOptions, options);
+
+ const canViewAll = await models.ACL.checkAccessAcl(ctx, 'Route', 'canViewAllRoute', 'READ');
+ let filterGrant = {};
+
+ if (canViewAll) {
+ const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
+ filterGrant = {
+ where: {'a.warehouseFk': userConfig.warehouseFk}
+ };
+ } else {
+ filterGrant = {
+ where: {'r.workerFk': userId}
+ };
+ }
+
+ const currentDate = Date.vnNew();
+ currentDate.setHours(0, 0, 0, 0);
+ const nextDay = Date.vnNew();
+ nextDay.setDate(currentDate.getDate() + 1);
+
+ const filter = {
+ where: {
+ and: [
+ {
+ or: [
+ {'r.created': currentDate},
+ {'r.created': nextDay}
+ ]
+ }
+ ]
+ },
+ order: [
+ 'r.created ASC',
+ 'r.time ASC',
+ 'am.name ASC'
+ ]
+ };
+
+ const result = await Self.filter(ctx, mergeFilters(filter, filterGrant));
+ return result;
+ };
+};
diff --git a/modules/route/back/methods/route/getDeliveryPoint.js b/modules/route/back/methods/route/getDeliveryPoint.js
index e5a50805a..3359f666e 100644
--- a/modules/route/back/methods/route/getDeliveryPoint.js
+++ b/modules/route/back/methods/route/getDeliveryPoint.js
@@ -1,7 +1,7 @@
module.exports = Self => {
Self.remoteMethod('getDeliveryPoint', {
description: 'get the deliveryPoint address',
- accessType: 'WRITE',
+ accessType: 'READ',
accepts: {
arg: 'vehicleId',
type: 'number',
diff --git a/modules/route/back/methods/route/guessPriority.js b/modules/route/back/methods/route/guessPriority.js
index c6b2a9b74..749075388 100644
--- a/modules/route/back/methods/route/guessPriority.js
+++ b/modules/route/back/methods/route/guessPriority.js
@@ -1,7 +1,7 @@
module.exports = Self => {
Self.remoteMethodCtx('guessPriority', {
description: 'Changes automatically the priority of the tickets in a route',
- accessType: 'READ',
+ accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
@@ -15,7 +15,7 @@ module.exports = Self => {
},
http: {
path: `/:id/guessPriority`,
- verb: 'GET'
+ verb: 'PATCH'
}
});
diff --git a/modules/route/back/methods/route/insertTicket.js b/modules/route/back/methods/route/insertTicket.js
index f78e1cb83..4ac8bad1a 100644
--- a/modules/route/back/methods/route/insertTicket.js
+++ b/modules/route/back/methods/route/insertTicket.js
@@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('insertTicket', {
description: 'Check if the ticket can be insert into the route and insert it',
- accessType: 'READ',
+ accessType: 'WRITE',
accepts: [{
arg: 'routeId',
type: 'number',
diff --git a/modules/route/back/methods/route/specs/getByWorker.spec.js b/modules/route/back/methods/route/specs/getByWorker.spec.js
new file mode 100644
index 000000000..f3103509a
--- /dev/null
+++ b/modules/route/back/methods/route/specs/getByWorker.spec.js
@@ -0,0 +1,36 @@
+const app = require('vn-loopback/server/server');
+const LoopBackContext = require('loopback-context');
+
+describe('route getByWorker()', () => {
+ const userId = 56;
+ const activeCtx = {
+ accessToken: {userId: userId},
+ http: {
+ req: {
+ headers: {origin: 'http://localhost'}
+ }
+ }
+ };
+ const ctx = {req: activeCtx};
+
+ beforeAll(() => {
+ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
+ active: activeCtx
+ });
+ });
+
+ it('should return routes assigned to the worker', async() => {
+ const result = await app.models.Route.getByWorker(ctx);
+
+ expect(result.every(route => route.workerFk === userId)).toBe(true);
+ });
+
+ it('should return all routes if user has canViewAllRoute permission', async() => {
+ // Simular que el usuario tiene permiso para ver todas las rutas
+ spyOn(app.models.ACL, 'checkAccessAcl').and.returnValue(Promise.resolve(true));
+
+ const result = await app.models.Route.getByWorker(ctx);
+
+ expect(result.some(route => route.workerFk != userId)).toBe(true);
+ });
+});
diff --git a/modules/route/back/models/agency-term-config.json b/modules/route/back/models/agency-term-config.json
index c94fc266b..81a608acf 100644
--- a/modules/route/back/models/agency-term-config.json
+++ b/modules/route/back/models/agency-term-config.json
@@ -7,7 +7,7 @@
}
},
"properties": {
- "expenceFk": {
+ "expenseFk": {
"type": "string",
"id": true
},
diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js
index 65fa43ab5..cbdd75679 100644
--- a/modules/route/back/models/route.js
+++ b/modules/route/back/models/route.js
@@ -17,6 +17,7 @@ module.exports = Self => {
require('../methods/route/cmr')(Self);
require('../methods/route/getExternalCmrs')(Self);
require('../methods/route/downloadCmrsZip')(Self);
+ require('../methods/route/getByWorker')(Self);
Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000'
@@ -31,5 +32,5 @@ module.exports = Self => {
const routeMaxKm = 1000;
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
err();
- };
+ }
};
diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js
index 8789708ac..a1b97005e 100644
--- a/modules/route/front/tickets/index.js
+++ b/modules/route/front/tickets/index.js
@@ -120,7 +120,7 @@ class Controller extends Section {
guessPriority() {
let query = `Routes/${this.$params.id}/guessPriority/`;
- this.$http.get(query).then(() => {
+ this.$http.patch(query).then(() => {
this.vnApp.showSuccess(this.$t('Order changed'));
this.$.model.refresh();
});
diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js
index 2c73048bd..fef4b8331 100644
--- a/modules/route/front/tickets/index.spec.js
+++ b/modules/route/front/tickets/index.spec.js
@@ -209,22 +209,6 @@ describe('Route', () => {
});
});
- describe('guessPriority()', () => {
- it('should perform a GET query then call both refresh and showSuccess methods', () => {
- jest.spyOn(controller.$.model, 'refresh');
- jest.spyOn(controller.vnApp, 'showSuccess');
- controller.$params = {id: 99};
-
- const url = `Routes/${controller.$params.id}/guessPriority/`;
- $httpBackend.expectGET(url).respond('ok');
- controller.guessPriority();
- $httpBackend.flush();
-
- expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Order changed');
- expect(controller.$.model.refresh).toHaveBeenCalledWith();
- });
- });
-
describe('onDrop()', () => {
it('should call the insert method when dragging a ticket number', () => {
jest.spyOn(controller, 'insert');
diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js
index 2419d3a5e..55ca474d7 100644
--- a/modules/ticket/back/methods/expedition/deleteExpeditions.js
+++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js
@@ -1,6 +1,7 @@
+const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
- Self.remoteMethod('deleteExpeditions', {
+ Self.remoteMethodCtx('deleteExpeditions', {
description: 'Delete the selected expeditions',
accessType: 'WRITE',
accepts: [{
@@ -9,44 +10,59 @@ module.exports = Self => {
required: true,
description: 'The expeditions ids to delete'
}],
- returns: {
- type: ['object'],
- root: true
- },
http: {
path: `/deleteExpeditions`,
verb: 'POST'
+ },
+ returns: {
+ type: ['object'],
+ root: true
}
});
- Self.deleteExpeditions = async(expeditionIds, options) => {
+ Self.deleteExpeditions = async(ctx, expeditionIds) => {
const models = Self.app.models;
- const myOptions = {};
- let tx;
+ const $t = ctx.req.__;
+ const notDeletedExpeditions = [];
+ const deletedExpeditions = [];
- if (typeof options == 'object')
- Object.assign(myOptions, options);
+ for (let expeditionId of expeditionIds) {
+ const filter = {
+ fields: [],
+ where: {
+ id: expeditionId
+ },
+ include: [
+ {
+ relation: 'agencyMode',
+ scope: {
+ fields: ['code'],
+ }
+ }
+ ]
+ };
- if (!myOptions.transaction) {
- tx = await Self.beginTransaction({});
- myOptions.transaction = tx;
- }
+ const expedition = await models.Expedition.findOne(filter);
+ const {code} = expedition.agencyMode();
- try {
- const promises = [];
- for (let expeditionId of expeditionIds) {
- const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions);
- promises.push(deletedExpedition);
+ if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
+ const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
+
+ if (isDeleted === 'true') {
+ const deletedExpedition = await models.Expedition.destroyById(expeditionId);
+ deletedExpeditions.push(deletedExpedition);
+ } else notDeletedExpeditions.push(expeditionId);
+ } else {
+ const deletedExpedition = await models.Expedition.destroyById(expeditionId);
+ deletedExpeditions.push(deletedExpedition);
}
-
- const deletedExpeditions = await Promise.all(promises);
-
- if (tx) await tx.commit();
-
- return deletedExpeditions;
- } catch (e) {
- if (tx) await tx.rollback();
- throw e;
}
+
+ if (notDeletedExpeditions.length) {
+ throw new UserError(
+ $t(`It was not able to remove the next expeditions:`, {expeditions: notDeletedExpeditions.join()})
+ );
+ }
+ return deletedExpeditions;
};
};
diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
index 61937989e..bf8bafe34 100644
--- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
+++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js
@@ -2,17 +2,16 @@ const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('ticket deleteExpeditions()', () => {
+ let ctx;
beforeAll(async() => {
- const activeCtx = {
+ ctx = {
accessToken: {userId: 9},
- http: {
- req: {
- headers: {origin: 'http://localhost'}
- }
+ req: {
+ headers: {origin: 'http://localhost'}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
- active: activeCtx
+ active: ctx
});
});
@@ -23,7 +22,7 @@ describe('ticket deleteExpeditions()', () => {
const options = {transaction: tx};
const expeditionIds = [12, 13];
- const result = await models.Expedition.deleteExpeditions(expeditionIds, options);
+ const result = await models.Expedition.deleteExpeditions(ctx, expeditionIds, options);
expect(result.length).toEqual(2);
diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json
index e32a3b23d..069c6e281 100644
--- a/modules/ticket/back/models/expedition.json
+++ b/modules/ticket/back/models/expedition.json
@@ -20,6 +20,9 @@
},
"counter": {
"type": "number"
+ },
+ "externalId": {
+ "type": "string"
}
},
"relations": {
@@ -30,7 +33,7 @@
},
"agencyMode": {
"type": "belongsTo",
- "model": "agency-mode",
+ "model": "AgencyMode",
"foreignKey": "agencyModeFk"
},
"worker": {
diff --git a/modules/ticket/back/models/ticket-service-type.json b/modules/ticket/back/models/ticket-service-type.json
index ec2c9232a..9340d6023 100644
--- a/modules/ticket/back/models/ticket-service-type.json
+++ b/modules/ticket/back/models/ticket-service-type.json
@@ -18,7 +18,7 @@
"expenseFk": {
"type": "number",
"mysql": {
- "columnName": "expenceFk"
+ "columnName": "expenseFk"
}
}
},
diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html
index d64c22408..1b0608633 100644
--- a/modules/worker/front/calendar/index.html
+++ b/modules/worker/front/calendar/index.html
@@ -70,17 +70,18 @@
fields="['started', 'ended']"
ng-model="$ctrl.businessId"
search-function="{businessFk: $search}"
+ show-field="businessFk"
value-field="businessFk"
order="businessFk DESC"
limit="5">
-
- #{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
-
-
-
-
+
+ #{{businessFk}}
+
+ {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
+
+
+
+
@@ -110,3 +111,4 @@
message="This item will be deleted"
question="Are you sure you want to continue?">
+
diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js
index 0a955c586..f8a94be52 100644
--- a/modules/worker/front/time-control/index.js
+++ b/modules/worker/front/time-control/index.js
@@ -111,10 +111,8 @@ class Controller extends Section {
dayIndex.setDate(dayIndex.getDate() + 1);
}
- if (this.worker) {
- this.fetchHours();
- this.getWeekData();
- }
+ this.fetchHours();
+ this.getWeekData();
}
set weekTotalHours(totalHours) {
diff --git a/modules/zone/back/models/zone-closure.js b/modules/zone/back/models/zone-closure.js
index d25d6f707..61350ef56 100644
--- a/modules/zone/back/models/zone-closure.js
+++ b/modules/zone/back/models/zone-closure.js
@@ -14,7 +14,7 @@ module.exports = Self => {
async function doCalc(ctx) {
try {
await Self.rawSql(`
- CREATE EVENT zoneClosure_doRecalc
+ CREATE DEFINER = CURRENT_ROLE EVENT zoneClosure_doRecalc
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 15 SECOND
DO CALL zoneClosure_recalc;
`);