diff --git a/Jenkinsfile b/Jenkinsfile
index 0aaba1e934..718582630e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -8,19 +8,17 @@ pipeline {
environment {
PROJECT_NAME = 'salix'
REGISTRY = 'registry.verdnatura.es'
- DOCKER_HOST_1 = 'vch1.verdnatura.es'
- DOCKER_HOST_2 = 'vch2.verdnatura.es'
PORT_MASTER_FRONT = '5002'
- PORT_MASTER_BACK = '3001-3002'
+ PORT_MASTER_BACK = '3001'
PORT_TEST_FRONT = '5001'
- PORT_TEST_BACK = '4001-4002'
+ PORT_TEST_BACK = '4001'
TAG = "${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
script {
- env.COMPOSE_PROJECT_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
+ env.STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
if (!env.GIT_COMMITTER_EMAIL) {
env.COMMITTER_EMAIL = sh(
@@ -65,18 +63,23 @@ pipeline {
}
}
stage('Test') {
- when { not { anyOf {
- branch 'test'
- branch 'master'
- }}}
environment {
NODE_ENV = ""
- FIREFOX_BIN = "/opt/firefox/firefox-bin"
}
- steps {
- nodejs('node-lts') {
- sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=1'
- sh 'gulp backTestDockerOnce --junit --random'
+ parallel {
+ stage('Frontend') {
+ steps {
+ nodejs('node-lts') {
+ sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=1'
+ }
+ }
+ }
+ stage('Backend') {
+ steps {
+ nodejs('node-lts') {
+ sh 'gulp backTestDockerOnce --junit --random'
+ }
+ }
}
}
}
@@ -96,6 +99,7 @@ pipeline {
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
sh 'docker-compose build --parallel'
sh 'docker-compose push'
+ sh 'docker logout $REGISTRY'
}
}
stage('Deploy') {
@@ -107,27 +111,8 @@ pipeline {
DOCKER_TLS_VERIFY = 1
}
parallel {
- stage('Host 1') {
- environment {
- DOCKER_HOST = "tcp://${env.DOCKER_HOST_1}:2376"
- }
- steps {
- withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
- sh 'docker-compose pull'
- sh 'docker-compose up -d --scale back=2'
- }
- }
- }
- stage('Host 2') {
- environment {
- DOCKER_HOST = "tcp://${env.DOCKER_HOST_2}:2376"
- }
- steps {
- withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
- sh 'docker-compose pull'
- sh 'docker-compose up -d --scale back=2'
- }
- }
+ steps {
+ sh "docker stack deploy --compose-file docker-compose.yml ${env.STACK_NAME}"
}
}
}
@@ -147,15 +132,6 @@ pipeline {
sh 'db/import-changes.sh -f $NODE_ENV'
}
}
- stage('Cleanup') {
- when { anyOf {
- branch 'test'
- branch 'master'
- }}
- steps {
- sh 'docker logout $REGISTRY'
- }
- }
}
post {
always {
diff --git a/db/changes/10120-december/00-expedition_beforeInsert.sql b/db/changes/10120-december/00-expedition_beforeInsert.sql
new file mode 100644
index 0000000000..819cd7a7f4
--- /dev/null
+++ b/db/changes/10120-december/00-expedition_beforeInsert.sql
@@ -0,0 +1,33 @@
+DROP TRIGGER IF EXISTS `vn`.`expedition_beforeInsert`;
+
+DELIMITER $$
+USE `vn`$$
+CREATE DEFINER=`root`@`%` TRIGGER `vn`.`expedition_beforeInsert`
+ BEFORE INSERT ON `expedition` FOR EACH ROW
+BEGIN
+ DECLARE intcounter INT;
+ DECLARE vShipFk INT;
+
+ IF NEW.isBox > 0 THEN
+
+ UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk;
+
+ SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
+ FROM expedition e
+ INNER JOIN ticket t1 ON e.ticketFk = t1.id
+ LEFT JOIN ticketState ts ON ts.ticket = t1.id
+ INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
+ AND t1.warehouseFk = t2.warehouseFk
+ WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk
+ AND t1.agencyModeFk = t2.agencyModeFk;
+
+ SET NEW.`counter` = intcounter;
+ END IF;
+
+ SELECT shipFk INTO vShipFk FROM stowaway WHERE id = NEW.ticketFk;
+
+ IF vShipFk THEN
+ CALL stowaway_unboarding(vShipFk, NEW.ticketFk);
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/changes/10120-december/00-stowaway_unboarding.sql b/db/changes/10120-december/00-stowaway_unboarding.sql
new file mode 100644
index 0000000000..271baba6c9
--- /dev/null
+++ b/db/changes/10120-december/00-stowaway_unboarding.sql
@@ -0,0 +1,31 @@
+
+USE `vn`;
+DROP procedure IF EXISTS `vn`.`stowawayUnBoarding`;
+
+DELIMITER $$
+USE `vn`$$
+CREATE DEFINER=`root`@`%` PROCEDURE `stowaway_unboarding`(vShipFk INT, vStowawayFk INT)
+BEGIN
+ DECLARE vWorker VARCHAR(255);
+
+ DELETE FROM stowaway
+ WHERE shipFk = vShipFk AND id = vStowawayFk;
+
+ DELETE tt FROM ticketTracking tt
+ JOIN state s ON s.id = tt.stateFk
+ WHERE code = 'BOARDING' AND ticketFk = vShipFk;
+
+ DELETE FROM sale
+ WHERE ticketFk = vShipFk
+ AND itemFk = 98
+ AND concept = CONCAT('POLIZÓN! ',vStowawayFk);
+
+ SELECT u.`name` INTO vWorker
+ FROM account.user u JOIN worker w ON w.userFk = u.id
+ WHERE w.id = client_getSalesPersonByTicket(vStowawayFk);
+
+ SELECT messageSend(vWorker,CONCAT('El ticket: ', vStowawayFk, ' ha dejado de ser un polizón')) INTO @a;
+END$$
+
+DELIMITER ;
+;
diff --git a/docker-compose.yml b/docker-compose.yml
index c0f02273e8..b04ecd0fbc 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,6 +10,8 @@ services:
- ${PORT_FRONT}:80
links:
- back
+ deploy:
+ replicas: 3
back:
image: registry.verdnatura.es/salix-back:${TAG}
restart: unless-stopped
@@ -22,3 +24,5 @@ services:
- /containers/salix:/etc/salix
- /mnt/storage/pdfs:/var/lib/salix/pdfs
- /mnt/storage/dms:/var/lib/salix/dms
+ deploy:
+ replicas: 6
diff --git a/gulpfile.js b/gulpfile.js
index 06c65e4514..dcb0aa6f1c 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -110,17 +110,27 @@ backTestOnce.description = `Runs the backend tests once, can receive --junit arg
async function backTestDockerOnce() {
let containerId = await docker();
- await backTestOnce();
- if (argv['random'])
- await execP(`docker rm -fv ${containerId}`);
+ try {
+ await backTestOnce();
+ } catch (e) {
+ throw e;
+ } finally {
+ if (argv['random'])
+ await execP(`docker rm -fv ${containerId}`);
+ }
}
backTestDockerOnce.description = `Runs backend tests using in site container once`;
async function backTestDocker() {
let containerId = await docker();
- await backTest();
- if (argv['random'])
- await execP(`docker rm -fv ${containerId}`);
+ try {
+ await backTest();
+ } catch (e) {
+ throw e;
+ } finally {
+ if (argv['random'])
+ await execP(`docker rm -fv ${containerId}`);
+ }
}
backTestDocker.description = `Runs backend tests restoring fixtures first`;
diff --git a/modules/claim/front/locale/es.yml b/modules/claim/front/locale/es.yml
index f636b43ee7..26b1eba32b 100644
--- a/modules/claim/front/locale/es.yml
+++ b/modules/claim/front/locale/es.yml
@@ -7,7 +7,7 @@ Claimed ticket: Ticket reclamado
Delete claim: Eliminar reclamación
Observation: Observación
Responsible: Responsable
-Remove sale: Borrar linea
+Remove sale: Eliminar linea
Claim Id: Id reclamación
Created: Creado
Send Pickup order: Enviar orden de recogida
diff --git a/modules/client/front/dms/index/index.html b/modules/client/front/dms/index/index.html
index e45821a4a5..9ecafe887e 100644
--- a/modules/client/front/dms/index/index.html
+++ b/modules/client/front/dms/index/index.html
@@ -61,7 +61,8 @@
{{::document.dms.file}}
+ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
+ {{::document.dms.file}}
@@ -74,7 +75,7 @@
+ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
diff --git a/modules/client/front/locale/es.yml b/modules/client/front/locale/es.yml
index baca4d4792..1b44b5652b 100644
--- a/modules/client/front/locale/es.yml
+++ b/modules/client/front/locale/es.yml
@@ -18,7 +18,7 @@ Sent: Enviado
Worker: Trabajador
Sample: Plantilla
Credit: Crédito
-Are you sure you want to delete this expedition?: ¿Está seguro de borrar esta expedición?
+Are you sure you want to delete this expedition?: ¿Está seguro de eliminar esta expedición?
Others: Otros
New order: Nuevo pedido
Client frozen: Cliente congelado
diff --git a/modules/invoiceOut/front/descriptor/locale/es.yml b/modules/invoiceOut/front/descriptor/locale/es.yml
index 4f6abcea3d..e85be96bfa 100644
--- a/modules/invoiceOut/front/descriptor/locale/es.yml
+++ b/modules/invoiceOut/front/descriptor/locale/es.yml
@@ -3,7 +3,7 @@ Volume: Volumen
Client card: Ficha del cliente
Invoice ticket list: Listado de tickets de la factura
Show invoice PDF: Ver factura en PDF
-Delete Invoice: Borrar factura
+Delete Invoice: Eliminar factura
InvoiceOut deleted: Factura eliminada
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
Book invoice: Asentar factura
diff --git a/modules/order/front/descriptor/locale/es.yml b/modules/order/front/descriptor/locale/es.yml
index 21f3051ca7..0734d76385 100644
--- a/modules/order/front/descriptor/locale/es.yml
+++ b/modules/order/front/descriptor/locale/es.yml
@@ -7,6 +7,6 @@ Items: Articulos
Agency: Agencia
Sales person: Comercial
Order ticket list: Ticket del pedido
-Delete order: Borrar pedido
-You are going to delete this order: El pedido se borrará
+Delete order: Eliminar pedido
+You are going to delete this order: El pedido se eliminará
continue anyway?: ¿Continuar de todos modos?
\ No newline at end of file
diff --git a/modules/order/front/line/locale/es.yml b/modules/order/front/line/locale/es.yml
index 6887785619..d1368d3691 100644
--- a/modules/order/front/line/locale/es.yml
+++ b/modules/order/front/line/locale/es.yml
@@ -1,3 +1,3 @@
Delete row: Eliminar linea
Order confirmed: Pedido confirmado
-Are you sure you want to delete this row?: ¿Estas seguro de que quieres borrar esta línea?
\ No newline at end of file
+Are you sure you want to delete this row?: ¿Estas seguro de que quieres eliminar esta línea?
\ No newline at end of file
diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml
index 7edeff17bf..02f9eed08c 100644
--- a/modules/route/front/tickets/locale/es.yml
+++ b/modules/route/front/tickets/locale/es.yml
@@ -1,8 +1,8 @@
-Remove ticket: Borrar ticket
+Remove ticket: Eliminar ticket
Open buscaman: Abrir buscaman
-Ticket removed from route: Ticket borrado de la ruta
+Ticket removed from route: Ticket quitado de la ruta
Order changed: Orden cambiado
-Delete ticket from route?: ¿Borrar ticket de la ruta?
+Delete ticket from route?: ¿Quitar el ticket de la ruta?
Sort routes: Ordenar rutas
Add ticket: Añadir ticket
Tickets to add: Tickets a añadir
\ No newline at end of file
diff --git a/modules/ticket/back/methods/ticket/canHaveStowaway.js b/modules/ticket/back/methods/ticket/canHaveStowaway.js
index 0d64c2d115..bbc6cf4b33 100644
--- a/modules/ticket/back/methods/ticket/canHaveStowaway.js
+++ b/modules/ticket/back/methods/ticket/canHaveStowaway.js
@@ -21,10 +21,17 @@ module.exports = Self => {
Self.canHaveStowaway = async id => {
const models = Self.app.models;
- const ticket = await models.Ticket.findById(id);
+ const ticket = await models.Ticket.findById(id, {
+ include: {
+ relation: 'ship',
+ scope: {
+ fields: ['id']
+ }
+ }
+ });
const warehouse = await models.Warehouse.findById(ticket.warehouseFk);
-
- if (warehouse && warehouse.hasStowaway)
+ const hasStowaway = ticket.ship() ? true : false;
+ if (warehouse && warehouse.hasStowaway && !hasStowaway)
return true;
return false;
diff --git a/modules/ticket/back/methods/ticket/deleteStowaway.js b/modules/ticket/back/methods/ticket/deleteStowaway.js
new file mode 100644
index 0000000000..6f3a1760ff
--- /dev/null
+++ b/modules/ticket/back/methods/ticket/deleteStowaway.js
@@ -0,0 +1,39 @@
+
+module.exports = Self => {
+ Self.remoteMethod('deleteStowaway', {
+ description: 'Deletes an stowaway',
+ accessType: 'WRITE',
+ accepts: [{
+ arg: 'id',
+ type: 'number',
+ required: true,
+ description: 'The ticket id',
+ http: {source: 'path'}
+ }],
+ returns: {
+ root: true
+ },
+ http: {
+ path: `/:id/deleteStowaway`,
+ verb: 'POST'
+ }
+ });
+
+ Self.deleteStowaway = async id => {
+ const ticket = await Self.findById(id, {
+ include: [{
+ relation: 'ship'
+ }, {
+ relation: 'stowaway'
+ }]
+ });
+
+ let params;
+ if (ticket.stowaway())
+ params = [ticket.stowaway().shipFk, ticket.stowaway().id];
+ else if (ticket.ship())
+ params = [ticket.ship().shipFk, ticket.ship().id];
+
+ return Self.rawSql(`CALL vn.stowaway_unboarding(?, ?)`, params);
+ };
+};
diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js
index 25e5a08c53..7ddde87859 100644
--- a/modules/ticket/back/methods/ticket/new.js
+++ b/modules/ticket/back/methods/ticket/new.js
@@ -26,17 +26,22 @@ module.exports = Self => {
let address = await models.Address.findOne({
where: {id: params.addressFk},
fields: ['id', 'clientFk'],
- include: [
- {relation: 'client',
- scope: {
- include: {
- relation: 'type'
- }
+ include: {
+ relation: 'client',
+ scope: {
+ include: {
+ relation: 'type'
}
}
- ]
+ }
});
+ // FIXME: #1953 Params should be declared with it's correct argument type
+ if (params.shipped)
+ params.shipped = new Date(params.shipped);
+ if (params.landed)
+ params.landed = new Date(params.landed);
+
if (!address)
throw new UserError(`This address doesn't exist`);
diff --git a/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js b/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js
new file mode 100644
index 0000000000..d5a10ac3be
--- /dev/null
+++ b/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js
@@ -0,0 +1,42 @@
+const app = require('vn-loopback/server/server');
+
+fdescribe('ticket deleteStowaway()', () => {
+ const shipId = 16;
+ const stowawayId = 17;
+
+ it('should create an stowaway', async() => {
+ await app.models.Stowaway.rawSql(`
+ INSERT INTO stowaway (id, shipFk) VALUES (?, ?)
+ `, [stowawayId, shipId]);
+
+ const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
+
+ expect(stowawayExists).toEqual(1);
+ });
+
+ it('should delete the stowaway from the ship ticket', async() => {
+ await app.models.Ticket.deleteStowaway(shipId);
+
+ const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
+
+ expect(stowawayExists).toEqual(0);
+ });
+
+ it('should create again an stowaway', async() => {
+ await app.models.Stowaway.rawSql(`
+ INSERT INTO stowaway (id, shipFk) VALUES (?, ?)
+ `, [stowawayId, shipId]);
+
+ const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
+
+ expect(stowawayExists).toEqual(1);
+ });
+
+ it('should delete the stowaway from the stowaway ticket', async() => {
+ await app.models.Ticket.deleteStowaway(stowawayId);
+
+ const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
+
+ expect(stowawayExists).toEqual(0);
+ });
+});
diff --git a/modules/ticket/back/models/ticket.js b/modules/ticket/back/models/ticket.js
index c42df62efe..8ba2bfb0d7 100644
--- a/modules/ticket/back/models/ticket.js
+++ b/modules/ticket/back/models/ticket.js
@@ -27,6 +27,7 @@ module.exports = Self => {
require('../methods/ticket/transferSales')(Self);
require('../methods/ticket/canHaveStowaway')(Self);
require('../methods/ticket/recalculateComponents')(Self);
+ require('../methods/ticket/deleteStowaway')(Self);
Self.observe('before save', async function(ctx) {
if (ctx.isNewInstance) return;
diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json
index 7b6c4a64b4..113e6a75f0 100644
--- a/modules/ticket/back/models/ticket.json
+++ b/modules/ticket/back/models/ticket.json
@@ -51,7 +51,7 @@
"foreignKey": "clientFk"
},
"ship": {
- "type": "hasMany",
+ "type": "hasOne",
"model": "Stowaway",
"foreignKey": "shipFk"
},
diff --git a/modules/ticket/front/descriptor/addStowaway.html b/modules/ticket/front/descriptor/addStowaway.html
index 4ffab8ce53..ec7005e797 100644
--- a/modules/ticket/front/descriptor/addStowaway.html
+++ b/modules/ticket/front/descriptor/addStowaway.html
@@ -7,10 +7,10 @@
class="modal-form"
on-open="model.refresh()">
-
+ href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js
index f8433b5fed..58ee9136ef 100644
--- a/modules/ticket/front/index.js
+++ b/modules/ticket/front/index.js
@@ -6,7 +6,6 @@ import './search-panel';
import './card';
import './descriptor';
import './descriptor/addStowaway';
-import './descriptor/removeStowaway';
import './descriptor-popover';
import './create/card';
import './create/index';
diff --git a/modules/ticket/front/locale/es.yml b/modules/ticket/front/locale/es.yml
index 2b7f75c0cc..b26a6d6fab 100644
--- a/modules/ticket/front/locale/es.yml
+++ b/modules/ticket/front/locale/es.yml
@@ -14,8 +14,8 @@ Counter: Contador
Created : Añadido
Date : Fecha
Delay: Retraso
-Delete: Borrar
-Delete expedition: Borrar expedición
+Delete: Eliminar
+Delete expedition: Eliminar expedición
Description: Descripción
Discount: Descuento
Employee : Empleado
@@ -42,7 +42,7 @@ PPU: Ud.
Price: Precio
Price gap: Diferencia de precio
Quantity: Cantidad
-Remove lines: Borrar lineas
+Remove lines: Eliminar lineas
Route: Ruta
SET OK: PONER OK
Shipment: Salida
diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml
index f381eb6e67..3ccdd528e1 100644
--- a/modules/ticket/front/sale/locale/es.yml
+++ b/modules/ticket/front/sale/locale/es.yml
@@ -1,7 +1,7 @@
New price: Nuevo precio
Add item: Añadir artículo
Add turn: Añadir a turno
-Delete ticket: Borrar ticket
+Delete ticket: Eliminar ticket
Mark as reserved: Marcar como reservado
Unmark as reserved: Desmarcar como reservado
Update discount: Actualizar descuento
@@ -10,7 +10,7 @@ Edit discount: Editar descuento
Transfer to ticket: Transferir a ticket
New ticket: Nuevo ticket
Edit price: Editar precio
-You are going to delete lines of the ticket: Vas a borrar lineas del ticket
+You are going to delete lines of the ticket: Vas a eliminar lineas del ticket
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
You have to allow pop-ups in your web browser to use this functionality:
Debes permitir los pop-pups en tu navegador para que esta herramienta funcione correctamente
@@ -29,5 +29,5 @@ SMSAvailability: >-
{{notAvailables}} no disponible/s. Disculpe las molestias.
Continue anyway?: ¿Continuar de todas formas?
This ticket is now empty: El ticket ha quedado vacio
-Do you want to delete it?: ¿Quieres borrarlo?
+Do you want to delete it?: ¿Quieres eliminarlo?
Recalculate price: Recalcular precio
\ No newline at end of file
diff --git a/modules/worker/front/time-control/locale/es.yml b/modules/worker/front/time-control/locale/es.yml
index 2f92657dd3..1d28b0e2b3 100644
--- a/modules/worker/front/time-control/locale/es.yml
+++ b/modules/worker/front/time-control/locale/es.yml
@@ -5,7 +5,7 @@ Hours: Horas
Add time: Añadir hora
Week total: Total semana
Current week: Semana actual
-This time entry will be deleted: Se borrará la hora fichada
+This time entry will be deleted: Se eliminará la hora fichada
Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla?
Finish at: Termina a las
Entry removed: Fichada borrada
\ No newline at end of file
diff --git a/print/core/mixins/user-locale.js b/print/core/mixins/user-locale.js
index f8001aefca..f30bc0b280 100644
--- a/print/core/mixins/user-locale.js
+++ b/print/core/mixins/user-locale.js
@@ -13,8 +13,11 @@ const userLocale = {
methods: {
getLocale(clientId) {
return db.findOne(`
- SELECT lang FROM account.user
- WHERE id = ?`, [clientId]).then(rows => {
+ SELECT IF(u.lang IS NOT NULL, u.lang, LOWER(ct.code)) lang
+ FROM client c
+ JOIN country ct ON ct.id = c.countryFk
+ JOIN account.user u ON u.id = c.id
+ WHERE c.id = ?`, [clientId]).then(rows => {
if (rows)
return rows.lang;
else return fallbackLocale;