merge
This commit is contained in:
commit
6351f4a93d
|
@ -14,9 +14,9 @@ Required applications.
|
|||
* Docker
|
||||
|
||||
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
|
||||
´´´
|
||||
```
|
||||
|
||||
You will need to install globally the following items.
|
||||
```
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submitGo('clientCard.credit.list')" pad-medium>
|
||||
<form name="form" ng-submit="watcher.submitGo('clientCard.credit.list')">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Add credit</vn-title>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<form name="form" ng-submit="$ctrl.submit()">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Item Barcodes</vn-title>
|
||||
<vn-title>Item barcode</vn-title>
|
||||
<vn-horizontal ng-repeat="barcode in $ctrl.barcodes track by $index">
|
||||
<vn-textfield
|
||||
vn-three
|
||||
label="code"
|
||||
label="Code"
|
||||
model="barcode.code"
|
||||
vn-acl="buyer, replenisher">
|
||||
</vn-textfield>
|
||||
|
|
|
@ -27,3 +27,11 @@ All it's properties will be copied: Todas sus propiedades serán copiadas
|
|||
Yes, clone: Si, clonar
|
||||
Value: Valor
|
||||
Priority: Prioridad
|
||||
Item tax: Tasas del artículo
|
||||
Country: País
|
||||
Class: Clase
|
||||
Item niches: Nichos del artículo
|
||||
Warehouse: Almacén
|
||||
Code: Código
|
||||
Botanical: Botánico
|
||||
Species: Especie
|
|
@ -5,7 +5,7 @@
|
|||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.submit()">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Item Niches</vn-title>
|
||||
<vn-title>Item niches</vn-title>
|
||||
<vn-horizontal ng-repeat="itemNiche in $ctrl.niches track by $index">
|
||||
<vn-autocomplete
|
||||
ng-if="!itemNiche.id"
|
||||
|
@ -27,7 +27,7 @@
|
|||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-two
|
||||
label="code"
|
||||
label="Code"
|
||||
model="itemNiche.code"
|
||||
rule="itemNiche.code"
|
||||
vn-acl="buyer,replenisher">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"module": "ticket",
|
||||
"name": "Tickets",
|
||||
"icon": "icon-ticket",
|
||||
"validations": false,
|
||||
"validations": true,
|
||||
"routes": [
|
||||
{
|
||||
"url": "/ticket",
|
||||
|
@ -47,9 +47,9 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url": "/observations",
|
||||
"state": "ticket.card.observations",
|
||||
"component": "vn-ticket-observations",
|
||||
"url": "/observation",
|
||||
"state": "ticket.card.observation",
|
||||
"component": "vn-ticket-observation",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
|
@ -59,15 +59,33 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url" : "/package",
|
||||
"abstract": true,
|
||||
"state": "ticket.card.package",
|
||||
"component": "ui-view"
|
||||
"url": "/volume",
|
||||
"state": "ticket.card.volume",
|
||||
"component": "vn-ticket-volume",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Volume",
|
||||
"icon": "icon-volume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/list",
|
||||
"state": "ticket.card.package.list",
|
||||
"component": "vn-ticket-package-list",
|
||||
"url": "/Expedition",
|
||||
"state": "ticket.card.expedition",
|
||||
"component": "vn-ticket-expedition",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Expedition",
|
||||
"icon": "icon-volum"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url" : "/package",
|
||||
"state": "ticket.card.package",
|
||||
"component": "vn-ticket-package",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
|
@ -77,17 +95,25 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"url" : "/review",
|
||||
"state": "ticket.card.review",
|
||||
"component": "vn-ticket-review",
|
||||
"url" : "/tracking",
|
||||
"state": "ticket.card.tracking",
|
||||
"component": "vn-ticket-tracking",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
},
|
||||
"menu": {
|
||||
"description": "Review",
|
||||
"description": "Tracking",
|
||||
"icon": "remove_red_eye"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/create",
|
||||
"state": "ticket.card.tracking.create",
|
||||
"component": "vn-ticket-tracking-create",
|
||||
"params": {
|
||||
"client": "$ctrl.client"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url" : "/sale",
|
||||
"state": "ticket.card.sale",
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<mg-ajax path="/ticket/api/Expeditions/filter" options="vnIndexNonAuto"></mg-ajax>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
<vn-vertical>
|
||||
<vn-title>Expedition</vn-title>
|
||||
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
|
||||
<vn-column-header vn-one pad-medium-h text="Delete"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="itemFk" text="Item"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="name" text="Name" order-locked></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="packageFk" text="Package type"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="counter" text="Counter"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="checked" text="Checked"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="worker" text="Worker"></vn-column-header>
|
||||
<vn-column-header vn-one pad-medium-h field="created" text="Created" default-order="DESC"></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="expedition in index.model.instances track by expedition.id">
|
||||
<vn-none pad-medium-h style="color:#FFA410;">
|
||||
<i
|
||||
pointer
|
||||
class="material-icons"
|
||||
vn-tooltip="delete expedition"
|
||||
ng-click="$ctrl.deleteExpedition(expedition)">delete</i>
|
||||
</vn-none>
|
||||
<vn-one pad-medium-h>{{expedition.itemFk}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.item.name}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.package.name}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.counter}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.checked}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.worker.firstName}} {{expedition.worker.name}}</vn-one>
|
||||
<vn-one pad-medium-h>{{expedition.created | date:'dd/MM/yyyy'}}</vn-one>
|
||||
</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>
|
|
@ -0,0 +1,22 @@
|
|||
import ngModule from '../module';
|
||||
import FilterTicketList from '../filter-ticket-list';
|
||||
|
||||
class Controller extends FilterTicketList {
|
||||
constructor($scope, $timeout, $stateParams, $http) {
|
||||
super($scope, $timeout, $stateParams);
|
||||
this.params = $stateParams;
|
||||
this.$http = $http;
|
||||
}
|
||||
deleteExpedition(expedition) {
|
||||
this.$http.delete(`/ticket/api/Expeditions/${expedition.id}`, this.params).then(
|
||||
() => this.$.index.accept()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$timeout', '$state', '$http'];
|
||||
|
||||
ngModule.component('vnTicketExpedition', {
|
||||
template: require('./ticket-expedition.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -3,6 +3,14 @@ Basic data: Datos básicos
|
|||
Description: Descripción
|
||||
Discount: Descuento
|
||||
Item: Articulo
|
||||
Delete: Borrar
|
||||
delete expedition: borrar expedición
|
||||
Expedition: Expedición
|
||||
Name: Nombre
|
||||
Package type: Tipo de porte
|
||||
Counter: Contador
|
||||
Checked: Comprobado
|
||||
Worker: Trabajador
|
||||
Notes: Notas
|
||||
Observation type: Tipo de observación
|
||||
Price: Precio
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Addresses"
|
||||
url="/ticket/api/Observation"
|
||||
id-field="id"
|
||||
data="$ctrl.address"
|
||||
form="form">
|
||||
|
@ -31,7 +31,8 @@
|
|||
vn-two
|
||||
margin-large-right
|
||||
label="Description"
|
||||
model="ticketObservation.description">
|
||||
model="ticketObservation.description"
|
||||
rule="ticketObservation.description">
|
||||
</vn-textfield>
|
||||
<vn-auto pad-medium-top>
|
||||
<vn-icon
|
|
@ -1,6 +1,6 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class TicketObservations {
|
||||
class Controller {
|
||||
constructor($stateParams, $scope, $http, $translate, vnApp) {
|
||||
this.params = $stateParams;
|
||||
this.$scope = $scope;
|
||||
|
@ -116,7 +116,7 @@ class TicketObservations {
|
|||
canSubmit = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||
|
||||
if (canSubmit) {
|
||||
return this.$http.post(`/ticket/api/TicketObservations/crudTicketObservations`, observationsObj).then(() => {
|
||||
return this.$http.post(`/ticket/api/TicketObservations/crudTicketObservation`, observationsObj).then(() => {
|
||||
this.getObservations();
|
||||
this._unsetDirtyForm();
|
||||
});
|
||||
|
@ -129,11 +129,11 @@ class TicketObservations {
|
|||
}
|
||||
}
|
||||
|
||||
TicketObservations.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
|
||||
Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
|
||||
|
||||
ngModule.component('vnTicketObservations', {
|
||||
template: require('./ticket-observations.html'),
|
||||
controller: TicketObservations,
|
||||
ngModule.component('vnTicketObservation', {
|
||||
template: require('./ticket-observation.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import './ticket-observations.js';
|
||||
import './ticket-observation.js';
|
||||
|
||||
describe('ticket', () => {
|
||||
describe('Component vnTicketObservations', () => {
|
||||
describe('Component vnTicketObservation', () => {
|
||||
let $componentController;
|
||||
let $state;
|
||||
let controller;
|
||||
|
@ -15,7 +15,7 @@ describe('ticket', () => {
|
|||
$componentController = _$componentController_;
|
||||
$state = _$state_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
controller = $componentController('vnTicketObservations', {$state: $state});
|
||||
controller = $componentController('vnTicketObservation', {$state: $state});
|
||||
}));
|
||||
|
||||
describe('add / remove observation', () => {
|
||||
|
@ -24,10 +24,10 @@ describe('ticket', () => {
|
|||
spyOn(controller, '_setIconAdd').and.callThrough();
|
||||
controller.addObservation();
|
||||
|
||||
expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
expect(controller.ticketObservations.length).toEqual(1);
|
||||
expect(controller.ticketObservations[0].id).toBe(undefined);
|
||||
expect(controller.ticketObservations[0].showAddIcon).toBeTruthy();
|
||||
expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should remove an observation that occupies the position in the index given and call _setIconAdd()', () => {
|
||||
|
@ -42,11 +42,11 @@ describe('ticket', () => {
|
|||
|
||||
controller.removeObservation(index);
|
||||
|
||||
expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
expect(controller.ticketObservations.length).toEqual(2);
|
||||
expect(controller.ticketObservations[0].showAddIcon).toBeFalsy();
|
||||
expect(controller.ticketObservations[1].showAddIcon).toBeTruthy();
|
||||
expect(controller.ticketObservations[index]).toBe(undefined);
|
||||
expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -70,16 +70,33 @@ describe('ticket', () => {
|
|||
|
||||
describe('get Observations()', () => {
|
||||
it('should perform a GET query to receive the ticket observations', () => {
|
||||
let res = [{id: 1, observationTypeFk: 1, description: 'one'}];
|
||||
let response = [{id: 1, observationTypeFk: 1, description: 'one'}];
|
||||
spyOn(controller, 'setOldObservations');
|
||||
|
||||
$httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond(res);
|
||||
$httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond(response);
|
||||
$httpBackend.expectGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`);
|
||||
controller.getObservations();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.setOldObservations).toHaveBeenCalledWith(jasmine.any(Object));
|
||||
});
|
||||
});
|
||||
|
||||
describe('submit()', () => {
|
||||
it("should return an error message 'Some fields are invalid'", () => {
|
||||
controller.$scope.form = {};
|
||||
controller.$scope.form.$invalid = true;
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
controller.ticketObservations = [
|
||||
{id: 1, observationTypeFk: 1, description: 'one', itemFk: 1},
|
||||
{observationTypeFk: 1, description: 'one', itemFk: 1}
|
||||
];
|
||||
controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Some fields are invalid');
|
||||
});
|
||||
|
||||
it("should return an error message 'The observation type must be unique'", () => {
|
||||
controller.$scope.form = {};
|
||||
spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
|
@ -100,7 +117,7 @@ describe('ticket', () => {
|
|||
controller.removedObservations = [1];
|
||||
|
||||
$httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservation`).respond('ok!');
|
||||
controller.submit();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
@ -111,7 +128,7 @@ describe('ticket', () => {
|
|||
controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one'}};
|
||||
|
||||
$httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservation`).respond('ok!');
|
||||
controller.submit();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
@ -121,7 +138,7 @@ describe('ticket', () => {
|
|||
controller.ticketObservations = [{observationTypeFk: 2, description: 'two'}];
|
||||
|
||||
$httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
$httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservation`).respond('ok!');
|
||||
controller.submit();
|
||||
$httpBackend.flush();
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
<mg-ajax
|
||||
path="/ticket/api/Tickets/{{index.params.id}}/packages"
|
||||
options="mgIndex">
|
||||
</mg-ajax>
|
||||
|
||||
<vn-card pad-large>
|
||||
<vn-title>Packages</vn-title>
|
||||
<vn-one>
|
||||
<vn-horizontal ng-repeat="package in index.model track by package.id">
|
||||
<vn-autocomplete vn-one
|
||||
margin-large-right
|
||||
url="/ticket/api/Packagings/listPackaging"
|
||||
label="Package"
|
||||
show-field="name"
|
||||
value-field="packagingFk"
|
||||
field="package.packagingFk">
|
||||
<tpl-item>{{id}} : {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Quantity"
|
||||
model="package.quantity">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Added"
|
||||
model="package.created | date: 'dd/MM/yyyy'"
|
||||
disabled="true"
|
||||
ng-readonly="true">
|
||||
</vn-textfield>
|
||||
<vn-auto pad-medium-top>
|
||||
<vn-icon
|
||||
pointer
|
||||
medium-grey
|
||||
vn-tooltip="Remove package"
|
||||
tooltip-position = "left"
|
||||
icon="remove_circle_outline"
|
||||
ng-click="$ctrl.removePackage($index)">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-icon
|
||||
pointer
|
||||
margin-medium-left
|
||||
vn-tooltip="Add package"
|
||||
tooltip-position = "right"
|
||||
orange
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.addPackage()">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-card>
|
|
@ -1,19 +0,0 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
class Controller {
|
||||
|
||||
construct($http, $scope) {
|
||||
this.$http = $http;
|
||||
this.$ = $scope;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$http', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketPackageList', {
|
||||
template: require('./package-list.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,68 @@
|
|||
<mg-ajax
|
||||
path="/ticket/api/Tickets/{{index.params.id}}/packages"
|
||||
options="mgIndex" actions="$ctrl.getPackages()">
|
||||
</mg-ajax>
|
||||
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.packages"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
|
||||
<form name="form" ng-submit="$ctrl.submit()">
|
||||
<vn-card pad-large>
|
||||
<vn-title>Packages</vn-title>
|
||||
<vn-one>
|
||||
<vn-horizontal ng-repeat="package in index.model track by $index">
|
||||
<vn-autocomplete vn-one
|
||||
margin-large-right
|
||||
url="/ticket/api/Packagings/listPackaging"
|
||||
label="Package"
|
||||
show-field="name"
|
||||
value-field="packagingFk"
|
||||
field="package.packagingFk">
|
||||
<tpl-item>{{id}} : {{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Quantity"
|
||||
model="package.quantity"
|
||||
rule="TicketPackaging.quantity">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
margin-large-right
|
||||
label="Added"
|
||||
model="package.created | date: 'dd/MM/yyyy'"
|
||||
disabled="true"
|
||||
ng-readonly="true">
|
||||
</vn-textfield>
|
||||
<vn-auto pad-medium-top>
|
||||
<vn-icon
|
||||
pointer
|
||||
medium-grey
|
||||
vn-tooltip="Remove package"
|
||||
tooltip-position = "left"
|
||||
icon="remove_circle_outline"
|
||||
ng-click="$ctrl.removePackage($index)">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-icon
|
||||
pointer
|
||||
margin-medium-left
|
||||
vn-tooltip="Add package"
|
||||
tooltip-position = "right"
|
||||
orange
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.addPackage()">
|
||||
</vn-icon>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,73 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
|
||||
constructor($http, $scope, $translate, vnApp) {
|
||||
this.$http = $http;
|
||||
this.$ = $scope;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
this.removedPackages = [];
|
||||
this.updatedPackages = [];
|
||||
}
|
||||
|
||||
submit() {
|
||||
let query = `/ticket/api/TicketPackagings/crudTicketPackaging`;
|
||||
let packagesObj = {
|
||||
delete: this.removedPackages,
|
||||
create: [],
|
||||
update: []
|
||||
};
|
||||
|
||||
this.packages.forEach(item => {
|
||||
if (typeof item.id === 'undefined')
|
||||
packagesObj.create.push(item);
|
||||
|
||||
if (typeof item.id !== 'undefined' && angular.equals(item, this.oldPackages[item.id]))
|
||||
packagesObj.update.push(item);
|
||||
});
|
||||
|
||||
this.$http.post(query, packagesObj).then(res => {
|
||||
this.$.index.accept();
|
||||
});
|
||||
}
|
||||
|
||||
removePackage(index) {
|
||||
if (this.packages[index] && this.packages[index].id)
|
||||
this.removedPackages.push(this.packages[index].id);
|
||||
|
||||
this.packages.splice(index, 1);
|
||||
}
|
||||
|
||||
addPackage() {
|
||||
let data = {
|
||||
packagingFk: null,
|
||||
quantity: null,
|
||||
created: Date.now(),
|
||||
ticketFk: this.ticket.id
|
||||
};
|
||||
this.packages.push(data);
|
||||
}
|
||||
|
||||
getPackages() {
|
||||
this.packages = this.$.index.model;
|
||||
this.setOldPackages();
|
||||
}
|
||||
|
||||
setOldPackages() {
|
||||
this.oldPackages = [];
|
||||
this.packages.forEach(item => {
|
||||
this.oldPackages[item.id] = item;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$http', '$scope'];
|
||||
|
||||
ngModule.component('vnTicketPackage', {
|
||||
template: require('./package.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,59 @@
|
|||
import './package.js';
|
||||
|
||||
describe('Ticket', () => {
|
||||
describe('Component vnTicketPackage', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('ticket');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_, $rootScope) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = {
|
||||
index: {
|
||||
accept: function() {}
|
||||
}
|
||||
};
|
||||
controller = $componentController('vnTicketPackage', {$scope: $scope});
|
||||
}));
|
||||
|
||||
describe('removePackage()', () => {
|
||||
it('should push a package to removedPackages in the controller', () => {
|
||||
controller.packages = [{id: 1}, {id: 2}];
|
||||
controller.removePackage(0);
|
||||
|
||||
expect(controller.removedPackages).toEqual([1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('submit()', () => {
|
||||
it('should perform a post', () => {
|
||||
spyOn(angular, 'equals').and.returnValue(true);
|
||||
let query = '/ticket/api/TicketPackagings/crudTicketPackaging';
|
||||
controller.removedPackages = [];
|
||||
controller.oldPackages = [
|
||||
{id: 1, quantity: 5, ticketFk: 1}
|
||||
];
|
||||
controller.packages = [
|
||||
{quantity: 5, ticketFk: 1},
|
||||
{id: 1, quantity: 25, ticketFk: 1}
|
||||
];
|
||||
let packagesObj = {
|
||||
delete: controller.removedPackages,
|
||||
create: [],
|
||||
update: []
|
||||
};
|
||||
|
||||
$httpBackend.whenPOST(query, packagesObj).respond('omg YEAH');
|
||||
$httpBackend.expectPOST(query, packagesObj);
|
||||
controller.submit();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -5,7 +5,9 @@ import './create/ticket-create';
|
|||
import './card/ticket-card';
|
||||
import './summary/ticket-summary';
|
||||
import './data/ticket-data';
|
||||
import './notes/ticket-observations';
|
||||
import './package/list/package-list';
|
||||
import './note/ticket-observation';
|
||||
import './expedition/ticket-expedition';
|
||||
import './volume/ticket-volume';
|
||||
import './package/package';
|
||||
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
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
<form name="form" ng-submit="$ctrl.submit()">
|
||||
<vn-card pad-large>
|
||||
<vn-one margin-medium-top>
|
||||
<vn-title>Volumes</vn-title>
|
||||
</vn-one>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -0,0 +1,147 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams, $scope, $http, $translate, vnApp) {
|
||||
this.params = $stateParams;
|
||||
this.$scope = $scope;
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
|
||||
this.ticketVolumes = [];
|
||||
this.oldVolumes = {};
|
||||
this.removedVolumes = [];
|
||||
}
|
||||
|
||||
_getTicketVolumes(ticketFk) {
|
||||
this.$http.get(`/tcket/api/Volumes/${ticketFk}/getVolumes`)
|
||||
.then(response => {
|
||||
this.ticketVolumes = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
// _setIconAdd() {
|
||||
// if (this.ticketVolumes.length) {
|
||||
// this.ticketVolumes.map(element => {
|
||||
// element.showAddIcon = false;
|
||||
// return true;
|
||||
// });
|
||||
// this.ticketVolumes[this.ticketVolumes.length - 1].showAddIcon = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// _setDirtyForm() {
|
||||
// if (this.$scope.form) {
|
||||
// this.$scope.form.$setDirty();
|
||||
// }
|
||||
// }
|
||||
|
||||
// _unsetDirtyForm() {
|
||||
// if (this.$scope.form) {
|
||||
// this.$scope.form.$setPristine();
|
||||
// }
|
||||
// }
|
||||
|
||||
// addVolume() {
|
||||
// this.ticketVolumes.push({description: null, ticketFk: this.params.id, showAddIcon: true});
|
||||
// this._setIconAdd();
|
||||
// }
|
||||
|
||||
// removeVolume(index) {
|
||||
// let item = this.ticketVolumes[index];
|
||||
// if (item) {
|
||||
// this.ticketVolumes.splice(index, 1);
|
||||
// this._setIconAdd();
|
||||
// if (item.id) {
|
||||
// this.removedVolumes.push(item.id);
|
||||
// this._setDirtyForm();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// _equalVolumes(oldVolume, newVolume) {
|
||||
// return oldVolume.id === newVolume.id && oldVolume.VolumeTypeFk === newVolume.VolumeTypeFk && oldVolume.description === newVolume.description;
|
||||
// }
|
||||
|
||||
// setOldVolumes(response) {
|
||||
// this._setIconAdd();
|
||||
// response.data.forEach(Volume => {
|
||||
// this.oldVolumes[Volume.id] = Object.assign({}, Volume);
|
||||
// });
|
||||
// }
|
||||
|
||||
// getVolumes() {
|
||||
// let filter = {
|
||||
// where: {ticketFk: this.params.id},
|
||||
// include: ['VolumeType']
|
||||
// };
|
||||
|
||||
// this.$http.get(`/ticket/api/TicketVolumes?filter=${JSON.stringify(filter)}`).then(response => {
|
||||
// this.ticketVolumes = response.data;
|
||||
// this.setOldVolumes(response);
|
||||
// });
|
||||
// }
|
||||
|
||||
// submit() {
|
||||
// let typesDefined = [];
|
||||
// let repeatedType = false;
|
||||
// let canSubmit;
|
||||
// let VolumesObj = {
|
||||
// delete: this.removedVolumes,
|
||||
// create: [],
|
||||
// update: []
|
||||
// };
|
||||
|
||||
// this.ticketVolumes.forEach(Volume => {
|
||||
// let isNewVolume = !Volume.id;
|
||||
|
||||
// delete Volume.showAddIcon;
|
||||
|
||||
// if (typesDefined.indexOf(Volume.VolumeTypeFk) !== -1) {
|
||||
// repeatedType = true;
|
||||
// return;
|
||||
// }
|
||||
// typesDefined.push(Volume.VolumeTypeFk);
|
||||
|
||||
// if (isNewVolume && Volume.description && Volume.VolumeTypeFk) {
|
||||
// VolumesObj.create.push(Volume);
|
||||
// }
|
||||
|
||||
// if (!isNewVolume && !this._equalVolumes(this.oldVolumes[Volume.id], Volume)) {
|
||||
// VolumesObj.update.push(Volume);
|
||||
// }
|
||||
// });
|
||||
|
||||
// if (this.$scope.form.$invalid) {
|
||||
// return this.vnApp.showMessage(this.$translate.instant('Some fields are invalid'));
|
||||
// }
|
||||
|
||||
// if (repeatedType) {
|
||||
// return this.vnApp.showMessage(this.$translate.instant('The Volume type must be unique'));
|
||||
// }
|
||||
|
||||
// canSubmit = VolumesObj.update.length > 0 || VolumesObj.create.length > 0 || VolumesObj.delete.length > 0;
|
||||
|
||||
// if (canSubmit) {
|
||||
// return this.$http.post(`/ticket/api/TicketVolumes/crudTicketVolumes`, VolumesObj).then(() => {
|
||||
// this.getVolumes();
|
||||
// this._unsetDirtyForm();
|
||||
// });
|
||||
// }
|
||||
// this.vnApp.showMessage(this.$translate.instant('No changes to save'));
|
||||
// }
|
||||
|
||||
$onInit() {
|
||||
// this.getVolumes();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp'];
|
||||
|
||||
ngModule.component('vnTicketVolume', {
|
||||
template: require('./ticket-volume.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -0,0 +1,143 @@
|
|||
// import './ticket-observations.js';
|
||||
|
||||
// describe('ticket', () => {
|
||||
// describe('Component vnTicketObservations', () => {
|
||||
// let $componentController;
|
||||
// let $state;
|
||||
// let controller;
|
||||
// let $httpBackend;
|
||||
|
||||
// beforeEach(() => {
|
||||
// angular.mock.module('ticket');
|
||||
// });
|
||||
|
||||
// beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
||||
// $componentController = _$componentController_;
|
||||
// $state = _$state_;
|
||||
// $httpBackend = _$httpBackend_;
|
||||
// controller = $componentController('vnTicketObservations', {$state: $state});
|
||||
// }));
|
||||
|
||||
// describe('add / remove observation', () => {
|
||||
// it('should add one empty observation into controller observations collection and call _setIconAdd()', () => {
|
||||
// controller.ticketObservations = [];
|
||||
// spyOn(controller, '_setIconAdd').and.callThrough();
|
||||
// controller.addObservation();
|
||||
|
||||
// expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
// expect(controller.ticketObservations.length).toEqual(1);
|
||||
// expect(controller.ticketObservations[0].id).toBe(undefined);
|
||||
// expect(controller.ticketObservations[0].showAddIcon).toBeTruthy();
|
||||
// });
|
||||
|
||||
// it('should remove an observation that occupies the position in the index given and call _setIconAdd()', () => {
|
||||
// let index = 2;
|
||||
// controller.ticketObservations = [
|
||||
// {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: false},
|
||||
// {id: 2, observationTypeFk: 2, description: 'two', showAddIcon: false},
|
||||
// {id: 3, observationTypeFk: 3, description: 'three', showAddIcon: true}
|
||||
// ];
|
||||
|
||||
// spyOn(controller, '_setIconAdd').and.callThrough();
|
||||
|
||||
// controller.removeObservation(index);
|
||||
|
||||
// expect(controller._setIconAdd).toHaveBeenCalledWith();
|
||||
// expect(controller.ticketObservations.length).toEqual(2);
|
||||
// expect(controller.ticketObservations[0].showAddIcon).toBeFalsy();
|
||||
// expect(controller.ticketObservations[1].showAddIcon).toBeTruthy();
|
||||
// expect(controller.ticketObservations[index]).toBe(undefined);
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('_equalObservations()', () => {
|
||||
// it('should return true if two observations are equals independent of control attributes', () => {
|
||||
// let observationOne = {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: true};
|
||||
// let observationTwo = {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: false};
|
||||
// let equals = controller._equalObservations(observationOne, observationTwo);
|
||||
|
||||
// expect(equals).toBeTruthy();
|
||||
// });
|
||||
|
||||
// it('should return false if two observations aint equals independent of control attributes', () => {
|
||||
// let observationOne = {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: true};
|
||||
// let observationTwo = {id: 1, observationTypeFk: 1, description: 'two', showAddIcon: true};
|
||||
// let equals = controller._equalObservations(observationOne, observationTwo);
|
||||
|
||||
// expect(equals).toBeFalsy();
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('get Observations()', () => {
|
||||
// it('should perform a GET query to receive the ticket observations', () => {
|
||||
// let res = [{id: 1, observationTypeFk: 1, description: 'one'}];
|
||||
|
||||
// $httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond(res);
|
||||
// $httpBackend.expectGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`);
|
||||
// controller.getObservations();
|
||||
// $httpBackend.flush();
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('submit()', () => {
|
||||
// it("should return an error message 'The observation type must be unique'", () => {
|
||||
// controller.$scope.form = {};
|
||||
// spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
// controller.ticketObservations = [
|
||||
// {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1},
|
||||
// {observationTypeFk: 1, description: 'one', itemFk: 1}
|
||||
// ];
|
||||
// controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one', itemFk: 1}};
|
||||
// controller.submit();
|
||||
|
||||
// expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The observation type must be unique');
|
||||
// });
|
||||
|
||||
// it("should perfom a query to delete observations", () => {
|
||||
// controller.$scope.form = {$setPristine: () => {}};
|
||||
// controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one'}};
|
||||
// controller.ticketObservations = [];
|
||||
// controller.removedObservations = [1];
|
||||
|
||||
// $httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
// $httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
// controller.submit();
|
||||
// $httpBackend.flush();
|
||||
// });
|
||||
|
||||
// it("should perfom a query to update observations", () => {
|
||||
// controller.$scope.form = {$setPristine: () => {}};
|
||||
// controller.ticketObservations = [{id: 1, observationTypeFk: 1, description: 'number one!'}];
|
||||
// controller.oldObservations = {1: {id: 1, observationTypeFk: 1, description: 'one'}};
|
||||
|
||||
// $httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
// $httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
// controller.submit();
|
||||
// $httpBackend.flush();
|
||||
// });
|
||||
|
||||
// it("should perfom a query to create new observation", () => {
|
||||
// controller.$scope.form = {$setPristine: () => {}};
|
||||
// controller.ticketObservations = [{observationTypeFk: 2, description: 'two'}];
|
||||
|
||||
// $httpBackend.whenGET(`/ticket/api/TicketObservations?filter={"where":{},"include":["observationType"]}`).respond([]);
|
||||
// $httpBackend.expectPOST(`/ticket/api/TicketObservations/crudTicketObservations`).respond('ok!');
|
||||
// controller.submit();
|
||||
// $httpBackend.flush();
|
||||
// });
|
||||
|
||||
// it("should return a message 'No changes to save' when there are no changes to apply", () => {
|
||||
// controller.$scope.form = {$setPristine: () => {}};
|
||||
// spyOn(controller.vnApp, 'showMessage').and.callThrough();
|
||||
// controller.oldObservations = [
|
||||
// {id: 1, observationTypeFk: 1, description: 'one', showAddIcon: false},
|
||||
// {id: 2, observationTypeFk: 2, description: 'two', showAddIcon: true}
|
||||
// ];
|
||||
// controller.ticketObservations = [];
|
||||
// controller.submit();
|
||||
|
||||
// expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save');
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
|
@ -288,8 +288,13 @@ export default {
|
|||
firstDescriptionInput: `vn-textfield[label="Description"] > div > input`,
|
||||
submitNotesButton: `${components.vnSubmit}`
|
||||
},
|
||||
ticketExpedition: {
|
||||
expeditionButton: `${components.vnMenuItem}[ui-sref="ticket.card.expedition"]`,
|
||||
secondExpeditionRemoveButton: `body > vn-app > vn-vertical > vn-vertical > ui-view > vn-ticket-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-ticket-expedition > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(2) > vn-none > i`,
|
||||
secondExpeditionText: `body > vn-app > vn-vertical > vn-vertical > ui-view > vn-ticket-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-ticket-expedition > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(2)`
|
||||
},
|
||||
ticketPackages: {
|
||||
packagesButton: `${components.vnMenuItem}[ui-sref="ticket.card.package.list"]`,
|
||||
packagesButton: `${components.vnMenuItem}[ui-sref="ticket.card.package"]`,
|
||||
firstPackageSelect: `${components.vnAutocomplete}[label="Package"] input`
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import createNightmare from '../../helpers/helpers';
|
||||
|
||||
describe('create item niche path', () => {
|
||||
describe('create ticket notes path', () => {
|
||||
const nightmare = createNightmare();
|
||||
|
||||
beforeAll(() => {
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import createNightmare from '../../helpers/helpers';
|
||||
|
||||
describe('delete ticket expeditions path', () => {
|
||||
const nightmare = createNightmare();
|
||||
|
||||
beforeAll(() => {
|
||||
return nightmare
|
||||
.waitForLogin('developer');
|
||||
});
|
||||
|
||||
it('should access to the tickets index by clicking the tickets button', () => {
|
||||
return nightmare
|
||||
.click(selectors.moduleAccessView.ticketsSectionButton)
|
||||
.wait(selectors.ticketsIndex.createTicketButton)
|
||||
.parsedUrl()
|
||||
.then(url => {
|
||||
expect(url.hash).toEqual('#!/ticket/list');
|
||||
});
|
||||
});
|
||||
|
||||
it('should search for the ticket with id 1', () => {
|
||||
return nightmare
|
||||
.wait(selectors.ticketsIndex.searchTicketInput)
|
||||
.type(selectors.ticketsIndex.searchTicketInput, '1')
|
||||
.click(selectors.ticketsIndex.searchButton)
|
||||
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
||||
.countSearchResults(selectors.ticketsIndex.searchResult)
|
||||
.then(result => {
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
it(`should click on the search result to access to the ticket expeditions`, () => {
|
||||
return nightmare
|
||||
.waitForTextInElement(selectors.ticketsIndex.searchResult, '1')
|
||||
.waitToClick(selectors.ticketsIndex.searchResult)
|
||||
.waitToClick(selectors.ticketExpedition.expeditionButton)
|
||||
.waitForURL('Expedition')
|
||||
.url()
|
||||
.then(url => {
|
||||
expect(url).toContain('Expedition');
|
||||
});
|
||||
});
|
||||
|
||||
it(`should delete a former expedition and confirm the remaining expedition is the expected one`, () => {
|
||||
return nightmare
|
||||
.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton)
|
||||
.click(selectors.ticketPackages.packagesButton)
|
||||
.wait(selectors.ticketPackages.firstPackageSelect)
|
||||
.click(selectors.ticketExpedition.expeditionButton)
|
||||
.wait(selectors.ticketExpedition.secondExpeditionText)
|
||||
.getInnerText(selectors.ticketExpedition.secondExpeditionText)
|
||||
.then(value => {
|
||||
expect(value).toContain('Iron Patriot');
|
||||
expect(value).toContain('root');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -55,7 +55,7 @@ UNLOCK TABLES;
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!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`;
|
||||
-- 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 */;
|
||||
/*!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`;
|
||||
-- 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 */;
|
||||
/*!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
|
||||
|
|
|
@ -401,7 +401,10 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create
|
|||
VALUES
|
||||
( 1, 1, 1, 0, CURDATE(), 1, 0, 2, 1),
|
||||
( 2, 1, 1, 1, CURDATE(), 2, 1, 0, 2),
|
||||
( 3, 2, 2, 2, CURDATE(), 3, 2, 0, NULL);
|
||||
( 3, 2, 1, 2, CURDATE(), 3, 2, 0, NULL),
|
||||
( 4, 1, 1, 0, CURDATE(), 1, 0, 2, 1),
|
||||
( 5, 1, 1, 1, CURDATE(), 2, 1, 0, 2),
|
||||
( 6, 2, 1, 2, CURDATE(), 3, 2, 0, NULL);
|
||||
|
||||
INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`)
|
||||
VALUES
|
||||
|
@ -517,3 +520,11 @@ INSERT INTO `bi`.`rotacion`(`Id_Article`, `warehouse_id`, `total`, `rotacion`, `
|
|||
( 1, 2, 0, 0.0000, 100, 0.0060, 0.0200, 0.0080, 0.0000),
|
||||
( 2, 1, 10, 3.5000, 0, 0.0000, 0.0000, 0.0080, 0.0000),
|
||||
( 3, 1, 50, 5.5000, 100, 0.0000, 0.0000, 0.0080, 0.0000);
|
||||
|
||||
INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
|
||||
VALUES
|
||||
( 101, 0),
|
||||
( 102, 100),
|
||||
( 103, 1000),
|
||||
( 104, 500),
|
||||
( 105, 5000);
|
|
@ -12,3 +12,4 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Expedition', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Expedition', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Expedition', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('AnnualAverageInvoiced', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
|
@ -5,6 +5,8 @@ echo USE `salix`; >> 02-dumpedFixtures.sql
|
|||
mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> 02-dumpedFixtures.sql
|
||||
echo USE `vn`; >> 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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
"The default consignee can not be unchecked": "The default consignee can not be unchecked",
|
||||
"Unable to default a disabled consignee": "Unable to default a disabled consignee",
|
||||
"El método de pago seleccionado requiere que se especifique el IBAN": "El método de pago seleccionado requiere que se especifique el IBAN",
|
||||
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre"
|
||||
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre",
|
||||
"Quantity cannot be zero": "Quantity cannot be zero"
|
||||
}
|
|
@ -8,9 +8,6 @@
|
|||
"can't be blank": "can't be blank",
|
||||
"DNI Incorrecto": "DNI Incorrecto",
|
||||
"Ya existe un usuario con ese nombre": "Ya existe un usuario con ese nombre",
|
||||
"ValidationError: The `Item` instance is not valid. Details: `originFk` Cannot be blank (value: undefined).": "ValidationError: The `Item` instance is not valid. Details: `originFk` Cannot be blank (value: undefined).",
|
||||
"Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE)": "Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE)",
|
||||
"Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE)": "Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`vn2008`.`Articles`, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE)",
|
||||
"INVALID_USER_NAME": "INVALID_USER_NAME",
|
||||
"La razón social debe ser única": "La razón social debe ser única"
|
||||
"is invalid": "is invalid",
|
||||
"Quantity cannot be zero": "La cantidad no puede ser cero"
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
||||
|
||||
describe('Client Create', () => {
|
||||
let sqlStatements = {deletes: `
|
||||
DELETE FROM vn.address WHERE nickname = "Wade";
|
||||
DELETE FROM vn.client WHERE name = "Wade";
|
||||
DELETE FROM account.user WHERE name = "Deadpool";
|
||||
DELETE FROM vn.address WHERE nickname = 'Wade';
|
||||
DELETE FROM vn.client WHERE name = 'Wade';
|
||||
DELETE FROM account.user WHERE name = 'Deadpool';
|
||||
`, inserts: ``, updates: ``};
|
||||
|
||||
beforeAll(() => {
|
||||
|
@ -17,70 +16,50 @@ describe('Client Create', () => {
|
|||
restoreFixtures(sqlStatements);
|
||||
});
|
||||
|
||||
let newAccountData = {
|
||||
active: true,
|
||||
name: 'Wade',
|
||||
let newAccount = {
|
||||
userName: 'Deadpool',
|
||||
email: 'Deadpool@marvel.com',
|
||||
fi: '16195279J',
|
||||
socialName: 'Deadpool Marvel',
|
||||
salesPersonFk: 1
|
||||
name: 'Wade',
|
||||
socialName: 'Deadpool Marvel'
|
||||
};
|
||||
|
||||
it('should find Charles Xavier', done => {
|
||||
app.models.Account.findOne({where: {name: 'CharlesXavier'}})
|
||||
.then(account => {
|
||||
expect(account.name).toEqual('CharlesXavier');
|
||||
done();
|
||||
});
|
||||
it(`should not find Deadpool as he's not created yet`, async() => {
|
||||
let account = await app.models.Account.findOne({where: {name: newAccount.userName}});
|
||||
let client = await app.models.Client.findOne({where: {name: newAccount.name}});
|
||||
|
||||
expect(account).toEqual(null);
|
||||
expect(client).toEqual(null);
|
||||
});
|
||||
|
||||
it(`should not find Deadpool as he's not created yet`, done => {
|
||||
app.models.Account.findOne({where: {name: newAccountData.userName}})
|
||||
.then(account => {
|
||||
expect(account).toEqual(null);
|
||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
||||
.then(client => {
|
||||
expect(client).toEqual(null);
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
it('should create a new account', async() => {
|
||||
let client = await app.models.Client.createWithUser(newAccount);
|
||||
let account = await app.models.Account.findOne({where: {name: newAccount.userName}});
|
||||
|
||||
expect(account.name).toEqual(newAccount.userName);
|
||||
|
||||
client = await app.models.Client.findOne({where: {name: newAccount.name}});
|
||||
|
||||
expect(client.id).toEqual(account.id);
|
||||
expect(client.name).toEqual(newAccount.name);
|
||||
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() => {
|
||||
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 {
|
||||
let client = await app.models.Client.createWithUser(formerAccountData);
|
||||
let client = await app.models.Client.createWithUser(newAccount);
|
||||
|
||||
expect(client).toBeNull();
|
||||
} catch (err) {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getVolumes', {
|
||||
description: 'Returns the volumes of a ticket',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'ticket id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'object'
|
||||
},
|
||||
http: {
|
||||
path: `/:id/getVolumes`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getVolumes = async ticketFk => {
|
||||
let query = `SELECT vn.ticketVolume(?) AS ticketVolumes`;
|
||||
let response = await Self.rawSql(query, [ticketFk]);
|
||||
return response[0];
|
||||
};
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
// const getDebt = require('../getDebt');
|
||||
|
||||
// describe('client getDebt()', () => {
|
||||
// it('should call the getDebt method', done => {
|
||||
// let clientFk = 109;
|
||||
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'rawSql']);
|
||||
// self.rawSql.and.returnValue(Promise.resolve([{debt: 100}]));
|
||||
// getDebt(self);
|
||||
// self.getDebt(clientFk)
|
||||
// .then(result => {
|
||||
// expect(result.debt).toEqual(100);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
|
@ -44,11 +44,11 @@ module.exports = function(Self) {
|
|||
allowBlank: true
|
||||
});
|
||||
|
||||
Self.validateAsync('fi', fiIsValid, {
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'DNI Incorrecto'
|
||||
});
|
||||
let validateDni = require('../validations/validateDni');
|
||||
async function fiIsValid(err, done) {
|
||||
let validateTin = require('../validations/validateTin');
|
||||
async function tinIsValid(err, done) {
|
||||
let filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
|
@ -56,7 +56,7 @@ module.exports = function(Self) {
|
|||
let country = await Self.app.models.Country.findOne(filter);
|
||||
let code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (!validateDni(this.fi, code))
|
||||
if (!validateTin(this.fi, code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
|
|
|
@ -3,4 +3,5 @@ module.exports = function(Self) {
|
|||
require('../methods/ticket/change-time.js')(Self);
|
||||
require('../methods/ticket/change-worker.js')(Self);
|
||||
require('../methods/ticket/filter.js')(Self);
|
||||
require('../methods/ticket/get-volume.js')(Self);
|
||||
};
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
const validateDni = require('../validateDni');
|
||||
const validateDni = require('../validateTin');
|
||||
|
||||
describe('DNI validation', () => {
|
||||
it('should return true for any DNI when no country is passed', () => {
|
||||
describe('TIN validation', () => {
|
||||
it('should return true for any TIN when no country is passed', () => {
|
||||
let isValid = validateDni('Pepinillos');
|
||||
|
||||
expect(isValid).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('Spanish', () => {
|
||||
it('should return true for valid spanish DNI', () => {
|
||||
it('should return true for valid spanish TIN', () => {
|
||||
let isValid = validateDni('20849756A', 'es');
|
||||
|
||||
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');
|
||||
|
||||
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');
|
||||
|
||||
expect(isValid).toBeFalsy();
|
||||
|
@ -40,19 +40,19 @@ describe('DNI validation', () => {
|
|||
});
|
||||
|
||||
describe('French', () => {
|
||||
it('should return true for valid french DNI', () => {
|
||||
let isValid = validateDni('1B123456789', 'fr');
|
||||
it('should return true for valid french TIN', () => {
|
||||
let isValid = validateDni('012345678', 'fr');
|
||||
|
||||
expect(isValid).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false for french DNI with exceeded digits', () => {
|
||||
let isValid = validateDni('1B12345678910', 'fr');
|
||||
it('should return false for french TIN with exceeded digits', () => {
|
||||
let isValid = validateDni('1B123456789101234', 'fr');
|
||||
|
||||
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');
|
||||
|
||||
expect(isValid).toBeFalsy();
|
||||
|
@ -60,19 +60,19 @@ describe('DNI validation', () => {
|
|||
});
|
||||
|
||||
describe('Italian', () => {
|
||||
it('should return true for valid italian DNI', () => {
|
||||
it('should return true for valid italian TIN', () => {
|
||||
let isValid = validateDni('12345678911', 'it');
|
||||
|
||||
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');
|
||||
|
||||
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');
|
||||
|
||||
expect(isValid).toBeFalsy();
|
||||
|
@ -80,19 +80,19 @@ describe('DNI validation', () => {
|
|||
});
|
||||
|
||||
describe('Portuguese', () => {
|
||||
it('should return true for valid portuguese DNI', () => {
|
||||
it('should return true for valid portuguese TIN', () => {
|
||||
let isValid = validateDni('123456789', 'pt');
|
||||
|
||||
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');
|
||||
|
||||
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');
|
||||
|
||||
expect(isValid).toBeFalsy();
|
|
@ -1,24 +1,24 @@
|
|||
module.exports = function(fi, country) {
|
||||
if (fi == null || country == null)
|
||||
module.exports = function(tin, country) {
|
||||
if (tin == null || country == null)
|
||||
return true;
|
||||
if (typeof fi != 'string' || typeof country != 'string')
|
||||
if (typeof tin != 'string' || typeof country != 'string')
|
||||
return false;
|
||||
|
||||
fi = fi.toUpperCase();
|
||||
tin = tin.toUpperCase();
|
||||
country = country.toLowerCase();
|
||||
|
||||
let len = fi.length;
|
||||
let len = tin.length;
|
||||
|
||||
let validators = {
|
||||
es: {
|
||||
regExp: /^[A-Z0-9]\d{7}[A-Z0-9]$/,
|
||||
validate: () => {
|
||||
let isCif = /[A-W]/.test(fi.charAt(0));
|
||||
let lastDigit = fi.charAt(len - 1);
|
||||
let isCif = /[A-W]/.test(tin.charAt(0));
|
||||
let lastDigit = tin.charAt(len - 1);
|
||||
let computedDigit;
|
||||
|
||||
if (isCif) {
|
||||
let numbers = fi.substring(1, 8)
|
||||
let numbers = tin.substring(1, 8)
|
||||
.split('')
|
||||
.map(x => parseInt(x));
|
||||
|
||||
|
@ -41,8 +41,8 @@ module.exports = function(fi, country) {
|
|||
computedDigit = index == -1 ? control.toString() : index;
|
||||
} else {
|
||||
// Foreign NIF
|
||||
let index = 'XYZ'.indexOf(fi.charAt(0));
|
||||
let nif = index == -1 ? fi : index.toString() + fi.substring(1);
|
||||
let index = 'XYZ'.indexOf(tin.charAt(0));
|
||||
let nif = index == -1 ? tin : index.toString() + tin.substring(1);
|
||||
|
||||
let rest = parseInt(nif.substring(0, 8)) % 23;
|
||||
computedDigit = 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(rest);
|
||||
|
@ -52,10 +52,10 @@ module.exports = function(fi, country) {
|
|||
}
|
||||
},
|
||||
fr: {
|
||||
regExp: /^[A-Z0-9]{2}\d{9}$/
|
||||
regExp: /^\d{1,13}$/
|
||||
},
|
||||
it: {
|
||||
regExp: /^\d{11}$/
|
||||
regExp: /^(\d{11}|[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z])$/
|
||||
},
|
||||
pt: {
|
||||
regExp: /^\d{9}$/
|
||||
|
@ -67,6 +67,6 @@ module.exports = function(fi, country) {
|
|||
if (!validator)
|
||||
return true;
|
||||
|
||||
return validator.regExp.test(fi)
|
||||
return validator.regExp.test(tin)
|
||||
&& (!validator.validate || validator.validate());
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
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: 'item',
|
||||
scope: {fields: ['name']}
|
||||
},
|
||||
{
|
||||
relation: 'worker',
|
||||
scope: {fields: ['firstName', 'name']}
|
||||
}]
|
||||
};
|
||||
}
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
Self.installCrudModel('crudTicketObservation');
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
Self.installCrudModel('crudTicketPackaging');
|
||||
};
|
|
@ -1,3 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.installCrudModel('crudTicketObservations');
|
||||
};
|
|
@ -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/expedition/filter.js')(Self);
|
||||
};
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/ticket/crudTicketObservations.js')(Self);
|
||||
require('../methods/notes/crudTicketObservation.js')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/packaging/crudTicketPackaging')(Self);
|
||||
|
||||
Self.validateBinded('quantity', validateQuantity, {
|
||||
message: 'Quantity cannot be zero',
|
||||
allowNull: false,
|
||||
allowBlank: false
|
||||
});
|
||||
|
||||
function validateQuantity(quantity) {
|
||||
return !isNaN(quantity) && quantity != 0;
|
||||
}
|
||||
|
||||
Self.validatesPresenceOf('packagingFk', {message: 'Package cannot be blank'});
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/ticketTracking/filter')(Self);
|
||||
};
|
Loading…
Reference in New Issue