Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
28a2c45c46
|
@ -0,0 +1,41 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('Ticket', () => {
|
||||||
|
describe('Component vnTicketCreate', () => {
|
||||||
|
let $componentController;
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $state;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('ticket');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => {
|
||||||
|
$componentController = _$componentController_;
|
||||||
|
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
$scope.card = {createTicket: () => {}};
|
||||||
|
$state = _$state_;
|
||||||
|
$state.go = () => {};
|
||||||
|
controller = $componentController('vnTicketCreate', {$scope: $scope, $state: $state});
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('onSubmit()', () => {
|
||||||
|
it(`should call createTicket()`, () => {
|
||||||
|
spyOn(controller.$.card, 'createTicket');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$.card.createTicket).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
xit(`should call go()`, () => {
|
||||||
|
spyOn(controller.$state, 'go');
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -59,10 +59,11 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="sale in index.model.instances track by sale.id">
|
<tr ng-repeat="sale in index.model.instances track by sale.id">
|
||||||
<td ng-show="sale.disponible" ><vn-icon icon="icon-reserved"></vn-icon></td>
|
<td><vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon></td>
|
||||||
<!-- <td>
|
<!-- <td>
|
||||||
<vn-icon icon="warning"></vn-icon>
|
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
|
||||||
<vn-icon icon="icon-reserved"></vn-icon>
|
<vn-icon ng-show="sale.disponible" icon="warning"></vn-icon>
|
||||||
|
<vn-icon ng-show="sale.disponible" icon="icon-reserved"></vn-icon>
|
||||||
</td> -->
|
</td> -->
|
||||||
<td number>
|
<td number>
|
||||||
<vn-check
|
<vn-check
|
||||||
|
|
|
@ -302,13 +302,6 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark sale as reserved
|
|
||||||
*/
|
|
||||||
markAsReserved() {
|
|
||||||
this.setReserved(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmark sale as reserved
|
* Unmark sale as reserved
|
||||||
*/
|
*/
|
||||||
|
@ -317,21 +310,17 @@ class Controller extends FilterTicketList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark/Unmark sale as reserved from selected lines
|
* Mark sale as reserved
|
||||||
* @param {Boolean} reserved reserved
|
|
||||||
*/
|
*/
|
||||||
|
markAsReserved() {
|
||||||
|
this.setReserved(true);
|
||||||
|
}
|
||||||
|
|
||||||
setReserved(reserved) {
|
setReserved(reserved) {
|
||||||
let data = {
|
let sales = this.getCheckedLines();
|
||||||
delete: [],
|
let params = {sales: sales, ticketFk: this.ticket.id, reserved: reserved};
|
||||||
create: [],
|
|
||||||
update: this.getCheckedLines()
|
|
||||||
};
|
|
||||||
|
|
||||||
data.update.forEach(line => {
|
this.$http.post(`/ticket/api/Sales/reserve`, params).then(() => {
|
||||||
line.reserved = reserved;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$http.post(`/ticket/api/Sales/crudSale`, data).then(() => {
|
|
||||||
this.$.index.accept();
|
this.$.index.accept();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
module.exports = Self => {
|
|
||||||
Self.installCrudModel('crudSale');
|
|
||||||
};
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('reserve', {
|
||||||
|
description: 'Change the state of a ticket',
|
||||||
|
accessType: '',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'params',
|
||||||
|
type: 'object',
|
||||||
|
required: true,
|
||||||
|
description: '[sales IDs], actualTicketFk, reserved',
|
||||||
|
http: {source: 'body'}
|
||||||
|
}],
|
||||||
|
returns: {
|
||||||
|
type: 'string',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/reserve`,
|
||||||
|
verb: 'post'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.reserve = async params => {
|
||||||
|
let thisTicketIsEditable = await Self.app.models.Ticket.isEditable(params.actualTicketFk);
|
||||||
|
if (!thisTicketIsEditable)
|
||||||
|
throw new Error(`The sales of this ticket can't be modified`);
|
||||||
|
|
||||||
|
for (let i = 0; i < params.sales.length; i++) {
|
||||||
|
await Self.app.models.Sale.update({id: params.sales[i].id}, {reserved: params.reserved});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -2,8 +2,8 @@ module.exports = Self => {
|
||||||
require('../methods/sale/filter')(Self);
|
require('../methods/sale/filter')(Self);
|
||||||
require('../methods/sale/saleComponentFilter')(Self);
|
require('../methods/sale/saleComponentFilter')(Self);
|
||||||
require('../methods/sale/priceDifference')(Self);
|
require('../methods/sale/priceDifference')(Self);
|
||||||
require('../methods/sale/crudSale')(Self);
|
|
||||||
require('../methods/sale/moveToTicket')(Self);
|
require('../methods/sale/moveToTicket')(Self);
|
||||||
|
require('../methods/sale/reserve')(Self);
|
||||||
require('../methods/sale/moveToNewTicket')(Self);
|
require('../methods/sale/moveToNewTicket')(Self);
|
||||||
require('../methods/sale/removes')(Self);
|
require('../methods/sale/removes')(Self);
|
||||||
require('../methods/sale/updateDiscount')(Self);
|
require('../methods/sale/updateDiscount')(Self);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
},
|
},
|
||||||
"reserved": {
|
"reserved": {
|
||||||
"type": "Number"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"isPicked": {
|
"isPicked": {
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
|
|
Loading…
Reference in New Issue