Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
a9c690a48c
|
@ -14,9 +14,9 @@ Required applications.
|
||||||
* Docker
|
* Docker
|
||||||
|
|
||||||
In Visual Studio Code we use the ESLint extension. Open Visual Studio Code, press Ctrl+P and paste the following command
|
In Visual Studio Code we use the ESLint extension. Open Visual Studio Code, press Ctrl+P and paste the following command
|
||||||
´´´
|
```
|
||||||
ext install dbaeumer.vscode-eslint
|
ext install dbaeumer.vscode-eslint
|
||||||
´´´
|
```
|
||||||
|
|
||||||
You will need to install globally the following items.
|
You will need to install globally the following items.
|
||||||
```
|
```
|
||||||
|
|
|
@ -71,17 +71,25 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url" : "/review",
|
"url" : "/tracking",
|
||||||
"state": "ticket.card.review",
|
"state": "ticket.card.tracking",
|
||||||
"component": "vn-ticket-review",
|
"component": "vn-ticket-tracking",
|
||||||
"params": {
|
"params": {
|
||||||
"ticket": "$ctrl.ticket"
|
"ticket": "$ctrl.ticket"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"description": "Review",
|
"description": "Tracking",
|
||||||
"icon": "remove_red_eye"
|
"icon": "remove_red_eye"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"url": "/create",
|
||||||
|
"state": "ticket.card.tracking.create",
|
||||||
|
"component": "vn-ticket-tracking-create",
|
||||||
|
"params": {
|
||||||
|
"client": "$ctrl.client"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url" : "/sale",
|
"url" : "/sale",
|
||||||
"state": "ticket.card.sale",
|
"state": "ticket.card.sale",
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
date : Fecha
|
|
||||||
Employee : Empleado
|
|
||||||
State: Estado
|
|
||||||
Review: Revision
|
|
|
@ -1,23 +0,0 @@
|
||||||
<mg-ajax path="" options="vnIndexNonAuto"></mg-ajax>
|
|
||||||
<vn-vertical pad-medium>
|
|
||||||
<vn-card pad-large>
|
|
||||||
<vn-vertical>
|
|
||||||
<vn-title>Review</vn-title>
|
|
||||||
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
|
||||||
<vn-column-header vn-one pad-medium-h field="date" text="date"></vn-column-header>
|
|
||||||
<vn-column-header vn-two pad-medium-h field="employee" text="Employee" default-order="ASC"></vn-column-header>
|
|
||||||
<vn-column-header vn-two pad-medium-h field="state" text="State" order-locked></vn-column-header>
|
|
||||||
</vn-grid-header>
|
|
||||||
<vn-one class="list list-content">
|
|
||||||
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-one>
|
|
||||||
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
|
|
||||||
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
|
|
||||||
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
|
|
||||||
</vn-vertical>
|
|
||||||
</vn-card>
|
|
||||||
</vn-vertical>
|
|
||||||
<a ui-sref="clientCard.ticket.create" fixed-bottom-right>
|
|
||||||
<vn-float-button icon="add"></vn-float-button>
|
|
||||||
</a>
|
|
|
@ -1,18 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
|
|
||||||
class ticketReview {
|
|
||||||
construct($http, $scope) {
|
|
||||||
this.$http = $http;
|
|
||||||
this.$ = $scope;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ticketReview.$inject = ['$http', '$scope'];
|
|
||||||
|
|
||||||
ngModule.component('vnTicketReview', {
|
|
||||||
template: require('./review.html'),
|
|
||||||
controller: ticketReview,
|
|
||||||
bindings: {
|
|
||||||
ticket: '<'
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -8,4 +8,4 @@ import './data/ticket-data';
|
||||||
import './notes/ticket-observations';
|
import './notes/ticket-observations';
|
||||||
import './package/package';
|
import './package/package';
|
||||||
import './sale/sale';
|
import './sale/sale';
|
||||||
import './review/review';
|
import './tracking/tracking';
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
Date : Fecha
|
||||||
|
Employee : Empleado
|
||||||
|
State: Estado
|
||||||
|
Tracking: Revisión
|
||||||
|
Created : Añadido
|
|
@ -0,0 +1,31 @@
|
||||||
|
<mg-ajax path="/ticket/api/TicketTrackings/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||||
|
<vn-vertical pad-medium>
|
||||||
|
<vn-card pad-large>
|
||||||
|
<vn-vertical>
|
||||||
|
<vn-title>Tracking</vn-title>
|
||||||
|
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
||||||
|
<vn-column-header vn-one pad-medium-h field="state.name" text="State"></vn-column-header>
|
||||||
|
<vn-column-header vn-two pad-medium-h field="employee" text="Employee"></vn-column-header>
|
||||||
|
<vn-column-header vn-two pad-medium-h field="created" text="Created" default-order="ASC"></vn-column-header>
|
||||||
|
|
||||||
|
</vn-grid-header>
|
||||||
|
<vn-one class="list list-content">
|
||||||
|
<vn-horizontal
|
||||||
|
vn-one class="list list-element text-center"
|
||||||
|
pad-small-bottom
|
||||||
|
ng-repeat="ticket in index.model.instances track by ticket.id">
|
||||||
|
<vn-one pad-medium-h>{{::ticket.state.name}}</vn-one>
|
||||||
|
<vn-two pad-medium-h>{{::ticket.worker.firstName}} {{::ticket.worker.name}}</vn-two>
|
||||||
|
<vn-two pad-medium-h>{{::ticket.created | date:'dd/MM/yyyy HH:mm' }}</vn-two>
|
||||||
|
|
||||||
|
</vn-horizontal>
|
||||||
|
</vn-one>
|
||||||
|
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
|
||||||
|
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
|
||||||
|
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
|
||||||
|
</vn-vertical>
|
||||||
|
</vn-card>
|
||||||
|
</vn-vertical>
|
||||||
|
<a ui-sref="ticket.card.tracking.create" fixed-bottom-right>
|
||||||
|
<vn-float-button icon="add"></vn-float-button>
|
||||||
|
</a>
|
|
@ -0,0 +1,7 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import FilterTicketList from '../filter-ticket-list';
|
||||||
|
|
||||||
|
ngModule.component('vnTicketTracking', {
|
||||||
|
template: require('./tracking.html'),
|
||||||
|
controller: FilterTicketList
|
||||||
|
});
|
|
@ -55,7 +55,7 @@ UNLOCK TABLES;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2018-03-07 9:44:56
|
-- Dump completed on 2018-03-21 14:01:01
|
||||||
USE `salix`;
|
USE `salix`;
|
||||||
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
||||||
--
|
--
|
||||||
|
@ -93,7 +93,7 @@ UNLOCK TABLES;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2018-03-07 9:44:57
|
-- Dump completed on 2018-03-21 14:01:02
|
||||||
USE `vn`;
|
USE `vn`;
|
||||||
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
||||||
--
|
--
|
||||||
|
@ -151,4 +151,42 @@ UNLOCK TABLES;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2018-03-07 9:44:57
|
-- Dump completed on 2018-03-21 14:01:02
|
||||||
|
USE `vn2008`;
|
||||||
|
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
||||||
|
--
|
||||||
|
-- Host: db.verdnatura.es Database: vn2008
|
||||||
|
-- ------------------------------------------------------
|
||||||
|
-- Server version 5.6.25-4-log
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `accion_dits`
|
||||||
|
--
|
||||||
|
|
||||||
|
LOCK TABLES `accion_dits` WRITE;
|
||||||
|
/*!40000 ALTER TABLE `accion_dits` DISABLE KEYS */;
|
||||||
|
INSERT INTO `accion_dits` VALUES (0,'Abono del ticket'),(104,'Abre a pesar del aviso'),(81,'Abre Entrada'),(116,'Abre Margenes'),(31,'Abre ticket'),(149,'Abre traslado'),(148,'Abre travel'),(12,'Acepta envio'),(64,'Acepta envio a pesar del aviso'),(23,'Aglutinació'),(92,'Añade credito'),(112,'Añade linea'),(132,'Añade manualmente Preparacion'),(33,'Añade promoción'),(144,'Añade ticket'),(129,'Bioniza Linea'),(130,'Bioniza Lineas Ok'),(128,'Bioniza Ticket'),(133,'Borra expedition'),(63,'Borrar promoción'),(80,'Cambia'),(106,'Cambia Activo'),(119,'Cambia Agencia'),(60,'Cambia almacen'),(56,'Cambia Article'),(53,'Cambia cantidad'),(78,'Cambia Categoria'),(34,'Cambia Cliente'),(74,'Cambia Color'),(110,'Cambia Comercial'),(137,'Cambia Conductor'),(82,'Cambia Consignatario'),(105,'Cambia Contabilizada'),(142,'Cambia Coste'),(114,'Cambia Costefijo'),(108,'Cambia crédito'),(97,'Cambia CyC'),(126,'Cambia de agencia sin eliminar la ruta'),(89,'Cambia delivered'),(98,'Cambia Descuento'),(163,'Cambia el turno'),(3,'Cambia Empresa'),(147,'Cambia etiquetas'),(107,'Cambia Factura mail'),(6,'Cambia Fecha'),(37,'Cambia forma de pago'),(122,'Cambia gestdoc_id'),(135,'Cambia grouping y lo falca'),(1,'Cambia hora'),(143,'Cambia hora fin'),(118,'Cambia Id_Agencia'),(140,'Cambia km_end'),(139,'Cambia km_start'),(90,'Cambia landing'),(79,'Cambia Medida'),(77,'Cambia Nicho'),(120,'Cambia No Vincular'),(14,'Cambia obs de:'),(141,'Cambia Ok'),(73,'Cambia Origen'),(150,'Cambia packing'),(117,'Cambia Precio'),(85,'Cambia Received'),(131,'Cambia Recibido Core VNH'),(72,'Cambia Recibido Sepa'),(161,'Cambia salario'),(86,'Cambia Shipment'),(11,'Cambia solucion'),(76,'Cambia Tallos'),(109,'Cambia Tarifa '),(13,'Cambia Tipo'),(121,'Cambia Todos a No Vincular'),(138,'Cambia Vehiculo'),(94,'Cambia Vencimiento'),(88,'Cambia Warehouse de entrada'),(87,'Cambia Warehouse de salida'),(115,'Cambiazo'),(61,'Cambio de fecha'),(93,'Cobro Web'),(32,'Crea Cliente'),(145,'Crea clon'),(83,'Crea Entrada'),(19,'Crea Promoción'),(136,'Crea Ruta'),(84,'Crea Ticket'),(51,'Crea Utilidades->Abono desde el Ticket'),(52,'CREDITO SUPERADO'),(30,'DESBLOQUEA A PESAR DEL AVISO'),(8,'Desbloquea en preparación'),(5,'Desbloquea servido'),(9,'Desmarca seguro'),(54,'Elimina'),(127,'Elimina desde traslado'),(156,'Elimina horario'),(125,'Elimina la ruta por cambio de agencia'),(160,'Elimina precio'),(165,'Elimina ticket turno'),(153,'Elimina zona'),(22,'Eliminación ticket'),(57,'Envia por AZKAR 13 a pesar del aviso'),(68,'Envio a'),(28,'FACTURA MULTIPLE'),(29,'FACTURA RAPIDA'),(111,'Factura Serie'),(58,'FALCA PREU'),(113,'Fusion'),(36,'Genera un abono santos al ticket'),(66,'Genera una reserva santos al ticket'),(69,'Hace click en Pedido'),(20,'Hace click en Ver'),(18,'Imprime CTRL_F5'),(134,'Imprime Ctrl_F5 con credito superado'),(26,'Imprimir Albarán'),(96,'Inserta cantidad en negativo'),(155,'Inserta horario'),(158,'Inserta precio'),(164,'Inserta ticket turno'),(95,'Inserta travel'),(151,'Inserta zona'),(124,'Intenta recalcular tarifas'),(59,'LLIBERA PREU'),(4,'Marca como Servido'),(7,'Marca en preparación'),(10,'Marca seguro de verano'),(157,'Modifica horario'),(159,'Modifica precio'),(154,'Modifica zona'),(99,'No desbloquea los precios'),(103,'No especificado'),(71,'No respeta disponible'),(101,'No respeta grouping'),(100,'No respeta packing'),(123,'Recalcula tarifas'),(2,'Recalculació'),(16,'Reimprime F5'),(67,'Reimprime F5 a pesar del aviso'),(65,'Reserva santos del ticket'),(146,'Revisa Ticket desde Web'),(70,'Revisado PDA'),(50,'S\'ha utilitzat la funció Imprimir_Etiquetas del TPV'),(27,'Se envia a revision'),(91,'Se imprime split'),(15,'SMS'),(102,'Split a MERCAFLOR'),(21,'Ticket Split(Automático)'),(25,'TOUR desde ticket'),(24,'TOUR hacia ticket'),(162,'Validado'),(17,'Visualiza CTRL_F5');
|
||||||
|
/*!40000 ALTER TABLE `accion_dits` ENABLE KEYS */;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||||
|
|
||||||
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||||
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||||
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
|
-- Dump completed on 2018-03-21 14:01:02
|
||||||
|
|
|
@ -5,6 +5,8 @@ echo USE `salix`; >> 02-dumpedFixtures.sql
|
||||||
mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> 02-dumpedFixtures.sql
|
mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> 02-dumpedFixtures.sql
|
||||||
echo USE `vn`; >> 02-dumpedFixtures.sql
|
echo USE `vn`; >> 02-dumpedFixtures.sql
|
||||||
mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak >> 02-dumpedFixtures.sql
|
mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak >> 02-dumpedFixtures.sql
|
||||||
|
echo USE `vn2008`; >> 02-dumpedFixtures.sql
|
||||||
|
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits >> 02-dumpedFixtures.sql
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
const app = require('../../../../../client/server/server');
|
const app = require('../../../../../client/server/server');
|
||||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
|
||||||
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
||||||
|
|
||||||
describe('Client Create', () => {
|
describe('Client Create', () => {
|
||||||
let sqlStatements = {deletes: `
|
let sqlStatements = {deletes: `
|
||||||
DELETE FROM vn.address WHERE nickname = "Wade";
|
DELETE FROM vn.address WHERE nickname = 'Wade';
|
||||||
DELETE FROM vn.client WHERE name = "Wade";
|
DELETE FROM vn.client WHERE name = 'Wade';
|
||||||
DELETE FROM account.user WHERE name = "Deadpool";
|
DELETE FROM account.user WHERE name = 'Deadpool';
|
||||||
`, inserts: ``, updates: ``};
|
`, inserts: ``, updates: ``};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -17,70 +16,50 @@ describe('Client Create', () => {
|
||||||
restoreFixtures(sqlStatements);
|
restoreFixtures(sqlStatements);
|
||||||
});
|
});
|
||||||
|
|
||||||
let newAccountData = {
|
let newAccount = {
|
||||||
active: true,
|
|
||||||
name: 'Wade',
|
|
||||||
userName: 'Deadpool',
|
userName: 'Deadpool',
|
||||||
email: 'Deadpool@marvel.com',
|
email: 'Deadpool@marvel.com',
|
||||||
fi: '16195279J',
|
fi: '16195279J',
|
||||||
socialName: 'Deadpool Marvel',
|
name: 'Wade',
|
||||||
salesPersonFk: 1
|
socialName: 'Deadpool Marvel'
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should find Charles Xavier', done => {
|
it(`should not find Deadpool as he's not created yet`, async() => {
|
||||||
app.models.Account.findOne({where: {name: 'CharlesXavier'}})
|
let account = await app.models.Account.findOne({where: {name: newAccount.userName}});
|
||||||
.then(account => {
|
let client = await app.models.Client.findOne({where: {name: newAccount.name}});
|
||||||
expect(account.name).toEqual('CharlesXavier');
|
|
||||||
done();
|
expect(account).toEqual(null);
|
||||||
});
|
expect(client).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not find Deadpool as he's not created yet`, done => {
|
it('should create a new account', async() => {
|
||||||
app.models.Account.findOne({where: {name: newAccountData.userName}})
|
let client = await app.models.Client.createWithUser(newAccount);
|
||||||
.then(account => {
|
let account = await app.models.Account.findOne({where: {name: newAccount.userName}});
|
||||||
expect(account).toEqual(null);
|
|
||||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
expect(account.name).toEqual(newAccount.userName);
|
||||||
.then(client => {
|
|
||||||
expect(client).toEqual(null);
|
client = await app.models.Client.findOne({where: {name: newAccount.name}});
|
||||||
done();
|
|
||||||
});
|
expect(client.id).toEqual(account.id);
|
||||||
})
|
expect(client.name).toEqual(newAccount.name);
|
||||||
.catch(catchErrors(done));
|
expect(client.email).toEqual(newAccount.email);
|
||||||
|
expect(client.fi).toEqual(newAccount.fi);
|
||||||
|
expect(client.socialName).toEqual(newAccount.socialName);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find an existing account', async() => {
|
||||||
|
let account = await app.models.Account.findOne({where: {name: newAccount.userName}});
|
||||||
|
|
||||||
|
expect(account.name).toEqual(newAccount.userName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to create a user if exists', async() => {
|
it('should not be able to create a user if exists', async() => {
|
||||||
let client = await app.models.Client.findOne({where: {name: 'Charles Xavier'}});
|
|
||||||
let account = await app.models.Account.findOne({where: {id: client.id}});
|
|
||||||
|
|
||||||
let formerAccountData = {
|
|
||||||
name: client.name,
|
|
||||||
userName: account.name,
|
|
||||||
email: client.email,
|
|
||||||
fi: client.fi,
|
|
||||||
socialName: client.socialName
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let client = await app.models.Client.createWithUser(formerAccountData);
|
let client = await app.models.Client.createWithUser(newAccount);
|
||||||
|
|
||||||
expect(client).toBeNull();
|
expect(client).toBeNull();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.details.codes.name[0]).toEqual('uniqueness');
|
expect(err.details.codes.name[0]).toEqual('uniqueness');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new account', async() => {
|
|
||||||
let client = await app.models.Client.createWithUser(newAccountData);
|
|
||||||
let account = await app.models.Account.findOne({where: {name: newAccountData.userName}});
|
|
||||||
|
|
||||||
expect(account.name).toEqual(newAccountData.userName);
|
|
||||||
|
|
||||||
client = await app.models.Client.findOne({where: {name: newAccountData.name}});
|
|
||||||
|
|
||||||
expect(client.id).toEqual(account.id);
|
|
||||||
expect(client.name).toEqual(newAccountData.name);
|
|
||||||
expect(client.email).toEqual(newAccountData.email);
|
|
||||||
expect(client.fi).toEqual(newAccountData.fi);
|
|
||||||
expect(client.socialName).toEqual(newAccountData.socialName);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,11 +44,11 @@ module.exports = function(Self) {
|
||||||
allowBlank: true
|
allowBlank: true
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validateAsync('fi', fiIsValid, {
|
Self.validateAsync('fi', tinIsValid, {
|
||||||
message: 'DNI Incorrecto'
|
message: 'DNI Incorrecto'
|
||||||
});
|
});
|
||||||
let validateDni = require('../validations/validateDni');
|
let validateTin = require('../validations/validateTin');
|
||||||
async function fiIsValid(err, done) {
|
async function tinIsValid(err, done) {
|
||||||
let filter = {
|
let filter = {
|
||||||
fields: ['code'],
|
fields: ['code'],
|
||||||
where: {id: this.countryFk}
|
where: {id: this.countryFk}
|
||||||
|
@ -56,7 +56,7 @@ module.exports = function(Self) {
|
||||||
let country = await Self.app.models.Country.findOne(filter);
|
let country = await Self.app.models.Country.findOne(filter);
|
||||||
let code = country ? country.code.toLowerCase() : null;
|
let code = country ? country.code.toLowerCase() : null;
|
||||||
|
|
||||||
if (!validateDni(this.fi, code))
|
if (!validateTin(this.fi, code))
|
||||||
err();
|
err();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
const validateDni = require('../validateDni');
|
const validateDni = require('../validateTin');
|
||||||
|
|
||||||
describe('DNI validation', () => {
|
describe('TIN validation', () => {
|
||||||
it('should return true for any DNI when no country is passed', () => {
|
it('should return true for any TIN when no country is passed', () => {
|
||||||
let isValid = validateDni('Pepinillos');
|
let isValid = validateDni('Pepinillos');
|
||||||
|
|
||||||
expect(isValid).toBeTruthy();
|
expect(isValid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Spanish', () => {
|
describe('Spanish', () => {
|
||||||
it('should return true for valid spanish DNI', () => {
|
it('should return true for valid spanish TIN', () => {
|
||||||
let isValid = validateDni('20849756A', 'es');
|
let isValid = validateDni('20849756A', 'es');
|
||||||
|
|
||||||
expect(isValid).toBeTruthy();
|
expect(isValid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for spanish DNI with exceeded digits', () => {
|
it('should return false for spanish TIN with exceeded digits', () => {
|
||||||
let isValid = validateDni('208497563239A', 'es');
|
let isValid = validateDni('208497563239A', 'es');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for spanish DNI with invalid letter', () => {
|
it('should return false for spanish TIN with invalid letter', () => {
|
||||||
let isValid = validateDni('20243746E', 'es');
|
let isValid = validateDni('20243746E', 'es');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
|
@ -40,19 +40,19 @@ describe('DNI validation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('French', () => {
|
describe('French', () => {
|
||||||
it('should return true for valid french DNI', () => {
|
it('should return true for valid french TIN', () => {
|
||||||
let isValid = validateDni('1B123456789', 'fr');
|
let isValid = validateDni('012345678', 'fr');
|
||||||
|
|
||||||
expect(isValid).toBeTruthy();
|
expect(isValid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for french DNI with exceeded digits', () => {
|
it('should return false for french TIN with exceeded digits', () => {
|
||||||
let isValid = validateDni('1B12345678910', 'fr');
|
let isValid = validateDni('1B123456789101234', 'fr');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for french DNI with bad syntax', () => {
|
it('should return false for french TIN with bad syntax', () => {
|
||||||
let isValid = validateDni('1B12345678A', 'fr');
|
let isValid = validateDni('1B12345678A', 'fr');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
|
@ -60,19 +60,19 @@ describe('DNI validation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Italian', () => {
|
describe('Italian', () => {
|
||||||
it('should return true for valid italian DNI', () => {
|
it('should return true for valid italian TIN', () => {
|
||||||
let isValid = validateDni('12345678911', 'it');
|
let isValid = validateDni('12345678911', 'it');
|
||||||
|
|
||||||
expect(isValid).toBeTruthy();
|
expect(isValid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for italian DNI with exceeded digits', () => {
|
it('should return false for italian TIN with exceeded digits', () => {
|
||||||
let isValid = validateDni('123456789112', 'it');
|
let isValid = validateDni('123456789112', 'it');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for italian DNI with bad syntax', () => {
|
it('should return false for italian TIN with bad syntax', () => {
|
||||||
let isValid = validateDni('1234567891A', 'it');
|
let isValid = validateDni('1234567891A', 'it');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
|
@ -80,19 +80,19 @@ describe('DNI validation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Portuguese', () => {
|
describe('Portuguese', () => {
|
||||||
it('should return true for valid portuguese DNI', () => {
|
it('should return true for valid portuguese TIN', () => {
|
||||||
let isValid = validateDni('123456789', 'pt');
|
let isValid = validateDni('123456789', 'pt');
|
||||||
|
|
||||||
expect(isValid).toBeTruthy();
|
expect(isValid).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for portuguese DNI with exceeded digits', () => {
|
it('should return false for portuguese TIN with exceeded digits', () => {
|
||||||
let isValid = validateDni('12345678910', 'pt');
|
let isValid = validateDni('12345678910', 'pt');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for portuguese DNI with bad syntax', () => {
|
it('should return false for portuguese TIN with bad syntax', () => {
|
||||||
let isValid = validateDni('12345678A', 'pt');
|
let isValid = validateDni('12345678A', 'pt');
|
||||||
|
|
||||||
expect(isValid).toBeFalsy();
|
expect(isValid).toBeFalsy();
|
|
@ -1,24 +1,24 @@
|
||||||
module.exports = function(fi, country) {
|
module.exports = function(tin, country) {
|
||||||
if (fi == null || country == null)
|
if (tin == null || country == null)
|
||||||
return true;
|
return true;
|
||||||
if (typeof fi != 'string' || typeof country != 'string')
|
if (typeof tin != 'string' || typeof country != 'string')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fi = fi.toUpperCase();
|
tin = tin.toUpperCase();
|
||||||
country = country.toLowerCase();
|
country = country.toLowerCase();
|
||||||
|
|
||||||
let len = fi.length;
|
let len = tin.length;
|
||||||
|
|
||||||
let validators = {
|
let validators = {
|
||||||
es: {
|
es: {
|
||||||
regExp: /^[A-Z0-9]\d{7}[A-Z0-9]$/,
|
regExp: /^[A-Z0-9]\d{7}[A-Z0-9]$/,
|
||||||
validate: () => {
|
validate: () => {
|
||||||
let isCif = /[A-W]/.test(fi.charAt(0));
|
let isCif = /[A-W]/.test(tin.charAt(0));
|
||||||
let lastDigit = fi.charAt(len - 1);
|
let lastDigit = tin.charAt(len - 1);
|
||||||
let computedDigit;
|
let computedDigit;
|
||||||
|
|
||||||
if (isCif) {
|
if (isCif) {
|
||||||
let numbers = fi.substring(1, 8)
|
let numbers = tin.substring(1, 8)
|
||||||
.split('')
|
.split('')
|
||||||
.map(x => parseInt(x));
|
.map(x => parseInt(x));
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ module.exports = function(fi, country) {
|
||||||
computedDigit = index == -1 ? control.toString() : index;
|
computedDigit = index == -1 ? control.toString() : index;
|
||||||
} else {
|
} else {
|
||||||
// Foreign NIF
|
// Foreign NIF
|
||||||
let index = 'XYZ'.indexOf(fi.charAt(0));
|
let index = 'XYZ'.indexOf(tin.charAt(0));
|
||||||
let nif = index == -1 ? fi : index.toString() + fi.substring(1);
|
let nif = index == -1 ? tin : index.toString() + tin.substring(1);
|
||||||
|
|
||||||
let rest = parseInt(nif.substring(0, 8)) % 23;
|
let rest = parseInt(nif.substring(0, 8)) % 23;
|
||||||
computedDigit = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(rest);
|
computedDigit = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(rest);
|
||||||
|
@ -52,10 +52,10 @@ module.exports = function(fi, country) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fr: {
|
fr: {
|
||||||
regExp: /^[A-Z0-9]{2}\d{9}$/
|
regExp: /^\d{1,13}$/
|
||||||
},
|
},
|
||||||
it: {
|
it: {
|
||||||
regExp: /^\d{11}$/
|
regExp: /^(\d{11}|[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z])$/
|
||||||
},
|
},
|
||||||
pt: {
|
pt: {
|
||||||
regExp: /^\d{9}$/
|
regExp: /^\d{9}$/
|
||||||
|
@ -67,6 +67,6 @@ module.exports = function(fi, country) {
|
||||||
if (!validator)
|
if (!validator)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return validator.regExp.test(fi)
|
return validator.regExp.test(tin)
|
||||||
&& (!validator.validate || validator.validate());
|
&& (!validator.validate || validator.validate());
|
||||||
};
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.installMethod('filter', filterParams);
|
||||||
|
|
||||||
|
function filterParams(params) {
|
||||||
|
return {
|
||||||
|
where: {
|
||||||
|
ticketFk: params.ticketFk
|
||||||
|
},
|
||||||
|
skip: (params.page - 1) * params.size,
|
||||||
|
limit: params.size,
|
||||||
|
order: params.order || 'created DESC',
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: "worker",
|
||||||
|
scope: {
|
||||||
|
fields: ["firstName", "name"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: "state",
|
||||||
|
scope: {
|
||||||
|
fields: ["name"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = function(Self) {
|
||||||
|
require('../methods/ticketTracking/filter')(Self);
|
||||||
|
};
|
Loading…
Reference in New Issue