Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
7a5aba7fb8
|
@ -441,7 +441,7 @@ export default {
|
||||||
addServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(3) > vn-icon-button > button > vn-icon',
|
addServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(3) > vn-icon-button > button > vn-icon',
|
||||||
firstDescriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input',
|
firstDescriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input',
|
||||||
firstQuantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input',
|
firstQuantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input',
|
||||||
firstPriceInput: 'vn-ticket-service vn-textfield[label="Price"] input',
|
firstPriceInput: 'vn-ticket-service vn-input-number[label="Price"] input',
|
||||||
firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]',
|
firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]',
|
||||||
fistDeleteServiceButton: 'vn-ticket-card > vn-main-block > div.content-block.ng-scope > vn-ticket-service > form > vn-card > div > vn-one:nth-child(1) > vn-horizontal:nth-child(1) > vn-auto > vn-icon-button[icon="delete"]',
|
fistDeleteServiceButton: 'vn-ticket-card > vn-main-block > div.content-block.ng-scope > vn-ticket-service > form > vn-card > div > vn-one:nth-child(1) > vn-horizontal:nth-child(1) > vn-auto > vn-icon-button[icon="delete"]',
|
||||||
serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal',
|
serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal',
|
||||||
|
|
|
@ -17,7 +17,6 @@ describe('Ticket services path', () => {
|
||||||
.write(selectors.ticketService.firstDescriptionInput, 'my service')
|
.write(selectors.ticketService.firstDescriptionInput, 'my service')
|
||||||
.clearInput(selectors.ticketService.firstQuantityInput)
|
.clearInput(selectors.ticketService.firstQuantityInput)
|
||||||
.write(selectors.ticketService.firstQuantityInput, 99)
|
.write(selectors.ticketService.firstQuantityInput, 99)
|
||||||
.clearInput(selectors.ticketService.firstPriceInput)
|
|
||||||
.write(selectors.ticketService.firstPriceInput, 999)
|
.write(selectors.ticketService.firstPriceInput, 999)
|
||||||
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'General VAT')
|
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'General VAT')
|
||||||
.waitToClick(selectors.ticketService.saveServiceButton)
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
let UserError = require('vn-loopback/util/user-error');
|
let UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('updateDiscount', {
|
Self.remoteMethodCtx('updateDiscount', {
|
||||||
description: 'Changes the discount of a sale',
|
description: 'Changes the discount of a sale',
|
||||||
accessType: '',
|
accessType: '',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -21,16 +21,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.updateDiscount = async params => {
|
Self.updateDiscount = async(ctx, params) => {
|
||||||
if (isNaN(params.editLines[0].discount))
|
if (isNaN(params.editLines[0].discount))
|
||||||
throw new UserError(`The value should be a number`);
|
throw new UserError(`The value should be a number`);
|
||||||
|
|
||||||
let model = Self.app.models;
|
let model = Self.app.models;
|
||||||
let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk);
|
let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk);
|
||||||
|
|
||||||
if (!thisTicketIsEditable)
|
|
||||||
throw new UserError(`The sales of this ticket can't be modified`);
|
|
||||||
|
|
||||||
let ticket = await model.Ticket.find({
|
let ticket = await model.Ticket.find({
|
||||||
where: {
|
where: {
|
||||||
id: params.editLines[0].ticketFk
|
id: params.editLines[0].ticketFk
|
||||||
|
@ -41,9 +37,16 @@ module.exports = Self => {
|
||||||
fields: ['salesPersonFk']
|
fields: ['salesPersonFk']
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
fields: ['id', 'clientFk']
|
fields: ['id', 'clientFk', 'refFk']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let userId = ctx.req.accessToken.userId;
|
||||||
|
let isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
|
||||||
|
|
||||||
|
if ((!thisTicketIsEditable && !isSalesAssistant) || (ticket.refFk && isSalesAssistant))
|
||||||
|
throw new UserError(`The sales of this ticket can't be modified`);
|
||||||
|
|
||||||
|
|
||||||
let componentToUse;
|
let componentToUse;
|
||||||
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,13 @@
|
||||||
model="service.quantity"
|
model="service.quantity"
|
||||||
rule="TicketService.quantity">
|
rule="TicketService.quantity">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-input-number
|
||||||
vn-one
|
vn-one
|
||||||
|
step="1"
|
||||||
label="Price"
|
label="Price"
|
||||||
model="service.price"
|
model="service.price"
|
||||||
rule="TicketService.price">
|
display-controls="false">
|
||||||
</vn-textfield>
|
</vn-input-number>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/api/TaxClasses"
|
url="/api/TaxClasses"
|
||||||
label="Tax class"
|
label="Tax class"
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Controller {
|
||||||
this.$scope.watcher.check();
|
this.$scope.watcher.check();
|
||||||
this.$scope.model.save().then(() => {
|
this.$scope.model.save().then(() => {
|
||||||
this.$scope.watcher.notifySaved();
|
this.$scope.watcher.notifySaved();
|
||||||
|
this.$scope.model.refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue