Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
gerard 2018-08-01 16:09:10 +02:00
commit c461f16ce7
63 changed files with 3902 additions and 3792 deletions

View File

@ -4,7 +4,6 @@ describe('Client', () => {
describe('Component vnClientAddressEdit', () => {
let $componentController;
let $state;
let controller;
let $httpBackend;
beforeEach(() => {

View File

@ -36,6 +36,17 @@ describe('Client', () => {
});
});
describe('onSubmit()', () => {
it(`should call notifyChanges() if there are changes on payMethod data`, () => {
spyOn(controller, 'notifyChanges');
controller.client.payMethodFk = 5;
controller.onSubmit();
expect(controller.hasPaymethodChanged()).toBeTruthy();
expect(controller.notifyChanges).toHaveBeenCalledWith();
});
});
describe('hasPaymethodChanged()', () => {
it(`should call hasPaymethodChanged() and return true if there are changes on payMethod data`, () => {
controller.client.payMethodFk = 5;
@ -49,16 +60,5 @@ describe('Client', () => {
expect(controller.hasPaymethodChanged()).toBeFalsy();
});
});
describe('onSubmit()', () => {
it(`should call notifyChanges() if there are changes on payMethod data`, () => {
spyOn(controller, 'notifyChanges');
controller.client.payMethodFk = 5;
controller.onSubmit();
expect(controller.hasPaymethodChanged()).toBeTruthy();
expect(controller.notifyChanges).toHaveBeenCalledWith();
});
});
});
});

View File

@ -18,6 +18,7 @@ describe('Client', () => {
controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$stateParams: $stateParams});
}));
describe('$onInit()', () => {
it('should perform a query to GET credit the credit classification', () => {
let res = [{finished: 'some value'}];
let query = '/client/api/CreditClassifications?filter=%7B%22fields%22%3A%5B%22finished%22%5D%2C%22where%22%3A%7B%22id%22%3A1%7D%7D';
@ -31,3 +32,4 @@ describe('Client', () => {
});
});
});
});

View File

@ -37,6 +37,7 @@ describe('Client', () => {
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnClientCreditCreate', {$scope: $scope}, {$state: $state});
}));
describe('onSubmit()', () => {
it('should perform a query to check (GET) if the client has an active recovery', () => {
$httpBackend.whenGET(`/client/api/Recoveries/101/hasActiveRecovery`).respond(true);
@ -65,6 +66,7 @@ describe('Client', () => {
expect(controller.addCredit).toHaveBeenCalledWith();
});
});
describe('returnDialog()', () => {
it('should call addCredit() when is called with ACCEPT', () => {
spyOn(controller, 'addCredit');
@ -73,6 +75,7 @@ describe('Client', () => {
expect(controller.addCredit).toHaveBeenCalledWith();
});
});
describe('addCredit()', () => {
it('should call the function go() on $state to go to the credit list', () => {
spyOn($state, 'go');

View File

@ -1,4 +1,7 @@
<vn-popover vn-id="popover">
<vn-client-descriptor client="$ctrl.client" clientFk="$ctrl.clientFk">
<vn-client-descriptor
client="$ctrl.client"
clientFk="$ctrl.clientFk"
quicklinks="$ctrl.quicklinks">
</vn-client-descriptor>
</vn-popover>

View File

@ -9,6 +9,22 @@ class Controller extends Component {
this.$timeout = $timeout;
this.isTooltip = true;
this.client = {};
this.links = {};
}
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
clear() {
@ -34,13 +50,6 @@ class Controller extends Component {
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
}
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
show() {
this.$.popover.parent = this.parent;
setTimeout(() => {
@ -56,6 +65,7 @@ ngModule.component('vnClientDescriptorPopover', {
controller: Controller,
bindings: {
client: '<',
clientFk: '<'
clientFk: '<',
quicklinks: '<'
}
});

View File

@ -53,11 +53,23 @@
ng-class="{bright: $ctrl.client.isTaxDataChecked == false}">
</vn-icon>
</vn-horizontal>
<vn-horizontal pad-small class="buttons">
<vn-button
vn-tooltip="Client ticket list"
icon="icon-ticket"
ng-click="$ctrl.goToClientTickets()">
<vn-horizontal pad-small class="quicklinks">
<vn-button ng-if="$ctrl.quicklinks.btnOne" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnOne.tooltip}}"
icon="{{::$ctrl.quicklinks.btnOne.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnOne.state, $ctrl.quicklinks.btnOne.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnTwo" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnTwo.tooltip}}"
icon="{{::$ctrl.quicklinks.btnTwo.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnTwo.state, $ctrl.quicklinks.btnTwo.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnThree" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnThree.tooltip}}"
icon="{{::$ctrl.quicklinks.btnThree.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnThree.state, $ctrl.quicklinks.btnThree.params)">
</vn-button>
</vn-horizontal>
</vn-card>

View File

@ -4,7 +4,31 @@ class Controller {
constructor($http, $state) {
this.$state = $state;
this.$http = $http;
this.links = {
btnOne: {
icon: 'icon-ticket',
state: 'ticket.index',
params: {q: `{"clientFk": ${$state.params.id}}`},
tooltip: 'Client ticket list'
}
};
}
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
_getClientDebt(clientFk) {
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
.then(response => {
@ -23,11 +47,8 @@ class Controller {
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
}
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
quicklinkGo(state, params) {
this.$state.go(state, params);
}
}
@ -37,7 +58,8 @@ ngModule.component('vnClientDescriptor', {
template: require('./index.html'),
bindings: {
client: '<',
clientFk: '<?'
clientFk: '<?',
quicklinks: '<'
},
controller: Controller
});

View File

@ -1,36 +0,0 @@
import './index';
describe('Client', () => {
describe('Component vnClientIndex', () => {
let $componentController;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
controller = $componentController('vnClientIndex');
}));
it('should define and set clientSelected property as null', () => {
expect(controller.clientSelected).toEqual(null);
});
// describe('search()', () => {
// it(`should set model's search to the search input`, () => {
// controller.model.search = 'batman';
// let index = {
// filter: {},
// accept: () => {
// return 'accepted';
// }
// };
// controller.search(index);
// expect(index.filter.search).toBe('batman');
// });
// });
});
});

View File

@ -1,6 +1,6 @@
import './index';
fdescribe('Client', () => {
describe('Client', () => {
describe('Component vnClientSampleCreate', () => {
let $componentController;
let $scope;

View File

@ -43,6 +43,7 @@ describe('Component vnStepControl', () => {
controller.steps = [{state: 'iam_not_current_state'}, {state: 'iam_a_current_state'}];
let result = controller.currentStepIndex;
expect(result).toEqual(1);
});
});

View File

@ -4,9 +4,15 @@
.icon-barcode:before { content: '\e802'; } /* '' */
.icon-bucket:before { content: '\e803'; } /* '' */
.icon-complementos:before { content: '\e804'; } /* '' */
.icon-dfiscales:before { content: '\e805'; } /* '' */
.icon-doc:before { content: '\e806'; } /* '' */
.icon-eye:before { content: '\e807'; } /* '' */
.icon-frozen:before { content: '\e808'; } /* '' */
.icon-greuge:before { content: '\e809'; } /* '' */
.icon-grid:before { content: '\e80a'; } /* '' */
.icon-disabled:before { content: '\e80b'; } /* '' */
.icon-invoices:before { content: '\e80c'; } /* '' */
.icon-frozen-1:before { content: '\e80d'; } /* '' */
.icon-noweb:before { content: '\e812'; } /* '' */
.icon-payment:before { content: '\e813'; } /* '' */
.icon-recovery:before { content: '\e815'; } /* '' */
@ -23,6 +29,7 @@
.icon-no036:before { content: '\e823'; } /* '' */
.icon-mana:before { content: '\e824'; } /* '' */
.icon-claims:before { content: '\e825'; } /* '' */
.icon-tags:before { content: '\e826'; } /* '' */
.icon-solunion:before { content: '\e827'; } /* '' */
.icon-reserva:before { content: '\e828'; } /* '' */
.icon-entry:before { content: '\e829'; } /* '' */

View File

@ -2,6 +2,7 @@
<vn-item-descriptor
item="$ctrl.item"
item-tags="$ctrl.itemTags"
tags="$ctrl.tags">
tags="$ctrl.tags"
quicklinks="$ctrl.quicklinks">
</vn-item-descriptor>
</vn-popover>

View File

@ -7,11 +7,19 @@ class Controller extends Component {
super($element, $scope);
this.$http = $http;
this.$timeout = $timeout;
this.links = {};
this.isTooltip = true;
this.clear();
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
clear() {
this.item = null;
this.tags = {};
@ -90,7 +98,8 @@ Controller.$inject = ['$element', '$scope', '$http', '$timeout'];
ngModule.component('vnItemDescriptorPopover', {
template: require('./index.html'),
bindings: {
itemFk: '<'
itemFk: '<',
quicklinks: '<'
},
controller: Controller
});

View File

@ -37,4 +37,23 @@
</vn-label-value>
</vn-auto>
</vn-vertical>
<vn-horizontal pad-small class="quicklinks">
<vn-button ng-if="$ctrl.quicklinks.btnOne" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnOne.tooltip}}"
icon="{{::$ctrl.quicklinks.btnOne.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnOne.state, $ctrl.quicklinks.btnOne.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnTwo" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnTwo.tooltip}}"
icon="{{::$ctrl.quicklinks.btnTwo.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnTwo.state, $ctrl.quicklinks.btnTwo.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnThree" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnThree.tooltip}}"
icon="{{::$ctrl.quicklinks.btnThree.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnThree.state, $ctrl.quicklinks.btnThree.params)">
</vn-button>
</vn-horizontal>
</vn-card>

View File

@ -1,11 +1,34 @@
import ngModule from '../module';
import './style.scss';
class Controller {
constructor($state) {
this.$state = $state;
this.links = {};
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
quicklinkGo(state, params) {
this.$state.go(state, params);
}
}
Controller.$inject = ['$state'];
ngModule.component('vnItemDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
item: '<',
itemTags: '<',
tags: '<'
tags: '<',
quicklinks: '<'
}
});

View File

@ -1,6 +1,6 @@
import './index.js';
fdescribe('Item', () => {
describe('Item', () => {
describe('Component vnItemDiary', () => {
let $componentController;
let $scope;

View File

@ -1,10 +1,6 @@
import ngModule from '../module';
class Controller {
constructor() {
}
setFilter() {
this.catalogue.applyFilter();
}

View File

@ -206,7 +206,7 @@ vn-main-block {
}
}
.buttons {
.quicklinks {
justify-content: center;
align-items: center;

View File

@ -1,4 +1,4 @@
/* import './step-three.js';
/* import './index.js';
describe('ticket', () => {
describe('Component vnTicketDataStepThree', () => {

View File

@ -164,7 +164,8 @@
</vn-table>
</vn-vertical>
</vn-card>
<vn-item-descriptor-popover vn-id="descriptor">
<vn-item-descriptor-popover vn-id="descriptor"
quicklinks="$ctrl.quicklinks">
</vn-item-descriptor-popover>
<!-- Add Turn Dialog -->

View File

@ -20,6 +20,25 @@ class Controller {
];
}
set ticket(value) {
this._ticket = value;
if (!value) return;
this.quicklinks = {
btnThree: {
icon: 'icon-transaction',
state: 'item.card.diary',
params: {id: value.id, q: `{"warehouseFk": ${value.warehouseFk}}`},
tooltip: 'Item diary'
}
};
}
get ticket() {
return this._ticket;
}
onDataChange() {
this.sales = this.$scope.model.data;
this.getTaxes();

View File

@ -159,8 +159,8 @@ describe('Ticket', () => {
});
describe('onStateChange()', () => {
it('should perform a post and then call a function', () => {
$httpBackend.expectPOST(`/ticket/api/TicketTrackings/changeState`).respond();
it('should perform a POST', () => {
$httpBackend.expectPOST(`/ticket/api/TicketTrackings`).respond();
controller.card = {reload: () => {}};
controller.onStateChange(3);
$httpBackend.flush();

View File

@ -88,6 +88,7 @@ describe('Client', () => {
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'SMASH!')
.waitForTextInInput(selectors.clientFiscalData.socialNameInput, 'SMASH!')
.clearInput(selectors.clientFiscalData.fiscalIdInput)
.type(selectors.clientFiscalData.fiscalIdInput, '94980061C')
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel)

View File

@ -441,7 +441,7 @@ gulp.task('docker', async () => {
/**
* Rebuilds the docker image, if already exists, destroys and
* rebuild it.
* rebuild it. calls upon docker task afterwards.
*/
gulp.task('docker-build', async () => {
try {
@ -456,6 +456,8 @@ gulp.task('docker-build', async () => {
log('Building image...');
await execP('docker build -t dblocal:latest ./services/db');
await runSequenceP('docker');
});
/**

7202
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,17 +20,17 @@ INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`)
(105, 'MaxEisenhardt', 'ac754a330530832ba1bf7687f577da91', 2 , 1, 'MaxEisenhardt@verdnatura.es'),
(106, 'DavidCharlesHaller', 'ac754a330530832ba1bf7687f577da91', 2 , 1, 'DavidCharlesHaller@verdnatura.es'),
(107, 'HankPym', 'ac754a330530832ba1bf7687f577da91', 2 , 1, 'HankPym@verdnatura.es'),
(108, 'CharlesXavier', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'CharlesXavier@verdnatura.es'),
(108, 'CharlesXavier', 'ac754a330530832ba1bf7687f577da91', 20, 1, 'CharlesXavier@verdnatura.es'),
(109, 'BruceBanner', 'ac754a330530832ba1bf7687f577da91', 2 , 1, 'BruceBanner@verdnatura.es'),
(110, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91' , 2, 1, 'JessicaJones@verdnatura.es');
(110, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 1 , 1, 'JessicaJones@verdnatura.es');
INSERT INTO `vn`.`worker`(`workerCode`, `id`, `firstName`, `name`, `userFk`)
VALUES
('LGN', 106, 'David Charles', 'Haller', 106),
('ANT', 107, 'Hank' , 'Pym' , 107),
('DCX', 108, 'Charles' , 'Xavier', 108),
('DCX', 110, 'Charles' , 'Xavier', 108),
('HLK', 109, 'Bruce' , 'Banner', 109),
('JJJ', 110, 'Jessica' , 'Jones' , 110);
('JJJ', 108, 'Jessica' , 'Jones' , 110);
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`)
VALUES
@ -614,7 +614,30 @@ INSERT INTO `vn`.`tag`(`id`,`name`,`isFree`,`isQuantitatif`,`sourceTable`,`unit`
(3, 'Shape', 0, 0, null, null),
(4, 'Location', 1, 0, null, null),
(5, 'Owner', 1, 1, null, null);
/*
INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
VALUES
(1, 1, 1, 'Yellow', 5),
(2, 1, 2, 'Manipulates time', 4),
(3, 1, 3, 'round', 3),
(4, 1, 4, 'Gamoras hideout', 2),
(5, 1, 5, 'Gamora', 1),
(6, 2, 1, 'Red', 5),
(7, 2, 2, 'Manipulates mind', 4),
(8, 2, 3, 'square', 3),
(9, 2, 4, 'unknown location', 2),
(10, 2, 5, 'Thanos', 1),
(11, 3, 1, 'Green', 5),
(12, 3, 2, 'Save the children', 4),
(13, 3, 3, 'human shape', 3),
(14, 3, 4, 'Stark tower', 2),
(15, 3, 5, 'Tony Stark', 1),
(16, 4, 1, 'Blue', 5),
(17, 4, 2, 'Protect the citizen', 4),
(18, 4, 3, 'human shape', 3),
(19, 4, 4, 'Manhattan', 2),
(20, 4, 5, 'Tony Stark', 1);
*/
INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
VALUES
(1, 1, 1, 'Yellow', 5),
@ -706,23 +729,25 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `companyFk`)
( 3, 1, CURDATE(), 3, 442),
( 4, 2, CURDATE(), 4, 69);
INSERT INTO `vn`.`agencyProvince`(`provinceFk`, `agencyFk`, `zone`, `warehouseFk`, `route`)
INSERT INTO `vn`.`agencyProvince`(`provinceFk`, `agencyFk`, `zone`, `warehouseFk`)
VALUES
( 1, 1, 1, 1, 1),
( 1, 1, 1, 2, 1),
( 1, 1, 1, 3, 1),
( 1, 2, 2, 2, 2),
( 1, 2, 2, 3, 2);
( 1, 1, 1, 1),
( 1, 1, 1, 2),
( 1, 1, 1, 3),
( 1, 2, 2, 2),
( 1, 2, 2, 3),
( 1, 7, 2, 1),
( 1, 8, 2, 1);
INSERT INTO `vn`.`agencyModeZone`(`agencyModeFk`, `zone`, `price`, `itemFk`, `warehouseFk`, `minimCost`, `inflation`)
VALUES
( 1, 1, 10, 1, 1, 1, 1.00),
( 1, 1, 20, 2, 1, 1, 1.00),
( 2, 1, 10, 1, 1, 1, 1.00),
( 2, 1, 20, 2, 1, 1, 2.00),
( 2, 2, 10, 1, 1, 0, 2.00),
( 7, 2, 10, 1, 1, 0, 2.00),
( 8, 2, 10, 1, 1, 0, 2.00);
( 1, 1, 10, 6, 1, 1, 1.00),
( 1, 1, 20, 6, 1, 1, 1.00),
( 2, 1, 10, 6, 1, 1, 1.00),
( 2, 1, 20, 6, 1, 1, 2.00),
( 2, 2, 10, 6, 1, 0, 2.00),
( 7, 2, 50, 6, 1, 0, 1.00),
( 8, 2, 100, 6, 1, 0, 2.00);
INSERT INTO `vn`.`agencyWeekDayBonus`(`id`, `warehouseFk`, `agencyFk`, `weekDay`, `zone`, `bonus`)
VALUES
@ -741,10 +766,10 @@ INSERT INTO `bi`.`claims_ratio`(`id_Cliente`, `Consumo`, `Reclamaciones`, `Ratio
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packageFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`,`minPrice`,`producer`,`printedStickers`,`isChecked`,`isIgnored`)
VALUES
(1, 1, 1, 2.5, 4, 1, 1, 0.350, 0.050, 0.000, 1, 1, 1, NULL, 1.50, 1.25, 1.30, 2.00, NULL, 0, 1, 0),
(2, 2, 2, 5 , 2, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2, 1.00, 1.30, 2.00, NULL, 0, 1, 0),
(3, 3, 3, 10 , 1, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2.50, 1.00, 2.50, 2.00, NULL, 0, 1, 0),
(4, 4, 4, 20 , 1, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2.50, 1.00, 2.50, 2.00, NULL, 0, 1, 0);
(1, 1, 1, 2.5, 10 , 1, 1, 0.350, 0.050, 0.000, 1, 1, 1, NULL, 1.50, 1.25, 1.30, 2.00, NULL, 0, 1, 0),
(2, 2, 2, 5 , 450, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2, 1.00, 1.30, 2.00, NULL, 0, 1, 0),
(3, 3, 3, 10 , 500, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2.50, 1.00, 2.50, 2.00, NULL, 0, 1, 0),
(4, 4, 4, 20 , 100, 1, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 2.50, 1.00, 2.50, 2.00, NULL, 0, 1, 0);
INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`)
VALUES

View File

@ -7,7 +7,7 @@ describe('Client listWorkers', () => {
.then(result => {
let amountOfEmployees = Object.keys(result).length;
expect(amountOfEmployees).toEqual(39);
expect(amountOfEmployees).toEqual(41);
done();
})
.catch(catchErrors(done));

View File

@ -1,12 +1,11 @@
const app = require(`${servicesDir}/client/server/server`);
describe('message send()', () => {
it('should call the send method and return the response', done => {
it('should call the send method and return the response', async() => {
let ctx = {req: {accessToken: {userId: 1}}};
app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx)
await app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx)
.then(response => {
expect(response.sent).toEqual(1);
done();
});
});
});

View File

@ -1,4 +1,4 @@
module.exports = State => {
var serverFilter = {where: {order: {gt: 0}}, order: "order, name"};
var serverFilter = {where: {order: {gt: 0}}, order: 'order, name'};
State.defineScope(serverFilter);
};

View File

@ -23,7 +23,7 @@ module.exports = function(Self) {
Self.changeState = function(ctx, state, cb) {
var tickets = ctx.req.body.tickets;
Self.connectToService(ctx, "client");
Self.connectToService(ctx, 'client');
Self.app.models.Worker.findOne({where: {userFk: ctx.req.accessToken.userId}}, function(err, emp) {
if (err)
@ -32,7 +32,7 @@ module.exports = function(Self) {
changeState(emp.id, tickets, state, cb);
});
Self.disconnectFromService("client");
Self.disconnectFromService('client');
};
function changeState(emp, tickets, state, cb) {

View File

@ -1,7 +1,7 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket componentUpdate()', () => {
it('should call the componentUpdate method', done => {
it('should call the componentUpdate method and receive an error', async() => {
let data = {
agencyModeFk: 1,
addressFk: 121,
@ -12,10 +12,9 @@ describe('ticket componentUpdate()', () => {
option: 1
};
let ctx = {req: {accessToken: {userId: 101}}};
app.models.Ticket.componentUpdate(1, data, ctx)
await app.models.Ticket.componentUpdate(1, data, ctx)
.catch(response => {
expect(response).toEqual(new Error('ER_SIGNAL_EXCEPTION: NO_AGENCY_AVAILABLE'));
done();
});
});
});

View File

@ -1,16 +1,15 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getShipped()', () => {
it('should call the getShipped method', done => {
it('should call the getShipped method', async() => {
let data = {
landed: new Date(),
addressFk: 121,
agencyModeFk: 7
};
app.models.Ticket.getShipped(data)
await app.models.Ticket.getShipped(data)
.then(response => {
expect(response.warehouseFk).toEqual(1);
done();
});
});
});

View File

@ -1,11 +1,10 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getTaxes()', () => {
it('should call the getTaxes method', done => {
app.models.Ticket.getTaxes(1)
it('should call the getTaxes method', async() => {
await app.models.Ticket.getTaxes(1)
.then(response => {
expect(response[0].tax).toEqual(20.95);
done();
});
});
});

View File

@ -1,19 +1,17 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getTotal()', () => {
it('should call the getTotal method and return the response', done => {
app.models.Ticket.getTotal(1)
it('should call the getTotal method and return the response', async() => {
await app.models.Ticket.getTotal(1)
.then(response => {
expect(response).toEqual(448.25);
done();
});
});
it(`should call the getTotal method and return zero if doesn't have lines`, done => {
app.models.Ticket.getTotal(13)
it(`should call the getTotal method and return zero if doesn't have lines`, async() => {
await app.models.Ticket.getTotal(13)
.then(response => {
expect(response).toEqual(0);
done();
});
});
});

View File

@ -1,19 +1,17 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getVAT()', () => {
it('should call the getVAT method and return the response', done => {
app.models.Ticket.getVAT(1)
it('should call the getVAT method and return the response', async() => {
await app.models.Ticket.getVAT(1)
.then(response => {
expect(response).toEqual(58.75);
done();
});
});
it(`should call the getVAT method and return zero if doesn't have lines`, done => {
app.models.Ticket.getVAT(13)
it(`should call the getVAT method and return zero if doesn't have lines`, async() => {
await app.models.Ticket.getVAT(13)
.then(response => {
expect(response).toEqual(0);
done();
});
});
});

View File

@ -1,12 +1,11 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getVolume()', () => {
it('should call the getVolume method', done => {
it('should call the getVolume method', async() => {
let ticketFk = 1;
app.models.Ticket.getVolume(ticketFk)
await app.models.Ticket.getVolume(ticketFk)
.then(response => {
expect(response[0].m3).toEqual(0.04);
done();
});
});
});

View File

@ -1,3 +1,3 @@
module.exports = Self => {
require('../methods/message/send')(Self);
}
};