Merge branch 'dev' of http://git.verdnatura.es/salix into dev
This commit is contained in:
commit
979660dac3
|
@ -52,7 +52,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
let ticket = await Self.getTicket(params);
|
let ticket = await Self.getTicket(params);
|
||||||
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'});
|
||||||
let currentLine = await Self.app.models.Sale.findOne({where: {id: params.id}, fields: 'price'});
|
let currentLine = await Self.app.models.Sale.findOne({where: {id: params.id}});
|
||||||
|
|
||||||
let componentToUse;
|
let componentToUse;
|
||||||
if (usesMana)
|
if (usesMana)
|
||||||
|
@ -67,7 +67,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
await Self.rawSql(query, [params.id, componentToUse, value, value]);
|
await Self.rawSql(query, [params.id, componentToUse, value, value]);
|
||||||
|
|
||||||
await Self.app.models.Sale.update({id: params.id}, {price: params.price});
|
await currentLine.updateAttributes({price: params.price});
|
||||||
|
|
||||||
query = `call vn.manaSpellersRequery(?)`;
|
query = `call vn.manaSpellersRequery(?)`;
|
||||||
await Self.rawSql(query, [ticket[0].client().salesPersonFk]);
|
await Self.rawSql(query, [ticket[0].client().salesPersonFk]);
|
||||||
|
|
|
@ -30,10 +30,10 @@ module.exports = Self => {
|
||||||
if (isNaN(quantity))
|
if (isNaN(quantity))
|
||||||
throw new UserError(`The value should be a number`);
|
throw new UserError(`The value should be a number`);
|
||||||
|
|
||||||
let currentLine = await Self.app.models.Sale.findOne({where: {id: id}, fields: ['quantity']});
|
let currentLine = await Self.app.models.Sale.findOne({where: {id: id}});
|
||||||
if (quantity > currentLine.quantity)
|
if (quantity > currentLine.quantity)
|
||||||
throw new UserError('The new quantity should be smaller than the old one');
|
throw new UserError('The new quantity should be smaller than the old one');
|
||||||
|
|
||||||
return await Self.app.models.Sale.update({id: id}, {quantity: quantity});
|
return await currentLine.updateAttributes({quantity: quantity});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,8 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deleted = async(ctx, params) => {
|
Self.deleted = async(ctx, params) => {
|
||||||
await Self.app.models.Ticket.update({id: params.id}, {isDeleted: '1'});
|
let currentTicket = await Self.app.models.Ticket.findById(params.id);
|
||||||
|
await currentTicket.updateAttributes({isDeleted: '1'});
|
||||||
|
|
||||||
if (ctx.req.accessToken) {
|
if (ctx.req.accessToken) {
|
||||||
let token = ctx.req.accessToken;
|
let token = ctx.req.accessToken;
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
const app = require(`${servicesDir}/ticket/server/server`);
|
||||||
|
|
||||||
|
describe('userConfig getUserConfig()', () => {
|
||||||
|
it(`should return the configuration data of a given user`, async() => {
|
||||||
|
await app.models.UserConfig.getUserConfig({req: {accessToken: {userId: 9}}})
|
||||||
|
.then(response => {
|
||||||
|
expect(response.warehouseFk).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue