diff --git a/back/methods/viaexpress-config/internationalExpedition.js b/back/methods/viaexpress-config/internationalExpedition.js
index 698bb1dac..df50b21e5 100644
--- a/back/methods/viaexpress-config/internationalExpedition.js
+++ b/back/methods/viaexpress-config/internationalExpedition.js
@@ -20,7 +20,7 @@ module.exports = Self => {
}
});
- Self.internationalExpedition = async expeditionFk => {
+ Self.internationalExpedition = async (expeditionFk) => {
const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({
diff --git a/back/methods/viaexpress-config/renderer.js b/back/methods/viaexpress-config/renderer.js
index e9abce5ca..c8533ea6b 100644
--- a/back/methods/viaexpress-config/renderer.js
+++ b/back/methods/viaexpress-config/renderer.js
@@ -20,11 +20,11 @@ module.exports = Self => {
}
});
- Self.renderer = async expeditionFk => {
+ Self.renderer = async (expeditionFk) => {
const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({
- fields: ['client', 'user', 'password', 'defaultWeight', 'deliveryType']
+ fields: ['client', 'user', 'password', 'defaultWeight', 'deliveryType', 'agencyModeFk']
});
const expedition = await models.Expedition.findOne({
@@ -34,7 +34,7 @@ module.exports = Self => {
{
relation: 'ticket',
scope: {
- fields: ['shipped', 'addressFk', 'clientFk', 'companyFk'],
+ fields: ['shipped', 'addressFk', 'clientFk', 'companyFk', 'agencyModeFk'],
include: [
{
relation: 'client',
@@ -102,7 +102,6 @@ module.exports = Self => {
}
]
}
-
}
]
});
@@ -110,13 +109,15 @@ module.exports = Self => {
const ticket = expedition.ticket();
const sender = ticket.company().client();
const shipped = ticket.shipped.toISOString();
+ const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk)
const data = {
viaexpressConfig,
sender,
senderAddress: sender.defaultAddress(),
client: ticket.client(),
address: ticket.address(),
- shipped
+ shipped,
+ isInterdia
};
const template = fs.readFileSync(__dirname + '/template.ejs', 'utf-8');
diff --git a/back/methods/viaexpress-config/template.ejs b/back/methods/viaexpress-config/template.ejs
index 0b6eb468c..f9acfe316 100644
--- a/back/methods/viaexpress-config/template.ejs
+++ b/back/methods/viaexpress-config/template.ejs
@@ -13,7 +13,7 @@
0
0
0
- 0
+ <%= isInterdia %>
0
diff --git a/back/models/viaexpress-config.json b/back/models/viaexpress-config.json
index 8df24201b..acab1f7e6 100644
--- a/back/models/viaexpress-config.json
+++ b/back/models/viaexpress-config.json
@@ -29,6 +29,9 @@
},
"deliveryType": {
"type": "string"
+ },
+ "agencyModeFk": {
+ "type": "number"
}
}
}
diff --git a/back/models/vn-user.js b/back/models/vn-user.js
index b1d09f0c0..39e7008ca 100644
--- a/back/models/vn-user.js
+++ b/back/models/vn-user.js
@@ -258,18 +258,20 @@ module.exports = function(Self) {
class Mailer {
async send(verifyOptions, cb) {
- const url = new URL(verifyOptions.verifyHref);
- if (process.env.NODE_ENV) url.port = '';
+ try {
+ const url = new URL(verifyOptions.verifyHref);
+ if (process.env.NODE_ENV) url.port = '';
- const params = {
- url: url.href,
- recipient: verifyOptions.to
- };
+ const email = new Email('email-verify', {
+ url: url.href,
+ recipient: verifyOptions.to
+ });
+ await email.send();
- const email = new Email('email-verify', params);
- email.send();
-
- cb(null, verifyOptions.to);
+ cb(null, verifyOptions.to);
+ } catch (err) {
+ cb(err);
+ }
}
}
diff --git a/db/changes/240001/00-truncate-where-signInLog.sql b/db/changes/240001/00-truncate-where-signInLog.sql
deleted file mode 100644
index 93d80d716..000000000
--- a/db/changes/240001/00-truncate-where-signInLog.sql
+++ /dev/null
@@ -1 +0,0 @@
-DELETE FROM `account`.`signInLog` where owner <> FALSE
diff --git a/db/changes/235001/00-silexToSalix.sql b/db/changes/240002/00-silexToSalix.sql
similarity index 100%
rename from db/changes/235001/00-silexToSalix.sql
rename to db/changes/240002/00-silexToSalix.sql
diff --git a/db/changes/235201/00-aclsMails.sql b/db/changes/240201/00-aclsMails.sql
similarity index 100%
rename from db/changes/235201/00-aclsMails.sql
rename to db/changes/240201/00-aclsMails.sql
diff --git a/db/changes/240001/00-fixInvoiceCorrectionConstraintsName.sql b/db/changes/240201/00-fixInvoiceCorrectionConstraintsName.sql
similarity index 100%
rename from db/changes/240001/00-fixInvoiceCorrectionConstraintsName.sql
rename to db/changes/240201/00-fixInvoiceCorrectionConstraintsName.sql
diff --git a/db/changes/240001/00-getTaxBases.sql b/db/changes/240201/00-getTaxBases.sql
similarity index 100%
rename from db/changes/240001/00-getTaxBases.sql
rename to db/changes/240201/00-getTaxBases.sql
diff --git a/db/changes/240201/00-truncateWhereSignInLog.sql b/db/changes/240201/00-truncateWhereSignInLog.sql
new file mode 100644
index 000000000..db5d8e25d
--- /dev/null
+++ b/db/changes/240201/00-truncateWhereSignInLog.sql
@@ -0,0 +1,2 @@
+DELETE FROM `account`.`signInLog` where owner <> FALSE;
+
diff --git a/db/changes/240001/01-newHasAnyPositiveBase.sql b/db/changes/240201/01-newHasAnyPositiveBase.sql
similarity index 100%
rename from db/changes/240001/01-newHasAnyPositiveBase.sql
rename to db/changes/240201/01-newHasAnyPositiveBase.sql
diff --git a/db/changes/240001/01-refactorHasAnyNegativeBase.sql b/db/changes/240201/01-refactorHasAnyNegativeBase.sql
similarity index 100%
rename from db/changes/240001/01-refactorHasAnyNegativeBase.sql
rename to db/changes/240201/01-refactorHasAnyNegativeBase.sql
diff --git a/db/changes/240202/.gitkeep b/db/changes/240202/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/db/changes/240202/00-aclWorkerTimeControl.sql b/db/changes/240202/00-aclWorkerTimeControl.sql
new file mode 100644
index 000000000..5ccb3131d
--- /dev/null
+++ b/db/changes/240202/00-aclWorkerTimeControl.sql
@@ -0,0 +1,14 @@
+DELETE FROM salix.ACL
+ WHERE model = 'WorkerTimeControl'
+ AND property IN ('*','addTime');
+
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES
+ ('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'deleteTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'updateTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'sendMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'updateWorkerTimeControlMail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'weeklyHourRecordEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'getMailStates', 'READ', 'ALLOW', 'ROLE', 'employee'),
+ ('WorkerTimeControl', 'resendWeeklyHourEmail', 'WRITE', 'ALLOW', 'ROLE', 'employee');
diff --git a/db/changes/240201/00-saleComponent.sql b/db/changes/240202/00-saleComponent.sql
similarity index 100%
rename from db/changes/240201/00-saleComponent.sql
rename to db/changes/240202/00-saleComponent.sql
diff --git a/db/changes/240203/.gitkeep b/db/changes/240203/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/db/changes/240203/00-viaExpressConfig.sql b/db/changes/240203/00-viaExpressConfig.sql
new file mode 100644
index 000000000..57832e7cd
--- /dev/null
+++ b/db/changes/240203/00-viaExpressConfig.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `vn`.`viaexpressConfig` ADD agencyModeFk int DEFAULT NULL NULL COMMENT 'Indica el agencyMode que es interdia';
+ALTER TABLE `vn`.`viaexpressConfig` ADD CONSTRAINT viaexpressConfig_agencyMode_Fk FOREIGN KEY (agencyModeFK) REFERENCES vn.agencyMode(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index acd13800b..dba430e66 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -735,7 +735,7 @@ export default {
},
createStateView: {
state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]',
- worker: 'vn-worker-autocomplete[ng-model="$ctrl.workerFk"]',
+ worker: 'vn-worker-autocomplete[ng-model="$ctrl.userFk"]',
saveStateButton: `button[type=submit]`
},
claimsIndex: {
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index 2c7dc6be1..0c3c9ec67 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -203,5 +203,6 @@
"keepPrice": "keepPrice",
"Cannot past travels with entries": "Cannot past travels with entries",
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
- "Incorrect pin": "Incorrect pin."
-}
+ "Incorrect pin": "Incorrect pin.",
+ "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
+}
\ No newline at end of file
diff --git a/modules/account/back/models/samba-config.js b/modules/account/back/models/samba-config.js
index f5672ca21..927510a29 100644
--- a/modules/account/back/models/samba-config.js
+++ b/modules/account/back/models/samba-config.js
@@ -7,7 +7,8 @@ const execFile = require('child_process').execFile;
* https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/useraccountcontrol-manipulate-account-properties
*/
const UserAccountControlFlags = {
- ACCOUNTDISABLE: 2
+ ACCOUNTDISABLE: 0x2,
+ DONT_EXPIRE_PASSWD: 0x10000
};
module.exports = Self => {
@@ -118,7 +119,8 @@ module.exports = Self => {
}
entry = {
- userAccountControl: sambaUser.userAccountControl
+ userAccountControl: (sambaUser.userAccountControl
+ | UserAccountControlFlags.DONT_EXPIRE_PASSWD)
& ~UserAccountControlFlags.ACCOUNTDISABLE,
uidNumber: info.uidNumber,
accountExpires: 0,
diff --git a/modules/route/back/locale/route/en.yml b/modules/route/back/locale/route/en.yml
index d86cbe342..34ebd8932 100644
--- a/modules/route/back/locale/route/en.yml
+++ b/modules/route/back/locale/route/en.yml
@@ -16,19 +16,4 @@ columns:
vehicleFk: vehicle
agencyModeFk: agency
routeFk: route
- zoneFk: zone
- name: name
- beachFk: beach
- ticketPacked: tickets packed
- ticketFree: tickets free
- ticketProduction: tickets production
- packages: packages
- note: note
- dated: dated
- dockFk: dock
- priority: priority
- etd: etd
- expeditionTruckFk: truck
- m3boxes: m3 boxes
- bufferFk: buffer
- isPickingAllowed: is picking allowed
\ No newline at end of file
+ zoneFk: zone
\ No newline at end of file
diff --git a/modules/route/back/locale/route/es.yml b/modules/route/back/locale/route/es.yml
index baefb6433..6693f7d1a 100644
--- a/modules/route/back/locale/route/es.yml
+++ b/modules/route/back/locale/route/es.yml
@@ -16,19 +16,4 @@ columns:
vehicleFk: vehículo
agencyModeFk: agencia
routeFk: ruta
- zoneFk: zona
- name: nombre
- beachFk: playa
- ticketPacked: tickets encajados
- ticketFree: tickets libres
- ticketProduction: tickets producción
- packages: paquetes
- note: nota
- dated: fecha
- dockFk: muelle
- priority: prioridad
- etd: etd
- expeditionTruckFk: camión
- m3boxes: m3 cajas
- bufferFk: buffer
- isPickingAllowed: está permitido recoger
\ No newline at end of file
+ zoneFk: zona
\ No newline at end of file
diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml
new file mode 100644
index 000000000..8908ee636
--- /dev/null
+++ b/modules/route/back/locale/routesMonitor/en.yml
@@ -0,0 +1,19 @@
+name: routesMonitor
+columns:
+ routeFk: route
+ name: name
+ beachFk: beach
+ ticketPacked: tickets packed
+ ticketFree: tickets free
+ ticketProduction: tickets production
+ packages: packages
+ note: note
+ dated: dated
+ dockFk: dock
+ m3: m3
+ priority: priority
+ etd: etd
+ expeditionTruckFk: truck
+ m3boxes: m3 boxes
+ bufferFk: buffer
+ isPickingAllowed: is picking allowed
\ No newline at end of file
diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml
new file mode 100644
index 000000000..9ded8983d
--- /dev/null
+++ b/modules/route/back/locale/routesMonitor/es.yml
@@ -0,0 +1,19 @@
+name: monitorRutas
+columns:
+ routeFk: ruta
+ name: nombre
+ beachFk: playa
+ ticketPacked: tickets encajados
+ ticketFree: tickets libres
+ ticketProduction: tickets producción
+ packages: paquetes
+ note: nota
+ dated: fecha
+ dockFk: muelle
+ m3: m3
+ priority: prioridad
+ etd: etd
+ expeditionTruckFk: camión
+ m3boxes: m3 cajas
+ bufferFk: buffer
+ isPickingAllowed: está permitido recoger
\ No newline at end of file
diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json
index 6688a243a..6cf8da986 100644
--- a/modules/route/back/model-config.json
+++ b/modules/route/back/model-config.json
@@ -22,5 +22,8 @@
},
"Vehicle": {
"dataSource": "vn"
+ },
+ "RoutesMonitor": {
+ "dataSource": "vn"
}
}
diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json
new file mode 100644
index 000000000..e5a0f6062
--- /dev/null
+++ b/modules/route/back/models/routesMonitor.json
@@ -0,0 +1,61 @@
+{
+ "name": "RoutesMonitor",
+ "base": "Loggable",
+ "options": {
+ "mysql": {
+ "table": "routesMonitor"
+ }
+ },
+ "properties": {
+ "routeFk": {
+ "type": "number",
+ "id": true,
+ "description": "Identifier"
+ },
+ "name": {
+ "type": "string"
+ },
+ "beachFk": {
+ "type": "number"
+ },
+ "ticketPacked": {
+ "type": "number"
+ },
+ "ticketFree": {
+ "type": "number"
+ },
+ "ticketProduction": {
+ "type": "number"
+ },
+ "packages": {
+ "type": "number"
+ },
+ "note": {
+ "type": "string"
+ },
+ "dated": {
+ "type": "date"
+ },
+ "dockFk": {
+ "type": "number"
+ },
+ "m3": {
+ "type": "number"
+ },
+ "priority": {
+ "type": "number"
+ },
+ "expeditionTruckFk": {
+ "type": "number"
+ },
+ "m3boxes": {
+ "type": "number"
+ },
+ "bufferFk": {
+ "type": "number"
+ },
+ "isPickingAllowed": {
+ "type": "boolean"
+ }
+ }
+}
diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js
index a5ccb6de4..fd8e31e82 100644
--- a/modules/ticket/back/methods/sale/clone.js
+++ b/modules/ticket/back/methods/sale/clone.js
@@ -14,17 +14,30 @@ module.exports = Self => {
}
try {
- const salesFilter = {
- where: {id: {inq: salesIds}},
- include: {
- relation: 'components',
- scope: {
- fields: ['saleFk', 'componentFk', 'value']
+ let sales;
+ let services;
+
+ if (salesIds && salesIds.length) {
+ sales = await models.Sale.find({
+ where: {id: {inq: salesIds}},
+ include: {
+ relation: 'components',
+ scope: {
+ fields: ['saleFk', 'componentFk', 'value']
+ }
}
- }
- };
- const sales = await models.Sale.find(salesFilter, myOptions);
- let ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))];
+ }, myOptions);
+ }
+
+ if (servicesIds && servicesIds.length) {
+ services = await models.TicketService.find({
+ where: {id: {inq: servicesIds}}
+ }, myOptions);
+ }
+
+ let ticketsIds = sales ?
+ [...new Set(sales.map(sale => sale.ticketFk))] :
+ [...new Set(services.map(service => service.ticketFk))];
const mappedTickets = new Map();
@@ -41,32 +54,28 @@ module.exports = Self => {
newTickets.push(newTicket);
mappedTickets.set(ticketId, newTicket.id);
}
+ if (sales) {
+ for (const sale of sales) {
+ const newTicketId = mappedTickets.get(sale.ticketFk);
- for (const sale of sales) {
- const newTicketId = mappedTickets.get(sale.ticketFk);
+ const createdSale = await models.Sale.create({
+ ticketFk: newTicketId,
+ itemFk: sale.itemFk,
+ quantity: negative ? - sale.quantity : sale.quantity,
+ concept: sale.concept,
+ price: sale.price,
+ discount: sale.discount,
+ }, myOptions);
- const createdSale = await models.Sale.create({
- ticketFk: newTicketId,
- itemFk: sale.itemFk,
- quantity: negative ? - sale.quantity : sale.quantity,
- concept: sale.concept,
- price: sale.price,
- discount: sale.discount,
- }, myOptions);
+ const components = sale.components();
+ for (const component of components)
+ component.saleFk = createdSale.id;
- const components = sale.components();
- for (const component of components)
- component.saleFk = createdSale.id;
-
- await models.SaleComponent.create(components, myOptions);
+ await models.SaleComponent.create(components, myOptions);
+ }
}
- if (servicesIds && servicesIds.length) {
- const servicesFilter = {
- where: {id: {inq: servicesIds}}
- };
- const services = await models.TicketService.find(servicesFilter, myOptions);
-
+ if (services) {
for (const service of services) {
const newTicketId = mappedTickets.get(service.ticketFk);
diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js
index a7831e7e3..e1d23001f 100644
--- a/modules/ticket/back/methods/sale/refund.js
+++ b/modules/ticket/back/methods/sale/refund.js
@@ -6,7 +6,6 @@ module.exports = Self => {
{
arg: 'salesIds',
type: ['number'],
- required: true
},
{
arg: 'servicesIds',
diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js
index 60f77e90c..ab5e1e281 100644
--- a/modules/ticket/back/methods/sale/specs/refund.spec.js
+++ b/modules/ticket/back/methods/sale/specs/refund.spec.js
@@ -44,24 +44,7 @@ describe('Sale refund()', () => {
const tickets = await models.Sale.refund(ctx, salesIds, servicesIds, withWarehouse, options);
- const refundedTicket = await models.Ticket.findOne({
- where: {
- id: tickets[0].id
- },
- include: [
- {
- relation: 'ticketSales',
- scope: {
- include: {
- relation: 'components'
- }
- }
- },
- {
- relation: 'ticketServices',
- }
- ]
- }, options);
+ const refundedTicket = await getTicketRefund(tickets[0].id, options);
const ticketsAfter = await models.Ticket.find({}, options);
const salesLength = refundedTicket.ticketSales().length;
const componentsLength = refundedTicket.ticketSales()[0].components().length;
@@ -77,4 +60,42 @@ describe('Sale refund()', () => {
throw e;
}
});
+
+ it('should create a ticket without sales', async() => {
+ const servicesIds = [4];
+ const tx = await models.Sale.beginTransaction({});
+ const options = {transaction: tx};
+ try {
+ const tickets = await models.Sale.refund(ctx, null, servicesIds, withWarehouse, options);
+ const refundedTicket = await getTicketRefund(tickets[0].id, options);
+
+ expect(refundedTicket).toBeDefined();
+
+ await tx.rollback();
+ } catch (e) {
+ await tx.rollback();
+ throw e;
+ }
+ });
});
+
+async function getTicketRefund(id, options) {
+ return models.Ticket.findOne({
+ where: {
+ id
+ },
+ include: [
+ {
+ relation: 'ticketSales',
+ scope: {
+ include: {
+ relation: 'components'
+ }
+ }
+ },
+ {
+ relation: 'ticketServices',
+ }
+ ]
+ }, options);
+}
diff --git a/modules/ticket/back/methods/ticket-tracking/setDelivered.js b/modules/ticket/back/methods/ticket-tracking/setDelivered.js
index d3cdb192f..eded63d11 100644
--- a/modules/ticket/back/methods/ticket-tracking/setDelivered.js
+++ b/modules/ticket/back/methods/ticket-tracking/setDelivered.js
@@ -49,7 +49,7 @@ module.exports = Self => {
for (const id of ticketIds) {
const promise = await models.Ticket.state(ctx, {
stateFk: state.id,
- workerFk: worker.id,
+ userFk: worker.id,
ticketFk: id
}, myOptions);
promises.push(promise);
diff --git a/modules/ticket/front/tracking/edit/index.html b/modules/ticket/front/tracking/edit/index.html
index 47f367007..3b42cb2c2 100644
--- a/modules/ticket/front/tracking/edit/index.html
+++ b/modules/ticket/front/tracking/edit/index.html
@@ -21,7 +21,7 @@
+ ng-model="$ctrl.userFk">
diff --git a/modules/ticket/front/tracking/edit/index.js b/modules/ticket/front/tracking/edit/index.js
index 3057c492b..fc9315d4c 100644
--- a/modules/ticket/front/tracking/edit/index.js
+++ b/modules/ticket/front/tracking/edit/index.js
@@ -17,19 +17,19 @@ class Controller extends Section {
set stateFk(value) {
this.params.stateFk = value;
this.isPickerDesignedState = this.getIsPickerDesignedState(value);
- this.workerFk = window.localStorage.currentUserWorkerId;
+ this.userFk = window.localStorage.currentUserWorkerId;
}
get stateFk() {
return this.params.stateFk;
}
- set workerFk(value) {
- this.params.workerFk = value;
+ set userFk(value) {
+ this.params.userFk = value;
}
- get workerFk() {
- return this.params.workerFk;
+ get userFk() {
+ return this.params.userFk;
}
getPickerDesignedState() {
diff --git a/modules/ticket/front/tracking/edit/index.spec.js b/modules/ticket/front/tracking/edit/index.spec.js
index 9d9aa7983..de3b85ca3 100644
--- a/modules/ticket/front/tracking/edit/index.spec.js
+++ b/modules/ticket/front/tracking/edit/index.spec.js
@@ -29,11 +29,11 @@ describe('Ticket', () => {
});
});
- describe('workerFk setter', () => {
- it('should set params.workerFk', () => {
- controller.workerFk = 1;
+ describe('userFk setter', () => {
+ it('should set params.userFk', () => {
+ controller.userFk = 1;
- expect(controller.params.workerFk).toEqual(1);
+ expect(controller.params.userFk).toEqual(1);
});
});
diff --git a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js
index 8f9541596..3e1d731bb 100644
--- a/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js
+++ b/modules/worker/back/methods/worker-time-control/deleteTimeEntry.js
@@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('deleteTimeEntry', {
description: 'Deletes a manual time entry for a worker if the user role is above the worker',
- accessType: 'READ',
+ accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
diff --git a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
index 8231be7bb..e9d35f880 100644
--- a/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
+++ b/modules/worker/back/methods/worker-time-control/updateTimeEntry.js
@@ -3,7 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('updateTimeEntry', {
description: 'Updates a time entry for a worker if the user role is above the worker',
- accessType: 'READ',
+ accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
index 2c183b6cc..9cc2600af 100755
--- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js
+++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js
@@ -7,7 +7,7 @@ module.exports = {
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
this.checkMainEntity(this.invoice);
this.client = await this.findOneFromDef('client', [this.reference]);
- this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference]);
+ this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]);
},
props: {
reference: {
diff --git a/print/templates/reports/invoice-incoterms/sql/client.sql b/print/templates/reports/invoice-incoterms/sql/client.sql
index 3e66c15c9..f3734bcd9 100644
--- a/print/templates/reports/invoice-incoterms/sql/client.sql
+++ b/print/templates/reports/invoice-incoterms/sql/client.sql
@@ -1,13 +1,12 @@
-SELECT
- c.id,
- c.socialName,
- c.street AS postalAddress,
- IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi,
- CONCAT(c.postcode, ' - ', c.city) postcodeCity
-FROM vn.invoiceOut io
- JOIN vn.client c ON c.id = io.clientFk
- JOIN vn.country cty ON cty.id = c.countryFk
- LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
- AND ios.taxAreaFk = 'CEE'
- LEFT JOIN ticket t ON t.refFk = io.ref
-WHERE t.refFk = ?
\ No newline at end of file
+SELECT c.id,
+ c.socialName,
+ c.street postalAddress,
+ IF (ios.taxAreaFk IS NOT NULL, CONCAT(cty.code, c.fi), c.fi) fi,
+ CONCAT(c.postcode, ' - ', c.city) postcodeCity
+ FROM vn.invoiceOut io
+ JOIN vn.client c ON c.id = io.clientFk
+ JOIN vn.country cty ON cty.id = c.countryFk
+ LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
+ AND ios.taxAreaFk = 'CEE'
+ LEFT JOIN ticket t ON t.refFk = io.ref
+ WHERE t.refFk = ?
\ No newline at end of file
diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
index 0c4af803d..b36f50084 100644
--- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql
+++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql
@@ -1,38 +1,14 @@
-SELECT io.issued,
- c.socialName,
- c.street postalAddress,
- c.fi,
- io.clientFk,
- c.postcode,
- c.city,
- io.companyFk,
- io.ref,
- tc.code,
- s.concept,
- s.quantity,
- s.price,
- s.discount,
- s.ticketFk,
- t.shipped,
- t.refFk,
- a.nickname,
- s.itemFk,
- s.id saleFk,
- pm.name AS pmname,
- sa.iban,
- c.phone,
- MAX(t.packages) packages,
+SELECT pack.packages,
a.incotermsFk,
- ic.name incotermsName ,
+ ic.name incotermsName,
t.weight,
- t.observations,
ca.fiscalName customsAgentName,
ca.street customsAgentStreet,
ca.nif customsAgentNif,
ca.phone customsAgentPhone,
ca.email customsAgentEmail,
- CAST(sub2.volume AS DECIMAL (10,2)) volume,
- sub3.intrastat
+ CAST(vol.volume AS DECIMAL (10,2)) volume,
+ intr.intrastat
FROM vn.invoiceOut io
JOIN vn.supplier su ON su.id = io.companyFk
JOIN vn.client c ON c.id = io.clientFk
@@ -42,26 +18,35 @@ SELECT io.issued,
LEFT JOIN vn.incoterms ic ON ic.code = a.incotermsFk
LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk
JOIN vn.sale s ON s.ticketFk = t.id
- JOIN (SELECT SUM(volume) volume
- FROM vn.invoiceOut io
- JOIN vn.ticket t ON t.refFk = io.ref
- JOIN vn.saleVolume sv ON sv.ticketFk = t.id
- WHERE t.refFk = ?
- ) sub2 ON TRUE
- JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk
+ JOIN (
+ SELECT SUM(volume) volume, COUNT(*) packages
+ FROM vn.invoiceOut io
+ JOIN vn.ticket t ON t.refFk = io.ref
+ JOIN vn.saleVolume sv ON sv.ticketFk = t.id
+ WHERE t.refFk = ?
+ ) vol
+ JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
+ AND itc.itemFk = s.itemFk
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
- JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'WORLD'
+ JOIN vn.invoiceOutSerial ios ON ios.code = io.serial
+ AND ios.taxAreaFk = 'WORLD'
JOIN vn.country cty ON cty.id = c.countryFk
JOIN vn.payMethod pm ON pm.id = c .payMethodFk
JOIN vn.company co ON co.id=io.companyFk
JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk
- LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) as intrastat
- FROM vn.ticket t
- JOIN vn.invoiceOut io ON io.ref = t.refFk
- JOIN vn.sale s ON t.id = s.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.intrastat ir ON ir.id = i.intrastatFk
- WHERE t.refFk = ?
- )sub3 ON TRUE
- WHERE t.refFk = ?
-
+ JOIN (
+ SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat
+ FROM vn.ticket t
+ JOIN vn.invoiceOut io ON io.ref = t.refFk
+ JOIN vn.sale s ON t.id = s.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.intrastat ir ON ir.id = i.intrastatFk
+ WHERE t.refFk = ?
+ ) intr
+ JOIN (
+ SELECT SUM(packages) packages
+ FROM ticket
+ WHERE refFk = ?
+ ) pack
+ WHERE t.refFk = ?
+ LIMIT 1
diff --git a/print/templates/reports/invoice-incoterms/sql/invoice.sql b/print/templates/reports/invoice-incoterms/sql/invoice.sql
index 571ea2af3..02074f5c4 100644
--- a/print/templates/reports/invoice-incoterms/sql/invoice.sql
+++ b/print/templates/reports/invoice-incoterms/sql/invoice.sql
@@ -1,18 +1,17 @@
-SELECT
- io.id,
- io.issued,
- io.clientFk,
- io.companyFk,
- io.ref,
- pm.code AS payMethodCode,
- cny.code companyCode,
- sa.iban,
- ios.footNotes
-FROM invoiceOut io
- JOIN client c ON c.id = io.clientFk
- JOIN payMethod pm ON pm.id = c.payMethodFk
- JOIN company cny ON cny.id = io.companyFk
- JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
- LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial
- LEFT JOIN ticket t ON t.refFk = io.ref
-WHERE t.refFk = ?
\ No newline at end of file
+SELECT io.id,
+ io.issued,
+ io.clientFk,
+ io.companyFk,
+ io.ref,
+ pm.code payMethodCode,
+ cny.code companyCode,
+ sa.iban,
+ ios.footNotes
+ FROM invoiceOut io
+ JOIN client c ON c.id = io.clientFk
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ JOIN company cny ON cny.id = io.companyFk
+ JOIN supplierAccount sa ON sa.id = cny.supplierAccountFk
+ LEFT JOIN invoiceOutSerial ios ON ios.code = io.serial
+ LEFT JOIN ticket t ON t.refFk = io.ref
+ WHERE t.refFk = ?
\ No newline at end of file