diff --git a/client/claim/index.js b/client/claim/index.js
new file mode 100644
index 000000000..8420b1093
--- /dev/null
+++ b/client/claim/index.js
@@ -0,0 +1 @@
+export * from './src';
diff --git a/client/claim/routes.json b/client/claim/routes.json
new file mode 100644
index 000000000..153d192bc
--- /dev/null
+++ b/client/claim/routes.json
@@ -0,0 +1,37 @@
+{
+ "module": "claim",
+ "name": "Claims",
+ "icon": "icon-claims",
+ "validations": true,
+ "routes": [
+ {
+ "url": "/claim",
+ "state": "claim",
+ "abstract": true,
+ "component": "ui-view",
+ "description": "Claims"
+ },
+ {
+ "url": "/index?q",
+ "state": "claim.index",
+ "component": "vn-claim-index",
+ "description": "Listado",
+ "acl": ["developer"]
+ },
+ {
+ "url": "/:id",
+ "state": "claim.card",
+ "abstract": true,
+ "component": "vn-claim-card"
+ },
+ {
+ "url": "/summary",
+ "state": "claim.card.summary",
+ "component": "vn-claim-summary",
+ "description": "Summary",
+ "params": {
+ "claim": "$ctrl.claim"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/client/claim/src/index.js b/client/claim/src/index.js
new file mode 100644
index 000000000..c7608c145
--- /dev/null
+++ b/client/claim/src/index.js
@@ -0,0 +1,7 @@
+export * from './module';
+
+import './index/';
+/*
+import './card';
+import './descriptor';
+import './summary'; */
diff --git a/client/claim/src/index/index.html b/client/claim/src/index/index.html
new file mode 100644
index 000000000..3fdc3169c
--- /dev/null
+++ b/client/claim/src/index/index.html
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Id
+ Client Id
+ Client
+ Created
+ Worker
+ Observation
+ Responsible
+ State
+
+
+
+
+
+ {{::claim.id}}
+ {{::claim.client.id}}
+ {{::claim.client.name}}
+ {{::claim.created | date:'dd/MM/yyyy'}}
+ {{::claim.worker.firstName}} {{::claim.worker.name}}
+ {{::claim.observation}}
+ {{::claim.claimResponsible.description}}
+ {{::claim.claimState.description}}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/claim/src/index/index.js b/client/claim/src/index/index.js
new file mode 100644
index 000000000..3721fb0fa
--- /dev/null
+++ b/client/claim/src/index/index.js
@@ -0,0 +1,45 @@
+import ngModule from '../module';
+
+export default class Controller {
+ constructor($scope) {
+ this.$ = $scope;
+ this.ticketSelected = null;
+
+ this.filter = {
+ include: [
+ {
+ relation: 'client',
+ scope: {
+ fields: ['name']
+ }
+ },
+ {
+ relation: 'worker',
+ scope: {
+ fields: ['firstName', 'name']
+ }
+ },
+ {
+ relation: 'claimResponsible',
+ scope: {
+ fields: ['description']
+ }
+ },
+ {
+ relation: 'claimState',
+ scope: {
+ fields: ['description']
+ }
+ }
+ ],
+ order: 'claimStateFk ASC, created DESC'
+ };
+ }
+}
+
+Controller.$inject = ['$scope'];
+
+ngModule.component('vnClaimIndex', {
+ template: require('./index.html'),
+ controller: Controller
+});
diff --git a/client/claim/src/locale/es.yml b/client/claim/src/locale/es.yml
new file mode 100644
index 000000000..fc6b2c490
--- /dev/null
+++ b/client/claim/src/locale/es.yml
@@ -0,0 +1,9 @@
+#Ordenar alfabeticamente
+Client Id: Id cliente
+Observation: Observación
+Responsible: Responsable
+
+#sections
+Claims: Reclamaciones
+List: Listado
+Summary: Vista previa
\ No newline at end of file
diff --git a/client/claim/src/module.js b/client/claim/src/module.js
new file mode 100644
index 000000000..14e9efcad
--- /dev/null
+++ b/client/claim/src/module.js
@@ -0,0 +1,5 @@
+import {ng} from 'vendor';
+import 'core';
+
+const ngModule = ng.module('claim', ['vnCore']);
+export default ngModule;
diff --git a/client/modules.yml b/client/modules.yml
index 0227e5f7d..617a08969 100644
--- a/client/modules.yml
+++ b/client/modules.yml
@@ -8,3 +8,4 @@ salix: []
#route: []
ticket: [item, client]
order: [item, ticket]
+claim: [item, client]
diff --git a/client/order/routes.json b/client/order/routes.json
index 0ec6c93e3..090907c33 100644
--- a/client/order/routes.json
+++ b/client/order/routes.json
@@ -9,14 +9,14 @@
"state": "order",
"abstract": true,
"component": "ui-view",
- "description": "Orders",
- "acl": ["developer"]
+ "description": "Orders"
},
{
"url": "/index?q",
"state": "order.index",
"component": "vn-order-index",
- "description": "List"
+ "description": "List",
+ "acl": ["developer"]
},
{
"url": "/:id",
diff --git a/client/salix/src/locale/es.yml b/client/salix/src/locale/es.yml
index 70baa3f2c..27df1e4db 100644
--- a/client/salix/src/locale/es.yml
+++ b/client/salix/src/locale/es.yml
@@ -5,9 +5,10 @@ Client Frozen: Cliente congelado
Client has debt: Cliente con riesgo
Client inactive: Cliente inactivo
Client not checked: Cliente no comprobado
-Clients: Clientes
credit: Crédito
creditInsurance: Crédito Asegurado
+Clients: Clientes
+Claims: Reclamaciones
Data saved!: ¡Datos guardados!
Home: Inicio
Items: Artículos
@@ -16,13 +17,13 @@ Logout: Cerrar sesión
Modules access : Acceso a módulos
Notifications: Notificaciones
name: Nombre
-Orders: Pedidos
phone: Teléfono
Preview: Vista previa
-Production : Producción
Profile: Perfil
+Production : Producción
Push on applications menu: Para abrir un módulo pulsa en el menú de aplicaciones
Return to module index: Volver a la página principal del módulo
Routes: Rutas
What is new: Novedades de la versión
Web Account inactive: Sin acceso Web
+Orders: Pedidos
\ No newline at end of file
diff --git a/client/spliting.js b/client/spliting.js
index 1699b202f..00f80ce64 100644
--- a/client/spliting.js
+++ b/client/spliting.js
@@ -12,5 +12,7 @@ export default {
ticket:
cb => require.ensure([], () => cb(require('ticket'))),
order:
- cb => require.ensure([], () => cb(require('order')))
+ cb => require.ensure([], () => cb(require('order'))),
+ claim:
+ cb => require.ensure([], () => cb(require('claim')))
};
diff --git a/services/loopback/common/models/specs/account.spec.js b/services/loopback/common/models/specs/account.spec.js
new file mode 100644
index 000000000..97abedd6e
--- /dev/null
+++ b/services/loopback/common/models/specs/account.spec.js
@@ -0,0 +1,15 @@
+const app = require(`${servicesDir}/client/server/server`);
+
+describe('loopback model Account', () => {
+ it('should return true if the user has the given role', async() => {
+ let result = await app.models.Account.hasRole(1, 'employee');
+
+ expect(result).toBeTruthy();
+ });
+
+ it('should return false if the user doesnt have the given role', async() => {
+ let result = await app.models.Account.hasRole(1, 'administrator');
+
+ expect(result).toBeFalsy();
+ });
+});
diff --git a/services/ticket/common/models/specs/ticket-packaging.spec.js b/services/ticket/common/models/specs/ticket-packaging.spec.js
new file mode 100644
index 000000000..c1f0f5897
--- /dev/null
+++ b/services/ticket/common/models/specs/ticket-packaging.spec.js
@@ -0,0 +1,38 @@
+const app = require(`${servicesDir}/ticket/server/server`);
+
+describe('ticket model TicketTracking', () => {
+ let ticketTrackingId;
+
+ afterAll(async() => {
+ await app.models.TicketPackaging.destroyById(ticketTrackingId);
+ });
+
+ it('should save a ticketTraing as the quantity is greater than 0', async() => {
+ let result = await app.models.TicketPackaging.create({ticketFk: 1, quantity: 1, packagingFk: 1});
+
+ expect(result).toBeTruthy();
+ ticketTrackingId = result.id;
+ });
+
+ it('should return an error as the quantity is 0', async() => {
+ let error;
+ try {
+ await app.models.TicketPackaging.create({ticketFk: 1, quantity: 0, packagingFk: 1});
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error.message).toContain('Enter an integer different to zero');
+ });
+
+ it('should return an error as the quantity isnt a number', async() => {
+ let error;
+ try {
+ await app.models.TicketPackaging.create({ticketFk: 1, quantity: 'random string', packagingFk: 1});
+ } catch (e) {
+ error = e;
+ }
+
+ expect(error.message).toContain('Enter an integer different to zero');
+ });
+});
diff --git a/services/ticket/common/models/specs/ticket-tracking.spec.js b/services/ticket/common/models/specs/ticket-tracking.spec.js
new file mode 100644
index 000000000..961d1732c
--- /dev/null
+++ b/services/ticket/common/models/specs/ticket-tracking.spec.js
@@ -0,0 +1,24 @@
+const app = require(`${servicesDir}/ticket/server/server`);
+
+describe('ticket model TicketTracking', () => {
+ let ticketTrackingId;
+
+ afterAll(async() => {
+ await app.models.TicketTracking.destroyById(ticketTrackingId);
+ });
+
+ it('should store the worker id into the instance', async() => {
+ let originalTrackings = await app.models.TicketTracking.find({where: {ticketFk: 1}});
+
+ expect(originalTrackings.length).toEqual(1);
+
+ await app.models.TicketTracking.create({ticketFk: 1, stateFk: 20});
+ let result = await app.models.TicketTracking.find({where: {ticketFk: 1}});
+
+ let workerFk = result[1].workerFk;
+ ticketTrackingId = result[1].id;
+
+ expect(result.length).toEqual(2);
+ expect(workerFk).toEqual(1);
+ });
+});
diff --git a/services/ticket/common/models/ticket-tracking.js b/services/ticket/common/models/ticket-tracking.js
index 5875a7816..45acf7f90 100644
--- a/services/ticket/common/models/ticket-tracking.js
+++ b/services/ticket/common/models/ticket-tracking.js
@@ -6,9 +6,9 @@ module.exports = function(Self) {
Self.observe('before save', async function(ctx) {
let models = Self.app.models;
let token = ctx.options.accessToken;
- let userId = token && token.userId;
+ let currentUserId = token && token.userId;
- let user = await models.Worker.findOne({where: {userFk: userId}});
- ctx.instance.workerFk = user.id;
+ let worker = await models.Worker.findOne({where: {userFk: currentUserId}});
+ ctx.instance.workerFk = worker.id;
});
};
diff --git a/services_tests.js b/services_tests.js
index c891bab91..05c780f25 100644
--- a/services_tests.js
+++ b/services_tests.js
@@ -1,3 +1,4 @@
+const fs = require('fs-extra');
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
@@ -18,15 +19,25 @@ let environment = require('gulp-env');
environment(".env.json");
+let serviceList = fs.readdirSync(servicesDir);
+let serviceSpecs = [
+ 'auth/server/**/*[sS]pec.js'
+];
+const exclude = ['auth', 'salix'];
+
+for (let service of serviceList) {
+ try {
+ let serviceDir = fs.readdirSync(`${servicesDir}/${service}`);
+ for (let file of serviceDir) {
+ if (file === 'server' && exclude.indexOf(service) == -1)
+ serviceSpecs.push(`${service}/common/**/*[sS]pec.js`);
+ }
+ } catch (e) {}
+}
+
jasmine.loadConfig({
spec_dir: 'services',
- spec_files: [
- 'auth/server/**/*[sS]pec.js',
- 'client/common/**/*[sS]pec.js',
- 'item/common/**/*[sS]pec.js',
- 'ticket/common/**/*[sS]pec.js',
- 'loopback/common/**/*[sS]pec.js'
- ],
+ spec_files: serviceSpecs,
helpers: [
'/services/utils/jasmineHelpers.js'
]